// Use this for initialization void Start() { isDead = false; util = (Utility)Instantiate(util); if (util is Reflect) { ((Reflect)util).shieldPrefab.GetComponent <Shield>().characterNumber = playerId; ((Reflect)util).shieldPrefab.GetComponent <Shield>().materialOfParent = renderer.material; } //util = new CloneCloak (); //((CloneCloak)(util)).clonePrefab = clonePrefab; invincible = false; playerId = currentId++; controller = (Controller)this.gameObject.GetComponent("Controller"); util.controller = controller; util.owningChar = this.gameObject; util.rigidBody = (Rigidbody)this.gameObject.GetComponent("Rigidbody"); util.init(); this.gameObject.name = "player" + playerId; isJuggernaut = false; controller.setCharacter(playerId); float x = (Random.value * 10) - 5; float y = (Random.value * 10) - 5; float z = (Random.value * 10) - 5; CharacterProjectile cp = this.gameObject.GetComponent <CharacterProjectile>(); cp.p.owner = this.gameObject; cp.p.bullet.characterNumber = playerId; defaultWeapon.owner = this.gameObject; runeRepresentation = (RuneRep)Instantiate(runeRepresentation); GameObject.DontDestroyOnLoad(runeRepresentation); GameObject.DontDestroyOnLoad(util); transform.Find("HaloPrefab").renderer.material.color = new Color(94.0f / 255.0f, 12.0f / 255.0f, 148.0f / 255.0f); transform.Find("HaloPrefab2").renderer.material.color = new Color(94.0f / 255.0f, 12.0f / 255.0f, 148.0f / 255.0f); doorPopUp = (GameObject)Instantiate(doorPopUp); doorPopUp.transform.position = new Vector3(500000, 500000, 500000); }
void OnCollisionEnter(Collision collision) { if (this.gameObject.name == "Magic Missile(Clone)" || this.gameObject.name == "Fireball(Clone)" || this.gameObject.name == "Ricochet Magic(Clone)") { ParticleSystem g = (ParticleSystem)Instantiate(onCollisionEffect, transform.position, Quaternion.identity); if (this.gameObject.name == "Fireball(Clone)") { ParticleSystem f = (ParticleSystem)Instantiate(onCollisionEffect, new Vector3(transform.position.x + screenWidth, transform.position.y, transform.position.z), Quaternion.identity); ParticleSystem d = (ParticleSystem)Instantiate(onCollisionEffect, new Vector3(transform.position.x - screenWidth, transform.position.y, transform.position.z), Quaternion.identity); ParticleSystem s = (ParticleSystem)Instantiate(onCollisionEffect, new Vector3(transform.position.x, transform.position.y + screenHeight, transform.position.z), Quaternion.identity); ParticleSystem a = (ParticleSystem)Instantiate(onCollisionEffect, new Vector3(transform.position.x, transform.position.y - screenHeight, transform.position.z), Quaternion.identity); Destroy(f.gameObject, onCollisionEffect.duration); Destroy(d.gameObject, onCollisionEffect.duration); Destroy(s.gameObject, onCollisionEffect.duration); Destroy(a.gameObject, onCollisionEffect.duration); } Destroy(g.gameObject, onCollisionEffect.duration); //Vector3 xOffset = transform.position; //xOffset.x = (((Screen.width * 2) / 3) % Screen.width); //ParticleSystem gx = (ParticleSystem)Instantiate(onCollisionEffect, xOffset, Quaternion.identity); //Destroy(gx.gameObject, onCollisionEffect.duration); // //Vector3 yOffset = new Vector3(); //yOffset.y = (Screen.height % ((Screen.height * 2) / 3)); //ParticleSystem gy = (ParticleSystem)Instantiate(onCollisionEffect, transform.position + yOffset, Quaternion.identity); //Destroy(gy.gameObject, onCollisionEffect.duration); } if (this.gameObject.name == "Fireball(Clone)") { Vector2 start = new Vector2(1, 0); int count = 16; GameObject getSound = GameObject.Find("SoundManager"); SoundManager SM = getSound.GetComponent <SoundManager>(); SM.playFireBallExplosion(); for (int i = 0; i < count; i++) { CharacterProjectile cp = owningChar.transform.root.GetComponent <CharacterProjectile>(); Controller con = owningChar.transform.root.GetComponent <Controller>(); Vector3 myDir = new Vector3(start.x, start.y, 0) * .4f; myDir = Quaternion.Euler(0, 0, i * (360 / count)) * myDir; Magic clone = (Magic)Instantiate(owningChar.GetComponent <Character>().fireballSpawn.bullet, gameObject.transform.position + myDir, gameObject.transform.rotation); clone.gameObject.renderer.material = gameObject.renderer.material; clone.owningChar = owningChar; clone.rigidbody.velocity = new Vector2(myDir.x, myDir.y).normalized; //clone.rigidbody.useGravity = true; clone.characterNumber = con.getCharacter(); } } Character guy = collision.collider.gameObject.GetComponent <Character>(); if (guy != null) { if (!guy.getInvincible() && !guy.diedLastFrame) { guy.diedLastFrame = true; if (characterNumber == guy.getId()) { //guy.alterNumKills(-1); } else if (owningChar.transform.root.GetComponent <CharacterProjectile>().getTeamNum() != guy.teamNum) { Destroy(this.gameObject); if (GameManager.gameType == 1 || GameManager.gameType == 2) { GameManager.getPlayer(characterNumber).alterNumKills(1); } else if (GameManager.gameType == 3) { if (guy.isJuggernaut) { GameManager.getPlayer(characterNumber).isJuggernaut = true; guy.isJuggernaut = false; } } GameManager.randomizeSpawn(guy); guy.Kill(); } } if (guy.getInvincible()) { Destroy(this.gameObject); } } if (collision.collider.gameObject.name != "Magic") { if (numberOfBounces > 0 && currentTime > 0.01) { GameObject getSound = GameObject.Find("SoundManager"); SoundManager SM = getSound.GetComponent <SoundManager>(); SM.playRicochetteBounce(); numberOfBounces--; //BOUNCE.... //Manually... Something to do with dot. } else if (numberOfBounces > 0 && currentTime < 0.01) { GameObject getSound = GameObject.Find("SoundManager"); SoundManager SM = getSound.GetComponent <SoundManager>(); SM.playRicochetteBounce(); transform.position = new Vector3(transform.position.x, transform.position.y + 0.4f, transform.position.z); } else if ((numberOfBounces == 0 && this.gameObject.name != "WallBullet(Clone)") || (this.gameObject.name == "WallBullet(Clone)" && !collision.collider.gameObject.GetComponent <Magic>())) { Destroy(this.gameObject); } } }
public void BackToPool(CharacterProjectile projectile) { _pool.Enqueue(projectile); }