コード例 #1
0
        public override Activity Tick(Actor self)
        {
            if (canceled)
            {
                return(NextActivity);
            }

            // Correct the visual position after we jumped
            if (jumpComplete)
            {
                if (ChildActivity == null)
                {
                    return(NextActivity);
                }

                ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
                return(this);
            }

            if (target.Type != TargetType.Invalid)
            {
                targetPosition = target.CenterPosition;
            }

            var position = length > 1 ? WPos.Lerp(origin, targetPosition, ticks, length - 1) : targetPosition;

            mobile.SetVisualPosition(self, position);

            // We are at the destination
            if (++ticks >= length)
            {
                // Revoke the run condition
                attack.IsAiming = false;

                // Move to the correct subcells, if our target actor uses subcells
                // (This does not update the visual position!)
                mobile.SetLocation(destinationCell, destinationSubCell, destinationCell, destinationSubCell);

                // Revoke the condition before attacking, as it is usually used to pause the attack trait
                attack.RevokeLeapCondition(self);
                attack.DoAttack(self, target);

                jumpComplete = true;
                QueueChild(self, mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)), true);

                return(this);
            }

            return(this);
        }
コード例 #2
0
        public override bool Tick(Actor self)
        {
            // Correct the visual position after we jumped
            if (canceled || jumpComplete)
            {
                return(true);
            }

            if (target.Type != TargetType.Invalid)
            {
                targetPosition = target.CenterPosition;
            }

            var position = length > 1 ? WPos.Lerp(origin, targetPosition, ticks, length - 1) : targetPosition;

            mobile.SetVisualPosition(self, position);

            // We are at the destination
            if (++ticks >= length)
            {
                // Revoke the run condition
                attack.IsAiming = false;

                // Move to the correct subcells, if our target actor uses subcells
                // (This does not update the visual position!)
                mobile.SetLocation(destinationCell, destinationSubCell, destinationCell, destinationSubCell);

                // Update movement which results in movementType set to MovementType.None.
                // This is needed to prevent the move animation from playing.
                mobile.UpdateMovement(self);

                // Revoke the condition before attacking, as it is usually used to pause the attack trait
                attack.RevokeLeapCondition(self);
                attack.DoAttack(self, target);

                jumpComplete = true;
                QueueChild(mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)));
            }

            return(false);
        }