コード例 #1
0
        public static void HandleChangeAllowedRessource(int fromClient, Packet packet)
        {
            int clientIDCheck = packet.ReadInt();

            if (fromClient != clientIDCheck)
            {
                Console.WriteLine($"Player with ID: \"{fromClient}\" has assumed the wrong client ID: \"{clientIDCheck}\"!");
            }

            Player         player            = Server.clients[fromClient].Player;
            HexCoordinates originCoordinates = packet.ReadHexCoordinates();

            if (GameLogic.PlayerInRange(originCoordinates, player))
            {
                HexCoordinates destinationCoordinates = packet.ReadHexCoordinates();
                RessourceType  ressourceType          = (RessourceType)packet.ReadByte();
                bool           newValue = packet.ReadBool();
                if (GameLogic.ChangeAllowedRessource(originCoordinates, destinationCoordinates, ressourceType, newValue))
                {
                    Console.WriteLine("Player: " + player.Name + "of tribe" + player.Tribe.Id.ToString() + " changed allowed Ressource: " + ressourceType.ToString() + " at " + originCoordinates.ToString() + ".");
                    ServerSend.BroadcastChangeAllowedRessource(originCoordinates, destinationCoordinates, ressourceType, newValue);
                    return;
                }
            }
            Console.WriteLine("Player: " + player.Name + "of tribe" + player.Tribe.Id.ToString() + " failed to change allowed Ressource at " + originCoordinates.ToString() + ".");
        }
コード例 #2
0
 public static string ToFriendlyString(this RessourceType ressourceType)
 {
     return(ressourceType.ToString().ToLower().FirstCharToUpper());
 }