예제 #1
0
    //Translate the client commands.
    private void TranslateCommands(string[] commands)
    {
        foreach (string command in commands)
        {
            string[] commandParts = command.Split();

            switch ((ClientMessage)int.Parse(commandParts[0]))
            {
            //Sets the angle of a player
            case ClientMessage.NewAngle:
            {
                players.SetAngle(commandParts);
                break;
            }

            //Sets the position of a player
            case ClientMessage.NewPos:
            {
                players.SetPosition(commandParts, map.hitboxes);
                break;
            }

            //Shoots a bullet
            case ClientMessage.Shoot:
            {
                string state = bullets.Add(commandParts, players);

                lock (lockGameState)
                {
                    gameState += state;
                }
            }
            break;

            //Changes the team of a player
            case ClientMessage.ChangeTeam:
            {
                string state = players.ChangeTeam(commandParts);
                lock (lockGameState)
                {
                    gameState += state;
                }
                CheckRoundStatus();
                break;
            }
            }
        }
    }