Exemplo n.º 1
0
        public HUD(AbstractCharacter character)
        {
            this.character       = character;
            this.maxHealth       = character.HealthLevel;
            this.vertOffset      = 2;
            this.vertOffsetScore = 8;
            this.horizOffset     = new int[maxHealth + 3];
            this.heartEmpty      = new AbstractAnimatedSprite[maxHealth];
            this.heartFull       = new AbstractAnimatedSprite[maxHealth];

            for (int i = 0; i < maxHealth; i++)
            {
                this.horizOffset[i] = 2 + 18 * i;
                this.heartEmpty[i]  = SpriteFactory.GetHeartEmptySprite();
                this.heartFull[i]   = SpriteFactory.GetHeartFullSprite();
            }

            this.horizOffset[maxHealth]     = this.horizOffset[maxHealth - 1] + 34;
            this.horizOffset[maxHealth + 1] = this.horizOffset[maxHealth] + 34;
            this.horizOffset[maxHealth + 2] = this.horizOffset[maxHealth + 1] + 200;

            this.powerUpViewer = SpriteFactory.GetPowerUpViewerSprite();

            this.waterMeter0p   = SpriteFactory.GetWaterMeter0pSprite();
            this.waterMeter25p  = SpriteFactory.GetWaterMeter25pSprite();
            this.waterMeter50p  = SpriteFactory.GetWaterMeter50pSprite();
            this.waterMeter75p  = SpriteFactory.GetWaterMeter75pSprite();
            this.waterMeter100p = SpriteFactory.GetWaterMeter100pSprite();

            this.sunscreen         = SpriteFactory.GetSunscreenSprite();
            this.invincibilityStar = SpriteFactory.GetInvincibilityStarSprite();
            this.bubbleShield      = SpriteFactory.GetBubbleShieldSprite();
        }
Exemplo n.º 2
0
 public UIButton(Rectangle position, AbstractAnimatedSprite sprite)
 {
     this.position = position;
     this.sprite   = sprite;
     this.oldMouse = Mouse.GetState();
     this.newMouse = Mouse.GetState();
     this.ShouldNotifyReceivers = false;
 }
Exemplo n.º 3
0
 protected AbstractTerrain(Rectangle position, AbstractAnimatedSprite sprite, CollisionType collisionType, string message)
 {
     this.Position = new Vector2(position.X, position.Y);
     this.Size     = new Vector2(position.Width, position.Height);
     this.sprite   = sprite;
     this.ShouldNotifyReceivers = false;
     this.CollisionType         = collisionType;
     this.MessageToReceivers    = message;
 }
Exemplo n.º 4
0
 public ButtonItem(Rectangle position, AbstractAnimatedSprite sprite, CollisionType collisionType, string message)
 {
     this.Position = new Vector2(position.X, position.Y);
     this.Size     = new Vector2(position.Width, position.Height);
     this.sprite   = sprite;
     this.ShouldNotifyReceivers = false;
     this.CollisionType         = collisionType;
     this.pressHitbox           = new Hitbox(Position, Size, new Vector2(0, 0), CollisionType.Solid);
     this.MessageToReceivers    = message;
 }
Exemplo n.º 5
0
 public Sandstone(Rectangle position, AbstractAnimatedSprite sprite, CollisionType collisionType, string message)
     : base(position, sprite, collisionType, message)
 {
     this.Position = new Vector2(position.X, position.Y);
     this.Size     = new Vector2(position.Width, position.Height);
     this.sprite   = sprite;
     this.ShouldNotifyReceivers = false;
     this.CollisionType         = collisionType;
     this.MessageToReceivers    = message;
 }
Exemplo n.º 6
0
 public WaterBottle(AbstractAnimatedSprite sprite, int amountOfWaterToRestore, Rectangle position, CollisionType collisionType, string message)
 {
     this.EffectHasFinished      = false;
     this.ShouldNotifyReceivers  = false;
     this.amountOfWaterToRestore = amountOfWaterToRestore;
     this.sprite             = sprite;
     this.CollisionType      = collisionType;
     this.Position           = new Vector2(position.X, position.Y);
     this.Size               = new Vector2(position.Width, position.Height);
     this.MessageToReceivers = message;
 }
Exemplo n.º 7
0
 public GolemEnemy(Rectangle position, Vector2 velocity, AbstractAnimatedSprite sprite, int power, CollisionType collisionType, string message)
 {
     this.Position           = new Vector2(position.X, position.Y);
     this.Size               = new Vector2(position.Width, position.Height);
     this.Velocity           = velocity;
     this.Power              = power;
     this.CollisionType      = collisionType;
     this.IsAlive            = true;
     this.sprite             = sprite;
     this.MessageToReceivers = message;
 }
Exemplo n.º 8
0
 public UIStartMenu()
 {
     this.startGameButton    = new UIButton(new Rectangle(61, 105, 362, 32), null);
     this.levelSelectButton  = new UIButton(new Rectangle(151, 203, 184, 32), null);
     this.selectLevel0Button = new UIButton(new Rectangle(138, 114, 212, 40), null);
     this.selectLevel1Button = new UIButton(new Rectangle(138, 183, 212, 40), null);
     this.startMenuSprite    = SpriteFactory.GetStartMenuSprite();
     this.levelMenuSprite    = SpriteFactory.GetLevelMenuSprite();
     this.isInLevelsMenu     = false;
     this.isFinished         = false;
 }
Exemplo n.º 9
0
 public Door(int nextLevel, bool isWaitingForActivation, AbstractAnimatedSprite sprite, Rectangle position, CollisionType collisionType, string message)
 {
     this.ShouldSwitchToNextLevel = false;
     this.ShouldNotifyReceivers   = false;
     this.sprite                 = sprite;
     this.Position               = new Vector2(position.X, position.Y);
     this.Size                   = new Vector2(position.Width, position.Height);
     this.CollisionType          = collisionType;
     this.NextLevel              = nextLevel;
     this.isWaitingForActivation = isWaitingForActivation;
     this.MessageToReceivers     = message;
 }
Exemplo n.º 10
0
 public Teleporter(AbstractAnimatedSprite sprite, Rectangle position, CollisionType collisionType, Vector2 destination, bool isWaitingForActivation, string message)
 {
     this.sprite                 = sprite;
     this.Position               = new Vector2(position.X, position.Y);
     this.Size                   = new Vector2(position.Width, position.Height);
     this.Velocity               = new Vector2(0, 0);
     this.CollisionType          = collisionType;
     this.destination            = destination;
     this.hitbox                 = new Hitbox(new Vector2(Position.X + 7, Position.Y + 7), new Vector2(35, 51), new Vector2(0, 0), CollisionType);
     this.MessageToReceivers     = message;
     this.isWaitingForActivation = isWaitingForActivation;
 }
Exemplo n.º 11
0
 public Coin(Rectangle position, AbstractAnimatedSprite sprite, CollisionType collisionType, int scoreToIncrease, string message)
 {
     this.HasBeenConsumed       = false;
     this.EffectHasFinished     = false;
     this.ShouldNotifyReceivers = false;
     this.MessageToReceivers    = message;
     this.Position        = new Vector2(position.X, position.Y);
     this.Size            = new Vector2(position.Width, position.Height);
     this.Velocity        = new Vector2(0, 0);
     this.CollisionType   = collisionType;
     this.sprite          = sprite;
     this.scoreToIncrease = scoreToIncrease;
 }
Exemplo n.º 12
0
 //Response Methods
 public void ChangeDirection()
 {
     if (spriteOrientation == SpriteOrientation.Right)
     {
         spriteOrientation = SpriteOrientation.Left;
     }
     else if (spriteOrientation == SpriteOrientation.Left)
     {
         spriteOrientation = SpriteOrientation.Right;
     }
     sprite   = SpriteFactory.GetHortoiseSprite(this.spriteOrientation);
     Velocity = new Vector2(-Velocity.X, Velocity.Y);
 }
Exemplo n.º 13
0
 public InvincibilityStar(AbstractAnimatedSprite sprite, int duration, Rectangle position, CollisionType collisionType, string message)
 {
     this.timer                 = ClockFactory.RegisterTimer(new TimeSpan(0, 0, duration));
     this.EffectHasFinished     = false;
     this.HasBeenConsumed       = false;
     this.ShouldNotifyReceivers = false;
     this.CollisionType         = collisionType;
     this.sprite                = sprite;
     this.duration              = duration;
     this.Position              = new Vector2(position.X, position.Y);
     this.Size = new Vector2(position.Width, position.Height);
     this.MessageToReceivers = message;
 }
Exemplo n.º 14
0
 public HortoiseEnemy(Rectangle position, int power, int velocity, SpriteOrientation spriteOrientation, CollisionType collisionType, string message)
 {
     this.Position              = new Vector2(position.X, position.Y);
     this.Size                  = new Vector2(position.Width, position.Height);
     this.Power                 = power;
     this.Velocity              = new Vector2(velocity, 0);
     this.CollisionType         = CollisionType.Liquid;
     this.IsAlive               = true;
     this.spriteOrientation     = spriteOrientation;
     this.sprite                = SpriteFactory.GetHortoiseSprite(this.spriteOrientation);
     this.ShouldNotifyReceivers = false;
     this.CollisionType         = collisionType;
     this.MessageToReceivers    = message;
 }
Exemplo n.º 15
0
        //Response Methods
        public void ChangeDirection()
        {
            if (spriteOrientation == SpriteOrientation.Up)
            {
                spriteOrientation = SpriteOrientation.Down;
            }
            else if (spriteOrientation == SpriteOrientation.Down)
            {
                spriteOrientation = SpriteOrientation.Up;
            }
            Velocity = new Vector2(0, -Velocity.Y);

            isJumping = false;
            sprite    = SpriteFactory.GetSpiderSprite(this.spriteOrientation);
        }
Exemplo n.º 16
0
 public SpiderEnemy(Rectangle position, int power, int speed, int jumpFrequency, SpriteOrientation spriteOrientation, CollisionType collisionType, string message)
 {
     this.Position              = new Vector2(position.X, position.Y);
     this.Size                  = new Vector2(position.Width, position.Height);
     this.Power                 = power;
     this.Velocity              = new Vector2(0, (spriteOrientation == SpriteOrientation.Up ? -1 : 1) * speed);
     this.isJumping             = false;
     this.jumpFrequency         = jumpFrequency;
     this.jumpCurrent           = 0;
     this.IsAlive               = true;
     this.ShouldNotifyReceivers = false;
     this.spriteOrientation     = spriteOrientation;
     this.sprite                = SpriteFactory.GetSpiderSprite(this.spriteOrientation);
     this.CollisionType         = collisionType;
     this.MessageToReceivers    = message;
 }
Exemplo n.º 17
0
 public void SetOrientation(SpriteOrientation spriteOrientation)
 {
     this.spriteOrientation = spriteOrientation;
     if (this.spriteOrientation == SpriteOrientation.Left)
     {
         this.Velocity = new Vector2(-speed, 0);
     }
     else if (this.spriteOrientation == SpriteOrientation.Right)
     {
         this.Velocity = new Vector2(speed, 0);
     }
     else if (this.spriteOrientation == SpriteOrientation.Up)
     {
         this.Velocity = new Vector2(0, -speed);
     }
     this.sprite = SpriteFactory.GetNeedleSprite(this.spriteOrientation);
 }
Exemplo n.º 18
0
        public virtual void SetEventLists(Level level, List <ICollidable> characterList, List <ICollidable> enemyList, List <ICollidable> collectableList,
                                          List <ICollidable> itemList, List <ICollidable> terrainList, List <IController> controllerList, List <ItemSet> itemSetList,
                                          Camera camera, AbstractAnimatedSprite background, HUD hud, SoundEffectInstance music, SoundEffectInstance invincibleMusic)
        {
            this.level         = level;
            this.characterList = characterList;

            this.enemyList       = enemyList;
            this.collectableList = collectableList;
            this.itemList        = itemList;
            this.terrainList     = terrainList;
            this.controllerList  = controllerList;
            this.itemSetList     = itemSetList;
            this.camera          = camera;
            this.background      = background;
            this.music           = music;
            this.invincibleMusic = invincibleMusic;
        }
Exemplo n.º 19
0
        public CactusEnemy(Rectangle position, int power, int velocity, int frequency, CollisionType collisionType, string message)
        {
            this.Position = new Vector2(position.X, position.Y);
            this.Size     = new Vector2(position.Width, position.Height);
            this.Power    = power;
            this.IsAlive  = true;
            this.sprite   = SpriteFactory.GetCactusSprite();
            this.ShouldNotifyReceivers = false;
            this.CollisionType         = collisionType;
            this.Velocity           = new Vector2(0, 0);
            this.needleSpeed        = velocity;
            this.needleFrequency    = frequency;
            this.timer              = frequency - 15;
            this.MessageToReceivers = message;

            needleRect = new Rectangle(
                position.X + position.Width / 2 - needleWidth / 2,
                position.Y + position.Height / 2 - needleHeight / 2,
                needleWidth,
                needleHeight);
            needles = new List <NeedleEnemy>(6);
        }
Exemplo n.º 20
0
        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();
                }
            }
        }
Exemplo n.º 21
0
        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();
                }
            }
        }
Exemplo n.º 22
0
 public override void SetSprite(AbstractAnimatedSprite newSprite)
 {
     this.sprite = newSprite;
 }
Exemplo n.º 23
0
 public PropertiesParser()
 {
     Music      = null;
     Background = null;
 }
Exemplo n.º 24
0
 public virtual void SetBackground(AbstractAnimatedSprite background)
 {
     this.background = (AbstractAnimatedSprite)background;
 }
Exemplo n.º 25
0
 public virtual void SetSprite(AbstractAnimatedSprite sprite)
 {
     this.sprite = sprite;
 }
Exemplo n.º 26
0
        public void Parse()
        {
            XElement root = XElement.Load(fileName);

            IEnumerable <XElement> terrain     = from el in root.Elements(GenericParser.terrainString) select el;
            IEnumerable <XElement> collectable = from el in root.Elements(GenericParser.collectableString) select el;
            IEnumerable <XElement> item        = from el in root.Elements(GenericParser.itemString) select el;
            IEnumerable <XElement> enemy       = from el in root.Elements(GenericParser.enemyString) select el;
            IEnumerable <XElement> character   = from el in root.Elements(GenericParser.characterString) select el;
            IEnumerable <XElement> camera      = from el in root.Elements(GenericParser.cameraString) select el;
            IEnumerable <XElement> properties  = from el in root.Elements(GenericParser.propertiesString) select el;
            IEnumerable <XElement> itemSets    = from el in root.Elements(GenericParser.itemSetString) select el;

            IEnumerable <XElement> terrains         = terrain.Elements <XElement>();
            IEnumerable <XElement> collectables     = collectable.Elements <XElement>();
            IEnumerable <XElement> items            = item.Elements <XElement>();
            IEnumerable <XElement> enemies          = enemy.Elements <XElement>();
            IEnumerable <XElement> characters       = character.Elements <XElement>();
            IEnumerable <XElement> cameras          = camera.Elements <XElement>();
            IEnumerable <XElement> propertyElements = properties.Elements <XElement>();
            IEnumerable <XElement> itemSetsElements = itemSets.Elements <XElement>();

            ICollectableParser collectableParser = new ICollectableParser();

            collectableParser.Parse(collectables);
            CollectablesList = collectableParser.CollectablesList;

            IItemParser itemParser = new IItemParser();

            itemParser.Parse(items);
            ItemsList = itemParser.ItemList;

            IEnemyParser enemyParser = new IEnemyParser();

            enemyParser.Parse(enemies);
            EnemiesList = enemyParser.EnemiesList;

            CharacterParser characterParser = new CharacterParser();

            characterParser.Parse(characters, controllers);
            CharactersList = characterParser.CharacterList;

            CameraParser cameraParser = new CameraParser();

            cameraParser.Parse(cameras, CharactersList);
            CamerasList = cameraParser.CameraList;

            ItemSetParser itemSetParser = new ItemSetParser();

            itemSetParser.Parse(itemSetsElements, controllers);
            ItemSetList = itemSetParser.ItemSetList;

            TerrainParser terrainParser = new TerrainParser();

            terrainParser.Parse(terrains);
            TerrainList = terrainParser.TerrainList;

            PropertiesParser propertiesParser = new PropertiesParser();

            propertiesParser.Parse(propertyElements);
            Music      = propertiesParser.Music;
            Background = propertiesParser.Background;
        }
Exemplo n.º 27
0
 public BoulderItem(Rectangle position, AbstractAnimatedSprite sprite, CollisionType collisionType, string message)
     : base(position, sprite, collisionType, message)
 {
 }