SunsetHigh.Hero.stopPickpocket C# (CSharp) Method

stopPickpocket() public method

Stops the pickpocketing minigame and checks for success. If successful, an Item is returned; if not, Item.Nothing is returned
public stopPickpocket ( ) : System.Item
return System.Item
        public Item stopPickpocket()
        {
            if (ppActive)
            {
                ppActive = false;

                if (ppSystem.success())
                {
                    Item i = ppTarget.inventory.removeRandomItem();
                    if (!i.Equals(Item.Nothing))
                    {
                        //Got item!
                        this.inventory.addItem(i, 1);
                        SoundFX.playSound("LTTP_Rupee1");
                        return i;
                    }
                    else
                    {
                        //Character c has nothing to steal! Cry...
                        return i;
                    }
                }
                else
                {
                    //if fail, do something here (play sound)
                }
            }
            return Item.Nothing;
        }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Handles the Hero's pickpocketing ability; call this method in the Game's update
 /// cycle (AFTER calling KeyboardManager.update())
 /// </summary>
 /// <param name="hero">The main character</param>
 /// <param name="targets">List of characters in the scene; one that is in range is chosen randomly</param>
 public static void handlePickpocketing(Hero hero, List<Character> targets)
 {
     nullCheck();
     if (KeyboardManager.isKeyPressed(keyTypes[(int)KeyInputType.Pickpocket]))
     {
         if (hero.isPickpocketing())
         {
             Item item = hero.stopPickpocket();
             System.Diagnostics.Debug.WriteLine("Stole " + Enum.GetName(typeof(Item), item));
         }
         else if (!hero.isPickpocketing())
         {
             //naive search through a list of characters
             // We should probably do this on a per-room basis later, for efficiency.
             // And/or use some sort of "expanding circle" search.
             for(int i = 0; i < targets.Count; i++)
             {
                 if (hero.inRangeAction(targets[i]))
                 {
                     hero.startPickpocket(targets[i]);
                     break;
                 }
             }
         }
     }
 }