Пример #1
0
        private GameActions TurnToAim(Player bot, Position aim)
        {
            var wantedAngle = Mathematics.CalcAngle(bot.Centre, aim);
            var isBigRotate = Math.Abs(bot.Direction - wantedAngle) > bigRotate;

            if (bot.Direction <= 180)
            {
                if (wantedAngle >= bot.Direction &&
                    wantedAngle <= bot.Direction + 180)
                {
                    return(isBigRotate ? GameActions.FastRight : GameActions.Right);
                }
                else
                {
                    return(isBigRotate ? GameActions.FastLeft : GameActions.Left);
                }
            }
            else
            {
                if (wantedAngle >= bot.Direction - 180 &&
                    wantedAngle <= bot.Direction)
                {
                    return(isBigRotate ? GameActions.FastLeft : GameActions.Left);
                }
                else
                {
                    return(isBigRotate ? GameActions.FastRight : GameActions.Right);
                }
            }
        }
Пример #2
0
        private bool IsRightDirection(Player bot, Position aim)
        {
            var angle = Mathematics.CalcAngle(bot.Centre, aim);

            return(Math.Abs(angle - bot.Direction) < 1);
        }