logo资料库

星球大战unity3游戏详解(内含代码).doc

第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
资料共11页,剩余部分请下载后查看
Introduction Game Design & Dev Business case Game development Degree Program: Course No.: Course Title: Type of Assessment: Deadline Date: Software Engineering Introduction Game Design & /Development Case study 6/12/2018
Assignment: Reason: Learning Outcomes: Business case Monsters Destruction Game Written report of 1000 words, excluding Table of Content and Appendix To assess students’ understanding of development of game design using Unity 5 tool explained at lesson, in particular way how to “Design” the game and implementing the corresponding “Logic” using C# programming language. 1. Understand the requirement for game development, both the design part and logic part, critically analyzing all the structures necessary for the game . 2. Demonstrate that student has learned all the explained technologies to a degree that he/she is able to develop a simple game application, that works based on customer’s requirements. 3. Demonstrate that the student is able to understand how to create a game application dividing the “Design” part from the “Logic” part. Deadline: 3 weeks after case has been introduced to the students. Assignment Format: Line space 1.5, Times New Roman size 12. Assessment Criteria: Criteria Project explanation Project implementation : game design Project implementation : logic implementation Code explanation Test phase Conclusions Total Points 10 20 20 30 10 10 100
The Case: Setting: A company “Pixar Animation Studios” contacted you to implement the Level 1 of Monsters Destruction Game. This application implements a space battle between humans and monsters that want to attack planet Earth. So the game consists of a “human” spaceship that fights against “monster” spaceships and has to destroy as many monster space shuttles as possible. This game must work as following described: 1. Human spaceship: can move left and right and back and forward, shooting bullets to destroy monster’s shuttle. 2. Monster spaceship: can move from top to down and when destroyed by some human bullets, it must emerge in a some position. Besides there are two types of monster spaceships: a. Monster 1 spaceship cannot shoot bullets and when destroyed you earn 2 point b. Monster 2 spaceship can shoot bullet toward human spaceship and when destroyed you earn 5 points 3. Collecting points : collecting and showing the total score, as you destroy an enemy. 4. Human and Monster all have life-times: for example, Human can have 3 life-times and monster can have 5 life-times and when it is collided with bullet its life will be decrease one and when the life-time is zero, it will be destroyed. Your job as software developer is to implement the corresponding “Design” phase and “Logic” code using C# as programming language. One important aspect of this project is “documentation”, that is you have also to prepare a short tutorial for the final customer, explaining how this application has been implemented and how to use it. For example, you have to provide the user with the following playing information: 1. How to move left/right and back/forward human spaceship
2. How to shoot bullets Create screenshot of the program to use as documentation for the final customer. Requirements: You can divide this project into two main parts: 1. Design implementation 2. Logic implementation providing the corresponding description, code, screenshots and all you think necessary for the project documentation. NOTE : I will pay particular attention at “Logic implementation” phase , where student must explain in a very detailed way how the game works and the corresponding C# code implementation. If you do not explain the C# code you will lose points!!! Tips: Create a complete “Shooting system” game, based on a simple shooting system(a Player, a Bullet and a Target). ADVICE : test your game every time you implement/change the C# script to avoid having to solve too many problems at the same time!!!
using UnityEngine; using System.Collections; //[AddComponentMenu("MyGame/Player")] public class Player : MonoBehaviour { public float m_speed = 1; public float m_life = 3; // prefab public Transform m_rocket; protected Transform m_transform; float m_rocketRate = 0; public AudioClip m_shootClip; protected AudioSource m_audio; public Transform m_explosionFX; protected Vector3 m_targetPos; public LayerMask m_inputMask; //float movev=0; //float moveh=0; // Use this for initialization void Start () { m_transform = this.transform; m_audio = this.GetComponent(); m_targetPos = this.m_transform.position; } // Update is called once per frame void Update () { if (Input.GetKey(KeyCode.UpArrow)) { //movev -= m_speed * Time.deltaTime; transform.Translate(Vector3.back * Time.deltaTime*m_speed); } if(Input.GetKey(KeyCode.DownArrow)){ // movev += m_speed * Time.deltaTime; transform.Translate(Vector3.forward * Time.deltaTime*m_speed); } if(Input.GetKey(KeyCode.LeftArrow)){ transform.Translate(Vector3.right * Time.deltaTime*m_speed); // moveh += m_speed * Time.deltaTime; } if ( Input.GetKey( KeyCode.RightArrow ) ) { //moveh -= m_speed * Time.deltaTime; transform.Translate(Vector3.left * Time.deltaTime*m_speed); // 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) ) { Instantiate( m_rocket, m_transform.position, m_transform.rotation ); m_audio.PlayOneShot(m_shootClip); } void OnTriggerEnter(Collider other) { if (other.tag.CompareTo("PlayerRocket") != 0) { m_life -= 1;
if (m_life <= 0) { Instantiate(m_explosionFX, m_transform.position, Quaternion.identity); Destroy(this.gameObject); } } } } using UnityEngine; using System.Collections; public class Enemy : MonoBehaviour { public float m_speed = 1; public float m_life = 10; protected float m_rotSpeed = 30; protected Transform m_transform; public Transform m_explosionFX; public int m_point = 10; // Use this for initialization void Start () { m_transform = this.transform; } // Update is called once per frame void Update () { UpdateMove(); } protected virtual void UpdateMove() { // moving left and right float rx = Mathf.Sin(Time.time) * Time.deltaTime; // move forward m_transform.Translate(new Vector3(rx, 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 <= 0) { GameManager.Instance.AddScore(m_point); Instantiate(m_explosionFX, m_transform.position, Quaternion.identity); Destroy(this.gameObject); } } } else if (other.tag.CompareTo("Player") == 0) { m_life = 0; Instantiate(m_explosionFX, m_transform.position, Quaternion.identity); Destroy(this.gameObject); } if (other.tag.CompareTo("bound") == 0) { m_life = 0; Destroy(this.gameObject); }
} } using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; public class GameManager : MonoBehaviour { public 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; } // Use this for initialization void Start () { } } // Update is called once per frame void Update () { // paly background music in loop if (!m_Audio.isPlaying) { m_Audio.clip = m_musicClip; m_Audio.Play(); } } void OnGUI() { // pause the game if (Time.timeScale == 0) { m_Audio = this.GetComponent(); // find player GameObject obj = GameObject.FindGameObjectWithTag("Player"); if (obj != null) { m_player = obj.GetComponent(); } // pause the game if (Time.timeScale > 0 && Input.GetKeyDown(KeyCode.Escape)) { Time.timeScale = 0; // continue the game if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.4f, 100, 30), "Continue the gaem")) Time.timeScale = 1; } // exit the game if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.6f, 100, 30), "game exit")) { { } // exit the game Application.Quit(); } int life = 0;
if (m_player != null) { // get the life value of player life = (int)m_player.m_life; } else // game over { // enlarger the font GUI.skin.label.fontSize = 50; // display the game failure GUI.skin.label.alignment = TextAnchor.LowerCenter; GUI.Label(new Rect(0, Screen.height * 0.2f, Screen.width, 60), "game failue"); GUI.skin.label.fontSize = 20; // display button to try again if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.5f, 100, 30), "Try again")) // read the current level SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); // Application.LoadLevel(Application.loadedLevelName); { } } GUI.skin.label.fontSize = 15; // display the player life value GUI.Label(new Rect(5, 5, 100, 30), "player" + life); // display the recorded highest score GUI.skin.label.alignment = TextAnchor.LowerCenter; GUI.Label(new Rect(0, 5, Screen.width, 30), "Records" + m_hiscore); // display the current score GUI.Label(new Rect(0, 25, Screen.width, 30), "Score " + m_score); } // public void AddScore( int point ) { m_score += point; // update the highest recorded score if (m_hiscore < m_score) m_hiscore = m_score; } } using UnityEngine; using System.Collections; [AddComponentMenu("MyGame/EnemyRocket")] public class EnemyRocket : Rocket { void OnTriggerEnter(Collider other) { if (other.tag.CompareTo("Player") != 0) return; Destroy(this.gameObject); } } using UnityEngine; using System.Collections; [AddComponentMenu("MyGame/EnemySpawn")] public class EnemySpawn : MonoBehaviour
分享到:
收藏