void Awake() { if (instance == null) { instance = this; } isAlive = true; }
// Use this for initialization void Start() { // setting a new object to the singleton everytime we get a new object if (singelton) { Destroy(singelton.gameObject); singelton = this; } else { singelton = this; bird = GetComponent <Bird>(); } }
public void Kill() { // TODO CHANGE THIS CHECK OF WHO IS THE WINNER // just in case we have a player component BirdPlayer playerComponent = this.GetComponent <BirdPlayer>(); //// if player is alive and //if (GameManager.instance.amountOfBirdsAlive == 1) //{ // // if we are the last bird alive we should check if we are player or AI // if (GameManager.instance.amountOfBirdsAlive == 1) // { // if (this.GetComponent<BirdPlayer>()) // { // ScoreManager.AddPointToPlayer(); // } // else // { // ScoreManager.AddPointToAI(); // } // } //} GameManager.instance.DecCurrentlyAliveBirdsCounterAndCheckForEndRound(); // checking if we our an evolutional AI Bird, if we are then call its kill function as well BirdEvolutionAI birdEvoAI = this.GetComponent <BirdEvolutionAI>(); if (birdEvoAI) { birdEvoAI.KillEvolutionAIBird(); } // removing this gameobject to the camera to stop following it CameraFollow.targets.Remove(this.gameObject); // instantiating the death explosion effect Instantiate(deathParticleSystem, transform.position, transform.rotation); // destory this bird gameobject Destroy(this.gameObject); // checking victory // if the player dies that show end game UI and add score to AI if (playerComponent) { ScoreManager.AddPointToAI(); GameManager.instance.PauseGame(); playerComponent.whoWinnerPanelToEnable.SetActive(true); playerComponent.whoWinnerText.text = "The Bot defeated You!"; } else { // we are here if we have 2 birds on screen and one of them is the player if (GameManager.instance.amountOfBirdsAlive == 1) { ScoreManager.AddPointToPlayer(); GameManager.instance.PauseGame(); BirdPlayer.singelton.whoWinnerPanelToEnable.SetActive(true); BirdPlayer.singelton.whoWinnerText.text = "You have defeated the Bot!"; } } }
public static void KillPlayer(BirdPlayer birdPlayer) { Destroy(birdPlayer.gameObject); }