当前位置:文档之家› unity3d游戏课程设计报告

unity3d游戏课程设计报告

游戏程序设计课程报告课程:Unity3D课程设计题目:探索迷宫班级:学号:姓名:日期:2014.12一、摘要UNITY游戏是一种新型的IT引擎。

我们研究主要内容是UNITY 游戏设计方法。

指以游戏客户端软件为窗口的旨在实现娱乐、休闲、交流和取得虚拟成就的具有可持续性的个体性单人游戏。

本报告主要讲述了这个小游戏的设计思路及初步使用Unity3D 软件的感受和总结。

设计过程中,首先建立自己想要的模型,然后在此基础上进行需求迭代,详细设计时不断地修正和完善,经过测试阶段反复调试和验证,最终形成达到设计要求的小游戏。

基于UNITY基础,构建了一个益智游戏风格的游戏,并有主角与关卡、游戏逻辑、游戏环境界面等设计,使得玩家可以在场景中进行寻找神龛的冒险游戏。

本游戏的控制很简单,及用键盘的W ASD及SPACE五个控制人物的上下左右跳跃五个方向,用户根据自己的战略方式选择寻找油桶点亮煤油灯然后寻找神龛。

二、概述《UNITY游戏程序设计》这一课程以大作业形式进行考核,能更好地锻炼学生综合运用本课程所授知识的能力。

大作业主要内容为设计完成面向某一主题内容的游戏演示程序。

自选游戏主题,并根据所选定的主题内容设计一个典型的游戏场景及玩家逻辑,其中包含主角与关卡,游戏逻辑,游戏环境界面与交互过程等的设计;开发完成与设计相符的游戏Demo。

要求使用Unity3D游戏开发软件实现上述游戏Demo。

三、具体要求1、每人单独完成,特殊可由多人合作完成。

2、游戏主题自拟。

3、根据所设游戏主题、场景及玩家逻辑,实现完成相应的游戏Demo,并撰写设计开发报告。

四、设计主题基于视频教程“平衡球”的基础,构建了一个益智游戏风格的游戏,并有主角与关卡(一关)、游戏逻辑(触碰油桶、神龛)、游戏环境界面(通道)等设计,使得玩家可以在场景轨道中进行吃油桶、神龛的冒险游戏。

五、设计思路本游戏以几个环环相扣的通道作为人物运动的轨迹,在通道上分别设计一些油桶,通过电脑上的WASD SPACE分别控制人物的运动方向;如果人物运动位置没有偏离所设计通道平面而且碰触到油桶,即算初步成功,当人物吃掉所设计的油桶,油灯就会点亮。

当人物找到并吃掉所设计的神龛,就会通过关卡。

本报告主要讲述了这个小游戏的设计思路及初步使用Unity3D 软件的感受和总结。

设计过程中,首先建立自己想要的模型,然后在此基础上进行需求迭代,详细设计时不断地修正和完善,经过测试阶段反复调试和验证,最终形成达到设计要求的小游戏。

六、具体构建步骤1、场景素材的添加,通过3DMAX建模完成素材的创建2、在UNITY3D中完成素材的组装3、为场景贴图。

贴图时,根据道具的风格,选择地面与墙的BSP贴图,每次贴图选择一个平面的一个面。

4、创建预组件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 () {}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 : MonoBehaviour {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 maxfuelAmount;//public Rect windowRect = new Rect(20, 20, 120, 50);// Use this for initializationvoid Start () {fuelAmount = 0;lanternlight = GameObject .Find ("Lantern").GetComponent <Light> ();maxfuelAmount = hudFuelAmount .Length;}// Update is called once per framevoid Update () {if (fueltimer > 0){fueltimer -=Time.deltaTime ;}if (fueltimer < 0.0f){lanternlight .light .intensity =0.0f;}if (fuelGUItimer > 0.0f && fuelAmount > 0) {fuelGUItimer -=Time.deltaTime ;}if (fuelGUItimer < 0.0f) {removeGUIfuel ();}}void FuelPickUp(){if (fuelAmount < maxfuelAmount - 1) {fueltimer += origfueltimer;AudioSource .PlayClipAtPoint (fuelcollectedsound, transform.position);fuelAmount ++;fuelAmountHUDGUI.texture = hudFuelAmount [fuelAmount];lanternlight .light .intensity = 1.0f;if (fuelGUItimer == 0.0f) {fuelGUItimer = origfuelGUItimer;}}}void removeGUIfuel(){if (fuelAmount > 0) {fuelAmount --;fuelAmountHUDGUI.texture = hudFuelAmount [fuelAmount];fuelGUItimer =origfuelGUItimer ;}}}3、油灯被触发时的事件:using UnityEngine;using System.Collections;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.Collections;public class gamestate : MonoBehaviour{private GameObject player;private playerspawncontroller playerspawnCTRL;private GameObject randPlayerSpawn;private GameObject Shrine;private Shrinespawn shrinespawnCTRL;private GameObject randShrinespawn;void Awake(){player = GameObject.FindWithTag ("Player");playerspawnCTRL = GameObject .FindGameObjectWithTag ("PlayerSpawnCTRL").GetComponent <playerspawncontroller > ();Shrine = GameObject .FindWithTag ("Shrine");shrinespawnCTRL = GameObject .FindGameObjectWithTag ("shrinespawnCTRL").GetComponent <Shrinespawn > ();}// Use this for initializationvoid Start (){int randNum = 0;int randNum1 = 0;randPlayerSpawn = 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(){Shrine .transform .position = randShrinespawn .transform .position;Debug .Log ("神龛出生在"+randShrinespawn .name );}}5、接触到油桶后油桶会消失using UnityEngine;using System.Collections;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 );}}八、游戏规则游戏规则模块也是本文的一个重点部分,需要实现人物接触油桶游戏的基本规则,因此,首先要解决的问题是触发问题,根据通道的大小制定油桶的地点,然后要解决的问题是人物与油桶的接触过程,保证人物接触油桶后油桶消失;如果能寻找到神龛,则游戏胜利。

相关主题