예제 #1
0
        /* ---------------------------------------------------------------------------------------------------------- */

        #region Constructors/Initialisation

        /// <summary>
        /// Creates a new movement action for the specified unit.
        /// </summary>
        /// <param name="unit">The unit this action is attached to.</param>
        /// <param name="startPosition">The initial position to start this action from.</param>
        /// <param name="distance">The total distance of the movement.</param>
        /// <param name="startRotation">The initial rotation to start this action from.</param>
        /// <param name="endRotation">The end rotation for this movement action.</param>
        /// <param name="speedModifier">The movement speed modifier.</param>
        internal UnitMovement(BattleUnit unit, Vector3 startPosition, Vector3 endPosition, BattleHex currentTile, HexDirection startDirection, HexDirection endDirection, float startRotation, float endRotation, float speedModifier)
            : base(unit)
        {
            this._startPosition      = startPosition;
            this._endPosition        = endPosition;
            this._endTile            = currentTile;
            this._endFacingDirection = endDirection;

            if (startDirection != endDirection)
            {
                HexDirection between = HexHelpers.DirectionBetween(startDirection, endDirection);

                this._rotateAround = currentTile.GetNeighbourPosition(between);

                this._startRotation = startRotation;
                this._endRotation   = endRotation;

                float rotation = endRotation - startRotation;

                while (rotation <= 0f)
                {
                    rotation += 360f;
                }

                this._rotationAngle = rotation;
            }

            this._speedModifier = speedModifier;

            this._lerpValue = 0f;
        }