コード例 #1
0
        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            if (this.lootTable == null)
            {
                return(true);
            }
            LootTable.LootResult loot = this.lootTable.Get();

            if (loot.item != null && loot.amount > 0)
            {
                switch (this.target)
                {
                case Target.PlayerInventory:
                    InventoryManager.Instance.AddItemToInventory(
                        loot.item.uuid,
                        loot.amount
                        );
                    break;

                case Target.Container:
                    Container containerInstance = this.container.GetComponent <Container>(target);
                    if (containerInstance != null)
                    {
                        containerInstance.AddItem(
                            loot.item.uuid,
                            loot.amount
                            );
                    }
                    break;
                }
            }

            return(true);
        }
コード例 #2
0
        private void OnUseLootTable(LootTable.LootResult result)
        {
            string itemName   = result.item.itemName.GetText();
            float  itemAmount = result.amount;

            this.storeItemName.Set(itemName, gameObject);
            this.storeItemAmount.Set(itemAmount, gameObject);

            this.ExecuteTrigger(gameObject);
        }