Exemplo n.º 1
0
 public void Update(Level level, GameTime gameTime)
 {
     if (IsAlive)
     {
         if ((float)CurrentHealth / (float)Health > 0.4f)
         {
             CurrentTexture = textures[0];
         }
         else if ((float)CurrentHealth / (float)Health > 0)
         {
             CurrentTexture = textures[1];
         }
         else
         {
             CurrentTexture = textures[2];
         }
         if (CurrentHealth <= 0)
         {
             IsAlive = false;
             level.SpawnDebris(Position);
         }
     }
     for (int i = DamagePopups.Count; i > 0; i--)
         {
             DamagePopups[i - 1].Update(gameTime);
             if (!DamagePopups[i - 1].isAlive)
                 DamagePopups.Remove(DamagePopups[i - 1]);
         }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            level1 = new Level();

            base.Initialize();
        }
Exemplo n.º 3
0
 public void LoadNewLevel(Level level)
 {
     Globals.audioManager.FadeToNewSong(0.0f, new TimeSpan(0, 0, 1), "Songs/Raptor Call of the Shadows - Bravo Sector");
     LoadedLevel = level;
     Globals.gameState = GameState.Gameplay;
 }
Exemplo n.º 4
0
 public void Update(Level level)
 {
     DrawableObjectCollection levelObjects = level.GetDrawableObjectList();
     UpdateObjectList();
     DragOutNewObject(level);
     for (int i = 0; i < drawableObjects.Count; i++)
         drawableObjects[i].Update();
     ModifySelectedWithInput(levelObjects);
     SwitchObjectList();
 }
Exemplo n.º 5
0
 private void DropNewObject(Level level)
 {
     level.AddDrawableObject(heldObject);
     LoadContent();
     heldObject = null;
 }
Exemplo n.º 6
0
        private void DragOutNewObject(Level level)
        {
            switch (objectList)
            {
                case ObjectList.Destructibles:
                    if (Globals.mouseState.LeftButton == ButtonState.Pressed)
                    {
                        PickupNewObject();
                        if (heldObject != null)
                        {
                            level.DeselectAll();
                            MoveHeldObject();
                        }
                    }
                    else if (heldObject != null && Globals.mouseState.LeftButton == ButtonState.Released)
                        DropNewObject(level);
                    break;

                case ObjectList.BackgroundTiles:
                    if (Globals.mouseState.LeftButton == ButtonState.Pressed && Globals.oldMouseState.LeftButton == ButtonState.Released)
                    {
                        for (int i = 0; i < backgroundTiles.Count; i++)
                            if (new Rectangle(5, 5 + i * backgroundTiles[i].Texture.Height, backgroundTiles[i].Texture.Width, backgroundTiles[i].Texture.Height).Contains(new Point(Globals.mouseState.X, Globals.mouseState.Y)))
                            {
                                level.ChangeBackgroundTile(backgroundTiles[i].Identifier);
                            }
                    }
                    break;
            }
        }
Exemplo n.º 7
0
 public override void Activate(MainMenu mainMenu)
 {
     Level level = new Level("Levels/" + name);
     Globals.game.LoadNewLevel(level);
 }
Exemplo n.º 8
0
        private void CheckKeyboardInput(Game1 game)
        {
            keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.W) && !oldKeyboardState.IsKeyDown(Keys.W))
            {
                Button selectedButton = getSelectedButton();
                if (levelButtons[0] == selectedButton)
                {
                    levelButtons[levelButtons.Count - 1].isSelected = true;
                }
                else
                {
                    for (int i = 0; i < levelButtons.Count; i++)
                    {
                        if (levelButtons[i].isSelected)
                            levelButtons[i - 1].isSelected = true;
                    }
                }
                selectedButton.isSelected = false;
            }
            else if (keyboardState.IsKeyDown(Keys.S) && !oldKeyboardState.IsKeyDown(Keys.S))
            {
                Button selectedButton = getSelectedButton();
                if (levelButtons[levelButtons.Count - 1] == selectedButton)
                {
                    levelButtons[0].isSelected = true;
                }
                else
                {
                    for (int i = levelButtons.Count - 1; i >= 0; i--)
                    {
                        if (levelButtons[i].isSelected)
                            levelButtons[i + 1].isSelected = true;
                    }
                }
                selectedButton.isSelected = false;
            }
            else if (keyboardState.IsKeyDown(Keys.Space) && !oldKeyboardState.IsKeyDown(Keys.Space))
            {
                foreach (LevelSelectorButton button in levelButtons)
                {
                    if (button.isSelected)
                    {
                        //var line = button.data.Split('%');
                        Level level = new Level("Levels/" + button.data);
                        game.LoadNewLevel(level);
                    }
                }
            }

            foreach (LevelSelectorButton b in levelButtons)
            {
                if( b.Clicked)
                {
                    Level level = new Level("Levels/" + b.data);
                    game.LoadNewLevel(level);
                }
            }

            oldKeyboardState = keyboardState;
        }