Unity 和 C# 游戲編程入門, 5/e (Learning C# by Developing Games with Unity 2020 : An enjoyable and intuitive approach to getting started with C# programming and Unity, 5/e)
[美]哈里森·費隆(Harrison Ferrone) 著 王冬、殷崇英 譯
- 出版商: 清華大學
- 出版日期: 2022-04-01
- 定價: $359
- 售價: 5.0 折 $180
- 語言: 簡體中文
- 頁數: 316
- 裝訂: 平裝
- ISBN: 7302602107
- ISBN-13: 9787302602101
-
相關分類:
C#、遊戲引擎 Game-engine
- 此書翻譯自: Learning C# by Developing Games with Unity 2020 : An enjoyable and intuitive approach to getting started with C# programming and Unity, 5/e
-
其他版本:
Unity 和 C# 游戲編程入門, 7/e
買這商品的人也買了...
-
$750Creating Weaponry and Accessories in 3D
-
$399Awesome Game Creation: No Programming Required, 2/e
-
$320$250 -
$480$379 -
$270$257 -
$403Unity 遊戲設計與實現 : 南夢宮一線程序員的開發實例 (修訂版)
-
$580$452 -
$560$476 -
$800$600 -
$479$455 -
$599$569 -
$980$735 -
$534$507 -
$479$455 -
$419$398 -
$980$774 -
$326UGUI 入門 : Unity 遊戲界面設計與製作
-
$250$198 -
$500$390 -
$419$398 -
$588$559 -
$588$559 -
$680$537 -
$780$616 -
$779$740
相關主題
商品描述
主要內容: ●通過簡單易懂的步驟和示例學習C#基礎編程 ●掌握如何在L Jnity中創建和應用腳本 ●用C#實現諸如角色控制和射擊等基本游戲機制 ●理解接口與抽象類的概念 ●利用**版C#的強大功能解決復雜的編程問題 ●熟悉堆棧、隊列、異常、錯誤處理等其他C#核心概念 ●探索游戲中人工智能( AI )的基礎知識並將其應用於 控制敵人行為
目錄大綱
目 錄
第1章瞭解開發環境 .............................................................................1
1.1 技術要求 ................................................................................................. 2
1.2 Unity 2020入門 ..................................................................................... 2
1.2.1 使用 macOS....................................................................................................7
1.2.2 創建一個新項目 .............................................................................................9
1.2.3 瀏覽編輯器 .................................................................................................. 10
1.3 在 Unity中使用 C# ............................................................................. 12
1.3.1 使用 C#腳本................................................................................................ 12
1.3.2 Visual Studio編輯器介紹 ........................................................................... 14
1.3.3 同步 C#文件................................................................................................ 16
1.4 探討技術文檔 ...................................................................................... 17
1.4.1 訪問 Unity的技術文檔 .............................................................................. 17
1.4.2 查找 C#資源................................................................................................ 19
1.5 本章小結 ............................................................................................... 21
1.6 小測驗——關於腳本 ........................................................................... 21
第2章編程的構成要素 ........................................................................22
2.1 變量的定義 ........................................................................................... 23
2.1.1 變量的名稱很重要 ..................................................................................... 24
2.1.2 變量充當占位符 .......................................................................................... 24
2.2 瞭解方法 ............................................................................................... 27
2.2.1 方法驅動行為 .............................................................................................. 28
2.2.2 方法也是占位符 .......................................................................................... 28
2.3 介紹類 ................................................................................................... 30
2.3.1 一個常用的 Unity類 .................................................................................. 31
2.3.2 類就像藍圖 .................................................................................................. 31
2.4 使用註釋 ............................................................................................... 32
2.4.1 實用的反斜杠 .............................................................................................. 33
2.4.2 多行註釋 ...................................................................................................... 33
2.5 將基礎模塊整合在一起 ...................................................................... 34
2.5.1 腳本成為組件 .............................................................................................. 35
2.5.2 來自 MonoBehavior的助力....................................................................... 36
2.6 類之間的通信 ...................................................................................... 37
2.7 本章小結 ............................................................................................... 38
2.8 小測驗 —— C#的構成要素 ................................................................ 38
第3章深入研究變量、類型和方法 .....................................................39
3.1 編寫符合規範的 C#代碼 .................................................................... 40
3.2 調試代碼 ............................................................................................... 41
3.3 聲明變量 ............................................................................................... 42
3.3.1 同時聲明類型和值 ..................................................................................... 43
3.3.2 僅聲明類型 .................................................................................................. 43
3.4 使用訪問修飾符 .................................................................................. 44
3.5 瞭解數據類型 ...................................................................................... 46
3.5.1 通用內置類型 .............................................................................................. 46
3.5.2 類型轉換 ...................................................................................................... 49
3.5.3 推斷式聲明 .................................................................................................. 50
3.5.4 自定義類型 .................................................................................................. 51
3.5.5 類型綜述 ...................................................................................................... 51
3.6 命名變量 ............................................................................................... 52
3.7 瞭解變量的作用域 .............................................................................. 53
3.8 運算符 ................................................................................................... 54
3.9 定義方法 ............................................................................................... 57
3.9.1 基本語法 ...................................................................................................... 57
3.9.2 修飾符和參數 .............................................................................................. 58
3.10 指定參數............................................................................................. 61
3.11指定返回值 ......................................................................................... 63
3.12 剖析常見的 Unity方法..................................................................... 66
3.12.1 Start( )方法................................................................................................. 67
3.12.2 Update( )方法............................................................................................. 67
3.13 本章小結............................................................................................. 68
3.14 小測驗——變量和方法 ................................................................... 69
第4章控制流和集合類型 ....................................................................70
4.1 選擇語句 ............................................................................................... 71
4.1.1 if-else語句................................................................................................... 71
4.1.2 switch語句................................................................................................... 80
4.1.3 小測驗 —— if語句與邏輯運算符 ............................................................84
4.2 初識集合 ............................................................................................... 84
4.2.1 數組 .............................................................................................................. 85
4.2.2 列表 .............................................................................................................. 87
4.2.3 字典 .............................................................................................................. 90
4.2.4 小測驗——集合 .......................................................................................... 94
4.3 迭代語句 ............................................................................................... 94
4.3.1 for循環 ........................................................................................................ 94
4.3.2 foreach循環................................................................................................. 97
4.3.3 while循環.................................................................................................... 99
4.3.4 超越無限 ....................................................................................................101
4.4 本章小結 ............................................................................................. 102
第5章類、結構體和 OOP ................................................................103
5.1 定義類 ................................................................................................. 104
5.1.1 基本語法 ....................................................................................................104
5.1.2 實例化類對象 ............................................................................................105
5.1.3 添加類字段 ................................................................................................106
5.1.4 使用構造函數 ............................................................................................107
5.1.5 聲明類方法 ................................................................................................110
5.2 聲明結構體 ......................................................................................... 112
5.3 理解引用和值類型 ............................................................................ 114
5.3.1 引用類型 ....................................................................................................115
5.3.2 值類型 ........................................................................................................116
5.4 植入面向對象的思維 ........................................................................ 118
5.4.1 封裝 ............................................................................................................118
5.4.2 繼承 ............................................................................................................120
5.4.3 組合 ............................................................................................................122
5.4.4 多態 ............................................................................................................123
5.4.5 面向對象編程綜述 ...................................................................................124
5.5 在 Unity中應用面向對象編程 ......................................................... 125
5.5.1 對象是類的行為 ........................................................................................125
5.5.2 訪問組件 ....................................................................................................126
5.6 本章小結 ............................................................................................. 131
5.7 小測驗 —— OOP的相關內容 .......................................................... 132
第6章親手實踐 Unity........................................................................133
6.1 游戲設計入門 .................................................................................... 134
6.1.1 游戲設計文檔 ............................................................................................134
6.1.2 Hero Born游戲單頁文檔 .........................................................................135
6.2 構建關卡 ............................................................................................. 136
6.2.1 創建原始對象 ............................................................................................136
6.2.2 用 3D思維思考 .........................................................................................138
6.2.3 材質 ............................................................................................................140
6.2.4 白盒 ............................................................................................................142
6.3 光照基礎 ............................................................................................. 151
6.3.1 創建光源 ....................................................................................................152
6.3.2 Light組件屬性 ..........................................................................................153
6.4 在 Unity中製作動畫 ......................................................................... 154
6.4.1 創建動畫剪輯 ............................................................................................154
6.4.2 錄制關鍵幀 ................................................................................................157
6.4.3 曲線和切線 ................................................................................................159
6.5 粒子系統 ............................................................................................. 162
6.6 本章小結 ............................................................................................. 164
6.7 小測驗 —— Unity基本功能 ............................................................. 164
第7章角色移動、攝像機以及碰撞 ...................................................165
7.1 角色移動 ............................................................................................. 166
7.1.1 玩家設置 ....................................................................................................167
7.1.2 理解向量 ....................................................................................................168
7.1.3 獲取玩家輸入 ............................................................................................170
7.2 添加攝像機跟隨 ................................................................................ 174
7.3 使用 Unity物理系統 ......................................................................... 177
7.3.1 剛體運動 ....................................................................................................179
7.3.2 碰撞體和碰撞 ............................................................................................183
7.3.3 使用碰撞體觸發器 ...................................................................................187
7.3.4 物理系統綜述 ............................................................................................191
7.4 本章小結 ............................................................................................. 192
7.5 小測驗 ——玩家控制和物理系統 ................................................... 192
第8章游戲機制腳本編寫 ..................................................................193
8.1 添加跳躍 ............................................................................................. 194
8.1.1 介紹枚舉 ....................................................................................................194
8.1.2 使用層遮罩 ................................................................................................198
8.2 發射子彈 ............................................................................................. 203
8.2.1 實例化對象 ................................................................................................203
8.2.2 管理游戲對象的堆積 ...............................................................................208
8.3 創建游戲管理器 ................................................................................ 209
8.3.1 追蹤玩家屬性 ............................................................................................209
8.3.2 get和 set屬性............................................................................................211
8.4 游戲的收尾打磨 ................................................................................ 216
GUI.............................................................................................................216
8.4.1
8.4.2 勝負條件 ....................................................................................................220
8.4.3 使用指令和命名空間 ...............................................................................222
8.5 本章小結 ............................................................................................. 225
8.6 小測驗 ——游戲機制 ....................................................................... 226
第9章 AI基礎與敵人行為 .................................................................227
9.1 Unity導航系統 .................................................................................. 228
9.2 移動敵人代理 .................................................................................... 231
9.3 敵人游戲機制 .................................................................................... 240
9.4 重構並保持“ DRY”........................................................................ 248
9.5 本章小結 ............................................................................................. 250
9.6 小測驗 —— AI和導航...................................................................... 250
第10章 再談類型、方法和類 ............................................................251
10.1 再談訪問修飾符 .............................................................................. 252
10.1.1 常量和只讀屬性 ...................................................................................252
10.1.2 使用 static關鍵字 .................................................................................253
10.2 再談方法........................................................................................... 255
10.2.1 方法重載 ...............................................................................................255
10.2.2 ref參數..................................................................................................257
10.2.3 out參數 .................................................................................................260
10.3 再談面向對象 .................................................................................. 260
10.3.1 接口 .......................................................................................................261
10.3.2 抽象類 ...................................................................................................264
10.3.3 類的擴展 ...............................................................................................266
10.4 再談命名空間 .................................................................................. 269
10.5 本章小結........................................................................................... 270
10.6 小測驗——升級 .............................................................................. 270
第11章棧、隊列和 HashSet ............................................................271
11.1棧 ....................................................................................................... 272
11.1.1 基本語法 ...............................................................................................272
11.1.2 出棧和查看棧頂 ...................................................................................274
11.1.3 常用方法 ...............................................................................................276
11.2隊列 ................................................................................................... 278
11.2.1 基本語法 ...............................................................................................278
11.2.2 添加、刪除和查看 ...............................................................................279
11.2.3 常用方法 ...............................................................................................279
11.3使用 HashSet .................................................................................... 280
11.3.1 基本語法 ...............................................................................................280
11.3.2 執行集合運算 .......................................................................................281
11.4本章小結 ........................................................................................... 283
11.5小測驗 ——中級集合 ...................................................................... 283
第12章探索泛型、委托等 ................................................................284
12.1 泛型................................................................................................... 284
12.1.1 泛型對象 ...............................................................................................285
12.1.2 泛型方法 ...............................................................................................287
12.1.3 約束類型參數 .......................................................................................290
12.2 委托行為........................................................................................... 291
12.2.1 基本語法 ...............................................................................................291
12.2.2 將委托作為參數類型 ...........................................................................294
12.3 觸發事件........................................................................................... 296
12.3.1 基本語法 ...............................................................................................296
12.3.2 處理事件訂閱 .......................................................................................298
12.4 處理異常........................................................................................... 301
12.4.1 拋出異常 ...............................................................................................301
12.4.2 使用 try-catch........................................................................................304
12.5 設計模式入門 .................................................................................. 307
12.6 本章小結........................................................................................... 309
12.7 小測驗——中級 C#......................................................................... 309
第13章旅程繼續 ...............................................................................310
13.1 有待深入的基礎知識 ...................................................................... 310
13.2 牢記面向對象編程 .......................................................................... 311
13.3 瞭解 Unity項目 ............................................................................... 312
13.4 進一步學習 ....................................................................................... 313
13.4.1 C#資源...................................................................................................313
13.4.2 Unity資源.............................................................................................314
13.4.3 Unity認證.............................................................................................314
13.5 本章小結........................................................................................... 315
小測驗答案 ............................................................................................317