Esempio n. 1
0
        public StatInstance GetStat(ItemSurrogate context, CollectionEntry entry)
        {
            var statsCollection = StatsMapping[context];
            var stat            = statsCollection[entry];

            return(stat);
        }
Esempio n. 2
0
        public virtual ItemSurrogate Generate()
        {
            if (RewardTemplate == null)
            {
                return(null);
            }

            int           count         = Random.Range(MinCount, MaxCount);
            ItemSurrogate generatedItem = RewardTemplate.GenerateItem();

            generatedItem.Quantity = count;
            return(generatedItem);
        }
Esempio n. 3
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int> countInput = Count[context];
            EventEntry            eventInput = Event[context];

            ItemSurrogate item = (ItemSurrogate)context;

            Action updateHandler = () =>
            {
                item.data.quantity.Value -= Mathf.Max(0, countInput.Value);
            };

            eventInput.OnEventFired += updateHandler;
        }
Esempio n. 4
0
        public override ItemSurrogate GenerateItem(ItemData data)
        {
            ItemSurrogate newItem = new ItemSurrogate();

            newItem.data     = data;
            newItem.template = this;

            if (prefix != null)
            {
                EnchantmentTemplate template = prefix.GetEnchantment();

                if (template != null)
                {
                    newItem.Prefix = new Enchantment(template);
                }
            }

            if (suffix != null)
            {
                EnchantmentTemplate template = suffix.GetEnchantment();

                if (template != null)
                {
                    newItem.Suffix = new Enchantment(template);
                }
            }


            SetupGraph(newItem);

            ItemInputNode node = GetNode <ItemInputNode> ();

            newItem.owner.onChanged += () =>
            {
                if (node == null)
                {
                    return;
                }

                node.Owner[newItem].Value = newItem.owner.Value;
            };

            node.StackSize[newItem].Value    = newItem.Quantity;
            newItem.data.quantity.onChanged += () =>
            {
                node.StackSize[newItem].Value = newItem.Quantity;
            };

            return(newItem);
        }
Esempio n. 5
0
        public void TryUse(ItemSurrogate context, RPGCharacter character)
        {
            ConnectionEntry <int> manaCostInput     = ManaCost.GetEntry(context);
            ConnectionEntry <int> quantityCostInput = QuantityCost.GetEntry(context);
            EventEntry            onActivateOutput  = OnActivate.GetEntry(context);

            if (CanCharacterUse(context, character))
            {
                context.owner.Value.States.CurrentMana.Value -= manaCostInput.Value;
                context.Quantity -= quantityCostInput.Value;

                onActivateOutput.OnEventFired();
                AudioManager.Play(ActivateSound);
            }
        }
Esempio n. 6
0
        public bool CanCharacterUse(ItemSurrogate context, RPGCharacter character)
        {
            ConnectionEntry <int> manaCostInput     = ManaCost[context];
            ConnectionEntry <int> quantityCostInput = QuantityCost[context];

            if (context.Quantity < quantityCostInput.Value)
            {
                return(false);
            }

            if (context.owner.Value.States.CurrentMana.Value < manaCostInput.Value)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry eventInput = Event[context];
            ConnectionEntry <RPGCharacter> characterInput = Character[context];

            Action updateHandler = () =>
            {
                if (characterInput.Value == null)
                {
                    return;
                }

                ItemSurrogate item = Item.Generate();

                characterInput.Value.inventory.Add(item);
            };

            eventInput.OnEventFired += updateHandler;
        }
Esempio n. 8
0
        public override ItemSurrogate GenerateItem(ItemData data)
        {
            var newItem = new ItemSurrogate
            {
                data     = data,
                template = this
            };

            this.SetupGraph(newItem);

            var itemNodes = this.GetNodes <IInputNode <ItemSurrogate> >();

            foreach (var itemNode in itemNodes)
            {
                itemNode.SetTarget(newItem, newItem);
            }

            if (prefix != null)
            {
                var template = prefix.GetEnchantment();

                if (template != null)
                {
                    newItem.Prefix = new Enchantment(template);
                }
            }

            if (suffix != null)
            {
                var template = suffix.GetEnchantment();

                if (template != null)
                {
                    newItem.Suffix = new Enchantment(template);
                }
            }

            return(newItem);
        }
Esempio n. 9
0
        public static ItemTier ItemTierRandom(ItemSurrogate Item, ItemTier min, ItemTier max)
        {
            int random = StatGenerator.IntRange(Item, 0, (int)min, (int)max);

            return((ItemTier)random);
        }
Esempio n. 10
0
 public void Setup(ItemSurrogate _item, EnchantmantData _data)
 {
     item = _item;
     data = _data;
 }