ImageVerifierCode 换一换
格式:DOCX , 页数:14 ,大小:17.35KB ,
资源ID:18888564      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/18888564.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Unity3D太空大战Word文件下载.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Unity3D太空大战Word文件下载.docx

1、 / Update is called once per frame void Update () UpdateMove(); protected virtual void UpdateMove() m_timer -= Time.deltaTime; if (m_timer = 0) m_timer = 3; /改变旋转方向 m_rotSpeed = -m_rotSpeed; / 旋转方向 m_transform.Rotate(Vector3.up, m_rotSpeed * Time.deltaTime, Space.World); / 前进 m_transform.Translate(n

2、ew Vector3(0, 0, -m_speed * Time.deltaTime); void OnTriggerEnter(Collider other) if (other.tag.CompareTo(PlayerRocket) = 0) Rocket rocket = other.GetComponent(); if (rocket != null) m_life -= rocket.m_power; if (m_life GameManager.Instance.AddScore(m_point); Instantiate(m_explosionFX, m_transform.po

3、sition, Quaternion.identity); Destroy(this.gameObject); else if (other.tag.CompareTo(Player m_life = 0;bound(2)EnemyRocket的源码:MyGame/EnemyRocketpublic class EnemyRocket : Rocket) ! return;(3)EnemySpawn敌人生成器:MyGame/EnemySpawnpublic class EnemySpawn : MonoBehaviour / 敌人的Prefab public Transform m_enemy

4、; / 生成敌人的时间间隔 protected float m_timer = 5; m_timer = Random.value * 15.0f; 5) m_timer = 5; Instantiate(m_enemy, m_transform.position, Quaternion.identity); void OnDrawGizmos () Gizmos.DrawIcon (transform.position, item.png, true);(4)GameMannager图形界面:MyGame/GameManagerpublic class GameManager : publi

5、c static GameManager Instance; /得分 public int m_score = 0; /纪录 public static int m_hiscore = 0; /主角 protected Player m_player; / 背景音乐 public AudioClip m_musicClip; / 声音源 protected AudioSource m_Audio; void Awake() Instance = this; m_Audio = this.audio; / 获取主角 GameObject obj = GameObject.FindGameObje

6、ctWithTag(); if (obj ! m_player = obj.GetComponent / 循环播放背景音乐 if (!m_Audio.isPlaying) m_Audio.clip = m_musicClip; m_Audio.Play(); / 暂停游戏 if (Time.timeScale 0 & Input.GetKeyDown(KeyCode.Escape) Time.timeScale = 0; void OnGUI() / 游戏暂停 if (Time.timeScale = 0) / 继续游戏按钮 if (GUI.Button(new Rect(Screen.wid

7、th * 0.5f - 50, Screen.height * 0.4f, 100, 30), 继续游戏) Time.timeScale = 1; / 退出游戏按钮 if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.6f, 100, 30), 退出游戏 / 退出游戏 Application.Quit(); int life = 0; if (m_player ! / 获得主角的生命值 life = (int)m_player.m_life; else / game over / 放大字体 GUI.skin.l

8、abel.fontSize = 50; / 显示游戏失败 GUI.skin.label.alignment = TextAnchor.LowerCenter; GUI.Label(new Rect(0, Screen.height * 0.2f, Screen.width, 60), 游戏失败 GUI.skin.label.fontSize = 20; / 显示按钮 if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.5f, 100, 30), 再试一次 / 读取当前关卡 Application.LoadLev

9、el(Application.loadedLevelName); GUI.skin.label.fontSize = 15; / 显示主角生命 GUI.Label(new Rect(5, 5, 100, 30), 装甲 + life); / 显示最高分 GUI.Label(new Rect(0, 5, Screen.width, 30), 纪录 + m_hiscore); / 显示当前得分 GUI.Label(new Rect(0, 25, Screen.width, 30), 得分 + m_score); / 增加分数 public void AddScore( int point ) m_

10、score += point; / 更新高分纪录 if (m_hiscore m_score) m_hiscore = m_score;(5)Player主飞船的源码:MyGame/Playerpublic class Player : public float m_life = 3; / 子弹prefab public Transform m_rocket; / 发射子弹频率 float m_rocketRate = 0; / 声音 public AudioClip m_shootClip; protected AudioSource m_audio; / 爆炸特效 m_audio = th

11、is.audio; / 纵向移动距离 float movev=0; / 水平移动距离 float moveh=0; / 按上键 if ( Input.GetKey( KeyCode.UpArrow ) ) movev -= m_speed * Time.deltaTime; / 按下键 if ( Input.GetKey( KeyCode.DownArrow ) ) movev += m_speed * Time.deltaTime; / 按左键 if ( Input.GetKey( KeyCode.LeftArrow ) ) moveh += m_speed * Time.deltaTime

12、; / 按右键 if ( Input.GetKey( KeyCode.RightArrow ) ) moveh -= m_speed * Time.deltaTime; / 移动 this.m_transform.Translate( new Vector3( moveh, 0, movev ) ); m_rocketRate -= Time.deltaTime; if ( m_rocketRate = 0 ) m_rocketRate = 0.1f; if ( Input.GetKey( KeyCode.Space ) | Input.GetMouseButton(0) ) Instanti

13、ate( m_rocket, m_transform.position, m_transform.rotation ); / 播放射击声音 m_audio.PlayOneShot(m_shootClip); m_life -= 1;= 0) (6)Rocket子弹的源码:MyGame/Rocketpublic class Rocket : / 子弹飞行速度 public float m_speed = 10; / 生存时间 public float m_liveTime = 1; / 威力 public float m_power = 1.0f; protected Transform m_t

14、rasform; m_trasform = this.transform; m_liveTime -= Time.deltaTime; if (m_liveTime m_trasform.Translate( new Vector3( 0, 0, -m_speed * Time.deltaTime ) );Enemy)!=0)(7)SuperEnemy源码:MyGame/SuperEnemypublic class SuperEnemy : Enemy protected float m_fireTimer = 2; protected Transform m_player; GameObje

15、ct obj=GameObject.FindGameObjectWithTag( if ( obj!=null ) m_player=obj.transform; protected override void UpdateMove() m_fireTimer -= Time.deltaTime; if (m_fireTimer m_fireTimer = 2; if ( m_player! Vector3 relativePos = m_transform.position-m_player.position; Instantiate( m_rocket, m_transform.posit

16、ion, Quaternion.LookRotation(relativePos) );(8)TitleScreen的源码:MyGame/TitleScreenpublic class TitleScreen : / 文字大小 GUI.skin.label.fontSize = 48; / UI中心对齐 / 显示标题 GUI.Label(new Rect(0, 30, Screen.width, 100), 太空大战 / 开始游戏按钮 if (GUI.Button(new Rect(Screen.width * 0.5f - 100, Screen.height * 0.7f, 200, 30), 开始游戏 / 开始读取下一关 Application.LoadLevel(level1

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1