Esempio n. 1
0
        public override Activity Tick(Actor self)
        {
            if (moveFraction == 0 && IsCanceled)
            {
                return(NextActivity);
            }
            if (!target.IsValid)
            {
                return(NextActivity);
            }

            self.Trait <AttackLeap>().IsLeaping = true;
            var mobile = self.Trait <Mobile>();

            ++moveFraction;

            mobile.PxPosition = PPos.Lerp(initialLocation, target.PxPosition, moveFraction, delay);

            if (moveFraction >= delay)
            {
                self.TraitsImplementing <IMove>().FirstOrDefault()
                .SetPosition(self, target.CenterLocation.ToCPos());

                if (target.IsActor)
                {
                    target.Actor.Kill(self);
                }
                self.Trait <AttackLeap>().IsLeaping = false;
                return(NextActivity);
            }

            return(this);
        }
Esempio n. 2
0
            public override Activity Tick(Actor self)
            {
                if (ticks >= length || length <= 1)
                {
                    husk.PxPosition = endLocation;
                    return(NextActivity);
                }

                husk.PxPosition = PPos.Lerp(startLocation, endLocation, ticks++, length - 1);
                return(this);
            }
Esempio n. 3
0
            void UpdateCenterLocation(Actor self, Mobile mobile)
            {
                mobile.PxPosition = PPos.Lerp(from, to, moveFraction, moveFractionTotal);

                if (moveFraction >= moveFractionTotal)
                {
                    mobile.Facing = toFacing & 0xFF;
                }
                else
                {
                    mobile.Facing = int2.Lerp(fromFacing, toFacing, moveFraction, moveFractionTotal) & 0xFF;
                }
            }
Esempio n. 4
0
        public override Activity Tick(Actor self)
        {
            var mobile = self.Trait <Mobile>();

            mobile.PxPosition = length > 1
                                ? PPos.Lerp(startLocation, endLocation, ticks, length - 1)
                                : endLocation;

            if (++ticks >= length)
            {
                mobile.IsMoving = false;
                return(NextActivity);
            }

            mobile.IsMoving = true;
            return(this);
        }
Esempio n. 5
0
 public static PPos BetweenCells(CPos from, CPos to)
 {
     return(PPos.Lerp(CenterOfCell(from), CenterOfCell(to), 1, 2));
 }