Example #1
0
        protected void WatchForCharacter()
        {
            // Only run the watch behavior every 16 frames.
            if (this.timer.frame16Modulus != this.test16Frame)
            {
                return;
            }

            // Make sure the cooldown is complete.
            if (this.actionEnd > this.timer.Frame)
            {
                return;
            }

            Bounds bounds = this.actor.bounds;

            // Determine view bounds based on direction actor is facing.
            int scanX = actor.posX + (actor.FaceRight ? bounds.Right : bounds.Left - this.viewDist);
            int scanY = actor.posY + bounds.Bottom - this.viewHeight;

            int objectId = CollideRect.FindOneObjectTouchingArea(
                this.actor.room.objects[(byte)LoadOrder.Character],
                scanX,
                scanY,
                this.viewDist,
                this.viewHeight
                );

            // If a character was located in the enemy's view range, enemy begins their stall (before their action).
            if (objectId != 0)
            {
                this.BeginStall();
            }
        }
Example #2
0
        public static void DamageAbove(RoomScene room, short gridX, short gridY)
        {
            // Damage Creatures Above (if applicable)
            int enemyFoundId = CollideRect.FindOneObjectTouchingArea(room.objects[(byte)LoadOrder.Enemy], gridX * (byte)TilemapEnum.TileWidth + 16, gridY * (byte)TilemapEnum.TileHeight - 4, 16, 4);

            if (enemyFoundId > 0)
            {
                Enemy enemy = (Enemy)room.objects[(byte)LoadOrder.Enemy][enemyFoundId];
                enemy.Die(DeathResult.Knockout);
            }
        }
Example #3
0
        private int WatchForCharacter(int midX, int midY)
        {
            int objectId = CollideRect.FindOneObjectTouchingArea(
                this.actor.room.objects[(byte)LoadOrder.Character],
                Math.Max(0, midX - this.reactDist),
                Math.Max(0, midY - this.reactDist),
                (short)(this.reactDist * 2),                // View Distance (Width)
                (short)(this.reactDist * 2)                 // View Height
                );

            return(objectId);
        }
Example #4
0
        private void WatchForCharacter(int midX, int midY)
        {
            // If there is no character in sight, check for a new one:
            if (this.charWatched is Character == false)
            {
                int objectId = CollideRect.FindOneObjectTouchingArea(
                    this.room.objects[(byte)LoadOrder.Character],
                    Math.Max(0, midX - ViewDistance),
                    Math.Max(0, midY - ViewDistance),
                    (ViewDistance * 2),                    // View Distance (Width)
                    (ViewDistance * 2)                     // View Height
                    );

                if (objectId > 0)
                {
                    this.charWatched = (Character)this.room.objects[(byte)LoadOrder.Character][objectId];
                }
            }
        }
Example #5
0
        public override void RunTick()
        {
            // While Slammer is Passive
            if (this.state == SlammerState.Passive)
            {
                if (this.viewHeight == 0)
                {
                    return;
                }

                // Check for Characters within Slammer's View. Being Slamming if one is found.
                int objectId = CollideRect.FindOneObjectTouchingArea(
                    this.actor.room.objects[(byte)LoadOrder.Character],
                    this.actor.posX + 8,
                    this.viewY,
                    (byte)TilemapEnum.TileWidth * 2 - 20,
                    this.viewHeight
                    );

                if (objectId > 0)
                {
                    this.state = SlammerState.Slamming;
                }
            }

            // While Slammer is Slamming
            else if (this.state == SlammerState.Slamming)
            {
                this.fallAccel += FInt.Create(0.12);
                if (this.fallAccel > 2)
                {
                    this.fallAccel = FInt.Create(2);
                }
                this.physics.velocity.Y += this.fallAccel;

                // If Slammer has completed its maximum journey.
                if (this.actor.posY >= this.endY)
                {
                    this.EndSlam(this.actor);
                    return;
                }
            }

            // While Slammer is Reset Delayed
            else if (this.state == SlammerState.ResetDelay)
            {
                if (this.resetFrame <= Systems.timer.Frame)
                {
                    this.state = SlammerState.Resetting;
                }
            }

            // While Slammer is Resetting
            else if (this.state == SlammerState.Resetting)
            {
                this.physics.velocity.Y -= FInt.Create(0.3);
                if (this.actor.posY <= this.startY)
                {
                    this.SlammerHasReset();
                }
            }
        }