public void init(tBoss owner) { this.owner = owner; transform.parent = owner.transform; // Set the model's parent to the gem. transform.localPosition = new Vector3(0, 0, 0); // Center the model on the parent. name = "Boss Model"; // Name the object. mat = GetComponent <Renderer>().material; mat.shader = Shader.Find("Sprites/Default"); // Tell the renderer that our textures have transparency. // Get the material component of this quad object. if (owner.m.bossCurrentLife == 1) { this.bossTex = "Textures/boss1d"; mat.mainTexture = Resources.Load <Texture2D>("Textures/boss1d0"); // Set the texture. Must be in Resources folder. } else if (owner.m.bossCurrentLife == 2) { this.bossTex = "Textures/boss2d"; mat.mainTexture = Resources.Load <Texture2D>("Textures/boss2d0"); // Set the texture. Must be in Resources folder. } else if (owner.m.bossCurrentLife == 3) { mat.color = new Color(0, 0, 1); } }
//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 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; }
// Use this for initialization public void init(tBoss owner) { this.name = "BossShield"; m = owner; ShieldHealth = 20; var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent <tBossShieldModel>(); // Add a marbleModel script to control visuals of the gem. model.init(this); BoxCollider2D bossbody = gameObject.AddComponent <BoxCollider2D> (); Rigidbody2D bossRbody = gameObject.AddComponent <Rigidbody2D> (); bossRbody.gravityScale = 0; bossbody.isTrigger = true; transform.localScale = new Vector3(1.5f, 1.5f, 1); //transform.localScale = new Vector3 (1.3f, 1.3f, 1); }
// Use this for initialization public void init(tBoss boss) { owner = boss; this.name = "BossBullet"; speed = owner.chargeSpeed * 1.5f; var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent <tBossBulletModel>(); // 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(.35f, .35f, 1); this.owner.m.bulletsFolder.Add(this.model.gameObject); }
// Use this for initialization public void init(tBoss owner) { this.name = "BossBlade"; m = owner; var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent <tBossBladesModel>(); // Add a marbleModel script to control visuals of the gem. model.init(this); this.transform.position = new Vector3(m.transform.position.x, m.transform.position.y, m.transform.position.z); BoxCollider2D playerbody = gameObject.AddComponent <BoxCollider2D> (); playerbody.isTrigger = true; transform.localScale = new Vector3(1f, 4.7f, 1); this.m.m.bulletsFolder.Add(this.gameObject); }
// Use this for initialization public void init(tBoss boss) { this.name = "BossBeam"; m = boss; speed = m.chargeSpeed * 1.1f; health = 2; var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent <tBossBeamModel>(); // 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, 0.2f, 1); this.GetComponent <BoxCollider2D> ().size = model.transform.localScale; this.transform.rotation = new Quaternion(m.transform.rotation.x, m.transform.rotation.y, m.transform.rotation.z, m.transform.rotation.w); this.m.m.bulletsFolder.Add(this.model.gameObject); }
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; } }