예제 #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
파일: HealNode.cs 프로젝트: gkjolin/RPGCore
        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
파일: HealNode.cs 프로젝트: xJayLee/RPGCore
        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
파일: GrantItem.cs 프로젝트: sishui/RPGCore
        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;
        }