示例#1
0
文件: Program.cs 项目: mys/BotWaRz
 // --------------------------------------------------------------------
 private static double GetAngleToEnemy(Bot myBot, Bot enemyBot)
 {
     return Math.Atan2(enemyBot.y - myBot.y, enemyBot.x - myBot.x) * 180 / Math.PI;
 }
示例#2
0
文件: Program.cs 项目: mys/BotWaRz
        // --------------------------------------------------------------------
        private static bool DetectEndOfWorld(Bot bot)
        {
            int radius = gameInfo.botRadius;

            // top end
            if (bot.y - radius == 0 && bot.angle < 0)
            {
                Log("Top end detected");
                return true;
            }
            // bot end
            if (bot.y + radius == gameInfo.world.height && bot.angle > 0)
            {
                Log("Bot end detected");
                return true;
            }
            // left end
            if (bot.x - radius == 0
                && (bot.angle > 90 || bot.angle < -90))
            {
                Log("Left end detected");
                return true;
            }
            // right end
            if (bot.x + radius == gameInfo.world.width
                && (bot.angle < 90 && bot.angle > -90))
            {
                Log("Right end detected");
                return true;
            }

            return false;
        }
示例#3
0
文件: Program.cs 项目: mys/BotWaRz
        // --------------------------------------------------------------------
        private static Bot SearchNearestBotID(Bot myBot)
        {
            double distance = 9999;
            Bot bot = null;

            foreach (Bot enemyBot in gameUpdate.players.Single(
                player => !player.nickname.Equals(NICKNAME)).bots)
            {
                double dist = Math.Sqrt(
                    Math.Pow(myBot.x - enemyBot.x, 2) +
                    Math.Pow(myBot.y - enemyBot.y, 2));

                if (dist < distance)
                {
                    distance = dist;
                    bot = enemyBot;
                }
            }

            if (bot == null)
                throw new Exception("No enemy bot found!");

            return bot;
        }