unity3d游戏课程设计报告.docx
《unity3d游戏课程设计报告.docx》由会员分享,可在线阅读,更多相关《unity3d游戏课程设计报告.docx(13页珍藏版)》请在冰豆网上搜索。
![unity3d游戏课程设计报告.docx](https://file1.bdocx.com/fileroot1/2022-10/3/25e61be2-6eaf-4ba0-befc-d934abe2f69c/25e61be2-6eaf-4ba0-befc-d934abe2f69c1.gif)
游戏程序设计课程报告
课程:
Unity3D课程设计
题目:
探索迷宫
班
级:
学
号:
姓
名:
日
期:
2014.12
一、摘要
13
UNITY游戏是一种新型的 IT引擎。
我们研究主要内容是
UNITY游戏设计方法。
指以游戏客户端软件为信息交互窗口的旨在实现娱乐、休闲、交流和取得虚拟成就的具有可持续性的个体性单人游戏。
本报告主要讲述了这个小游戏的设计思路及初步使用Unity3D软件的感受和总结。
设计过程中,首先建立自己想要的模型,然后在此基础上进行需求迭代,详细设计时不断地修正和完善,经过测试阶段反复调试和验证,最终形成达到设计要求的小游戏。
基于UNITY基础,构建了一个益智游戏风格的游戏,并有主角与关卡、游戏逻辑、游戏环境界面等设计,使得玩家可以在场景中进行寻找神龛的冒险游戏。
本游戏的控制很简单,及用键盘的WASD及SPACE五个控制人物的上下左右跳跃五个方向,用户根据自己的战略方式选择寻找油桶点亮煤油灯然后寻找神龛。
二、概述
《UNITY游戏程序设计》这一课程以大作业形式进行考核,能更好地锻炼学生综合运用本课程所授知识的能力。
大作业主要内容为设计完成面向某一主题内容的游戏演示程序。
自选游戏主题,并根据所选定的主题内容设计一个典型的游戏
场景及玩家逻辑,其中包含主角与关卡,游戏逻辑,游戏环境界面与交互过程等的设计;开发完成与设计相符的游戏Demo。
要求使用Unity3D游戏开发软件实现上述游戏Demo。
三、具体要求
1、 每人单独完成,特殊可由多人合作完成。
2、 游戏主题自拟。
3、 根据所设游戏主题、场景及玩家逻辑,实现完成相应的游戏Demo,并撰写设计开发报告。
四、设计主题
基于视频教程“平衡球”的基础,构建了一个益智游戏风格的游戏,并有主角与关卡(一关)、游戏逻辑(触碰油桶、神龛)、游戏环境界面(通道)等设计,使得玩家可以在场景轨道中进行吃油桶、神龛的冒险游戏。
五、设计思路
本游戏以几个环环相扣的通道作为人物运动的轨迹,在通道上分别设计一些油桶,通过电脑上的WASDSPACE分别控制人物的运动方向;如果人物运动位置没有偏离所设计通道平面而且碰触到油桶,即算初步成功,当人物吃掉所设计的油桶,油灯就会点亮。
当人物找到并吃掉所设计的神龛,就会通过关卡。
本报告主要讲述了这个小游戏的设计思路及初步使用Unity3D软件的感受和总结。
设计过程中,首先建立自己想要的模型,然后在此基础上进行需求迭代,详细设计时不断地修正和完善,经过测
试阶段反复调试和验证,最终形成达到设计要求的小游戏。
六、具体构建步骤
1、场景素材的添加,通过3DMAX建模完成素材的创建
2、在UNITY3D中完成素材的组装
3、为场景贴图。
贴图时,根据道具的风格,选择地面与墙的
BSP贴图,每次贴图选择一个平面的一个面。
4、创建预组件
5、将创建并且组装的模型添加到预组件中,并且通过复制完成整个游戏场景的拼接
6、导入UNITY的人物控制组件
7、在场景中添加细节
七、程序脚本
1、游戏开始触发器程序(main):
usingUnityEngine;
usingSystem.Collections;
publicclassmain:
MonoBehaviour{
publicRectwindowRect=newRect(20,20,120,50);
//Usethisforinitialization
voidStart(){
}
//Updateiscalledonceperframe
voidUpdate(){
}
voidOnGUI(){
windowRect=GUILayout.Window(0,windowRect,DoMyWindow,"FindShrine");
}
voidDoMyWindow(intwindowID){
if(GUILayout.Button("GameStart")){Application.LoadLevel("testgame_02");print("Gotaclick");
}
}
}
2、人物所触发的事件:
usingUnityEngine;
usingSystem.Collections;
publicclassinventory:
MonoBehaviour{publicintfuelAmount=0;
publicAudioClipfuelcollectedsound;publicTexture2D[]hudFuelAmount;publicGUITexturefuelAmountHUDGUI;publicLightlanternlight;
publicfloatorigfueltimer=30.0f;publicfloatfueltimer=0.0f;
publicfloatorigfuelGUItimer=30.0f;publicfloatfuelGUItimer=0.0f;publicintmaxfuelAmount;
//publicRectwindowRect=newRect(20,20,120,50);
//Usethisforinitialization
voidStart(){fuelAmount=0;
lanternlight=GameObject.Find("Lantern").GetComponent();maxfuelAmount=hudFuelAmount.Length;
}
//Updateiscalledonceperframe
voidUpdate(){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();
}
}
voidFuelPickUp(){
if(fuelAmountAudioSource.PlayClipAtPoint(fuelcollectedsound,
transform.position);
fuelAmount++;
fuelAmountHUDGUI.texture=hudFuelAmount[fuelAmount];lanternlight.light.intensity=1.0f;
if(fuelGUItimer==0.0f){
fuelGUItimer=origfuelGUItimer;
}
}
}
voidremoveGUIfuel(){
if(fuelAmount>0){fuelAmount--;
fuelAmountHUDGUI.texture=hudFuelAmount[fuelAmount];fuelGUItimer=origfuelGUItimer;
}
}
}
3、油灯被触发时的事件:
usingUnityEngine;
usingSystem.Collections;
publicclassLanternFuel:
MonoBehaviour
{
//Usethisforinitialization
voidStart()
{
}
//Updateiscalledonceperframe
voidUpdate()
{
}
voidOnTriggerEnter(Colliderplayer)
{
player.gameObject.SendMessage("FuelPickUp");Destroy(this.gameObject);
}
}
4、游戏开始时随机出现人物与神龛的位置:
usingUnityEngine;
usingSystem.Collections;
publicclassgamestate:
MonoBehaviour
{
privateGameObjectplayer;
privateplayerspawncontrollerplayerspawnCTRL;privateGameObjectrandPlayerSpawn;
privateGameObjectShrine;
privateShrinespawnshrinespawnCTRL;privateGameObjectrandShrinespawn;
voidAwake()
{
player=GameObject.FindWithTag("Player");playerspawnCTRL=GameObject.FindGameObjectWithTag
("PlayerSpawnCTRL").GetComponent();Shrine=GameObject.FindWithTag("Shrine");shrinespawnCTRL=GameObject.FindGameObjectWithTag
("shrinespawnCTRL").GetComponent();
}
//Usethisforinitialization
voidStart()
{
intrandNum=0;intrandNum1=0;
randPlayerSpawn=playerspawnCTRL.GetRandomPlayerSpawn(randNum);SpawnPlayer();
randShrinespawn=shrinespawnCTRL.GetRandomshrineSpawn(randNum1);
Spawnshrine();
}
//Updateiscalledonceperframe
voidUpdate()
{
}
voidSpawnPlayer()
{
player.transform.position=randPlayerSpawn.transform.position;Debug.Log("你出生在"+randPlayerSpawn.name);
}
voidSpawnshrine()