Пример #1
0
        public void CreateAdam()
        {
            var bot = BotFactory.Get(Width / 2, Height / 2);

            bot.Health = Bot.MaxHealth + 1;

            bot.Direction = Direction.Random();
            bot.Color.Reset();

            Matrix[bot.X, bot.Y] = bot;
        }
Пример #2
0
        public bool Delete(Bot bot)
        {
            if (bot == null)
            {
                return(false);
            }

            Matrix[bot.X, bot.Y] = null; // удаление бота с карты

            BotFactory.ToCache(bot);

            return(true);
        }
Пример #3
0
        public readonly Bot[,] Matrix; //Матрица мира

        public void LoadWorld(WorldInfo worldInfo, IEnumerable <WorldChunk> worldChunks)
        {
            Clear();

            Width     = worldInfo.Width;
            Height    = worldInfo.Height;
            Iteration = worldInfo.Iteration;

            foreach (var worldChunk in worldChunks)
            {
                foreach (var botDto in worldChunk.Bots)
                {
                    var bot = BotFactory.Get(botDto.X, botDto.Y);
                    bot.Load(botDto);

                    Matrix[bot.X, bot.Y] = bot;
                }
            }
        }
Пример #4
0
        public void AddRandomBot()
        {
            var x = Utils.Next(Width);
            var y = Utils.Next(Height);

            var bot = Matrix[x, y];

            if (bot == null)
            {
                bot = BotFactory.Get(x, y);
                Matrix[bot.X, bot.Y] = bot;
            }

            bot.Reset();
            bot.Health = Bot.MaxHealth + 1;

            for (int i = 0; i < Consciousness.Size; i++)
            {
                bot.Consciousness.Mutate();
            }
        }