示例#1
0
        protected override void Initialize()
        {
            SpriteFactory.SetContentManager(Content);
            SoundFactory.SetContentManager(Content);
            LevelFactory.Setup();
            ClockFactory.Setup();
            EventFactory.Setup();
            ScoreManager.Setup();
            keyboard          = new KeyboardController();
            gamepadcontroller = new GamePadController();
            controllers       = new List <IController>();

            if (gamepadcontroller.IsConnected())
            {
                controllers = new List <IController>()
                {
                    gamepadcontroller
                };
            }
            else
            {
                controllers = new List <IController>()
                {
                    keyboard
                };
            }


            IsMouseVisible = true;
            base.Initialize();
        }
示例#2
0
        public void DehydrateCharacter()
        {
            if (ClockFactory.IsTimerFinished(timer) && isDehydrationEnabled)
            {
                if (!StateManager.IsImmuneToDehydration)
                {
                    SoundFactory.PlayCharacterHurtSound();

                    HealthLevel -= dehydrationDamage;

                    if (HealthLevel <= 0)
                    {
                        StateManager.IsDead = true;
                        StateManager.HandleDeath();
                    }
                    else
                    {
                        characterDrawingManager.SetCharacterBlinking(true);
                    }
                }

                ClockFactory.ResetTimer(timer);
                ClockFactory.StartTimer(timer);
            }
        }
示例#3
0
 public virtual void SetMusic(SoundEffectInstance music)
 {
     this.music           = (SoundEffectInstance)music;
     this.invincibleMusic = SoundFactory.GetInvincibleSong();
     if (music != null)
     {
         music.Play();
     }
 }
示例#4
0
        public override void Jump()
        {
            float jumpMult = 1;

            if (CurrentItem != null)
            {
                jumpMult = Constants.ENCUMB_JMP_CONST;
            }
            SoundFactory.PlayCharacterJumpingSound();
            Velocity = new Vector2(Velocity.X, -Constants.CHAR_JMP_CONST * jumpMult);
        }
        private static void RespondToICollectableCollision(ICollectable powerUp, AbstractCharacter character)
        {
            if (!powerUp.HasBeenConsumed)
            {
                SoundFactory.PlayCollectibleCollectedSound();
                powerUp.SetCharacter(character);

                if (character.CurrentPowerup != null)
                {
                    ICollectable current = character.CurrentPowerup;
                    current.Destroy();
                }

                character.CurrentPowerup = powerUp;
                powerUp.Consume();
            }
        }
        public void Parse(IEnumerable <XElement> elements)
        {
            foreach (XElement element in elements)
            {
                String b, m;
                b = (string)element.Attribute(GenericParser.backgroundAttr);
                m = (string)element.Attribute(GenericParser.musicAttr);

                if (b.Equals(GenericParser.desert))
                {
                    Background = SpriteFactory.GetDesertBackgroundSprite();
                }

                else if (b.Equals(GenericParser.hospital))
                {
                    Background = SpriteFactory.GetHospitalBackgroundSprite();
                }

                else
                {
                    Background = SpriteFactory.GetDSBackgroundSprite();
                }

                if (m.Equals(GenericParser.desert))
                {
                    Music = SoundFactory.GetDesertSong();
                }

                else if (m.Equals(GenericParser.hospital))
                {
                    Music = SoundFactory.GetHospitalSong();
                }

                else
                {
                    Music = SoundFactory.GetInvincibleSong();
                }
            }
        }
        public static void ParseProperties(IEnumerable <XElement> elements)
        {
            foreach (XElement element in elements)
            {
                String b, m;
                b = (string)element.Attribute(backgroundAttr);
                m = (string)element.Attribute(musicAttr);

                if (b.Equals(desert))
                {
                    background = SpriteFactory.GetDesertBackgroundSprite();
                }

                else if (b.Equals(hospital))
                {
                    background = SpriteFactory.GetDesertBackgroundSprite();
                }

                else
                {
                    //background = SpriteFactory.GetDesertBackgroundSprite();
                }

                if (m.Equals(desert))
                {
                    music = SoundFactory.GetDesertSong();
                }

                else if (m.Equals(hospital))
                {
                    music = SoundFactory.GetHospitalSong();
                }

                else
                {
                    //music = SoundFactory.GetDesertSongSound();
                }
            }
        }