GameWorldControl.AddDeaths C# (CSharp) Method

AddDeaths() public method

public AddDeaths ( int number ) : void
number int
return void
    public void AddDeaths(int number)
    {
        deaths += number;
        kdRatioLabel.text = "Kills/Deaths:" + kills + "/" + deaths;
        
        //check that they can afford the cheapest ship, developer has to maintain this if adding new ships
        if (sol < 80)
        {
            //Player Defeat
            NGUITools.SetActive(defeatPanel, true);
        }
        else
        {
            //Open the Ship Selection Panel again
            NGUITools.SetActive(shipSelectionPanel, true);
        }

        //Check for victory
        //This is odd in that it will be run by every player playing anytime they die to a player or otherwise
        //It needs to check that I'm alive and no one else is, which is netcode dependent
        if (playerShip != null && CheckEnemyStationsDead() && CheckOtherPlayersDead())
        {
            //Set Victory Panel active
            NGUITools.SetActive(victoryPanel, true);
        }
        
    }

Usage Example

Example #1
0
 void Death()
 {
     //Explode animation
     Instantiate(shipExplosionAnimation, transform.position, transform.rotation);
     //Blow up sound
     AudioSource.PlayClipAtPoint(shipExplosionSound.audio.clip, transform.position);
     //Update your death count
     //You died
     if (gameObject != null)
     {
         Destroy(gameObject);
     }
     gameWorldControlScript.AddDeaths(1);
 }