public void whenPlayerDies() { //setHealthText (); if (currentplayer.getHealth() <= 0) { //recenter the boss Vector3 p = THEBOSS.transform.position; float q = p.z; THEBOSS.transform.position = new Vector3(0, 0, q); THEBOSS.giveFullHealth(); //Start a corouting to slow down the time: foreach (GameObject x in this.bulletsFolder) { Destroy(x); } bulletsFolder.Clear(); //currentplayer.destroy(); //this.THEBOSS.model.transform.position.y = 0; players.Remove(currentplayer); shadowPlayers.Add(currentplayer); //startitr = true; if (shadowPlayers.Count <= this.playerLives) { //playertype++; } else if (shadowPlayers.Count >= this.playerLives) { this.gameOver(); } addPlayer(playerOrder[playerOrderIndex], 1, -4, -4); playerOrderIndex++; currentplayer = players [0]; StartCoroutine(iterationSlowdown(3)); if (currentplayer.playerType == 0) { //square currentplayer.setCD(this.coolDownSquare); } else if (currentplayer.playerType == 1) { //circle currentplayer.setCD(this.coolDownCircle); } else if (currentplayer.playerType == 2) { //triangle currentplayer.setCD(this.coolDownTriangle); } } }
public void init(int playerType, tPlayer owner) { this.owner = owner; this.playerType = playerType; movex = 0; movey = 0; // healthval = 40; // damagebuf = 0; cooldownText = Resources.Load <Texture2D> ("Textures/cooldown"); specialText = Resources.Load <Texture2D> ("Textures/special"); abilityOnText = Resources.Load <Texture2D> ("Textures/ability on"); transform.parent = owner.transform; transform.localPosition = new Vector3(0, 0, 0); name = "Player Model"; mat = GetComponent <Renderer> ().material; mat.shader = Shader.Find("Sprites/Default"); if (playerType == 1) { //circle // cd = owner.m.coolDownCircle; cdbuf = -0.5f; this.cdA = 1.5f; this.cdbufA = 0f; mat.mainTexture = Resources.Load <Texture2D> ("Textures/Circle"); //mat.color = Color.red; } else if (playerType == 0) { //square //cd = owner.m.coolDownCircle; cdbuf = -0.5f; this.cdA = 1.5f; mat.mainTexture = Resources.Load <Texture2D> ("Textures/Square"); //mat.color = Color.red; } else if (playerType == 2) { //triangle // cd = 0; cdbuf = -0.5f; this.cdA = 1.5f; mat.mainTexture = Resources.Load <Texture2D> ("Textures/triangle2"); transform.localScale = new Vector3(1.5f, 1.5f, 0); //mat.color = Color.red; } /*else if (playerType == 3) { * mat.mainTexture = Resources.Load<Texture2D> ("Textures/Square"); * mat.color = new Color (1, 5, 1, 1); * //transform.eulerAngles = new Vector3 (0, 0, -45); * }*/ }
//create next boss public void createNextBoss() { this.bossCurrentLife++; GameObject bossObject = new GameObject(); tBoss boss = bossObject.AddComponent <tBoss>(); boss.init(this, bossCurrentLife); //Destroy (THEBOSS.gameObject); THEBOSS = boss; playerOrderIndex = 0; foreach (tPlayer x in players) { Destroy(x.gameObject); } foreach (tPlayer x in shadowPlayers) { Destroy(x.gameObject); } foreach (tEnvVar x in envVariables) { Destroy(x.model.gameObject); Destroy(x.gameObject); } this.players.Clear(); this.shadowPlayers.Clear(); this.envVariables.Clear(); players = new List <tPlayer> (); shadowPlayers = new List <tPlayer> (); envVariables = new List <tEnvVar> (); //createInitialEnv (); playerOrderIndex = 0; addPlayer(playerOrder[playerOrderIndex], 1, -4, -4); playerOrderIndex++; currentplayer = players [0]; if (currentplayer.playerType == 0) { //square currentplayer.setCD(this.coolDownSquare); } else if (currentplayer.playerType == 1) { //circle currentplayer.setCD(this.coolDownCircle); } else if (currentplayer.playerType == 2) { //triangle currentplayer.setCD(this.coolDownTriangle); } }
// Use thi s for initialization public void init(tPlayer target) { this.name = "AOE"; t = target; var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent <tAOEModel>(); // Add a marbleModel script to control visuals of the gem. model.init(this); BoxCollider2D playerbody = gameObject.AddComponent <BoxCollider2D> (); playerbody.isTrigger = true; transform.localScale = new Vector3(1.8f, 1.8f, 1); }
public void addPlayer(int playerTypee, int initHealth, int x, int y) { System.Random rng = new System.Random(); float posx = rng.Next(-8, 8) * 1.0f; //float posy = rng.Next (-4, 4) * 1.0f; //print("sc vector:" + Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0))); //print("screex" + Screen.width +", " + Screen.height + ", " + posx) ; GameObject playerObject = new GameObject(); tPlayer player = playerObject.AddComponent <tPlayer>(); player.transform.parent = playerFolder.transform; player.transform.position = new Vector3(posx, y, 0); player.init(playerTypee, this); players.Add(player); playernum++; player.name = "Player " + players.Count; }
// Use this for initialization public void init(tPlayer target, tBoss owner) { this.name = "TracerBullet"; t = target; m = owner; speed = m.speed; var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent <tTracerBulletModel>(); // Add a marbleModel script to control visuals of the gem. model.init(this); BoxCollider2D playerbody = gameObject.AddComponent <BoxCollider2D> (); playerbody.isTrigger = true; transform.localScale = new Vector3(.8f, .82f, 1); clock = 0; }
void OnGUI() { if (GUI.Button(new Rect(Screen.width - 150, Screen.height - 105, 100, 60), skipToGame)) { SceneManager.LoadScene("scene"); } if (GUI.Button(new Rect(Screen.width - 150, Screen.height - 165, 100, 60), quitText)) { Application.Quit(); } // GUI.Box (new Rect (970, 28, 200, 33), nextUpText); if (level == 0) { // GUIStyle myStyle = new GUIStyle(GUI.skin.GetStyle("label")); // myStyle.fontSize = 40; GUI.skin.box.alignment = TextAnchor.MiddleLeft; GUI.skin.box.fontSize = 25; GUI.Box(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 270, 500, 400), titleText); GUI.color = Color.white; GUI.skin.box.fontSize = 12; GUI.skin.box.alignment = TextAnchor.MiddleCenter; // if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2 + 50, 140, 60),tutorialText)) // { // //level = 10; // SceneManager.LoadScene("main"); // // Here, we can just load a differnet scene // } if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 130, 300, 100), startText) || Input.GetKeyDown(KeyCode.Return)) { level = 1; addPlayer(playerOrder[playerOrderIndex], 1, -4, -4); playerOrderIndex++; currentplayer = players [0]; print("firstplayertype: " + currentplayer.playerType); if (currentplayer.playerType == 0) { //square currentplayer.setCD(this.coolDownSquare); } else if (currentplayer.playerType == 1) { //circle currentplayer.setCD(this.coolDownCircle); } else if (currentplayer.playerType == 2) { //triangle currentplayer.setCD(this.coolDownTriangle); } //setHealthText (); clock = 0f; shadow = new List <Vector3> (); shadowiterator = 0; startitr = false; this.createInitialEnv(); GameObject bossObject = new GameObject(); tBoss boss = bossObject.AddComponent <tBoss>(); boss.init(this, bossCurrentLife); THEBOSS = boss; StartCoroutine(iterationSlowdown(3)); } // if (GUI.Button(new Rect(25, Screen.height - 85, 110, 60), quitText)){ // Application.Quit(); // } if (GUI.Button(new Rect(25, Screen.height - 1555, 110, 60), skipToGame)) { SceneManager.LoadScene("scene"); } } if (level == 10) //level selction { for (int i = 1; i < 7; i++) { GUIStyle BStyle = new GUIStyle(GUI.skin.GetStyle("Button")); BStyle.fontSize = 25; if (GUI.Button(new Rect(Screen.width / 8 + (i - 1) * Screen.width / 8, Screen.height / 2 - Screen.width / 8 / 2 + Screen.width / 8 / 4 / 2, Screen.width / 8 - Screen.width / 8 / 4, Screen.width / 8 - Screen.width / 8 / 4), i.ToString(), BStyle)) { // resetLevel(); level = i; // makeLevel(); } if (GUI.Button(new Rect(100, Screen.height - 100, 200, 80), "Back To Menu")) { // resetLevel(); level = 0; // makeLevel(); } } } if (level == 1) { if (this.gameover) { GUI.skin.box.alignment = TextAnchor.MiddleLeft; GUI.skin.box.fontSize = 25; if (GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height / 2 - 50, 600, 100), gameoverText)) { SceneManager.LoadScene("tutorial"); } GUI.color = Color.white; GUI.skin.box.fontSize = 12; GUI.skin.box.alignment = TextAnchor.MiddleCenter; } if (this.gamewon) { foreach (tPlayer x in this.players) { Destroy(x.gameObject); } this.players.Clear(); foreach (tPlayer x in this.shadowPlayers) { Destroy(x.gameObject); } this.shadowPlayers.Clear(); //Destroy (this.THEBOSS.model1.gameObject); //Destroy (this.THEBOSS.gameObject); THEBOSS.transform.position = new Vector3(-200, -200, 0); GUI.skin.box.alignment = TextAnchor.MiddleLeft; GUI.skin.box.fontSize = 25; if (GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height / 2 - 100, 600, 200), gamewonText)) { SceneManager.LoadScene("scene"); } GUI.color = Color.white; GUI.skin.box.fontSize = 12; GUI.skin.box.alignment = TextAnchor.MiddleCenter; } if (this.guiTransition) { if (GUI.Button(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 100, 400, 200), nextbossText)) { this.guiTransition = false; } } // ****** TO reset the game - we will need to use a scene manager - Luxing take a look at this!********** // if(GUI.Button(new Rect((Screen.width- 100, Screen.height - 200, 500, 20), "Reset")) { // Application. // } /*GUI.Box(new Rect (1100, 28, 200, 33), scoreText); * int s1 = score / 10000; * int s2 = (score-10000*s1 )/ 1000; * int s3 = (score-10000*s1-1000*s2 )/ 100; * int s4 = (score-10000*s1-1000*s2 -100*s3) / 10; * int s5 = score-10000*s1-1000*s2 -100*s3-10*s4; * if (score >= 10000) { * GUI.Box (new Rect (1050, 58, 40, 40), Resources.Load<Texture> ("Textures/number" + s1)); * } * if (score >= 1000) { * GUI.Box (new Rect (1080, 58, 40, 40), Resources.Load<Texture> ("Textures/number" + s2)); * } * if (score >= 100) { * GUI.Box (new Rect (1110, 58, 40, 40), Resources.Load<Texture> ("Textures/number" + s3)); * } * if (score >= 10) { * GUI.Box (new Rect (1140, 58, 40, 40), Resources.Load<Texture> ("Textures/number" + s4)); * } * GUI.Box (new Rect (1170, 58, 40, 40), Resources.Load<Texture>("Textures/number"+s5));*/ if (!this.gamewon && !this.gameover) { if (currentplayer.playerType == 0) { GUI.Box(new Rect(50, Screen.height - 120, 300, 50), squareins); GUI.Box(new Rect(50, Screen.height - 170, 300, 50), squareab); // ******JUN LI ******* Look here for tutorial instructions // The next one would be for the instruction for this tutorial // Use the square as a shield to protect others // Use shadows to kill the boss within 30 secs //GUI.Box (new Rect (50, Screen.height-170, 300, 50), squareab); } else if (currentplayer.playerType == 1) { GUI.Box(new Rect(50, Screen.height - 120, 300, 50), circleins); GUI.Box(new Rect(50, Screen.height - 170, 300, 50), circleab); // The next one would be for the instruction for this tutorial // Use special ability to kill the boss within 30 secs //GUI.Box (new Rect (50, Screen.height-170, 300, 50), squareab); } else { GUI.Box(new Rect(50, Screen.height - 120, 300, 50), diamondins); GUI.Box(new Rect(50, Screen.height - 170, 300, 50), diamondab); // The next one would be for the instruction for this tutorial // Use rapid fire ability to kill the boss within 30 secs //GUI.Box (new Rect (50, Screen.height-170, 300, 50), squareab); } } if (this.currentplayer.model.healthval > 3) { GUI.color = Color.green; } else { GUI.color = Color.red; } GUI.skin.box.alignment = TextAnchor.MiddleLeft; GUI.skin.box.fontSize = 22; String ss = ""; for (int i = 0; i < this.currentplayer.model.healthval; i++) { ss += "I"; } GUI.color = Color.white; GUI.skin.box.fontSize = 12; GUI.skin.box.alignment = TextAnchor.MiddleCenter; if (this.playerOrderIndex < playerLives) { GUI.skin.box.alignment = TextAnchor.LowerCenter; GUI.skin.box.fontSize = 22; GUI.Box(new Rect(900, 25, 110, 34), nextUpText); int nextType = playerOrder [playerOrderIndex]; if (nextType == 0) { GUI.Box(new Rect(925, 60, 50, 50), this.forSq); } else if (nextType == 1) { GUI.Box(new Rect(925, 60, 50, 50), this.forC); } else if (nextType == 2) { GUI.Box(new Rect(925, 60, 50, 50), this.forT); } } else { //GUI.color = Color.red; GUI.skin.box.fontSize = 22; GUI.Box(new Rect(900, 19, 100, 40), lastLifeText); } GUI.skin.box.fontSize = 12; } }