Exemplo n.º 1
0
        public void _PlayerDestroyed()
        {
            TDS.PlayerDestroyed();

            if (respawning)
            {
                return;
            }

            //player unit is destroyed, check playerLife and respawn player if need be

            playerLife -= 1;

            if (playerLife <= 0)                //playerLife's used up, game over
            {
                GameOver(false);
                return;
            }

            respawning = true;                  //set respawning flag to true to prevent duplicate spawn

            //create a duplicate of current player unit so the selected weapon and ability is retained
            GameObject obj = (GameObject)Instantiate(player.gameObject, player.thisT.position, player.thisT.rotation);

            player          = obj.GetComponent <UnitPlayer>();
            player.hitPoint = player.GetFullHitPoint();
            player.Start();
            player.ClearAllEffect();

            //set the new player unit to false to give it a little delay before showing it again
            obj.SetActive(false);

            //call the coroutine which will do the delay and reactivate the new unit
            StartCoroutine(ActivateRepawnPlayer());
        }