House.House.validateHouse C# (CSharp) Méthode

validateHouse() public méthode

public validateHouse ( string PlayerName, int houseIndex ) : void
PlayerName string
houseIndex int
Résultat void
        public void validateHouse(string PlayerName, int houseIndex)
        {
            PlayerHouses playerHouse = playerHouses[GetPlayerHouseIndex(PlayerName)];
            PlayerHouseCoords playerHouseCoords = playerHouse.Houses[houseIndex];

            if (!((playerHouseCoords.TopLeft.X == 0 && playerHouseCoords.TopLeft.Y == 0) ||
                  (playerHouseCoords.BottomRight.X == 0 && playerHouseCoords.BottomRight.Y == 0)))
            {
                // Check for top left/bottom right reversed
                if (playerHouseCoords.TopLeft.X > playerHouseCoords.BottomRight.X ||
                    playerHouseCoords.TopLeft.Y > playerHouseCoords.BottomRight.Y)
                {
                    Server.GetPlayerByName(PlayerName).sendMessage("Top right corner is greater than bottom left, deleting house " +
                        playerHouseCoords.BottomRight.X + "," + playerHouseCoords.BottomRight.Y, chatColor);
                    playerHouse.Houses.RemoveAt(houseIndex);
                }

                // Check area
                int houseArea = (playerHouseCoords.BottomRight.X - playerHouseCoords.TopLeft.X) *
                    (playerHouseCoords.BottomRight.Y - playerHouseCoords.TopLeft.Y);
                if (houseArea > maxArea)
                {
                    Server.GetPlayerByName(PlayerName).sendMessage("Your house exceeds the maximum area, deleting house", chatColor);
                    playerHouse.Houses.RemoveAt(houseIndex);
                }

                // Check min height
                if (playerHouseCoords.BottomRight.Y < minHeight)
                {
                    Server.GetPlayerByName(PlayerName).sendMessage("Your house is below the minimum depth level, deleting house", chatColor);
                    playerHouse.Houses.RemoveAt(houseIndex);
                }

                // Check max height
                if (playerHouseCoords.BottomRight.Y > maxHeight)
                {
                    Server.GetPlayerByName(PlayerName).sendMessage("Your house is above the maximum depth level, deleting house", chatColor);
                    playerHouse.Houses.RemoveAt(houseIndex);
                }
            }
        }