Ejemplo n.º 1
0
        public override void Update()
        {
            AudioSystem.LoopSoundWhileActive(GameData.SOUND_BOOMERANG_LOOP);

            if (isReturning)
            {
                // Return to owner.
                Vector2F trajectory = owner.Center - Center;
                if (trajectory.Length <= speed)
                {
                    OnReturnedToOwner();
                    Destroy();
                }
                else
                {
                    physics.Velocity = trajectory.Normalized * speed;
                }
            }
            else
            {
                // Update return timer.
                timer++;
                if (timer > returnDelay)
                {
                    BeginReturn();
                }
            }

            base.Update();
        }
Ejemplo n.º 2
0
        public override void Update()
        {
            AudioSystem.LoopSoundWhileActive(GameData.SOUND_BOOMERANG_LOOP);

            // Check for boomerangable tiles.
            if (itemBoomerang.Level == Item.Level2)
            {
                Point2I tileLoc = RoomControl.GetTileLocation(position);
                if (tileLoc != tileLocation && RoomControl.IsTileInBounds(tileLoc))
                {
                    Tile tile = RoomControl.GetTopTile(tileLoc);
                    if (tile != null)
                    {
                        tile.OnBoomerang();
                    }
                }
                tileLocation = tileLoc;
            }

            // Pickup collectibles.
            foreach (Collectible collectible in Physics.GetEntitiesMeeting <Collectible>(CollisionBoxType.Soft))
            {
                if (collectible.IsPickupable && collectible.IsCollectibleWithItems)
                {
                    collectibles.Add(collectible);
                    collectible.Destroy();
                    BeginReturn();
                }
            }

            base.Update();
        }
Ejemplo n.º 3
0
        public override void Update()
        {
            base.Update();

            AudioSystem.LoopSoundWhileActive(GameData.SOUND_MINECART_LOOP);

            // Update minecart animation.
            minecartAnimationPlayer.Update();

            // Keep the default player animation to be in a minecart.
            if (player.MoveAnimation == GameData.ANIM_PLAYER_DEFAULT)
                player.MoveAnimation = GameData.ANIM_PLAYER_MINECART_IDLE;

            // Update movement.
            moveDistance += minecartSpeed;
            if (moveDistance >= GameSettings.TILE_SIZE) {
                // Move to the next tile.
                if (!MoveToNextTile()) {
                    ExitMinecart(direction);
                    return;
                }
            }

            UpdatePlayerPosition();

            // Collide with monsters.
        }
Ejemplo n.º 4
0
        //-----------------------------------------------------------------------------
        // Updating
        //-----------------------------------------------------------------------------

        // Updates the rupees and player life incrementation.
        public void Update()
        {
            int rupees = Inventory.GetAmmo("rupees").Amount;
            int health = gameControl.Player.Health;

            // Update dynamic rupees.
            if (dynamicRupees != rupees)
            {
                dynamicRupees += Math.Sign(rupees - dynamicRupees);
                if (dynamicRupees == rupees)
                {
                    AudioSystem.PlaySound(GameData.SOUND_GET_RUPEE);
                }
                else
                {
                    AudioSystem.LoopSoundWhileActive(GameData.SOUND_GET_RUPEE_LOOP);
                }
            }

            // Update dynamic health.
            if (dynamicHealth < health)
            {
                if (healthTimer < 3)
                {
                    healthTimer++;
                }
                else
                {
                    healthTimer = 0;
                    dynamicHealth++;
                    if (dynamicHealth % 4 == 0)
                    {
                        AudioSystem.PlaySound(GameData.SOUND_GET_HEART);
                    }
                }
            }
            else if (dynamicHealth > health)
            {
                dynamicHealth--;
            }
            else
            {
                healthTimer = 0;
            }
        }
Ejemplo n.º 5
0
        public override void Update()
        {
            if (isLifting)
            {
            }
            else if (isReturning)
            {
                AudioSystem.LoopSoundWhileActive(GameData.SOUND_SWITCH_HOOK_LOOP);

                // Return to player.
                Vector2F trajectory = (RoomControl.Player.Center + new Vector2F(0, 3)) - Center;
                if (trajectory.Length <= speed)
                {
                    if (collectible != null)
                    {
                        collectible.Collect();
                    }
                    Destroy();
                }
                else
                {
                    physics.Velocity = trajectory.Normalized * speed;
                }
            }
            else if (isHooked)
            {
                // This is the state when latched on to on object, before lifting up.
                timer++;
                if (timer >= GameSettings.SWITCH_HOOK_LATCH_DURATION)
                {
                    // Start lifting if object is still alive.
                    if (IsHookedObjectAlive())
                    {
                        BeginSwitching();
                    }
                    else
                    {
                        BeginReturn(true);
                    }
                }
            }
            else
            {
                AudioSystem.LoopSoundWhileActive(GameData.SOUND_SWITCH_HOOK_LOOP);

                // Check for collectibles to pick up.
                foreach (Collectible c in Physics.GetEntitiesMeeting <Collectible>(CollisionBoxType.Soft))
                {
                    if (c.IsPickupable && c.IsCollectibleWithItems)
                    {
                        collectible = c;
                        c.Destroy();
                        BeginReturn(true);
                    }
                }

                // Return after extending to the maximum distance.
                distance += speed;
                if (distance >= length)
                {
                    BeginReturn(false);
                }
            }

            base.Update();

            // This should handle room edge collisions.
            if (!isReturning && !isHooked && !isLifting && physics.IsColliding)
            {
                BeginReturn(false);
            }
        }