Beispiel #1
0
        public override void Update()
        {
            base.Update();

            // TODO: Sparkle effects should update while text is reading.

            if (isActivated) {
                timer++;

                // Create a sparkle every 8 ticks.
                if (timer % 8 == 1 && sparkleIndex < sparklePositions.Length) {
                    Effect effect = new Effect(GameData.ANIM_EFFECT_OWL_SPARKLE);
                    effect.Graphics.IsAnimatedWhenPaused = true;
                    RoomControl.SpawnEntity(effect,
                        Position + sparklePositions[sparkleIndex]);
                    sparkleIndex++;
                }

                if (timer == 49) {
                    SpriteIndex = 1;
                    //CustomSprite = GameData.SPR_TILE_OWL_ACTIVATED;
                }
                if (timer == 58) {
                    string text = Properties.GetString("text", GameSettings.TEXT_UNDEFINED);
                    RoomControl.GameControl.DisplayMessage(text);
                }
                if (timer > 80) {
                    isActivated = false;
                    SpriteIndex = 0;
                    //CustomSprite = GameData.SPR_TILE_OWL;
                }
            }
        }
Beispiel #2
0
        public override void Update()
        {
            base.Update();

            // TODO: Sparkle effects should update while text is reading.

            if (isActivated) {
                timer++;

                // Create a sparkle every 8 ticks.
                if (timer % 8 == 1 && sparkleIndex < sparklePositions.Length) {
                    Effect effect = new Effect(GameData.ANIM_EFFECT_OWL_SPARKLE, DepthLayer.EffectOwlSparkles, true);
                    RoomControl.SpawnEntity(effect,
                        Position + sparklePositions[sparkleIndex]);
                    sparkleIndex++;
                }

                if (timer == 49) {
                    Graphics.PlaySpriteAnimation(SpriteList[1]);
                    //Graphics.PlaySprite(GameData.SPR_TILE_OWL_ACTIVATED);
                }
                if (timer == 58) {
                    string text = Properties.GetString("text", GameSettings.TEXT_UNDEFINED);
                    RoomControl.GameControl.DisplayMessage(text);
                }
                if (timer > 80) {
                    isActivated = false;
                    Graphics.PlaySpriteAnimation(SpriteList[0]);
                    //Graphics.PlaySprite(GameData.SPR_TILE_OWL);
                }
            }
        }
 //-----------------------------------------------------------------------------
 // Internal methods
 //-----------------------------------------------------------------------------
 public void Break()
 {
     if (tile.BreakAnimation != null) {
         Effect breakEffect = new Effect(tile.BreakAnimation, DepthLayer.EffectTileBreak, true);
         RoomControl.SpawnEntity(breakEffect, Center);
     }
     if (tile.BreakSound != null)
         AudioSystem.PlaySound(tile.BreakSound);
     Destroy();
 }
Beispiel #4
0
        // Create an effect that plays an animation and then dissapears
        public Effect(Effect copy)
            : this()
        {
            destroyTimer = copy.destroyTimer;
            destroyOnAnimationComplete = copy.destroyOnAnimationComplete;
            fadeDelay = copy.fadeDelay;
            Graphics.DepthLayer = copy.Graphics.DepthLayer;

            if (copy.Graphics.Animation != null)
                Graphics.PlayAnimation(copy.Graphics.Animation);
        }
        public override void OnBegin(PlayerState previousState)
        {
            player.Movement.CanJump = false;
            player.Movement.MoveSpeedScale = 1.0f;
            player.Movement.AutoAccelerate = false;

            isSubmerged = false;
            player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_SWIM);

            // Create a splash effect.
            Effect splash = new Effect(GameData.ANIM_EFFECT_WATER_SPLASH);
            splash.Position = player.Position - new Vector2F(0, 4);
            player.RoomControl.SpawnEntity(splash);
        }
        //-----------------------------------------------------------------------------
        // Internal methods
        //-----------------------------------------------------------------------------
        private void PerformDig(PlayerState state)
        {
            // Look for tiles to dig up.
            float distance = 6.5f;
            Vector2F center = Player.Center;
            if (Directions.IsVertical(Player.Direction))
                distance = 7.5f;
            else
                center.Y += 4.0f;
            Vector2F hotspot = GMath.Round(center) + (Directions.ToVector(Player.Direction) * distance);
            Point2I tileLoc = RoomControl.GetTileLocation(hotspot);
            if (!RoomControl.IsTileInBounds(tileLoc))
                return;

            Tile tile = RoomControl.GetTopTile(tileLoc);

            if (tile != null && tile.OnDig(Player.Direction)) {
                // Spawn dirt effect.
                Effect effect = new Effect();
                effect.Graphics.DepthLayer = DepthLayer.EffectDirt;
                effect.CreateDestroyTimer(15);
                effect.EnablePhysics(PhysicsFlags.HasGravity);
                effect.Physics.Velocity = Directions.ToVector(Player.Direction) * 0.5f;
                effect.Graphics.IsShadowVisible = false;
                effect.Graphics.PlayAnimation(GameData.ANIM_EFFECT_DIRT);
                effect.Graphics.SubStripIndex = Player.Direction;
                if (Directions.IsHorizontal(Player.Direction)) {
                    effect.Physics.ZVelocity	= 3.0f;
                    effect.Physics.Gravity		= 0.5f;
                }
                else {
                    effect.Physics.ZVelocity	= 2.5f;
                    effect.Physics.Gravity		= 0.4f;
                }
                RoomControl.SpawnEntity(effect, tile.Center);

                AudioSystem.PlaySound(GameData.SOUND_SHOVEL);
            }
            else {
                AudioSystem.PlaySound(GameData.SOUND_EFFECT_CLING);
            }

            // Check for monster interactions.
            Rectangle2I shovelHitBox = new Rectangle2I(-4, -4, 8, 8);
            shovelHitBox.Point += (Point2I) Player.CenterOffset;
            shovelHitBox.ExtendEdge(Player.Direction, 7);
            foreach (Monster monster in Player.Physics.GetEntitiesMeeting<Monster>(shovelHitBox, CollisionBoxType.Soft)) {
                monster.TriggerInteraction(InteractionType.Shovel, Player);
            }
        }
        public override void Break(bool spawnDrops)
        {
            if (isGrown) {
                // Spawn the leaves effect and spawn drops.
                Effect effect = new Effect(GameData.ANIM_EFFECT_LEAVES, DepthLayer.EffectTileBreak, true);
                RoomControl.SpawnEntity(effect, Center);
                AudioSystem.PlaySound(GameData.SOUND_LEAVES);

                if (spawnDrops)
                    SpawnDrop();

                isGrown = false;
                Graphics.PlayAnimation(new Animation(GameData.SPR_TILE_REGROWING_PLANT_CUT));
                regrowTimer = 0;

                SetFlags(TileFlags.Cuttable | TileFlags.Bombable, false);
            }
        }
        //-----------------------------------------------------------------------------
        // Overridden Methods
        //-----------------------------------------------------------------------------
        public override void OnInitialize()
        {
            base.OnInitialize();
            timer = 0;

            fallsInHoles = false;

            // Spawn the poof effect.
            if (spawnOptions.PoofEffect) {
                Point2I size = tile.Size;
                for (int x = 0; x < size.X; x++) {
                    for (int y = 0; y < size.Y; y++) {
                        Effect effect = new Effect(GameData.ANIM_EFFECT_BLOCK_POOF,
                            Entities.DepthLayer.EffectSomariaBlockPoof);
                        Vector2F pos = (Location + new Point2I(x, y) + new Vector2F(0.5f, 0.5f)) * GameSettings.TILE_SIZE;
                        RoomControl.SpawnEntity(effect, pos);
                    }
                }
                AudioSystem.PlaySound(GameData.SOUND_APPEAR_VANISH);
            }
        }
        public override void OnBegin(PlayerState previousState)
        {
            player.Movement.CanJump = false;
            player.Movement.MoveSpeedScale = 1.0f;
            player.Movement.AutoAccelerate = false;

            isSubmerged = false;
            player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_SWIM);

            // Create a splash effect.
            if (player.Physics.IsInLava) {
                Effect splash = new Effect(GameData.ANIM_EFFECT_LAVA_SPLASH, DepthLayer.EffectSplash, true);
                splash.Position = player.Center + new Vector2F(0, 4);
                player.RoomControl.SpawnEntity(splash);
            }
            else {
                Effect splash = new Effect(GameData.ANIM_EFFECT_WATER_SPLASH, DepthLayer.EffectSplash, true);
                splash.Position = player.Center + new Vector2F(0, 4);
                player.RoomControl.SpawnEntity(splash);
            }

            // Check if the player should drown.
            if ((player.Physics.IsInWater && !player.SwimmingSkills.HasFlag(PlayerSwimmingSkills.CanSwimInWater)) ||
                player.Physics.IsInOcean && !player.SwimmingSkills.HasFlag(PlayerSwimmingSkills.CanSwimInOcean))
            {
                player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_DROWN);
                player.RespawnDeath();
                // TODO: Cancel the hurt animation if the player was knocked in.
                //player.InvincibleTimer = 0;
                //player.Graphics.IsHurting = false;
            }
            else if (player.Physics.IsInLava && !player.SwimmingSkills.HasFlag(PlayerSwimmingSkills.CanSwimInLava)) {
                player.Graphics.IsHurting = true;
                player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_DROWN);
                player.RespawnDeath();
            }

            AudioSystem.PlaySound(GameData.SOUND_PLAYER_WADE);
        }
Beispiel #10
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------
        // Called when the items button is pressed (A or B).
        public override void OnButtonPress()
        {
            // Shoot an arrow!
            if (ammo[currentAmmo].IsEmpty)
                return;

            Player.Direction = Player.UseDirection;

            Projectile projectile = new Projectile();

            // General
            projectile.Owner			= Player;
            projectile.Position			= new Vector2F(Player.X, Player.Y - 8) + (Directions.ToVector(Player.Direction) * 8.0f);
            projectile.ZPosition		= Player.ZPosition;
            projectile.Angle			= Directions.ToAngle(Player.Direction);
            projectile.Physics.Velocity	= Directions.ToVector(Player.Direction) * 3.0f;

            Player.Direction = Player.Direction;

            // Graphics.
            projectile.Graphics.SubStripIndex = projectile.Angle;
            projectile.Graphics.PlayAnimation(GameData.ANIM_PROJECTILE_PLAYER_ARROW);

            // Physics.
            projectile.Physics.CollisionBox	= new Rectangle2F(-2, -2, 4, 4);
            projectile.EnablePhysics(PhysicsFlags.CollideWorld | PhysicsFlags.LedgePassable |
                                PhysicsFlags.HalfSolidPassable | PhysicsFlags.DestroyedOutsideRoom);

            // Crash event.
            Vector2F v = projectile.Physics.Velocity;
            projectile.EventCollision += delegate() {
                // Create crash effect.
                Effect effect = new Effect();
                effect.Position = projectile.Position;
                effect.CreateDestroyTimer(32);

                effect.Physics.Velocity		= -(v.Normalized) * 0.25f;
                effect.Physics.ZVelocity	= 1;
                effect.Physics.Gravity		= 0.07f;
                effect.EnablePhysics(PhysicsFlags.HasGravity);

                effect.Graphics.IsShadowVisible = false;
                effect.Graphics.PlayAnimation(GameData.ANIM_PROJECTILE_PLAYER_ARROW_CRASH);

                RoomControl.SpawnEntity(effect);
                projectile.Destroy();
            };

            RoomControl.SpawnEntity(projectile);
            ammo[currentAmmo].Amount--;

            Player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_THROW);
            Player.BeginBusyState(10);
        }
 public static InteractionStaticDelegate ContactEffect(Effect effect)
 {
     return delegate(Monster monster, Entity sender, EventArgs args) {
         Effect clonedEffect = effect.Clone();
         InteractionArgs interactionArgs = args as InteractionArgs;
         monster.RoomControl.SpawnEntity(clonedEffect, interactionArgs.ContactPoint);
     };
 }
Beispiel #12
0
 public override void Die()
 {
     Effect explosion = new Effect(GameData.ANIM_EFFECT_MONSTER_EXPLOSION, DepthLayer.EffectMonsterExplosion);
     AudioSystem.PlaySound(GameData.SOUND_MONSTER_DIE);
     RoomControl.SpawnEntity(explosion, Center);
     if (!softKill)
         Properties.Set("dead", true);
     base.Die();
 }
Beispiel #13
0
        private Entity CreateEffect(SeedType seedType, bool satchelEffect, Vector2F effectPosition)
        {
            Entity effectEntity = null;

            // Create the seed's effect.
            if (seedType == SeedType.Ember) {
                effectEntity = new Fire();
                AudioSystem.PlaySound(GameData.SOUND_FIRE);
            }
            else if (seedType == SeedType.Scent) {
                if (satchelEffect) {
                    effectEntity = new ScentPod();
                    AudioSystem.PlaySound(GameData.SOUND_SCENT_SEED_POD);
                }
                else {
                    effectEntity = new Effect(GameData.ANIM_EFFECT_SEED_SCENT, DepthLayer.EffectSeed);
                    AudioSystem.PlaySound(GameData.SOUND_SCENT_SEED);
                }
            }
            else if (seedType == SeedType.Mystery) {
                effectEntity = new Effect(GameData.ANIM_EFFECT_SEED_MYSTERY, DepthLayer.EffectSeed);
                AudioSystem.PlaySound(GameData.SOUND_MYSTERY_SEED);
            }
            else if (seedType == SeedType.Pegasus) {
                effectEntity = new Effect(GameData.ANIM_EFFECT_SEED_PEGASUS, DepthLayer.EffectSeed);
                AudioSystem.PlaySound(GameData.SOUND_FIRE);
            }
            else if (seedType == SeedType.Gale) {
                effectEntity = new EffectGale(satchelEffect);
                AudioSystem.PlaySound(GameData.SOUND_GALE_SEED);
            }

            RoomControl.SpawnEntity(effectEntity, effectPosition);
            return effectEntity;
        }
Beispiel #14
0
        //-----------------------------------------------------------------------------
        // Projectile Methods
        //-----------------------------------------------------------------------------
        protected void Crash(bool isInitialCollision)
        {
            if (crashAnimation != null) {
                // Create crash effect.
                Effect effect;

                if (bounceOnCrash) {
                    effect = new Effect();
                    effect.CreateDestroyTimer(32);
                    effect.EnablePhysics(PhysicsFlags.HasGravity);
                    if (!isInitialCollision)
                        effect.Physics.Velocity = Angles.ToVector(Angles.Reverse(Angle)) * 0.25f;
                    effect.Physics.ZVelocity	= 1.0f;
                    effect.Physics.Gravity		= 0.07f;
                    effect.Graphics.PlayAnimation(crashAnimation);
                }
                else {
                    effect = new Effect(crashAnimation, Graphics.DepthLayer);
                }

                effect.Graphics.IsShadowVisible = false;
                effect.Graphics.DepthLayer = Graphics.DepthLayer;

                RoomControl.SpawnEntity(effect, position);
                DestroyAndTransform(effect);
            }
            else {
                Destroy();
            }

            OnCrash();
        }
        public override void Update()
        {
            // Slow down movement over time from strokes
            if (player.Movement.MoveSpeedScale > 1.0f)
                player.Movement.MoveSpeedScale -= 0.025f;

            // Stroking scales the movement speed.
            if (player.Movement.MoveSpeedScale <= 1.4f && Controls.A.IsPressed()) {
                AudioSystem.PlaySound(GameData.SOUND_PLAYER_SWIM);
                player.Movement.MoveSpeedScale = 2.0f;
            }

            // Auto accelerate during the beginning of a stroke.
            player.Movement.AutoAccelerate = IsStroking;

            // Update the submerge state.
            if (isSubmerged) {
                submergedTimer--;
                player.IsPassable = true;
                if (submergedTimer <= 0 || Controls.B.IsPressed()) {
                    isSubmerged = false;
                    player.IsPassable = false;
                    player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_SWIM);
                    player.Graphics.DepthLayer = DepthLayer.PlayerAndNPCs;
                }
            }
            else if (Controls.B.IsPressed()) {
                isSubmerged = true;
                player.IsPassable = true;
                submergedTimer = submergedDuration;
                player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_SUBMERGED);

                // Create a splash effect.
                Effect splash = new Effect(GameData.ANIM_EFFECT_WATER_SPLASH, DepthLayer.EffectSplash, true);
                splash.Position = player.Center + new Vector2F(0, 4);
                player.RoomControl.SpawnEntity(splash);

                AudioSystem.PlaySound(GameData.SOUND_PLAYER_WADE);

                // Change player depth to lowest.
                player.Graphics.DepthLayer = DepthLayer.PlayerSubmerged;
            }

            base.Update();
        }
Beispiel #16
0
        //-----------------------------------------------------------------------------
        // Mutators
        //-----------------------------------------------------------------------------
        // Break the tile, destroying it.
        public virtual void Break(bool spawnDrops)
        {
            // Spawn the break effect.
            if (breakAnimation != null) {
                Effect breakEffect = new Effect(breakAnimation, DepthLayer.EffectTileBreak, true);
                RoomControl.SpawnEntity(breakEffect, Center);
            }

            if (breakSound != null)
                AudioSystem.PlaySound(breakSound);

            // Spawn drops.
            if (spawnDrops)
                SpawnDrop();

            // Destroy the tile.
            if (properties.GetBoolean("disable_on_destroy", false))
                Properties.Set("enabled", false); // TODO: this won't exactly work anymore.
            RoomControl.RemoveTile(this);
        }
        //-----------------------------------------------------------------------------
        // Update
        //-----------------------------------------------------------------------------
        public void Update()
        {
            // Determine movement mode.
            if (player.RoomControl.IsSideScrolling && isOnSideScrollLadder)
                mode = moveModeNormal;
            else if (player.Physics.IsInAir)
                mode = moveModeAir;
            else if (player.Physics.IsInWater)
                mode = moveModeWater;
            else if (player.Physics.IsOnIce)
                mode = moveModeIce;
            else if (player.Physics.IsOnStairs || player.Physics.IsOnLadder)
                mode = moveModeSlow;
            else if (player.Physics.IsInGrass)
                mode = moveModeGrass;
            else
                mode = moveModeNormal;

            // Update movement.
            UpdateMoveControls();
            UpdateFallingInHoles();
            velocityPrev = player.Physics.Velocity;

            // Update sprinting.
            if (isSprinting) {
                // Create the sprint effect.
                if (sprintTimer % GameSettings.PLAYER_SPRINT_EFFECT_INTERVAL == 0 &&
                    player.IsOnGround && player.CurrentState != player.SwimState)
                {
                    AudioSystem.PlaySound(GameData.SOUND_PLAYER_LAND);
                    Effect sprintEffect = new Effect(GameData.ANIM_EFFECT_SPRINT_PUFF, DepthLayer.EffectSprintPuff, true);
                    player.RoomControl.SpawnEntity(sprintEffect, player.Position);
                }
                sprintTimer--;
                if (sprintTimer <= 0)
                    isSprinting = false;
            }

            // Check for ledge jumping (ledges/waterfalls)
            CollisionInfo collisionInfo = player.Physics.CollisionInfo[moveDirection];
            if (canLedgeJump && mode.CanLedgeJump && isMoving &&
                collisionInfo.Type == CollisionType.Tile &&
                !player.RoomControl.IsSideScrolling)
            {
                Tile tile = collisionInfo.Tile;
                if (tile.IsLedge && moveDirection == tile.LedgeDirection && !tile.IsMoving)
                    TryLedgeJump(tile.LedgeDirection);
            }

            // Check for walking on color barriers.
            if (player.IsOnGround && (player.Physics.TopTile is TileColorBarrier) &&
                ((TileColorBarrier) player.Physics.TopTile).IsRaised)
            {
                IsOnColorBarrier = true;
            }
            else if (player.IsOnGround)
                IsOnColorBarrier = false;

            // Face up if climbing a side-scroll ladder.
            if (player.RoomControl.IsSideScrolling && isOnSideScrollLadder) {
                bool faceUp = false;
                if (HighestSideScrollLadderTile != null)
                    faceUp = (player.Y > HighestSideScrollLadderTile.Bounds.Top + 4.0f);
                if (faceUp && allowMovementControl)
                    player.Direction = Directions.Up;
            }
        }