using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization.Formatters.Binary; using System.IO; using UnityEngine.SceneManagement; public class menu : MonoBehaviour { public GUIStyle mystyle;// GUI (, ...) string score; void Start () { StreamReader scoredata = new StreamReader (Application.persistentDataPath + "/score1.gd");// score = scoredata.ReadLine ();// scoredata.Close ();// } // Update is called once per frame void Update () { } void OnGUI(){ GUI.Box (new Rect (Screen.width*0.15f, Screen.height*0.8f, Screen.width*0.7f, Screen.height*0.1f), "MAX DESTROYED:"+score,mystyle); if (GUI.Button (new Rect (Screen.width*0.15f, Screen.height*0.25f, Screen.width*0.7f, Screen.height*0.1f), "START",mystyle)) { SceneManager.LoadScene (1);// } if (GUI.Button (new Rect (Screen.width*0.15f, Screen.height*0.4f, Screen.width*0.7f, Screen.height*0.1f), "EXIT",mystyle)) { Application.Quit();// } } }
using UnityEngine; using System.Collections; public class activemenu : MonoBehaviour { float speed=-0.1f; void Start () { } // Update is called once per frame void Update () { transform.Translate (new Vector3 (0f,speed,0f)); if (transform.position.y < -12f) { transform.position=new Vector3(0f,13f,0f); } } }
using UnityEngine; using System.Collections; public class systemcontrolobjects : MonoBehaviour { void Start () { } void Update () { } void OnTriggerExit2D(Collider2D col) { Destroy(col.gameObject); } }
using UnityEngine; using System.Collections; using System.Runtime.Serialization.Formatters.Binary; using System.IO; public class blockgenerator : MonoBehaviour { public GameObject asteroid;// float x,y,timer; float timerespawn=0.25f;// . . bool trigtime=false;// . true . public int score;// . . , . public float data; void Start () { score = 0;// timer = timerespawn; StreamReader scoredata = new StreamReader (Application.persistentDataPath + "/score1.gd"); data = float.Parse(scoredata.ReadLine ()); scoredata.Close (); } void Update () { if (timer==timerespawn)// : { x = Random.Range (-2.5f, 2.5f);//1) . Instantiate(asteroid, new Vector3(x,5.5f,-2.17f),transform.rotation);//2) . x . trigtime = true;//3) . timerrespawn . } if (trigtime==true)// { timer = timer-Time.deltaTime;// . } if (timer < 0)// : { timer = timerespawn;//1) timerespawn trigtime = false;//2) // " ". . } } }
using UnityEngine; using System.Collections; public class asteroidlogic : MonoBehaviour { public GameObject explosion;// float speedasteroid=-0.1f;// void Start () { } void Update () { transform.Translate (new Vector3 (0, speedasteroid, 0f));// } void OnTriggerEnter2D(Collider2D col) { if (col.tag == "systemcontrol") { return;// controlcountobjects } if (col.tag == "laser") // { Destroy (col.gameObject);// GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().score++;// Instantiate(explosion, transform.position,transform.rotation);// Destroy (this.gameObject);// } } }
using UnityEngine; using System.Collections; public class rotator : MonoBehaviour { int f; float sc; void Start () { f = Random.Range (-5, 5); sc = Random.Range (0.1f,0.2f); transform.localScale = new Vector3 (sc,sc,sc);// } void Update () { transform.rotation *= Quaternion.AngleAxis (f,new Vector3(0,0,1));// } }
using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; using System.Runtime.Serialization.Formatters.Binary; using System.IO; public class carconroller : MonoBehaviour { public GameObject laser;// laser public GameObject laser3x;// laser3x public GameObject laserhor;// laserhor public GameObject laser3xhor;// laser3xhor public GameObject sphere;// sphere public GameObject sphere3x;// sphere3x public GameObject explosionplayer;// explosionplayer float x,y,z,x1,y1; bool trigtime=false; public float speedreset=0.25f;// float timer; Vector2 startpos; Vector2 startcar; // laser...sphere3x public bool gun1 = true;// 1 (laser), , (laser3x...) public bool gun2 = false; public bool gun3 = false; public bool gun4 = false; public bool gun5 = false; public bool gun6 = false; // . . int guncount=0;// , . . void Start () { timer = speedreset; y = laser.transform.position.y; z = laser.transform.position.z; } public void Update () { if (timer < 0) { timer = speedreset; trigtime = false; } if (Input.GetMouseButton(0))// { Vector2 pos = Camera.main.ScreenToWorldPoint (Input.mousePosition);// pos , . transform.position = pos;// pos transform.position = new Vector2 (transform.position.x,transform.position.y+1f);// () if (timer==speedreset)// ( ) { if (gun1 == true)// { Instantiate (laser, new Vector2(transform.position.x,transform.position.y+1.1f), transform.rotation);// laser ( ) trigtime = true; } if (gun2 == true && guncount > 0)// 2- { guncount--;// if (guncount == 0) // 1 { gun1 = true; gun2 = false; gun3 = false; gun4 = false; gun5 = false; gun6 = false; } Instantiate (laser3x, new Vector2(transform.position.x,transform.position.y+1.1f), transform.rotation);// laser3x trigtime = true; } // "" if (gun3 == true && guncount > 0) { guncount--; if (guncount == 0) { gun1 = true; gun2 = false; gun3 = false; gun4 = false; gun5 = false; gun6 = false; } Instantiate (laserhor, new Vector2(transform.position.x,transform.position.y+1.1f), transform.rotation); trigtime = true; } if (gun4 == true && guncount > 0) { guncount--; if (guncount == 0) { gun1 = true; gun2 = false; gun3 = false; gun4 = false; gun5 = false; gun6 = false; } Instantiate (laser3xhor, new Vector2(transform.position.x,transform.position.y+2f), transform.rotation); trigtime = true; } if (gun5 == true && guncount > 0) { guncount--; if (guncount == 0) { gun1 = true; gun2 = false; gun3 = false; gun4 = false; gun5 = false; gun6 = false; } Instantiate (sphere, new Vector2(transform.position.x,transform.position.y+1.1f), transform.rotation); trigtime = true; } if (gun6 == true && guncount > 0) { guncount--; if (guncount == 0) { gun1 = true; gun2 = false; gun3 = false; gun4 = false; gun5 = false; gun6 = false; } Instantiate (sphere3x, new Vector2(transform.position.x,transform.position.y+2f), transform.rotation); trigtime = true; } } if (trigtime == true) { timer = timer - Time.deltaTime;// } } } void OnTriggerEnter2D(Collider2D col) { if (col.tag == "systemcontrol") { return;// controlcountobject } if (col.tag == "gunactivator2")// "" gunactivator2 { gun2 = true;// guncount = 85;// gun1 = false;// "" gun3 = false; gun4 = false; gun5 = false; gun6 = false; Destroy (col.gameObject);// "" return; } // if (col.tag == "gunactivator3") { gun3 = true; guncount = 50; gun1 = false; gun2 = false; gun4 = false; gun5 = false; gun6 = false; Destroy (col.gameObject); return; } if (col.tag == "gunactivator4") { gun4 = true; guncount = 15; gun1 = false; gun3 = false; gun2 = false; gun5 = false; gun6 = false; Destroy (col.gameObject); return; } if (col.tag == "gunactivator5") { gun5 = true; guncount = 100; gun1 = false; gun3 = false; gun4 = false; gun2 = false; gun6 = false; Destroy (col.gameObject); return; } if (col.tag == "gunactivator6") { gun6 = true; guncount = 50; gun1 = false; gun3 = false; gun4 = false; gun5 = false; gun2 = false; Destroy (col.gameObject); return; } // "" , . Handheld.Vibrate ();// ( ) if (GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().score>GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().data)// , { StreamWriter scoredata=new StreamWriter(Application.persistentDataPath + "/score1.gd"); scoredata.WriteLine(GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().score); scoredata.Close(); } Instantiate (explosionplayer, transform.position, transform.rotation);// Destroy (col.gameObject);// Destroy(this.gameObject);// } }
using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; using System.Runtime.Serialization.Formatters.Binary; using System.IO; public class Exit : MonoBehaviour { public GameObject target;// float timer=3f; void Start () { } void Update () { if (Input.GetKey (KeyCode.Escape))// , : { if (GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().score>GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().data) { StreamWriter scoredata=new StreamWriter(Application.persistentDataPath + "/score1.gd"); scoredata.WriteLine(GameObject.Find ("Main Camera").GetComponent<blockgenerator> ().score); // score "blockgenerator", scoredata.Close(); } SceneManager.LoadScene (0);// } if (!GameObject.Find ("playercar"))// ( ) timer { timer = timer - Time.deltaTime; if (timer < 0) { SceneManager.LoadScene (0); } } } }
using UnityEngine; using System.Collections; public class DestroyAsteroid : MonoBehaviour { void Start () { } void Update () { Destroy (this.gameObject,0.4f);// . 400 . . } }
using UnityEngine; using System.Collections; using System.Runtime.Serialization.Formatters.Binary; using System.IO; public class laser : MonoBehaviour { float speedlaser=0.5f; void Start () { } void Update () { transform.Translate (new Vector3 (0, speedlaser, 0f)); } }
using UnityEngine; using System.Collections; public class enemygenerator : MonoBehaviour { public GameObject enemy; bool trigtime=false; float speedreset=2f; float timer,x; void Start () { timer = speedreset; } void Update () { if (timer < 0) { timer = speedreset; trigtime = false; } if (timer == speedreset) { x = Random.Range (-2.5f, 2.5f);// Instantiate(enemy, new Vector2(x,5.5f),transform.rotation);// trigtime = true; } if (trigtime == true) { timer = timer - Time.deltaTime; } } }
using UnityEngine; using System.Collections; public class enemylogic : MonoBehaviour { public GameObject explosionenemy;// public GameObject laserenemy;// // public GameObject gunactivator2; public GameObject gunactivator3; public GameObject gunactivator4; public GameObject gunactivator5; public GameObject gunactivator6; // bool trigtime=false; float speedreset=1.5f;// float timer; float speedenemy = -0.02f;// float x; void Start () { timer = speedreset; } void Update () { if (timer < 0) { timer = speedreset; trigtime = false; } if (timer == speedreset) { Instantiate (laserenemy, new Vector2(transform.position.x,transform.position.y-0.4f), transform.rotation); trigtime = true; } if (trigtime == true) { timer = timer - Time.deltaTime; } transform.Translate (new Vector3 (0, speedenemy, 0f)); } void OnTriggerEnter2D(Collider2D col) { if (col.tag == "systemcontrol") { return; } if (col.tag == "Player") { Instantiate (explosionenemy, transform.position, transform.rotation); Destroy(this.gameObject); } if (col.tag == "laser") { x = Random.Range (0f, 100f);// 0 100 if (x > 1f && x < 5f) // 1 5 gunactivator2 { Instantiate (gunactivator2, transform.position, transform.rotation); } // if (x > 20f && x < 25f) { Instantiate (gunactivator3, transform.position, transform.rotation); } if (x > 40f && x < 45f) { Instantiate (gunactivator4, transform.position, transform.rotation); } if (x > 60f && x < 65f) { Instantiate (gunactivator5, transform.position, transform.rotation); } if (x > 80f && x < 85f) { Instantiate (gunactivator6, transform.position, transform.rotation); } Instantiate (explosionenemy, transform.position, transform.rotation); Destroy(this.gameObject); } } }
using UnityEngine; using System.Collections; public class gunactivatorlogic : MonoBehaviour { float speed = -0.025f; void Start () { } void Update () { transform.Translate (new Vector3 (0, speed, 0f)); } }
Source: https://habr.com/ru/post/324288/