Ejemplo n.º 1
0
 ///<summary>To be used with Mouse and NOT with gamepad</summary>
 internal void UpdateMouse()
 {
     if (Currentstate != MenuButtonState.Disabled)
     {
         var M = Mouse.GetState();
         var i = Inside(M.Position);
         var m = M.LeftButton == ButtonState.Pressed;
         var b = Currentstate == MenuButtonState.ButtonPressed;
         if (i)
         {
             if (m)
             {
                 Currentstate = MenuButtonState.ButtonPressed;
             }
             else if (b)
             {
                 Currentstate = MenuButtonState.ButtonReleased;
             }
             else
             {
                 Currentstate = MenuButtonState.OnButton;
             }
         }
         else if (b && m)
         {
             Currentstate = MenuButtonState.ButtonPressed;
         }
         else
         {
             Currentstate = MenuButtonState.Idle;
         }
     }
     Update(Currentstate);
 }
Ejemplo n.º 2
0
        //Menu Button Switch
        //MenuUpdate*
        public void MenuButtonSwitch(KeyboardState key1)
        {
            previousKey = key;
            key         = Keyboard.GetState();
            switch (currentMenuButtonState)
            {
            case MenuButtonState.ActivePlayButton:
                if (key.IsKeyDown(Keys.Down))
                {
                    currentMenuButtonState = MenuButtonState.ActiveOptionButton;
                }
                else if (key.IsKeyDown(Keys.Enter) && previousKey.IsKeyUp(Keys.Enter) == true)
                {
                    Game1.currentGameState = GameState.PlayGame;
                }
                break;

            case MenuButtonState.ActiveOptionButton:

                if (key.IsKeyDown(Keys.Up))
                {
                    currentMenuButtonState = MenuButtonState.ActivePlayButton;
                }
                else if (key.IsKeyDown(Keys.Enter))
                {
                    Game1.currentGameState = GameState.Options;
                }
                break;
            }
        }
Ejemplo n.º 3
0
 //Constructors
 public Buttons()
 {
     currentMenuButtonState   = MenuButtonState.ActivePlayButton;
     currentOptionButtonState = OptionButtonState.ActiveEasy;
     currentPauseButtonState  = PauseButtonState.ActiveResume;
     currentGameOverState     = GameOverState.ActiveRestart;
 }
 public void Update()
 {
     // There are much better ways to impliment button interaction than this
     // but here is a simple example:
     // If the mouse cursor is on our MenuButton...
     if (InputManager.GetMouseBounds(true).Intersects(bounds))
     {
         // And if the Left mouse button is down...
         if (InputManager.GetIsMouseButtonDown(MouseButton.Left, true))
         {
             // Then our MenuButton is down!
             currentState = MenuButtonState.Pressed;
         }
         // Else if the Left mouse button WAS down but isn't any more...
         else if (InputManager.GetIsMouseButtonDown(MouseButton.Left, false))
         {
             // Then our MenuButton has been clicked!
             currentState = MenuButtonState.Clicked;
         }
         // Otherwise...
         else
         {
             // The mouse cursor is simply hovering above our MenuButton!
             currentState = MenuButtonState.Hovered;
         }
     }
     else
     {
         // If the cursor does not intersect with the MenuButton then just set the state to released.
         currentState = MenuButtonState.Released;
     }
 }
 public MenuButton(Texture2D texture, Vector2 position)
 {
     this.texture  = texture;
     this.position = position;
     // Cast position X and Y to ints for the rectangle's constructor.
     bounds = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
     // MenuButton starts off as Released.
     currentState = MenuButtonState.Released;
 }
Ejemplo n.º 6
0
    // *******************
    // * Unity Callbacks *
    // *******************

    private void Start()
    {
        animator = GetComponent <Animator>();

        if (SceneManager.Instance.currentState.Equals(MenuManager.MenuStates.Main))
        {
            menuButtonState = MenuButtonState.Open;
        }
        else
        {
            menuButtonState = MenuButtonState.Back;
        }

        ChangeState(menuButtonState);
        // Debug.Log("HH");
    }
Ejemplo n.º 7
0
        public bool ButtonUpdate()
        {
            mouseState = Mouse.GetState();
            prevMouseState = currMouseState;
            currMouseState = mouseState.LeftButton == ButtonState.Pressed;

            if (new Rectangle(mouseState.X, mouseState.Y, 1, 1).Intersects(rectangle))
            {
                if (!mouseIsIntersecting)
                {
                    Audio.SoundBank.PlayCue("tap");
                    mouseIsIntersecting = true;
                }

                if (currMouseState)
                {
                    state = MenuButtonState.MouseButtonDown;
                    color = Color.LimeGreen;
                    return false;
                }
                else if (!currMouseState && prevMouseState)
                {
                    if (state == MenuButtonState.MouseButtonDown)
                    {
                        Audio.SoundBank.PlayCue("clunch");
                        state = MenuButtonState.MouseButtonReleased;
                        return true;
                    }
                    return false;
                }
                else
                {
                    state = MenuButtonState.MouseHover;
                    color = Color.Green;
                    return false;
                }
            }
            else
            {
                state = MenuButtonState.MouseButtonUp;
                mouseIsIntersecting = false;
                color = Color.White;
            }

            return false;
        }
Ejemplo n.º 8
0
        public SimpleMenuButton(string t, int Width, int Height, int Posx, int Posy)
        {
            var h4 = 4 * Height;

            ButtonSprite = new Texture2D(G.Gdm.GraphicsDevice, 1, h4);
            Dest         = new Rectangle(Posx, Posy, Width, Height);
            Source       = new Rectangle(0, 0, 1, Height);
            Color[] xx = new Color[h4];
            for (int x = 0; x < h4; x++)
            {
                xx[x] = GPMenuFunctions.buttonColor[x / Height];
            }
            ButtonSprite.SetData <Color>(xx);
            Sf           = GPMenuFunctions.Sf;
            Text         = t;
            Currentstate = MenuButtonState.Idle;
            GPMenuFunctions.FitTextCentered(Text, Dest, Sf, out TextPosition, out Scale);
        }
Ejemplo n.º 9
0
    public void ManageState(bool reverse = false)
    {
        switch (menuButtonState)
        {
        case MenuButtonState.Open:     // Means ham burger sign
            if (reverse)
            {
                menuButtonState = MenuButtonState.Close;
                ManageState();
                return;
            }
            EnableHeader(false);
            break;

        case MenuButtonState.Close:     // Means cross sign
            if (reverse)
            {
                menuButtonState = MenuButtonState.Open;
                ManageState();
                return;
            }
            EnableHeader(true);
            break;

        case MenuButtonState.Back:
            if (reverse)
            {
                menuButtonState = MenuButtonState.Close;
                MenuManager.Instance.ChangeState(MenuManager.MenuStates.Main);
                ManageState();

                // SelectButton();
                return;
            }
            EnableHeader(true);
            break;
        }

        a_MenuButton.SetInteger("State", (int)menuButtonState);
    }
Ejemplo n.º 10
0
 private void setMenuButtonState(MenuButtonState state)
 {
     if (state.Equals(MenuButtonState.Default))
     {
         //default state
         Button_DownloadLiveData.IsEnabled = true;
     }
     else if (state.Equals(MenuButtonState.Operating))
     {
         //data loaded
         Button_DownloadLiveData.IsEnabled = false;
     }
     else if (state.Equals(MenuButtonState.DataLoaded))
     {
         //data loaded
         Button_DownloadLiveData.IsEnabled = true;
     }
     else if (state.Equals(MenuButtonState.DataProcessed))
     {
         //data loaded and processed
         Button_DownloadLiveData.IsEnabled = true;
     }
 }
Ejemplo n.º 11
0
 ///<summary>To be used with GamePad and NOT with mouse</summary>
 internal void Update(MenuButtonState s)
 {
     Source.Y = (int)s % 4 * Source.Height;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // getting gamePad, keyboard, and mouse info
            foreach(Player p in playerList) {
                p.Controls.Refresh();
            }
            // TODO: Add your update logic here
            switch(GlobalVariables.gameState) {
                case GlobalVariables.GameState.Menu:
                    menuPlayer.Controls.Refresh();
                    if(menuPlayer.Controls.CurrentGPS.IsConnected) {
                        //currentGPS = GamePad.GetState(0);

                        if(SingleKeyPress(Buttons.LeftThumbstickUp)) {
                            if(menuButtonState == MenuButtonState.None) {
                                menuButtonState = MenuButtonState.Quit;
                            } else if(menuButtonState == MenuButtonState.Single) {
                                menuButtonState = MenuButtonState.Quit;
                            } else if(menuButtonState == MenuButtonState.Multi) {
                                menuButtonState = MenuButtonState.Single;
                            } else if(menuButtonState == MenuButtonState.Quit) {
                                menuButtonState = MenuButtonState.Multi;
                            }
                        }
                        if(SingleKeyPress(Buttons.LeftThumbstickDown)) {
                            if(menuButtonState == MenuButtonState.None) {
                                menuButtonState = MenuButtonState.Single;
                            } else if(menuButtonState == MenuButtonState.Single) {
                                menuButtonState = MenuButtonState.Multi;
                            } else if(menuButtonState == MenuButtonState.Multi) {
                                menuButtonState = MenuButtonState.Quit;
                            } else if(menuButtonState == MenuButtonState.Quit) {
                                menuButtonState = MenuButtonState.Single;
                            }
                        }
                        if(menuPlayer.Controls.CurrentGPS.IsButtonDown(Buttons.A)) {
                            playerList.Clear(); // Empty the player list.
                            if(menuButtonState == MenuButtonState.Single) {
                                playerList.Add(new Player("Name", 1, new Rectangle(200, 345, humanoidWidth, humanoidHeight)));
                                GlobalVariables.gameState = GlobalVariables.GameState.InGame;
                                singleTinkerInstance = new Tinkering.SingleTinker(playerList[0]);
                            }
                            if(menuButtonState == MenuButtonState.Multi) {
                                if(GamePad.GetState(PlayerIndex.One).IsConnected) {
                                    playerList.Add(new Player("Name", PlayerIndex.One, new Rectangle(200, 345, humanoidWidth, humanoidHeight)));
                                }
                                if(GamePad.GetState(PlayerIndex.Two).IsConnected) {
                                    playerList.Add(new Player("Name", PlayerIndex.Two, new Rectangle(220, 345, humanoidWidth, humanoidHeight)));
                                }
                                if(GamePad.GetState(PlayerIndex.Three).IsConnected) {
                                    playerList.Add(new Player("Name", PlayerIndex.Three, new Rectangle(240, 345, humanoidWidth, humanoidHeight)));
                                }
                                if(GamePad.GetState(PlayerIndex.Four).IsConnected) {
                                    playerList.Add(new Player("Name", PlayerIndex.Four, new Rectangle(260, 345, humanoidWidth, humanoidHeight)));
                                }
                                GlobalVariables.gameState = GlobalVariables.GameState.InGame;
                            }
                            if(menuButtonState == MenuButtonState.Quit) {
                                this.Exit();
                            }
                        }
                    } else {
                        if(menuPlayer.Controls.CurrentMS.X > 280 && menuPlayer.Controls.CurrentMS.X < 500) {
                            if(menuPlayer.Controls.CurrentMS.Y > 165 && menuPlayer.Controls.CurrentMS.Y < 210) {
                                menuButtonState = MenuButtonState.Single;
                            } else if(menuPlayer.Controls.CurrentMS.Y > 265 && menuPlayer.Controls.CurrentMS.Y < 310) {
                                menuButtonState = MenuButtonState.Multi;
                            } else if(menuPlayer.Controls.CurrentMS.Y > 365 && menuPlayer.Controls.CurrentMS.Y < 410) {
                                menuButtonState = MenuButtonState.Quit;
                            } else {
                                menuButtonState = MenuButtonState.None;
                            }
                        } else {
                            menuButtonState = MenuButtonState.None;
                        }
                    }
                    if(menuPlayer.Controls.CurrentMS.LeftButton == ButtonState.Pressed) {
                        playerList.Clear(); // Empty the player list.
                        if(menuButtonState == MenuButtonState.Single) {
                            playerList.Add(new Player("Name", 1, new Rectangle(200, 345, humanoidWidth, humanoidHeight)));
                            GlobalVariables.gameState = GlobalVariables.GameState.InGame;
                            singleTinkerInstance = new Tinkering.SingleTinker(playerList[0]);
                        }
                        if(menuButtonState == MenuButtonState.Multi) {
                            if(GamePad.GetState(PlayerIndex.One).IsConnected) {
                                playerList.Add(new Player("Name", PlayerIndex.One, new Rectangle(200, 345, humanoidWidth, humanoidHeight)));
                            }
                            if(GamePad.GetState(PlayerIndex.Two).IsConnected) {
                                playerList.Add(new Player("Name", PlayerIndex.Two, new Rectangle(220, 345, humanoidWidth, humanoidHeight)));
                            }
                            if(GamePad.GetState(PlayerIndex.Three).IsConnected) {
                                playerList.Add(new Player("Name", PlayerIndex.Three, new Rectangle(240, 345, humanoidWidth, humanoidHeight)));
                            }
                            if(GamePad.GetState(PlayerIndex.Four).IsConnected) {
                                playerList.Add(new Player("Name", PlayerIndex.Four, new Rectangle(260, 345, humanoidWidth, humanoidHeight)));
                            }
                            GlobalVariables.gameState = GlobalVariables.GameState.InGame;
                        }
                        if(menuButtonState == MenuButtonState.Quit) {
                            this.Exit();
                        }
                    }
                    break;

                case GlobalVariables.GameState.InGame:
                    //Console.Clear();
                    foreach(Player p in playerList) {
                        if(p.Tinkering) {
                            if(playerList.Count == 1) {
                                singleTinkerInstance.Update();
                            } else {
                                ;
                            }
                        } else {
                            p.Update(gameTime, platformTilesList, bulletList);
                        }
                    }

                    bool go = true;
                    Portal use = null;
                    foreach(Player p in playerList) {
                        if(p.Vote != null) {
                            if(use == null || p.Vote == use) {
                                use = p.Vote;
                            } else {
                                go = false;
                            }
                        } else {
                            go = false;
                        }
                    }
                    if(go && use != null) {
                        GlobalVariables.map.SwitchArea(use.LinkTo);
                        if(use.LinkTo.Name.Equals("Safehouse", StringComparison.OrdinalIgnoreCase)) {
                            foreach(Player p in playerList) {
                                p.X = use.LinkX;
                                p.Y = use.LinkY;
                                p.Vote = null;
                                p.RefillClips();
                            }
                        } else {
                            foreach(Player p in playerList) {
                                p.X = use.LinkX;
                                p.Y = use.LinkY;
                                p.Vote = null;
                            }
                        }
                        zombieList.Clear();
                        activeItems.Clear();
                    }

                    if(!(GlobalVariables.map.AtSafehouse)) {
                        //chance of spawning a zombie
                        if(rgen.Next(100) == 0 && zombieList.Count < (playerList.Count * 5))
                            zombieList.Add(new Zombie(new Rectangle(rgen.Next() * viewportWidth, viewportHeight / 2, humanoidWidth, humanoidHeight)));

                        for(int i = 0; i < zombieList.Count; i++) {
                            //run zombie actions
                            Zombie zombie = zombieList[i];

                            if(zombie.ZombieAction == ZombieActions.Chase) {
                                //get closest player
                                int distanceClosestPlayer = int.MaxValue;
                                Player closestPlayer = null;
                                foreach(Player player in playerList) {
                                    int dist = (int)Math.Sqrt(Math.Pow((player.X - zombie.X), 2) + Math.Pow((player.Y - zombie.Y), 2));
                                    if(dist < distanceClosestPlayer) {
                                        distanceClosestPlayer = dist;
                                        closestPlayer = player;
                                    }
                                }

                                //chase after closest player
                                if(zombie.X > closestPlayer.X) {
                                    zombie.WalkLeft();
                                    zombie.FacingRight = false;
                                } else if(zombie.X < closestPlayer.X) {
                                    zombie.WalkRight();
                                    zombie.FacingRight = true;
                                }

                                if(closestPlayer.Y < zombie.Y) {
                                    int side = 1;
                                    if(zombie.FacingRight) { side *= -1; }
                                    Rectangle inFront = new Rectangle(zombie.X + (side * (tileSize - 23)), zombie.Y - 10, zombie.Location.Width, zombie.Location.Height);
                                    //check for lack of platform in front of them to jump
                                    foreach(Platform tile in GlobalVariables.map.GetTiles()) {

                                        if(tile.Location.Intersects(inFront)) {
                                            zombie.Jump();
                                        }
                                    }
                                }

                                if(zombie.Jumping == true) {
                                    zombie.MoveSpeed = 2;
                                } else {
                                    zombie.MoveSpeed = 1;
                                }
                            } else if(zombie.ZombieAction == ZombieActions.Patrol) {
                                //move back and forth until player is detected
                                foreach(Player player in playerList) {
                                    if(zombie.DetectPlayers(player))
                                        zombie.ZombieAction = ZombieActions.Chase;
                                }
                                if(zombie.FacingRight) zombie.WalkRight();
                                else zombie.WalkLeft();

                                zombie.changeDirection();
                            } else zombie.ZombieAction = ZombieActions.Patrol;

                            zombie.PosUpdate();
                            zombie.Gravity();

                            foreach(Player player in playerList) {
                                player.CheckCollisions(zombie, player);
                            }
                            for(int j = 50; j < 75; j++) {
                                zombie.CheckCollisions(platformTilesList[j], zombie);
                            }
                            foreach(Platform pl in GlobalVariables.map.GetTiles()) {
                                zombie.CheckCollisions(pl, zombie);
                            }

                            if (zombie.HP <= 0)
                            {
                                int itemDrop = rgen.Next(100);
                                /* ============ Zombie Item Drops ============= */
                                //25%
                                if (itemDrop > 85) //15%
                                    activeItems.Add(new AmmoItem(rgen.Next(50, 100), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - ammoImage.Height, ammoImage.Width, ammoImage.Height)));
                                else if (itemDrop > 75) //10%
                                    activeItems.Add(new HealingItem(new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - medkitImage.Height, medkitImage.Width, medkitImage.Height)));

                                /* ============ Zombie GunBit Drops ============= */ //35%
                                else if (itemDrop > 69) //6%
                                    activeItems.Add(new GunBarrel(rgen.Next(25, 75), rgen.Next(5, 20), rgen.Next(1, 8),  new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["GunBarrel"].Height, gunImagesList["GunBarrel"].Width, gunImagesList["GunBarrel"].Height)));
                                else if (itemDrop > 63) //6%
                                    activeItems.Add(new GunStock(rgen.Next(25, 75), rgen.Next(1, 8), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["GunStock"].Height, gunImagesList["GunStock"].Width, gunImagesList["GunStock"].Height)));
                                else if (itemDrop > 54) //9%
                                    activeItems.Add(new GunClip(rgen.Next(1, 10), rgen.Next(5, 50), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["GunClip"].Height, gunImagesList["GunClip"].Width, gunImagesList["GunClip"].Height)));
                                else if (itemDrop > 45) //9%
                                    activeItems.Add(new GunBody(rgen.Next(25, 75), rgen.Next(1, 8), rgen.Next(10, 50), rgen.Next(5, 20), rgen.Next(1, 10), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["GunBody"].Height, gunImagesList["GunBody"].Width, gunImagesList["GunBody"].Height)));
                                else if (itemDrop > 40) //5%
                                    activeItems.Add(new GunScope(rgen.Next(25, 75), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["GunScope"].Height, gunImagesList["GunScope"].Width, gunImagesList["GunScope"].Height)));
                                /* ============ Zombie Weapon Drops ============= */ //12%
                                else if (itemDrop > 35) //5%
                                    activeItems.Add(new WeaponStock("Pistol", rgen.Next(60, 100), rgen.Next(1, 5), rgen.Next(10, 25), rgen.Next(1, 3), rgen.Next(6, 12), "Pistol", rgen.Next(5, 10), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["Pistol"].Height * 3, gunImagesList["Pistol"].Width * 3, gunImagesList["Pistol"].Height * 3)));
                                else if (itemDrop > 30) //5%
                                    activeItems.Add(new WeaponStock("SMG", rgen.Next(50, 100), rgen.Next(6, 10), rgen.Next(10, 25), rgen.Next(2, 5), rgen.Next(20, 40), "SMG", rgen.Next(10, 20), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["SMG"].Height * 2, gunImagesList["SMG"].Width * 2, gunImagesList["SMG"].Height * 2)));
                                else if (itemDrop > 28) //2%
                                    activeItems.Add(new WeaponStock("AR", rgen.Next(75, 100), rgen.Next(11, 20), rgen.Next(20, 50), rgen.Next(4, 10), rgen.Next(30, 50), "AR", rgen.Next(5, 15), new Rectangle(zombieList[i].X, zombieList[i].Y + zombieList[i].Location.Height - gunImagesList["AR"].Height, gunImagesList["AR"].Width, gunImagesList["AR"].Height)));

                                zombieList.Remove(zombieList[i]);
                            }
                        }
                    } //end loop through zombies' actions

                    //check if player can pickup item
                    foreach(Item item in activeItems) {
                        foreach(Player p in playerList) {
                            p.PickUpItemCheck(item);
                        }
                    }
                    //move bullets
                    //counts backwards so deleting bullets won't mess with the loop
                    for(int i = bulletList.Count - 1; i >= 0; i--) {
                        Bullet bullet = bulletList[i];
                        if(bullet.Active == true) {
                            bullet.Move();
                            foreach(Zombie z in zombieList)
                                z.CheckCollisions(bullet, z);

                            if(bullet.X < 0 || bullet.X > viewportWidth || bullet.Y < 0 || bullet.Y > viewportHeight)
                                bulletList.RemoveAt(i);
                        } else bulletList.RemoveAt(i);
                    }

                    //move bullets
                    //counts backwards so deleting bullets won't mess with the loop
                    for(int i = bulletList.Count - 1; i >= 0; i--) {
                        Bullet bullet = bulletList[i];
                        if(bullet.Active == true) {
                            bullet.Move();
                            if(bullet.X < 0 || bullet.X > viewportWidth || bullet.Y < 0 || bullet.Y > viewportHeight)
                                bulletList.RemoveAt(i);
                        } else bulletList.RemoveAt(i);
                    }

                    // Check Player Liveliness
                    List<Player> temp = new List<Player>(playerList); // Create a temporary list to be looping through
                    foreach(Player p in temp) {
                        if(p.HP <= 0) { // If they're dead
                            playerList.Remove(p); // Remove from player list
                        }
                    }
                    if(playerList.Count == 0) { // If everyone's dead
                        GlobalVariables.gameState = GlobalVariables.GameState.GameOver; // Game Over.
                    }

                    break; //end case inGame

                case GlobalVariables.GameState.Pause:
                    foreach(Player p in playerList) {
                        if(SingleKeyPress(p, Buttons.A) || SingleKeyPress(p, Keys.Enter)) {
                            GlobalVariables.gameState = GlobalVariables.GameState.InGame;
                            break;
                        }
                    }
                    break;

                case GlobalVariables.GameState.GameOver:
                    menuPlayer.Controls.Refresh();
                    if(SingleKeyPress(Buttons.A) || SingleKeyPress(Keys.Enter)) {
                        GlobalVariables.gameState = GlobalVariables.GameState.Menu;
                        menuButtonState = MenuButtonState.None;
                        break;
                    }
                    break;
            }
            base.Update(gameTime);
        }
Ejemplo n.º 13
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
            menuButtonState = MenuButtonState.None;
            GlobalVariables.gameState = GlobalVariables.GameState.Menu;
            hpBarWidth = 130;
            tileSize = 32;
            viewportHeight = GraphicsDevice.Viewport.Height;
            viewportWidth = GraphicsDevice.Viewport.Width;
            humanoidHeight = 75;
            humanoidWidth = 23;

            platformTilesList = new List<Platform>();
            zombieList = new List<Zombie>();
            activeItems = new List<Item>();
            bulletList = new List<Bullet>();
            playerList = new List<Player>();

            gunImagesList = new Dictionary<string, Rectangle>();
            gunImagesList.Add("Pistol", new Rectangle(0, 0, 11, 8));
            gunImagesList.Add("SMG", new Rectangle(13, 0, 23, 13));
            gunImagesList.Add("AR", new Rectangle(36, 0, 40, 12));
            gunImagesList.Add("GunBarrel", new Rectangle(0, 13, 29, 10));
            gunImagesList.Add("GunScope", new Rectangle(0, 23, 26, 10));
            gunImagesList.Add("GunStock", new Rectangle(29, 13, 20, 12));
            gunImagesList.Add("GunBody", new Rectangle(26, 25, 28, 16));
            gunImagesList.Add("GunClip", new Rectangle(54, 12, 18, 24));

            initializeGround();
            rgen = new Random();

            IsMouseVisible = true;

            base.Initialize();
        }
Ejemplo n.º 14
0
 public override void onUpdate()
 {
     MouseState mouse = sourceMenu.viewport.getMouse();
     if(enabled) {
         if(mouse.X > dimensions.X && mouse.X < dimensions.X + dimensions.Width && mouse.Y > dimensions.Y && mouse.Y < dimensions.Y + dimensions.Height) {
             if(mouse.LeftButton == ButtonState.Pressed)
                 state = MenuButtonState.down;
             else {
                 if(sourceMenu.viewport.getLastMouse() != null && sourceMenu.viewport.getLastMouse().LeftButton == ButtonState.Pressed)
                     sourceMenu.performEvent(id);
                 state = MenuButtonState.over;
             }
         }
         else
             state = MenuButtonState.up;
     }
 }
Ejemplo n.º 15
0
 public void ChangeState(MenuButtonState newState)
 {
     menuButtonState = newState;
     ManageState();
 }
Ejemplo n.º 16
0
        // Returns if clicked
        public Boolean Update()
        {
            MouseState mouseState = Mouse.GetState();
            if (Active)
                if (Bounds.Contains(ScaledMouse.ScaledMousePosition()))
                {
                    if (mouseState.LeftButton == ButtonState.Pressed) // MouseDown
                    {
                        CurrentMenuButtonState = MenuButtonState.MouseDown;
                    }
                    else if (mouseState.LeftButton == ButtonState.Released && oldState == ButtonState.Pressed) //Mouse Up
                    {
                        CurrentMenuButtonState = MenuButtonState.Default;
                        oldState = mouseState.LeftButton;
                        onClicked(EventArgs.Empty);
                        return true;
                    }
                    else // Mouse Over
                    {
                        CurrentMenuButtonState = MenuButtonState.MouseOver;

                    }

                }
                else
                {
                    CurrentMenuButtonState = MenuButtonState.Default;

                }
            else
                CurrentMenuButtonState = MenuButtonState.Disabled;
            oldState = mouseState.LeftButton;
            return false;
        }