/// <summary>
        ///     Initializes a new instance of the <see cref="ChickenUnitState"/> class.
        /// </summary>
        internal ChickenUnitState(ChickenUnit unit, MoveInfo previousMove, MoveInfoStates previousMoveState)
        {
            #region Argument Check

            if (unit == null)
            {
                throw new ArgumentNullException("unit");
            }

            if (previousMove == null)
            {
                throw new ArgumentNullException("previousMove");
            }

            #endregion

            this.Unit              = unit;
            this.UniqueId          = unit.UniqueId;
            this.Team              = unit.Team;
            this.IsDead            = unit.IsDead;
            this.Position          = unit.Position;
            this.BeakAngle         = unit.BeakAngle;
            this.PreviousMove      = previousMove;
            this.PreviousMoveState = previousMoveState;
            this.View              = new ViewInfo(unit);
            this.CanShoot          = unit.CanShoot();
        }
Example #2
0
        internal DirectionalPosition GetPosition(ChickenUnit unit)
        {
            #region Argument Check

            if (unit == null)
            {
                throw new ArgumentNullException("unit");
            }

            #endregion

            return(_unitToPositionMap[unit]);
        }
Example #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ShotUnit"/> class.
        /// </summary>
        internal ShotUnit(ChickenUnit owner, GameObjectId uniqueId)
        {
            #region Argument Check

            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            if (!uniqueId.IsValid)
            {
                throw new ArgumentException("Invalid shot ID.", "uniqueId");
            }

            #endregion

            var beakTipPosition = GameHelper.GetBeakTipPosition(owner.Position, owner.BeakAngle);

            this.UniqueId     = uniqueId;
            this.Owner        = owner;
            this.Position     = GameHelper.GetNewPosition(beakTipPosition, owner.BeakAngle, GameConstants.ShotUnit.Radius);
            this.Angle        = owner.BeakAngle;
            this.CreationTime = DateTime.Now;
        }