示例#1
0
 override public void Reset()
 {
     pot     = new HealthPot();
     channel = new Channel();
     spell   = new Spell();
     Logic   = (c, cs) => {
         pot.Logic();
         if (channel.Logic())
         {
             return;
         }
         spell.Logic(c, cs);
         s.myHero.Attack(c);
     };
 }
    public void interact(GameAgent interactor)
    {
        source.PlayOneShot(chestOpeningSFX);
        int    randomItemIndex  = Settings.globalRNG.Next(itemOptions.Length);
        int    randomItemAmount = Settings.globalRNG.Next(1, 5);
        string itemChoice       = itemOptions[randomItemIndex];
        Item   toAdd;

        switch (itemChoice)
        {
        case "health":
            toAdd = new HealthPot(randomItemAmount); break;

        case "mana":
            toAdd = new ManaPot(randomItemAmount); break;

        case "helmet":
            toAdd = new Helmet(); break;

        case "armor":
            toAdd = new Armor(); break;

        case "gloves":
            toAdd = new Glove(); break;

        case "boot":
            toAdd = new Boot(); break;

        default:
            toAdd = null; break;
        }
        if (toAdd == null)
        {
            return;
        }

        interactor.inventory.AddItem(toAdd);
        UI_TextAlert.DisplayText("Received " + toAdd.Amount + " " + toAdd.Name + "(s)!");
        GameManager.kill(this, 0.5f);
    }