Пример #1
0
        public World Generate()
        {
            Console.WriteLine("Generating new World...");
            world.Day = 1;
            world.Width = 50;
            world.Height = 50;
            world.Tiles = GenerateMap(world.Width, world.Height);
            world.Registrations = new List<Registration>();
            world.Players = new List<Player>();
            world.Villages = new List<Village>();
            world.IPBans = new List<IPBan>();

            #if DEBUG
            System.Security.Cryptography.SHA256Managed sha256 = new System.Security.Cryptography.SHA256Managed();
            UTF8Encoding utf8Encoder = new UTF8Encoding();
            Player player = new Player();
            player.Name = "Majzlík";
            player.Login = "******";
            player.Password = sha256.ComputeHash(utf8Encoder.GetBytes("majzlik"));
            world.Players.Add(player);
            player = new Player();
            player.Name = "Setal";
            player.Login = "******";
            player.Password = sha256.ComputeHash(utf8Encoder.GetBytes("setal"));
            world.Players.Add(player);
            #endif
            Console.WriteLine("New World Generated");
            return world;
        }
Пример #2
0
        public string GetMap(Player player, byte xCenter, byte yCenter)
        {
            if (xCenter < 5)
            {
                xCenter = 5;
            }
            if (xCenter > world.Width - 6)
            {
                xCenter = (byte)(world.Width - 6);
            }
            if (yCenter < 5)
            {
                yCenter = 5;
            }
            if (yCenter > world.Height - 6)
            {
                yCenter = (byte)(world.Height - 6);
            }

            string dataPartOne = string.Format("{0}~{1}~{2}~{3}~", world.Width, world.Height, xCenter, yCenter);
            string dataPartTwo = string.Empty;
            for (int i = 0; i < 121; i++)
            {
                Tile tile = world.Tiles[i % 11 + (xCenter - 5), i / 11 + (yCenter - 5)];
                if (tile is Village)
                {
                    Village village = tile as Village;
                    char villageState = 'E';
                    if (village.Owner == null)
                    {
                        villageState = 'I';
                    }
                    if (village.Owner == player)
                    {
                        villageState = 'M';
                    }
                    dataPartOne += string.Format("{0}~", (village.Buildings[0] / 5) + 128);
                    dataPartTwo += string.Format("{0}~{1}~{2}~{3}~", village.Name, village.Owner.Name, villageState, (int)village.Population);
                }
                else
                {
                    dataPartOne += string.Format("{0}~", tile.Type);
                }
            }
            return dataPartOne + dataPartTwo;
        }
Пример #3
0
 public string GetMap(Player player)
 {
     return GetMap(player, (byte)(world.Width / 2), (byte)(world.Height / 2));
 }
Пример #4
0
 public string GetNotifications(Player player)
 {
     return string.Format("{0}~", world.Day);
 }