Пример #1
0
        //[Space]
        //public FloatOutput RemainingDuration;
        //public FloatOutput TotalDuration;

        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry applyOutput  = Apply[context];
            EventEntry removeOutput = Remove[context];
            ConnectionEntry <RPGCharacter> targetOutput = Target[context];

            ConnectionEntry <int> ticksOutput = Ticks[context];

            //ConnectionEntry<float> totalDurationOutput = TotalDuration[context];
            //ConnectionEntry<float> remainingDurationOutput = RemainingDuration[context]

            targetOutput.OnBeforeChanged += () =>
            {
                if (targetOutput.Value != null)
                {
                    removeOutput.Invoke();
                }
            };

            targetOutput.OnAfterChanged += () =>
            {
                if (targetOutput.Value != null)
                {
                    applyOutput.Invoke();
                }
            };
        }
Пример #2
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry            rerollInput = Reroll[context];
            ConnectionEntry <int> minInput    = Min[context];
            ConnectionEntry <int> maxInput    = Max[context];
            ConnectionEntry <int> output      = Output[context];

            float roll = 0.0f;

            Action outputHandlder = () =>
            {
                output.Value = Mathf.RoundToInt(Mathf.Lerp(minInput.Value, maxInput.Value, roll));
            };

            Action rerollHandler = () =>
            {
                roll = UnityEngine.Random.Range(0.0f, 1.0f);

                outputHandlder();
            };

            rerollInput.OnEventFired += rerollHandler;
            minInput.OnAfterChanged  += outputHandlder;
            maxInput.OnAfterChanged  += outputHandlder;

            rerollHandler();
        }
Пример #3
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <float> attackInput             = AttackDamage[context];
            ConnectionEntry <float> attackSpeedInput        = AttackSpeed[context];
            ConnectionEntry <float> criticalChanceInput     = CriticalChance[context];
            ConnectionEntry <float> criticalMultiplierInput = CriticalMultiplier[context];

            var statsCollection = new WeaponStatInstanceCollection();

            StatsMapping[context] = statsCollection;
            statsCollection.GetEnumerator();

            var attackModifier = statsCollection.Attack.AddFlatModifier(attackInput.Value);

            attackInput.OnAfterChanged += () => attackModifier.Value = attackInput.Value;

            var attackSpeedModifier = statsCollection.AttackSpeed.AddFlatModifier(attackSpeedInput.Value);

            attackSpeedInput.OnAfterChanged += () => attackSpeedModifier.Value = attackSpeedInput.Value;

            var criticalChanceModifier = statsCollection.CriticalStrikeChance.AddFlatModifier(criticalChanceInput.Value);

            criticalChanceInput.OnAfterChanged += () => criticalChanceModifier.Value = criticalChanceInput.Value;

            var criticalMultiplierModifier = statsCollection.CriticalStrikeMultiplier.AddFlatModifier(criticalMultiplierInput.Value);

            criticalMultiplierInput.OnAfterChanged += () => criticalMultiplierModifier.Value = criticalMultiplierInput.Value;
        }
Пример #4
0
        protected override void OnSetup(IBehaviourContext character)
        {
            ConnectionEntry <int>  valueAInput = ValueA.GetEntry(character);
            ConnectionEntry <int>  valueBInput = ValueB.GetEntry(character);
            ConnectionEntry <bool> output      = Output.GetEntry(character);

            Action updateHandler = () =>
            {
                if (Operator == Comparison.Equal)
                {
                    output.Value = valueAInput.Value == valueBInput.Value;
                }
                else if (Operator == Comparison.Greater)
                {
                    output.Value = valueAInput.Value > valueBInput.Value;
                }
                else if (Operator == Comparison.Less)
                {
                    output.Value = valueAInput.Value < valueBInput.Value;
                }
            };

            valueAInput.OnAfterChanged += updateHandler;
            valueBInput.OnAfterChanged += updateHandler;

            updateHandler();
        }
Пример #5
0
        public string Description(IBehaviourContext character)
        {
            ConnectionEntry <RPGCharacter> targetInput = Target.GetEntry(character);
            ConnectionEntry <float>        effectInput = Effect.GetEntry(character);

            StatInstance inst = targetInput.Value.Stats[entry];

            return(Display.Replace("{0}", inst.Info.RenderModifier(effectInput.Value, Scaling)));
        }
Пример #6
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <ItemSurrogate> targetInput = Target[context];
            ConnectionEntry <float>         valueOutput = Value[context];

            Action updateListener = () =>
            {
                if (targetInput.Value == null)
                {
                    valueOutput.Value = 0.0f;
                    return;
                }

                var weaponNode = targetInput.Value.Template.GetNode <D> ();

                if (weaponNode == null)
                {
                    valueOutput.Value = 0;
                    return;
                }
                valueOutput.Value = weaponNode.GetStats(targetInput.Value)[Stat].Value;
            };

            if (targetInput.Value != null)
            {
                targetInput.Value.Template.GetNode <D> ()
                .GetStats(targetInput.Value)[Stat].OnValueChanged += updateListener;

                updateListener();
            }

            targetInput.OnBeforeChanged += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.Template.GetNode <D> ()
                .GetStats(targetInput.Value)[Stat].OnValueChanged -= updateListener;
            };

            targetInput.OnAfterChanged += () =>
            {
                updateListener();
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.Template.GetNode <D> ()
                .GetStats(targetInput.Value)[Stat].OnValueChanged += updateListener;
            };
        }
Пример #7
0
        protected override void OnRemove(IBehaviourContext context)
        {
            EventEntry removeOutput = Remove[context];
            ConnectionEntry <RPGCharacter> targetOutput = Target[context];

            targetOutput.Value = null;

            EventEntry applyOutput = Apply[context];

            applyOutput.Invoke();
        }
Пример #8
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry            setInput  = Set[context];
            ConnectionEntry <int> sizeInput = Size[context];

            setInput.OnEventFired += () =>
            {
                Buff buff = (Buff)context;

                buff.BaseStackSize.Value = 0;
            };
        }
Пример #9
0
        protected override void OnSetup(IBehaviourContext character)
        {
            ConnectionEntry <RPGCharacter> centerInput        = Center.GetEntry(character);
            ConnectionEntry <bool>         includeCasterInput = IncludeCaster.GetEntry(character);
            ConnectionEntry <float>        distanceInput      = Distance.GetEntry(character);

            CharacterConnection.EntryCollection targetsOutput = Targets.GetEntry(character);

            GameObject       proximityHolder = new GameObject("Proximity Cheacker");
            ProximityChecker proximity       = proximityHolder.AddComponent <ProximityChecker> ();

            proximity.enabled = false;

            proximity.Conditions += (RPGCharacter target) =>
            {
                return(includeCasterInput.Value ? true : target != centerInput.Value);
            };

            proximity.OnEnter += (RPGCharacter target) =>
            {
                targetsOutput.Add(target);
            };

            proximity.OnExit += (RPGCharacter target) =>
            {
                targetsOutput.Remove(target);
            };

            Action changeHandler = () =>
            {
                if (centerInput.Value == null)
                {
                    proximityHolder.transform.SetParent(null);
                    proximity.enabled = false;
                    return;
                }

                proximityHolder.transform.SetParent(centerInput.Value.transform);
                proximityHolder.transform.localPosition = Vector3.zero;
                proximity.enabled = true;
            };

            Action distanceChangeHandler = () =>
            {
                proximity.Distance = distanceInput.Value;
            };

            distanceChangeHandler();
            changeHandler();

            centerInput.OnAfterChanged   += changeHandler;
            distanceInput.OnAfterChanged += distanceChangeHandler;
        }
Пример #10
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int> countInput = Count[context];
            var itemInput  = Item[context];
            var eventInput = Event[context];

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

            eventInput.OnEventFired += updateHandler;
        }
Пример #11
0
        public void SetTarget(IBehaviourContext context, Buff target)
        {
            ConnectionEntry <int> stackSizeOutput = StackSize[context];
            EventEntry            onTickOutput    = OnTick[context];

            stackSizeOutput.Value       = target.StackSize.Value;
            target.StackSize.onChanged += () =>
            {
                stackSizeOutput.Value = target.StackSize.Value;
            };

            target.OnTick += onTickOutput.Invoke;
        }
Пример #12
0
        public void SetRPGCoreBuff(IBehaviourContext context, Buff buff)
        {
            ConnectionEntry <int> stackSizeOutput = StackSize[context];
            EventEntry            onTickOutput    = OnTick[context];

            stackSizeOutput.Value     = buff.StackSize.Value;
            buff.StackSize.onChanged += () =>
            {
                stackSizeOutput.Value = buff.StackSize.Value;
            };

            buff.OnTick += onTickOutput.Invoke;
        }
Пример #13
0
            public C GetEntry(IBehaviourContext context)
            {
                C foundEntry;

                if (SourceNode == null)
                {
                    if (defaultEntry == null)
                    {
                        defaultEntry = new C();

                        defaultEntry.Value = defaultValue;
                    }

                    foundEntry = defaultEntry;

                    return(foundEntry);
                }

                if (contextCahce == null)
                {
                    contextCahce = new Dictionary <IBehaviourContext, C> ();
                }

                bool result = contextCahce.TryGetValue(context, out foundEntry);

                if (!result)
                {
                    foundEntry = new C();

                    contextCahce.Add(context, foundEntry);

                    ISocket sourceOutput = (ISocket)SourceSocket;

                    ConnectionEntry connectionEntry = sourceOutput.GetBaseEntry(context);

                    if (!typeof(ISocketConvertable <T>).IsAssignableFrom(connectionEntry.GetType()))
                    {
                        Debug.Log(SourceSocket.GetType().Name + " is not convertable to "
                                  + GetType().Name);
                    }

                    ISocketConvertable <T> socket = (ISocketConvertable <T>)connectionEntry;

                    connectionEntry.OnAfterChanged += () =>
                    {
                        foundEntry.Value = socket.Convert;
                    };
                }

                return(foundEntry);
            }
Пример #14
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <ItemSurrogate> targetInput = Target[context];
            ConnectionEntry <float>         valueInput  = Value[context];

            Action updateListener = () =>
            {
                var weaponNode = targetInput.Value.Template.GetNode <WeaponInputNode> ();

                if (weaponNode == null)
                {
                    valueInput.Value = 0;
                    return;
                }

                var localStatInput = weaponNode.GetStat(targetInput.Value, Stat);

                valueInput.Value = localStatInput.Value;
            };

            if (targetInput.Value != null)
            {
                targetInput.Value.Template.GetNode <ArmourInputNode> ()
                .Armour[targetInput.Value].OnAfterChanged += updateListener;

                updateListener();
            }

            targetInput.OnBeforeChanged += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.Template.GetNode <ArmourInputNode> ()
                .Armour[targetInput.Value].OnAfterChanged -= updateListener;
            };

            targetInput.OnAfterChanged += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.Template.GetNode <ArmourInputNode> ()
                .Armour[targetInput.Value].OnAfterChanged += updateListener;
                updateListener();
            };
        }
Пример #15
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;
        }
Пример #16
0
        public string Description(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> targetInput = Target[context];
            ConnectionEntry <float>        effectInput = Effect[context];

            if (targetInput.Value == null)
            {
                return("");
            }

            StatInstance inst = targetInput.Value.Stats[entry];

            return(Display.Replace("{0}", inst.Info.RenderModifier(effectInput.Value, Scaling)));
        }
Пример #17
0
        public string Description(IBehaviourContext context)
        {
            ConnectionEntry <ItemSurrogate> targetInput = Target[context];
            ConnectionEntry <float>         effectInput = Effect[context];

            if (targetInput.Value == null)
            {
                return("");
            }

            var info = WeaponStatInformationDatabase.Instance.WeaponStatInfos[Stat];

            return(Display.Replace("{0}", info.RenderModifier(effectInput.Value, Scaling)));
        }
Пример #18
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> targetInput       = Target[context];
            ConnectionEntry <int>          damageTakenOutput = DamageTaken[context];
            EventEntry onHitOutput = OnHit[context];

            bool isActive = false;

            Action eventHandler = () =>
            {
                if (targetInput.Value.States.CurrentHealth.Delta >= 1.0f)
                {
                    damageTakenOutput.Value = (int)targetInput.Value.States.CurrentHealth.Delta;
                    onHitOutput.Invoke();
                }
            };

            Action subscriber = () =>
            {
                if (targetInput.Value == null)
                {
                    isActive = false;
                    return;
                }

                if (!isActive)
                {
                    targetInput.Value.States.CurrentHealth.OnValueChanged += eventHandler;
                }

                isActive = true;
            };

            subscriber();

            targetInput.OnBeforeChanged += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                if (isActive)
                {
                    targetInput.Value.States.CurrentHealth.OnValueChanged -= eventHandler;
                }
            };

            targetInput.OnAfterChanged += subscriber;
        }
Пример #19
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry applyInput = Apply[context];
            ConnectionEntry <RPGCharacter> targetInput    = Target[context];
            ConnectionEntry <int>          stackSizeInput = StackSize[context];

            applyInput.OnEventFired += () =>
            {
                if (Mode == ApplyMode.Add)
                {
                    Buff      buff      = new Buff(this, context);
                    BuffClock buffClock = new BuffClockFixed(this, context);

                    buffClock.StackSize.AddFlatModifier(stackSizeInput.Value);

                    buff.AddClock(buffClock);

                    targetInput.Value.Buffs.Add(buff);
                }
                else if (Mode == ApplyMode.Stack)
                {
                    Buff buff = targetInput.Value.Buffs.Find(BuffToApply);

                    Debug.Log(BuffToApply.name);

                    if (buff == null)
                    {
                        buff = new Buff(this, context);

                        BuffClock buffClock = new BuffClockFixed(this, context);
                        buffClock.StackSize.AddFlatModifier(0);

                        buff.AddClock(buffClock);

                        targetInput.Value.Buffs.Add(buff);
                    }

                    buff.BaseStackSize.Value += stackSizeInput.Value;
                }
            };

            stackSizeInput.OnAfterChanged += () =>
            {
                return;

                // if (modifier != null)
                //	modifier.Value = stackSizeInput.Value;
            };
        }
Пример #20
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);
            }
        }
Пример #21
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry eventInput = Event[context];
            ConnectionEntry <RPGCharacter> targetInput = Target[context];
            ConnectionEntry <int>          effectInput = Effect[context];

            eventInput.OnEventFired += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.TakeDamage(effectInput.Value);
            };
        }
Пример #22
0
        protected override void OnSetup(IBehaviourContext character)
        {
            ConnectionEntry <int> valueAInput = ValueA.GetEntry(character);
            ConnectionEntry <int> valueBInput = ValueB.GetEntry(character);
            ConnectionEntry <int> output      = Output.GetEntry(character);

            Action updateHandler = () =>
            {
                output.Value = valueAInput.Value + valueBInput.Value;
            };

            valueAInput.OnAfterChanged += updateHandler;
            valueBInput.OnAfterChanged += updateHandler;

            updateHandler();
        }
Пример #23
0
        protected override void OnSetup(IBehaviourContext character)
        {
            EventEntry eventInput = Event.GetEntry(character);
            ConnectionEntry <RPGCharacter> targetInput = Target.GetEntry(character);
            ConnectionEntry <int>          effectInput = Effect.GetEntry(character);

            eventInput.OnEventFired += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.Heal(effectInput.Value);
            };
        }
Пример #24
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int> minInput = Min.GetEntry(context);
            ConnectionEntry <int> maxInput = Max.GetEntry(context);
            ConnectionEntry <int> output   = Output.GetEntry(context);

            Action updateHandler = () =>
            {
                output.Value = UnityEngine.Random.Range(minInput.Value, maxInput.Value + 1);
            };

            minInput.OnAfterChanged += updateHandler;
            maxInput.OnAfterChanged += updateHandler;

            updateHandler();
        }
Пример #25
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var eventInput  = Event[context];
            var targetInput = Target[context];
            ConnectionEntry <int> effectInput = Effect[context];

            eventInput.OnEventFired += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                targetInput.Value.Heal(effectInput.Value);
            };
        }
Пример #26
0
        protected override void OnSetup(IBehaviourContext context)
        {
            object fieldInputObject = Field.GetConnectionObject(context);

            // Debug.Log (fieldInputObject);

            ConnectionEntry fieldInput      = (ConnectionEntry)fieldInputObject;
            EventEntry      onChangedOutput = onChanged.GetEntry(context);

            Action eventHandler = () =>
            {
                onChangedOutput.Invoke();
            };

            fieldInput.OnAfterChanged += eventHandler;
        }
Пример #27
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> targetInput     = Target.GetEntry(context);
            ConnectionEntry <RPGCharacter> hitTargetOutput = HitTarget.GetEntry(context);
            EventEntry onHitOutput = OnHit.GetEntry(context);

            bool isActive = false;

            Action <RPGCharacter> eventHandler = (RPGCharacter target) =>
            {
                hitTargetOutput.Value = target;
                onHitOutput.Invoke();
            };

            Action subscriber = () =>
            {
                if (targetInput.Value == null)
                {
                    isActive = false;
                    return;
                }

                if (!isActive)
                {
                    targetInput.Value.OnHit += eventHandler;
                }

                isActive = true;
            };

            subscriber();

            targetInput.OnBeforeChanged += () =>
            {
                if (targetInput.Value == null)
                {
                    return;
                }

                if (isActive)
                {
                    targetInput.Value.OnHit -= eventHandler;
                }
            };

            targetInput.OnAfterChanged += subscriber;
        }
Пример #28
0
        public ArmourStatInstanceCollection GetStats(IBehaviourContext context)
        {
            ArmourStatInstanceCollection statsCollection;

            if (!StatsMapping.TryGetValue(context, out statsCollection))
            {
                ConnectionEntry <float> armourInput = Armour[context];

                statsCollection       = new ArmourStatInstanceCollection();
                StatsMapping[context] = statsCollection;
                statsCollection.GetEnumerator();

                var attackModifier = statsCollection.Armour.AddFlatModifier(armourInput.Value);
                armourInput.OnAfterChanged += () => attackModifier.Value = armourInput.Value;
            }
            return(statsCollection);
        }
Пример #29
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);
        }
Пример #30
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;
        }