Exemplo n.º 1
0
    /// <summary>
    /// Reaction on left. Deactivate the rating write and the snake.
    /// </summary>
    /// <param name="otherPlayer"></param>
    public override void OnPlayerLeftRoom(Player otherPlayer)
    {
        if (gameOver)
        {
            return;
        }

        var actorID = (int)otherPlayer.CustomProperties[PlayerOptionKeys.ActorID];

        for (var i = 0; i < Snakes.Count; i++)
        {
            if (Snakes[i].GetActorIDOfCreator() == actorID)
            {
                Snakes[i].Clear();
                Snakes[i].Disconnect = true;
                rating.PlayerLeft(actorID);
                //End game if need
                if (Snakes.Count(s => !s.Disconnect) < 2)
                {
                    CompleteGame(timeIsEnd: false);
                }
                return;
            }
        }
    }