public void CheckCollisions(GameTime gTime, GameplayScreen screen, character Player, bool buttonClick, Vector2 mousePos,
                                        GameplayScreen.playerHand hand, GameplayScreen.playerHand hand2)
        {
            bool hit = false;

            if (buttonClick)
            {
                foreach (machine index in machineArray)
                {
                    bool tempBool = index.CheckCollisions(gTime, screen, Player, mousePos, hand);
                    if (tempBool)
                        hit = tempBool;
                }
                if (hit == false && hand.isEmpty == false)
                {
                    #region RANDOM CHANCE OF DROP
                    if ((WOLOLOLO.NextDouble() < Player.DATA.stat[5]) &&
                            Player.INVENTORY.BOTTLES.Count > 0)
                    {
                        drop fallingItem = null;
                        drop fallingItem2;
                        if (Player.INVENTORY.BOTTLES[0].type == returnablesLIST.Type.glass)
                        {
                            hand.isEmpty = true;
                            fallingItem = new drop(glassReject, mousePos, snd_glassDrop, true, false);
                            fallingItem2 = new drop(glassReject, new Vector2(hand2.X, hand2.Y), snd_glassDrop, true, true);
                            fallingItems.Add(fallingItem);
                            fallingItems.Add(fallingItem2);
                        }
                        else if (Player.INVENTORY.BOTTLES[0].type == returnablesLIST.Type.can)
                        {
                            hand.isEmpty = true;
                            fallingItem = new drop(cansReject, mousePos, snd_canDrop, false, false);
                            fallingItem2 = new drop(cansReject, new Vector2(hand2.X, hand2.Y), snd_canDrop, false, true);
                            fallingItems.Add(fallingItem);
                            fallingItems.Add(fallingItem2);
                        }
                        else if (Player.INVENTORY.BOTTLES[0].type == returnablesLIST.Type.plastic)
                        {
                            hand.isEmpty = true;
                            fallingItem = new drop(plasticReject, mousePos, snd_plasticDrop, false, false);
                            fallingItem2 = new drop(plasticReject, new Vector2(hand2.X, hand2.Y), snd_plasticDrop, false, true);
                            fallingItems.Add(fallingItem);
                            fallingItems.Add(fallingItem2);
                        }

                        if (fallingItem != null && fallingItem.breakable)
                        {
                            Player.INVENTORY.BOTTLES.RemoveAt(0);
                        }
                        else if (Player.INVENTORY.BOTTLES[0] != null)
                        {
                            Player.INVENTORY.BOTTLES.Add(Player.INVENTORY.BOTTLES[0]);
                            Player.INVENTORY.BOTTLES.RemoveAt(0);
                        }

                    }
                    #endregion
                }
            }
        }
Ejemplo n.º 2
0
 public bool CheckCollisions(GameTime gTime, GameplayScreen screen, character Player, Vector2 mousePos,
                                 GameplayScreen.playerHand hand)
 {
     #region MACHINE HIT
     if (mouseIsInside(mousePos, hitbox) && currentSound.State != SoundState.Playing && !hand.isEmpty)
     {
         if (this.machineType == global::bottleReturn.machineType.CANS)
         {
             if (Player.INVENTORY.BOTTLES[0].type == returnablesLIST.Type.can)
             {
                 Player.INVENTORY.BOTTLES.RemoveAt(0);       // Remove Current Bottle From Player's Inventory
                 if (screen.ScreenManager.GlobalOptions.SOUND_ENABLE)
                 {
                     currentSound.Play();
                 }
                 currentValue += .05;
                 hand.isEmpty = true;
                 //SCORE MARKER
                 Player.score += 5 * ((int)Player.intoxicationLevel + (int)Player.wantedLevel + (int)Player.odorLevel);
                 Player.energy -= 0.75f * (Player.odorLevel / 100);
                 Player.odorLevel += 0.25f;
             }
             else
             {
                 rejectBottleOccupado = true;
                 rejectBottleType = Player.INVENTORY.BOTTLES[0].type;
                 hand.isEmpty = true;
                 Player.INVENTORY.BOTTLES.RemoveAt(0);
                 Player.energy -= 0.375f * (Player.odorLevel / 100);
                 Player.odorLevel += 0.25f;
                 // Play bottle reject sound
             }
         }
         if (this.machineType == global::bottleReturn.machineType.GLASS)
         {
             if (Player.INVENTORY.BOTTLES[0].type == returnablesLIST.Type.glass)
             {
                 Player.INVENTORY.BOTTLES.RemoveAt(0);       // Remove Current Bottle From Player's Inventory
                 if (screen.ScreenManager.GlobalOptions.SOUND_ENABLE)
                 {
                     currentSound.Play();
                 }
                 currentValue += .05;
                 hand.isEmpty = true;
                 //SCORE MARKER
                 Player.score += 5 * ((int)Player.intoxicationLevel + (int)Player.wantedLevel);
                 Player.energy -= 0.75f * (Player.odorLevel / 100);
                 Player.odorLevel += 0.50f;
             }
             else
             {
                 rejectBottleOccupado = true;
                 rejectBottleType = Player.INVENTORY.BOTTLES[0].type;
                 hand.isEmpty = true;
                 Player.INVENTORY.BOTTLES.RemoveAt(0);
                 Player.energy -= 0.375f * (Player.odorLevel / 100);
                 Player.odorLevel += 0.50f;
                 // Play bottle reject sound
             }
         }
         if (this.machineType == global::bottleReturn.machineType.PLASTIC)
         {
             if (Player.INVENTORY.BOTTLES[0].type == returnablesLIST.Type.plastic)
             {
                 Player.INVENTORY.BOTTLES.RemoveAt(0);       // Remove Current Bottle From Player's Inventory
                 if (screen.ScreenManager.GlobalOptions.SOUND_ENABLE)
                 {
                     currentSound.Play();
                 }
                 currentValue += .05;
                 hand.isEmpty = true;
                 //SCORE MARKER
                 Player.score += 5 * ((int)Player.intoxicationLevel + (int)Player.wantedLevel);
                 Player.energy -= 0.75f * (Player.odorLevel / 100);
                 Player.odorLevel += 0.50f;
             }
             else
             {
                 rejectBottleOccupado = true;
                 rejectBottleType = Player.INVENTORY.BOTTLES[0].type;
                 hand.isEmpty = true;
                 Player.INVENTORY.BOTTLES.RemoveAt(0);
                 Player.energy -= 0.375f * (Player.odorLevel / 100);
                 Player.odorLevel += 0.50f;
                 // Play bottle reject sound
             }
         }
         return true;
     }
     #endregion
     #region TICKET HIT
     if (mouseIsInside(mousePos, ticketHitbox) && currentValue != 0 && hand.isEmpty)
     {
         Player.VOUCHERS.Add(new ticket(currentValue));
         if (screen.ScreenManager.GlobalOptions.SOUND_ENABLE)
         {
             ticketSound.Play();
         }
         currentValue = 0;
         //SCORE MARKER
         Player.score += 10 * ((int)Player.intoxicationLevel + (int)Player.wantedLevel);
         Player.energy -= 0.10f * (int)(Player.odorLevel / 100);
         Player.odorLevel += 0.125f;
         return true;
     }
     #endregion
     #region BOTTLE REJECT HIT
     if (mouseIsInside(mousePos, rejectHitbox) && hand.isEmpty)
     {
         // Picking a bottle back up.
         rejectBottleOccupado = false;
         Player.INVENTORY.BOTTLES.Add(new returnableItem(rejectBottleType));
         //SCORE MARKER
         Player.score += 2 * ((int)Player.intoxicationLevel + (int)Player.wantedLevel);
         Player.energy -= 0.25f * (int)(Player.odorLevel / 100);
         Player.odorLevel += 0.125f;
     }
     #endregion
     #region MISS
     // If none of the above happen, we will always return false.
     if (!hand.isEmpty)
         return false;
     #endregion
     // If we got through all of the above, then our
     // hand is empty and we are just clicking randomly.
     return true;
 }
        public void Update(GameTime gTime, GameplayScreen screen, float hitBoxScale, float rotation,
                            character player, float fadeSpeed_X, float fadeSpeed_Y)
        {
            for (int index = 0; index < machineArray.Count; index++)
            {
                machineArray[index].Update(gTime, hitBoxScale, index, rotation, BgRect);
            }

            //foreach (drop index in fallingItems)
            for (int i=0;i<fallingItems.Count;i++)
            {
                if (fallingItems[i].fade)
                {
                    fallingItems[i].UpdateFade(gTime, new Vector2(0, dropSpeed));//new Vector2(fadeSpeed_X , fadeSpeed_Y));
                }
                else
                {
                    fallingItems[i].Update(gTime, new Vector2(0, dropSpeed));
                }
                if (fallingItems[i].getLocation().Y > 720)
                {
                    if (screen.ScreenManager.GlobalOptions.SOUND_ENABLE)
                    {
                        fallingItems[i].PlaySound();
                    }

                    fallingItems.RemoveAt(i);
                }
            }
        }