Ejemplo n.º 1
0
        public Player(Sprite_Player player, int itemsServed, int customersSaved, int ordersFinished, int bonusPoints, int charScore)
        {
            this.player = player;
            this.items = itemsServed;
            this.orders = ordersFinished;
            this.saves = customersSaved;
            this.bonus = bonusPoints;
            this.score = charScore;

            speed = defaultspeed;
            isPowerUpActive = false;

            this.carrying = new List<Sprite_Item>();
            //this.position = charPosition;
        }
Ejemplo n.º 2
0
        public bool IsButtonPressed(Sprite_Player player, string button)
        {
            //switches are kinda weird in c#....can't short circuit return?
            bool value = false;
            switch (button)
            {
                case "X":
                    if (player.GetcurrentGPState.Buttons.X == ButtonState.Released &&
                        player.GetpreviousGPState.Buttons.X == ButtonState.Pressed)
                        value = true;
                    break;

                case "Y":
                    if (player.GetcurrentGPState.Buttons.Y == ButtonState.Released &&
                        player.GetpreviousGPState.Buttons.Y == ButtonState.Pressed)
                        value = true;
                    break;

                case "A":
                    if (player.GetcurrentGPState.Buttons.A == ButtonState.Released &&
                        player.GetpreviousGPState.Buttons.A == ButtonState.Pressed)
                        value = true;
                    break;

                case "B":
                    if (player.GetcurrentGPState.Buttons.B == ButtonState.Released &&
                        player.GetpreviousGPState.Buttons.B == ButtonState.Pressed)
                        value = true;
                    break;

                case "LS":
                    if (player.GetcurrentGPState.Buttons.LeftShoulder == ButtonState.Released &&
                        player.GetpreviousGPState.Buttons.LeftShoulder == ButtonState.Pressed)
                        value = true;
                    break;

                default:
                    value = false;
                    break;

            }
            //sound here..cuts down on repeat code puttig here
            PlaySound(value);

            return value;
        }
Ejemplo n.º 3
0
        public void Bounds(Sprite_Player player, Vector2 old_position)
        {
            //we want it to glow (indicatioin to player) but still be able to move
            //problem occurs if we set bounds equal; then we never toggle an intersection as we always
            //move to the old position.  So this is a fudge for visualization.

            if (player.collisionRect.Intersects(
                new Rectangle(this.collisionRectY.X + OFFSET, this.collisionRectY.Y + OFFSET,
                    this.collisionRectY.Width - 2 * OFFSET, this.collisionRectY.Height - 2 * OFFSET)))
            {
                if (player.collisionRect.Right < (this.collisionRectY.Left + OFFSET + player.direction.X + 1))
                    player.PositionX = old_position.X;
                else if (player.collisionRect.Left > (this.collisionRectY.Right - OFFSET + player.direction.X - 1))
                    player.PositionX = old_position.X;
                else if (player.collisionRect.Top < (this.collisionRectY.Y + OFFSET - player.direction.Y + 1))
                    player.PositionY = old_position.Y;
                //player.Position = old_position;
            }
        }
Ejemplo n.º 4
0
        /* WHY HARDCORD IMAGES TO TABLES?
         * we can generate them dynamically
         * and overlay the items on each table....oh well
         */
        public void ItemManager(Sprite_Player player)
        {
            //hmm can't figure out why texture2d.name isn't working....that would be nice
            //instead of hardcoding...bleh

            //addItem checks for valid # of items so we don't bother checking here
            if (player.collisionRect.Intersects(this.collisionRectY))
            {

                //name is "table name" passed on instantiation..argh static it be i guess..
                switch (name)
                {

                    case "candy":
                        //string itemName, Texture2D itemPic, SoundEffect itemSound
                        if (IsButtonPressed(player, "X"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("chocolate", player.Position, assetManager));
                        }
                        else if (IsButtonPressed(player, "A"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("gummyBears", player.Position, assetManager));
                        }
                        break;

                    case "nachos":
                        if (IsButtonPressed(player, "X"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("nachosLarge", player.Position, assetManager));
                        }
                        else if (IsButtonPressed(player, "A"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("nachosSmall", player.Position, assetManager));
                        }
                        break;

                    case "popcorn":
                        if (IsButtonPressed(player, "X"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("popcornLarge", player.Position, assetManager));
                        }
                        else if (IsButtonPressed(player, "A"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("popcornMedium", player.Position, assetManager));
                        }
                        else if (IsButtonPressed(player, "B"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("popcornSmall", player.Position, assetManager));
                        }
                        break;

                    case "soda":
                        if (IsButtonPressed(player, "X"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("sodaLarge", player.Position, assetManager));
                        }
                        else if (IsButtonPressed(player, "A"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("sodaMedium", player.Position, assetManager));
                        }
                        else if (IsButtonPressed(player, "B"))
                        {
                            player.getPlayer.AddItem(new Sprite_Item("sodaSmall", player.Position, assetManager));
                        }
                        break;

                    case "garbage":
                        if (player.getPlayer.Carrying.Count() > 0)
                        {
                            if (player.getPlayer.Carrying.Count() == 1 &&
                                (IsButtonPressed(player, "LS") ||
                                player.GetcurrentGPState.Triggers.Left < .5 && player.GetpreviousGPState.Triggers.Left > .5))
                            {
                                player.getPlayer.Carrying.RemoveAt(0);
                            }
                            else if (player.getPlayer.Carrying.Count() == 2)
                            {

                                //weird but ok might as well....
                                //see ordercomparison function for explanation of why bellow code was commented out
                                if (player.GetcurrentGPState.Buttons.RightShoulder == ButtonState.Pressed ||
                                    player.GetcurrentGPState.Triggers.Right > .5)
                                {
                                    //&& previousState.Buttons.RightShoulder == ButtonState.Pressed)
                                    player.getPlayer.Carrying.RemoveAt(1);
                                    PlaySound(true);
                                }
                                if ((IsButtonPressed(player, "LS") ||
                                player.GetcurrentGPState.Triggers.Left < .5 && player.GetpreviousGPState.Triggers.Left > .5))
                                {
                                    player.getPlayer.Carrying.RemoveAt(0);
                                }
                            }
                            else if (player.getPlayer.Carrying.Count() == 3)
                            {
                                if (player.GetcurrentGPState.Buttons.RightShoulder == ButtonState.Pressed ||
                                    player.GetcurrentGPState.Triggers.Right > .5)
                                {
                                    //&& previousState.Buttons.RightShoulder == ButtonState.Pressed)
                                    player.getPlayer.Carrying.RemoveAt(1);
                                    PlaySound(true);
                                }
                                if ((IsButtonPressed(player, "LS") ||
                                player.GetcurrentGPState.Triggers.Left < .5 && player.GetpreviousGPState.Triggers.Left > .5))
                                {
                                    player.getPlayer.Carrying.RemoveAt(0);
                                }
                                if (player.GetcurrentGPState.DPad.Up == ButtonState.Released && player.GetpreviousGPState.DPad.Up == ButtonState.Pressed)
                                {
                                    player.getPlayer.Carrying.RemoveAt(2);
                                }
                            }
                        }

                        break;

                    default:

                        break;

                }

            }
        }
Ejemplo n.º 5
0
        //LOGIC BUG HERE - WE JUMP DOWN ON UPPER LEFT CORNER (in both Game1 & Game2,)
        //this is kinda messy probably want to redo this but works for now
        //suggest constant bounds and refine those equations
        //ISN"T FLEXIBLE ONCE ARENA GRAPHIC GETS CHANGED
        public void Bounds(Sprite_Player thisPlayer, Vector2 old_position)
        {
            float y1;

            //this is the left diagonal boundary checks
             if (thisPlayer.Position.X >= 134 && thisPlayer.Position.X <= 250)
            {
                //this takes care of the top left diagonal
                if (thisPlayer.Position.Y < 440)
                {
                    y1 = -thisPlayer.Position.X * 148 / 116 + 468;

                    if (thisPlayer.Position.Y < y1)
                    {
                        thisPlayer.Position = new Vector2(thisPlayer.Position.X - (thisPlayer.Position.X - old_position.X)*2 / 3, y1);
                    }
                }

                //this test takes care of the bottom left diagonal
                //this was more involved because the top and bottom diagonals are not the same size
                else if (thisPlayer.Position.X <= 180)
                {
                    y1 = thisPlayer.Position.X * 84 / 85 + 396;
                    if (thisPlayer.Position.Y > y1)
                        thisPlayer.Position = new Vector2(thisPlayer.Position.X, y1);
                }
                else if (thisPlayer.Position.Y > 580)
                    thisPlayer.Position = new Vector2(thisPlayer.Position.X, 580);
            }

                //********this is the right diagonal boundary checks
            else if (thisPlayer.Position.X >= 980 && thisPlayer.Position.X <= 1080)
            {
                //this checks the top right boundary
                if (thisPlayer.Position.Y < 440)
                {
                    y1 = thisPlayer.Position.X * 150 / 120 - 1060;
                    if (thisPlayer.Position.Y < y1)
                        thisPlayer.Position = new Vector2(thisPlayer.Position.X -(thisPlayer.Position.X - old_position.X)/2, y1);
                }

                    //this takes care of the bottom right diagonal boundary
                else
                {
                    y1 = -thisPlayer.Position.X * 60 / 100 + 1168;
                    if (thisPlayer.Position.Y > y1)
                        thisPlayer.Position = new Vector2(thisPlayer.Position.X, y1);

                }
            }

            //This is the top arena boundary
            else if (thisPlayer.Position.Y < 150)
                thisPlayer.Position = new Vector2(thisPlayer.Position.X, 150);

            //this is the bottom arena boundary
            else if (thisPlayer.Position.Y > 580)
                thisPlayer.Position = new Vector2(thisPlayer.Position.X, 580);

            //this is the left boundary
            else if (thisPlayer.Position.X < 134)
            {
                thisPlayer.Position = new Vector2(134, thisPlayer.Position.Y);

                //these two fix the glitch where the character seeed to slide upon reaching the
                //diagonal boundaries
                if (thisPlayer.Position.Y < 340)
                    thisPlayer.Position = new Vector2(thisPlayer.Position.X, 340);
                if (thisPlayer.Position.Y > 548)
                    thisPlayer.Position = new Vector2(thisPlayer.Position.X, 548);
            }

                //this is the right boundary
            else if (thisPlayer.Position.X > 1080)
            {
                thisPlayer.Position = new Vector2(1080, thisPlayer.Position.Y);

                //these two fix the glitch where the character seed to slide upon reaching the
                //diagonal boundaries
                if (thisPlayer.Position.Y < 290)
                    thisPlayer.Position = new Vector2(thisPlayer.Position.X, 290);
                if (thisPlayer.Position.Y > 540)
                    thisPlayer.Position = new Vector2(thisPlayer.Position.X, 540);
            }
        }
Ejemplo n.º 6
0
        public void LoadPlayers()
        {
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
            {
                Sprite_Player player1 = new Sprite_Player(PlayerIndex.One, assetManager.GetTextures("character_sheet2"), assetManager.GetFont[2], PLAYER1_POS,
                        0, new Point(76, 116), new Point(0, 0), new Point(3, 6), player_speed, 160, null);

                Sprite_Player player2 = new Sprite_Player(PlayerIndex.Two, assetManager.GetTextures("character_sheet"), assetManager.GetFont[2], PLAYER2_POS,
                    0, new Point(76, 116), new Point(0, 0), new Point(3, 6), player_speed, 160, null);

                player1.getPlayer.Opponent = player2;
                player2.getPlayer.Opponent = player1;

                playerList.Add(player1);

                playerList.Add(player2);
            }
            //WE CAN ADD MORE PLAYERS HERE max 4? once we get les sprites could be cool

            if (GamePad.GetState(PlayerIndex.Three).IsConnected)
            {
                playerList.Add(new Sprite_Player(PlayerIndex.Three, assetManager.GetTextures("character_sheet3"), assetManager.GetFont[2], PLAYER3_POS,
                     0, new Point(76, 116), new Point(0, 0), new Point(3, 6), player_speed, 160, null));
            }
            if (GamePad.GetState(PlayerIndex.Four).IsConnected)
            {
                playerList.Add(new Sprite_Player(PlayerIndex.Four, assetManager.GetTextures("character_sheet4"), assetManager.GetFont[2], PLAYER4_POS,
                     0, new Point(76, 116), new Point(0, 0), new Point(3, 6), player_speed, 160, null));
            }
        }