Ejemplo n.º 1
0
        public override bool Activate()
        {
            // Make sure the power can be activated
            if (!this.CanActivate())
            {
                return(false);
            }

            // Prepare Direction
            sbyte directionHor  = 0;
            sbyte directionVert = 0;

            // Character Input determines which way the air burst effect occurs.
            PlayerInput input = this.character.input;

            if (input.isDown(IKey.Up))
            {
                directionVert = -1;
            }
            else if (input.isDown(IKey.Down))
            {
                directionVert = 1;
            }

            if (input.isDown(IKey.Left))
            {
                directionHor = -1;
            }
            else if (input.isDown(IKey.Right))
            {
                directionHor = 1;
            }

            // Default to Upward Direction
            if (directionHor == 0 && directionVert == 0)
            {
                directionVert = -1;
            }

            // If the character is standing on ground, it interferes with actions; fix that.
            if (this.character.physics.touch.toBottom)
            {
                this.character.physics.touch.ResetTouch();
                this.character.physics.MoveToPosY(this.character.posY - 1);
            }

            // Trigger the Air Burst Action
            ActionMap.AirBurst.StartAction(this.character, directionHor, directionVert);

            // Display the "Air" particle event and play the "Air" sound.
            BurstEmitter.AirPuff(this.character.room, this.character.posX + this.character.bounds.MidX, this.character.posY + this.character.bounds.MidY, directionHor, directionVert, 18);
            this.character.room.PlaySound(Systems.sounds.air, 0.5f, this.character.posX + 16, this.character.posY + 16);
            return(true);
        }
Ejemplo n.º 2
0
        public override bool Activate()
        {
            // Make sure the power can be activated
            if (!this.CanActivate())
            {
                return(false);
            }

            // Make sure you're not on the ground when attempting to activate.
            if (this.character.physics.touch.toFloor)
            {
                return(false);
            }

            // Start the Slam Action
            ActionMap.Slam.StartAction(this.character);

            // Display the "Air" particle event and play the "Air" sound.
            BurstEmitter.AirPuff(this.character.room, this.character.posX + this.character.bounds.MidX, this.character.posY + this.character.bounds.MidY, 0, 1, 18);
            this.character.room.PlaySound(Systems.sounds.air, 0.5f, this.character.posX + 16, this.character.posY + 16);

            return(true);
        }
Ejemplo n.º 3
0
        public override bool RunImpact(RoomScene room, GameObject actor, short gridX, short gridY, DirCardinal dir)
        {
            // Only run this test for Characters.
            if (!(actor is Character))
            {
                return(false);
            }

            Character character = (Character)actor;

            // Don't run this test if the character is already in an air-burst action.
            if (character.status.action is AirBurst)
            {
                return(false);
            }

            // Test against an Inner Boundary so that it doesn't touch so easily.
            DirCardinal newDir = TileSolidImpact.RunOverlapTest(actor, gridX * (byte)TilemapEnum.TileWidth + 6, gridX * (byte)TilemapEnum.TileWidth + (byte)TilemapEnum.TileWidth - 6, gridY * (byte)TilemapEnum.TileHeight + 6, gridY * (byte)TilemapEnum.TileHeight + (byte)TilemapEnum.TileHeight - 6);

            if (newDir == DirCardinal.None)
            {
                return(false);
            }

            // If the character isn't centered with the puff block, move it closer to center.
            //sbyte diffX = (sbyte)(character.posX + character.bounds.MidX - (gridX * (byte)TilemapEnum.TileWidth + (byte)TilemapEnum.HalfWidth));
            //sbyte diffY = (sbyte)(character.posY + character.bounds.MidY - (gridY * (byte)TilemapEnum.TileHeight + (byte)TilemapEnum.HalfHeight));

            // Get the SubType
            byte subType = room.tilemap.GetMainSubType(gridX, gridY);

            // Determine Movement Pattern
            sbyte hor  = 0;
            sbyte vert = 0;

            if (subType == (byte)PuffBlockSubType.Up)
            {
                vert = -1;
                character.physics.MoveToPosX(gridX * (byte)TilemapEnum.TileWidth + (byte)TilemapEnum.HalfWidth - character.bounds.MidX);
            }
            else if (subType == (byte)PuffBlockSubType.Right)
            {
                hor = 1;
                character.physics.MoveToPosY(gridY * (byte)TilemapEnum.TileHeight + (byte)TilemapEnum.HalfHeight - character.bounds.MidY);
            }
            else if (subType == (byte)PuffBlockSubType.Down)
            {
                vert = 1;
                character.physics.MoveToPosX(gridX * (byte)TilemapEnum.TileWidth + (byte)TilemapEnum.HalfWidth - character.bounds.MidX);
            }
            else if (subType == (byte)PuffBlockSubType.Left)
            {
                hor = -1;
                character.physics.MoveToPosY(gridY * (byte)TilemapEnum.TileHeight + (byte)TilemapEnum.HalfHeight - character.bounds.MidY);
            }

            // Character is sent into an "Air Burst" action.
            ActionMap.AirBurst.StartAction(character, hor, vert, true, this.puffDuration);

            // Draw Overlap Particle
            BurstEmitter.AirPuff(room, character.posX + character.bounds.MidX, character.posY + character.bounds.MidY, hor, vert, 18);

            room.PlaySound(Systems.sounds.air, 1f, gridX * (byte)TilemapEnum.TileWidth, gridY * (byte)TilemapEnum.TileHeight);

            return(true);
        }
Ejemplo n.º 4
0
        public override bool Activate()
        {
            // Make sure the power can be activated
            if (!this.CanActivate())
            {
                return(false);
            }

            // Prepare Direction
            sbyte directionHor  = 0;
            sbyte directionVert = 0;

            // Character Input determines which way the air burst effect occurs.
            PlayerInput input = this.character.input;

            if (input.isDown(IKey.Up))
            {
                directionVert = -1;
            }
            else if (input.isDown(IKey.Down))
            {
                directionVert = 1;
            }

            if (input.isDown(IKey.Left))
            {
                directionHor = -1;
            }
            else if (input.isDown(IKey.Right))
            {
                directionHor = 1;
            }

            // Default to Upward Direction
            if (directionHor == 0 && directionVert == 0)
            {
                directionVert = -1;
            }

            Physics physics = this.character.physics;

            // Affect Character's Velocity
            if (directionHor != 0)
            {
                physics.velocity.X += 6 * directionHor;

                if (physics.velocity.X.RoundInt > 16)
                {
                    physics.velocity.X = (FInt)16;
                }
                else if (physics.velocity.X.RoundInt < -16)
                {
                    physics.velocity.X = (FInt)0 - 16;
                }
            }

            if (directionVert == -1)
            {
                // If you're already moving upward, increase speed by -10 (up to -16). Otherwise, automatically increase to -12.
                if (physics.velocity.Y < 0)
                {
                    physics.velocity.Y -= 10;
                    if (physics.velocity.Y < -16)
                    {
                        physics.velocity.Y = (FInt)0 - 16;
                    }
                }
                else
                {
                    physics.velocity.Y = (FInt)0 - 12;
                }
            }
            else if (directionVert == 1)
            {
                physics.velocity.Y += 4;
            }

            // Display the "Air" particle event and play the "Air" sound.
            BurstEmitter.AirPuff(this.character.room, this.character.posX + this.character.bounds.MidX, this.character.posY + this.character.bounds.MidY, directionHor, directionVert, 18);
            this.character.room.PlaySound(Systems.sounds.air, 0.5f, this.character.posX + 16, this.character.posY + 16);
            return(true);
        }