Esempio n. 1
0
        // Returns TRUE if we're on an animation update cycle.
        public bool IsAnimationTick(TimerGlobal timer)
        {
            // If the animation is limited to 1 frame or less, it has no animations; therefore, no animation tick.
            if (this.AnimCycles.Length <= 1)
            {
                return(false);
            }

            // Check if the Animation Tick has met the next frame required.
            return(this.NextFrame <= timer.Frame);
        }
Esempio n. 2
0
 // Get 5-Per-Second Global Animation ID: Animations that cycle between five texture IDs per second.
 public static byte Get5PSAnimId(TimerGlobal timer)
 {
     if (timer.frame60Modulus >= 36)
     {
         return(timer.frame60Modulus >= 48 ? (byte)5 : (byte)4);
     }
     if (timer.frame60Modulus >= 12)
     {
         return(timer.frame60Modulus >= 24 ? (byte)3 : (byte)2);
     }
     return(1);
 }
Esempio n. 3
0
 // Get 3-Per-Quarter-Second Global Animation ID: Animations that cycle between three texture IDs per quarter-second.
 public static byte Get3PQSAnimId(TimerGlobal timer)
 {
     if (timer.frame16Modulus >= 10)
     {
         return(3);
     }
     if (timer.frame16Modulus >= 5)
     {
         return(2);
     }
     return(1);
 }
Esempio n. 4
0
 // Get 3-Per-Half-Second Global Animation ID: Animations that cycle between three texture IDs per half-second.
 public static byte Get3PHSAnimId(TimerGlobal timer)
 {
     if (timer.frame60Modulus >= 40)
     {
         return(timer.frame60Modulus >= 50 ? (byte)3 : (byte)2);
     }
     if (timer.frame60Modulus >= 20)
     {
         return(timer.frame60Modulus >= 30 ? (byte)1 : (byte)3);
     }
     return(timer.frame60Modulus >= 10 ? (byte)2 : (byte)1);
 }
Esempio n. 5
0
 // Get 3-Per-Second Global Animation ID: Animations that cycle between three texture IDs per second.
 public static byte Get3PSAnimId(TimerGlobal timer)
 {
     if (timer.frame60Modulus >= 40)
     {
         return(3);
     }
     if (timer.frame60Modulus >= 20)
     {
         return(2);
     }
     return(1);
 }
Esempio n. 6
0
        protected bool dirRight;                                        // If the charge is facing right (or false if left).

        public DetectCharBehavior(EnemyLand actor, byte viewDistance = 144, byte viewHeight = 32) : base(actor)
        {
            // Reaction
            this.viewDist   = viewDistance;
            this.viewHeight = viewHeight;
            this.dirRight   = false;

            // Timer
            this.timer     = Systems.timer;
            this.actionEnd = 0;

            this.SetBehavePassives();
        }
Esempio n. 7
0
        // The Animation Tick, which should be run during the object's RunTick cycle.
        public void RunAnimationTick(TimerGlobal timer)
        {
            // Only run if this frame will update the animation.
            if (!this.IsAnimationTick(timer))
            {
                return;
            }

            // Update the Animation ID (and cycle it once it reaches the animation number limit).
            this.CycleId += 1;
            if (this.CycleId >= this.AnimCycles.Length)
            {
                this.CycleId = 0;
            }

            // Update the next frame that the animation will tick.
            this.NextFrame = timer.Frame + this.AnimSpeed;

            // Update the actor's sprite name according to the next animation cycle.
            this.actor.SetAnimationSprite(this.BaseName + this.AnimCycles[this.CycleId]);
        }
Esempio n. 8
0
        public LevelState(GameHandler handler)
        {
            this.handler = handler;
            this.timer   = Systems.timer;

            // Build Flags
            this.checkpoint = new FlagJson {
                active = false,
                roomId = 0,
                gridX  = 0,
                gridY  = 0,
            };

            this.retryFlag = new FlagJson {
                active = false,
                used   = false,
                roomId = 0,
                gridX  = 0,
                gridY  = 0,
            };

            // Reset Level
            this.FullReset();
        }
Esempio n. 9
0
        public bool CanActivate()
        {
            // Cannot activate this power while holding an item:
            if (this.character.heldItem.IsHeld)
            {
                return(false);
            }

            TimerGlobal timer = Systems.timer;

            // Delay if last activation was too recent.
            if (timer.Frame < this.lastActivation)
            {
                return(false);
            }

            // If this character is a fast caster, run special activation behaviors:
            byte fastCastMult = this.character.stats.CanFastCast ? (byte)2 : (byte)1;

            // Loop through available power uses:
            for (byte i = 0; i < this.lastUseTracker.Length; i++)
            {
                if (timer.Frame > this.lastUseTracker[i])
                {
                    // Consume this activation for now:
                    this.lastUseTracker[i] = timer.Frame + this.cooldown / fastCastMult;

                    // Set most recent activation:
                    this.lastActivation = timer.Frame + this.delayBetweenUses / fastCastMult;

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 10
0
 // Returns TRUE if we're on an animation tick (which is the same as a beat frame)
 public static bool IsAnimationTick(TimerGlobal timer)
 {
     return(timer.IsBeatFrame);
 }
Esempio n. 11
0
 // Get 4-Per-Second Global Animation ID: Animations that cycle between four texture IDs per second.
 public static byte Get4PSAnimId(TimerGlobal timer)
 {
     return((byte)(timer.beat4Modulus + 1));
 }
Esempio n. 12
0
 // Get 2-Per-Second Global Animation ID: Animations that cycle between two texture IDs per second.
 public static byte Get2PSAnimId(TimerGlobal timer)
 {
     return(timer.beat4Modulus >= 2 ? (byte)2 : (byte)1);
 }