示例#1
0
 void Awake()
 {
     if (g == null)
     {
         g = this;
     }
     else
     {
         Destroy(this);
     }
 }
示例#2
0
 public void CmdHauntReady()
 {
     HauntManager.PlayerReady(this);
 }
示例#3
0
    void Update()
    {
        if (isServer && HauntManager.gameState == HauntManager.HauntState.HAUNT)
        {
            //Check if traitor(s) have won
            bool allHeroesDead = true;
            foreach (GamePlayer player in NetworkGame.GetPlayers())
            {
                if (player.playerState == GamePlayer.PlayerType.HERO && player.gameObject.GetComponent <Damageable> ().IsDead() == false)
                {
                    allHeroesDead = false;
                }
            }

            /*if (allHeroesDead) {
             *      //Traitor wins
             *      HauntManager.EndHaunt();
             *      winner = GamePlayer.PlayerType.TRAITOR;
             * }*/

            //Check if heroes have won
            if (theRing == null)
            {
                HauntManager.EndHaunt();
                winner = GamePlayer.PlayerType.HERO;
            }

            //Update ring and invisibility
            foreach (GamePlayer player in NetworkGame.GetPlayers())
            {
                if (player.playerState == GamePlayer.PlayerType.TRAITOR)
                {
                    bool hasRing = false;
                    foreach (GameObject item in player.GetComponent <Inventory>().items)
                    {
                        if (item != null)
                        {
                            if (item.GetComponent <Item> ().itemName == "Ring")
                            {
                                hasRing = true;
                                item.GetComponent <Item> ().canDrop = false;
                            }
                        }
                    }
                    traitorHasRing = hasRing;
                    if (hasRing)
                    {
                        RpcMakeInvisible(chosenOne.gameObject);
                    }
                    else
                    {
                        RpcMakeVisible(chosenOne.gameObject);
                    }
                }
                if (player.playerState == GamePlayer.PlayerType.HERO)
                {
                    foreach (GameObject item in player.GetComponent <Inventory>().items)
                    {
                        if (item != null && item.GetComponent <Item> ().itemName == "Ring")
                        {
                            item.GetComponent <Item> ().canDrop = true;
                        }
                    }
                }
            }

            //Update traitor death times
            foreach (GamePlayer player in NetworkGame.GetPlayers())
            {
                if (player.playerState == GamePlayer.PlayerType.TRAITOR &&
                    player.GetComponent <Damageable>().IsDead())
                {
                    if (traitorDeadTimes [player] == 0)
                    {
                        //If the traitor just died
                        player.AddTimedMessage("You are dead, but it's only temporary", respawnTime);
                    }
                    traitorDeadTimes [player] = traitorDeadTimes [player] + Time.deltaTime;
                    if (traitorDeadTimes [player] >= respawnTime)
                    {
                        traitorDeadTimes [player] = 0;
                        player.ServerRespawn();
                        player.gameObject.transform.position = traitorSpawns [player];
                        player.AddTimedMessage("You are back in the world of the living, for now...", 2.5f);
                    }
                }
            }
        }
    }