public static GameAngle GetBeakMovement(BeakTurn beakTurn) { if (beakTurn.Value.IsZero()) { return(GameAngle.Zero); } var degreeAngle = GameConstants.ChickenUnit.DefaultAngularSpeed * beakTurn.Value; return(GameAngle.FromDegrees(degreeAngle)); }
public static void PositionRandomly( [NotNull] GamePositionEventArgs eventArgs, [CanBeNull] Random randomGenerator) { #region Argument Check if (eventArgs == null) { throw new ArgumentNullException("eventArgs"); } #endregion var actualRandomGenerator = randomGenerator ?? DefaultRandomGenerator; for (var index = 0; index < eventArgs.UnitStates.Count; index++) { var unitState = eventArgs.UnitStates[index]; Point2D position; do { var nominalPosition = new Point( actualRandomGenerator.Next(eventArgs.Data.NominalSize.Width), actualRandomGenerator.Next(eventArgs.Data.NominalSize.Height)); position = GameHelper.NominalToReal(nominalPosition); }while (eventArgs.UnitStates.Take(index).Any( item => eventArgs.GetPosition(item).Position.GetDistance(position) < GameConstants.NominalCellSize)); var plainAngle = (float)Math.Floor( MathHelper.HalfRevolutionDegrees - actualRandomGenerator.NextDouble() * MathHelper.RevolutionDegrees); var angle = GameAngle.FromDegrees(plainAngle); eventArgs.SetPosition(unitState, new DirectionalPosition(position, angle)); } }