1、游戏程序设计课程报告课程: Unity3D 课程设计题目: 探索迷宫班级: 学号: 姓名: 日期: 2014.12一、 摘要13UNITY 游戏是一种新型的IT 引擎。我们研究主要内容是UNITY 游戏设计方法。指以游戏客户端软件为信息交互窗口的旨在实现娱乐、休闲、交流和取得虚拟成就的具有可持续性的个体性单人游戏。本报告主要讲述了这个小游戏的设计思路及初步使用 Unity3D 软件的感受和总结。设计过程中,首先建立自己想要的模型,然后在此基础上进行需求迭代,详细设计时不断地修正和完善,经过测试阶段反复调试和验证,最终形成达到设计要求的小游戏。基于 UNITY 基础,构建了一个益智游戏风格的游戏
2、,并有主角与关卡、游戏逻辑、游戏环境界面等设计,使得玩家可以在场景中进行寻找神龛的冒险游戏。本游戏的控制很简单,及用键盘的 WASD 及 SPACE 五个控制人物的上下左右跳跃五个方向,用户根据自己的战略方式选择寻找油桶点亮煤油灯然后寻找神龛。二、 概述UNITY 游戏程序设计这一课程以大作业形式进行考核,能更好地锻炼学生综合运用本课程所授知识的能力。大作业主要内容为设计完成面向某一主题内容的游戏演示程序。自选游戏主题,并根据所选定的主题内容设计一个典型的游戏场景及玩家逻辑,其中包含主角与关卡,游戏逻辑,游戏环境界面与交互过程等的设计;开发完成与设计相符的游戏 Demo。要求使用 Unity3
3、D 游戏开发软件实现上述游戏 Demo。三、 具体要求1、每人单独完成,特殊可由多人合作完成。2、游戏主题自拟。3、根据所设游戏主题、场景及玩家逻辑,实现完成相应的游戏 Demo,并撰写设计开发报告。四、 设计主题 基于视频教程“平衡球”的基础,构建了一个益智游戏风格的游戏,并有主角与关卡(一关)、游戏逻辑(触碰油桶、神龛)、游戏环境界面(通道)等设计,使得玩家可以在场景轨道中进行吃油桶、神龛的冒险游戏。五、 设计思路 本游戏以几个环环相扣的通道作为人物运动的轨迹,在通道上 分别设计一些油桶,通过电脑上的 WASD SPACE 分别控制人物的运动方向;如果人物运动位置没有偏离所设计通道平面而且
4、碰触到油桶, 即算初步成功,当人物吃掉所设计的油桶,油灯就会点亮。当人物 找到并吃掉所设计的神龛,就会通过关卡。 本报告主要讲述了这个小游戏的设计思路及初步使用 Unity3D 软件的感受和总结。设计过程中,首先建立自己想要的模型,然后在此基础上进行需求迭代,详细设计时不断地修正和完善,经过测试阶段反复调试和验证,最终形成达到设计要求的小游戏。六、 具体构建步骤 1、 场景素材的添加,通过 3DMAX 建模完成素材的创建2、 在 UNITY3D 中完成素材的组装3、 为场景贴图。贴图时,根据道具的风格,选择地面与墙的BSP 贴图,每次贴图选择一个平面的一个面。4、 创建预组件5、 将创建并且组
5、装的模型添加到预组件中,并且通过复制完成整个游戏场景的拼接6、 导入 UNITY 的人物控制组件 7、在场景中添加细节七、 程序脚本1、 游戏开始触发器程序(main):using UnityEngine;using System.Collections;public class main : MonoBehaviour public Rect windowRect = new Rect(20, 20, 120, 50);/ Use this for initializationvoid Start () / Update is called once per framevoid Update
6、 () void OnGUI() windowRect = GUILayout.Window(0, windowRect, DoMyWindow, Find Shrine);void DoMyWindow(int windowID) if (GUILayout.Button (Game Start) Application .LoadLevel (testgame_02); print (Got a click);2、 人物所触发的事件:using UnityEngine;using System.Collections;public class inventory : MonoBehavio
7、ur public int fuelAmount=0;public AudioClip fuelcollectedsound; public Texture2D hudFuelAmount; public GUITexture fuelAmountHUDGUI; public Light lanternlight;public float origfueltimer=30.0f; public float fueltimer=0.0f;public float origfuelGUItimer=30.0f; public float fuelGUItimer=0.0f; public int
8、maxfuelAmount;/public Rect windowRect = new Rect(20, 20, 120, 50);/ Use this for initializationvoid Start () fuelAmount = 0;lanternlight = GameObject .Find (Lantern).GetComponent (); maxfuelAmount = hudFuelAmount .Length;/ Update is called once per framevoid Update () if (fueltimer 0)fueltimer -=Tim
9、e.deltaTime ;if (fueltimer 0.0f & fuelAmount 0) fuelGUItimer -=Time.deltaTime ;if (fuelGUItimer 0.0f) removeGUIfuel ();void FuelPickUp()if (fuelAmount 0) fuelAmount -;fuelAmountHUDGUI.texture = hudFuelAmount fuelAmount; fuelGUItimer =origfuelGUItimer ;3、 油灯被触发时的事件:using UnityEngine;using System.Coll
10、ections;public class LanternFuel : MonoBehaviour/ Use this for initializationvoid Start ()/ Update is called once per framevoid Update ()void OnTriggerEnter(Collider player)player .gameObject .SendMessage (FuelPickUp); Destroy (this.gameObject );4、 游戏开始时随机出现人物与神龛的位置:using UnityEngine;using System.Co
11、llections;public class gamestate : MonoBehaviourprivate GameObject player;private playerspawncontroller playerspawnCTRL; private GameObject randPlayerSpawn;private GameObject Shrine;private Shrinespawn shrinespawnCTRL; private GameObject randShrinespawn;void Awake()player = GameObject.FindWithTag (P
12、layer); playerspawnCTRL = GameObject .FindGameObjectWithTag(PlayerSpawnCTRL).GetComponent (); Shrine = GameObject .FindWithTag (Shrine); shrinespawnCTRL = GameObject .FindGameObjectWithTag(shrinespawnCTRL).GetComponent ();/ Use this for initializationvoid Start ()int randNum = 0; int randNum1 = 0;ra
13、ndPlayerSpawn = playerspawnCTRL.GetRandomPlayerSpawn (randNum); SpawnPlayer ();randShrinespawn = shrinespawnCTRL .GetRandomshrineSpawn (randNum1);Spawnshrine ();/ Update is called once per framevoid Update ()void SpawnPlayer()player.transform.position = randPlayerSpawn .transform .position; Debug .Log (你出生在+randPlayerSpawn .name );void Spawnshrine()
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1