Ejemplo n.º 1
0
        public override BotAction NextAction()
        {
            var result = new BotAction { Action = ActionType.Move };

            var botToAttack = GetBotInRange();
            if (botToAttack != null)
            {
                result.Action = ActionType.Attack;
                result.Target = botToAttack.Position;
                return result;
            }

            bool success = false;

            while (!success)
            {
                Direction direction;
                lock (_locker)
                {
                    direction = (Direction)random.Next(0, 4);
                }

                var target = GetDirection(direction, Position);

                if (World.Current.Map[target] != -1)
                {
                    result.Target = target;
                    success = true;
                }
            }

            return result;
        }
Ejemplo n.º 2
0
        public override BotAction NextAction()
        {
            var result = new BotAction { Action = ActionType.Move };
            bool success = false;

            while (!success)
            {
                Direction direction;
                lock (_locker)
                {
                    direction = (Direction)random.Next(0, 4);
                }

                var target = GetDirection(direction, Position);

                if (World.Current.Map[target] != -1)
                {
                    result.Target = target;
                    success = true;
                }
            }

            return result;
        }