示例#1
0
    private void CheckEndGame()
    {
        var player1 = SystemController.GetSystem <OperativeInfoSystem>().GetEntitiesByOwner(PlayerType.Player1).Count;
        var player2 = SystemController.GetSystem <OperativeInfoSystem>().GetEntitiesByOwner(PlayerType.Player2).Count;

        if (player1 == 0 || player2 == 0)
        {
            PlayerType?winner = null;
            if (player1 == 0 && player2 == 0)
            {
                Debug.Log("Draw");
            }
            else if (player1 == 0)
            {
                winner = PlayerType.Player2;
                Debug.Log("player2 wins!");
            }
            else if (player2 == 0)
            {
                winner = PlayerType.Player1;
                Debug.Log("player1 wins!");
            }
            Messages.SendEvent(new PlayerWinMsg(winner));
        }
    }