Beispiel #1
0
        public void Interact()
        {
            switch (doorState)
            {
            case IDoor.DoorState.Open:
                connectedDoor.State = IDoor.DoorState.Open;
                game.RoomHandler.LoadNewRoom(game.RoomHandler.currentRoom + roomTranslationVector, connectedDoor);
                break;

            case IDoor.DoorState.Bombed:
                game.RoomHandler.LoadNewRoom(game.RoomHandler.currentRoom + roomTranslationVector, connectedDoor);
                break;

            case IDoor.DoorState.Closed:
                break;

            case IDoor.DoorState.Locked:
                if (InventoryManager.Instance.inventory[InventoryManager.ItemType.Key] > 0)
                {
                    InventoryManager.Instance.inventory[InventoryManager.ItemType.Key]--;
                    State = IDoor.DoorState.Open;
                    connectedDoor.State = IDoor.DoorState.Open;
                    SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
                }
                break;

            case IDoor.DoorState.Wall:     //do nothing
                break;

            default:     //this should never happen
                break;
            }
        }
Beispiel #2
0
        public void Attack()
        {
            if ((mode != LinkMode.Moving && mode != LinkMode.Still) || pauseMovement)
            {
                return;
            }
            mode = LinkMode.Attack;
            SoundFactory.PlaySound(SoundFactory.Instance.swordSlash);

            Vector2 startingPosition = getItemLocation(currDirection);

            linkInventory.CreateWeapon(startingPosition, currDirection);

            int minHealth = SettingsValues.Instance.GetValue(SettingsValues.Variable.MinProjectileSwordHealth);

            if (minHealth < 0)
            {
                minHealth += totalHealth + 1;
            }
            if (minHealth <= health)
            {
                linkInventory.CreateSwordProjectile(startingPosition, currDirection);
            }

            SetAttackAnimation();
        }
        public void CheckCondition()
        {
            if (conditionVariables[3] == 0 && RoomEnemies.Instance.ListRef.Count == 0)
            {
                conditionVariables[3] = 1;
                Vector2 startPos = new Vector2(conditionVariables[0], conditionVariables[1]);
                switch (conditionVariables[2])
                {
                case 0:
                    ItemSpriteFactory.Instance.CreateKeyItem(startPos, true, false);
                    SoundFactory.PlaySound(SoundFactory.Instance.keyAppear);
                    break;

                case 1:
                    ItemSpriteFactory.Instance.CreateBoomerangItem(startPos, true, false);
                    break;

                case 2:
                    ItemSpriteFactory.Instance.CreateHeartContainerItem(startPos, true, false);
                    break;

                case 3:
                    ItemSpriteFactory.Instance.CreateHeartItem(startPos, true, false);
                    break;

                default:     //this should never happen
                    break;
                }
            }
        }
        private void LoadFireballs()
        {
            //the direction the fireballs will travel
            Vector2 direction1;
            Vector2 direction2;
            Vector2 direction3;

            //all fireballs originate in the mouth
            Vector2 location;

            location.X  = this.center.X;
            location.X -= MovementConstants.AquamentusFireballChangeX;
            if (aquamentusSprite.StartingFrameIndex == (int)AquamentusSprite.FrameIndex.RightFacing)
            {
                location.X += 2 * MovementConstants.AquamentusFireballChangeX;
            }
            location.Y = this.center.Y - 10;

            direction2 = player.Center - location;
            direction2.Normalize();
            double angle2 = Math.Atan2(direction2.Y, direction2.X);
            double angle1 = angle2 + MovementConstants.AquamentusFireballSpreadAngle;
            double angle3 = angle2 - MovementConstants.AquamentusFireballSpreadAngle;

            direction1 = new Vector2((float)Math.Cos(angle1), (float)Math.Sin(angle1));
            direction3 = new Vector2((float)Math.Cos(angle3), (float)Math.Sin(angle3));

            ProjectileHandler projectileHandler = ProjectileHandler.Instance;

            projectileHandler.CreateFireballObject(spriteBatch, location, direction1);
            projectileHandler.CreateFireballObject(spriteBatch, location, direction2);
            projectileHandler.CreateFireballObject(spriteBatch, location, direction3);

            SoundFactory.PlaySound(SoundFactory.Instance.bossScream);
        }
        public void CheckCondition()
        {
            IDoor.DoorState doorState = IDoor.DoorState.Open;
            foreach (IBlock block in RoomBlocks.Instance.ListRef)
            {
                if (!block.IsMoved())
                {
                    doorState = IDoor.DoorState.Closed;
                    break;
                }
            }

            List <IDoor> doors = RoomDoors.Instance.ListRef as List <IDoor>;

            foreach (int doornum in conditionVariables)
            {
                doors[doornum].State = doorState;
            }

            if (doorState != prevState)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
            }
            prevState = doorState;
        }
Beispiel #6
0
        public void CheckCondition()
        {
            IDoor.DoorState doorState = IDoor.DoorState.Open;
            if (RoomEnemies.Instance.ListRef.Count == 0)
            {
                List <ISpawner> spawners = RoomSpawners.Instance.ListRef as List <ISpawner>;
                foreach (ISpawner spawner in spawners)
                {
                    if (spawner.CurrentCount > 0)
                    {
                        doorState = IDoor.DoorState.Closed;
                        break;
                    }
                }
            }
            else
            {
                doorState = IDoor.DoorState.Closed;
            }

            List <IDoor> doors = RoomDoors.Instance.ListRef as List <IDoor>;

            foreach (int doornum in conditionVariables)
            {
                doors[doornum].State = doorState;
            }

            if (doorState != prevState)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
            }
            prevState = doorState;
        }
Beispiel #7
0
        private void HandleTriforceItem(IItem item)
        {
            linkState.Health = linkState.TotalHealth;
            GameStateManager.Instance.LinkPickupItem(601, true);
            VisionBlocker.Instance.Triforce = true;
            Vector2 startingPos = linkState.GameWonAnimation();

            item.Center   = startingPos;
            AnimationItem = item;
            ((TriforceItem)item).GameWon = true;
            SoundFactory.PlaySound(SoundFactory.Instance.getItem, 0.25f);
            SoundFactory.PlaySound(SoundFactory.Instance.triforce, 0.25f);
        }
Beispiel #8
0
        public void Update(GameTime gameTime)
        {
            if (this.isGrabbed)
            {
                if (this.shoveDistance < 0)
                {
                    isGrabbed  = false;
                    this.speed = LinkConstants.defaultSpeed;
                }
                else
                {
                    CenterPosition += currDirection * speed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    this.shoveDistance--;
                }
                return;
            }

            UpdateDamageDelay(gameTime);
            Movement(gameTime);

            if (linkSprite.Update(gameTime) != 0)
            {
                if (mode == LinkMode.Attack || mode == LinkMode.Item || mode == LinkMode.GameWon)
                {
                    if (mode == LinkMode.Item || mode == LinkMode.GameWon)
                    {
                        Inventory.RemoveItemAnimation();
                    }
                    mode = LinkMode.Still;
                    ChangeDirection(new Vector2(0, 0));
                }
                else if (mode == LinkMode.Death)
                {
                    linkSprite.DeathMaskHandler.LoadMask();
                    mode = LinkMode.Still;
                    this.pauseMovement = true;
                    linkSprite.setFrameSet(LinkSprite.AnimationState.DownFacing);
                    linkSprite.DamageMaskHandler.Disabled = false;
                }
            }

            if (health <= HeartConstants.HeartLowCount && health != totalHealth)
            {
                lowHealthSoundDelay--;
                if (lowHealthSoundDelay == 0)
                {
                    lowHealthSoundDelay = LinkConstants.defaultSoundDelay;
                    SoundFactory.PlaySound(SoundFactory.Instance.lowHealth);
                }
            }
        }
Beispiel #9
0
 private void playItemSounds(ItemType type)
 {
     if (type == InventoryManager.ItemType.Heart || type == InventoryManager.ItemType.Key)
     {
         SoundFactory.PlaySound(SoundFactory.Instance.getHeart);
     }
     else if (type == InventoryManager.ItemType.Rupee)
     {
         SoundFactory.PlaySound(SoundFactory.Instance.getRupee);
     }
     else
     {
         SoundFactory.PlaySound(SoundFactory.Instance.getItem);
     }
 }
Beispiel #10
0
        public void TakeDamage(int damage)
        {
            if (damage > 0)
            {
                damage = Inventory.updateDamage(damage);
                if (remainingDamageDelay > 0 && linkSprite.Damaged)
                {
                    return;
                }
                linkSprite.Damaged   = true;
                health              -= damage;
                remainingDamageDelay = DamageConstants.DamageDisableDelay;
            }

            SoundFactory.PlaySound(SoundFactory.Instance.linkHit);
        }
        public void CheckCondition()
        {
            IDoor.DoorState doorState = IDoor.DoorState.Closed;
            if (RoomEnemies.Instance.ListRef.Count == 0)
            {
                doorState = IDoor.DoorState.Open;
            }

            List <IDoor> doors = RoomDoors.Instance.ListRef as List <IDoor>;

            foreach (int doornum in conditionVariables)
            {
                doors[doornum].State = doorState;
            }

            if (doorState != prevState)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
            }
            prevState = doorState;
        }
        public void CheckCondition()
        {
            bool allMoved = true;

            foreach (IBlock block in RoomBlocks.Instance.ListRef)
            {
                if (!block.IsMoved())
                {
                    allMoved = false;
                    break;
                }
            }

            if (allMoved && !alreadyPlayed)
            {
                alreadyPlayed = true;
                SoundFactory.PlaySound(SoundFactory.Instance.secret);
            }
            else if (!allMoved)
            {
                alreadyPlayed = false;
            }
        }
Beispiel #13
0
        public void Update(GameTime gameTime, Vector2 center, Boolean pauseAnim)
        {
            this.center = center;
            if (isIntro)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.mariogreeting, 0.2f);
                isIntro = false;
            }
            if (fireballCounter > fireballDelay)
            {
                LoadFireballs();
                fireballCounter = 0;
            }
            else
            {
                fireballCounter += (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            if (!pauseAnim)
            {
                marioBossSprite.Update(gameTime);
            }
        }