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); } } }
private bool IsRightDirection(Player bot, Position aim) { var angle = Mathematics.CalcAngle(bot.Centre, aim); return(Math.Abs(angle - bot.Direction) < 1); }