Ejemplo n.º 1
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <bool> valueAInput = ValueA[context];
            ConnectionEntry <bool> valueBInput = ValueB[context];
            ConnectionEntry <bool> output      = Output[context];

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

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

            updateHandler();
        }
Ejemplo n.º 2
0
        public void SetTarget(IBehaviourContext context, ItemSurrogate target)
        {
            Item[context].Value = target;

            Owner[context].Value    = target.owner.Value;
            target.owner.onChanged += () =>
            {
                Owner[context].Value = target.owner.Value;
            };

            StackSize[context].Value        = target.Quantity;
            target.data.quantity.onChanged += () =>
            {
                StackSize[context].Value = target.Quantity;
            };
        }
Ejemplo n.º 3
0
        protected override void OnSetup(IBehaviourContext character)
        {
            ConnectionEntry <float> valueAInput = ValueA.GetEntry(character);
            ConnectionEntry <float> valueBInput = ValueB.GetEntry(character);
            ConnectionEntry <float> output      = Output.GetEntry(character);

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

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

            updateHandler();
        }
Ejemplo n.º 4
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);
            };
        }
Ejemplo n.º 5
0
        protected override void OnSetup(IBehaviourContext context)
        {
            object fieldInputObject = Field.GetConnectionObject(context);

            // Debug.Log (fieldInputObject);

            var fieldInput      = (ConnectionEntry)fieldInputObject;
            var onChangedOutput = onChanged[context];

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

            fieldInput.OnAfterChanged += eventHandler;
        }
Ejemplo n.º 6
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int> minInput = Min[context];
            ConnectionEntry <int> maxInput = Max[context];
            ConnectionEntry <int> output   = Output[context];

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

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

            updateHandler();
        }
Ejemplo n.º 7
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);
            };
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
            public override void RemoveContext(IBehaviourContext context)
            {
                if (ContextCahce == null)
                {
                    return;
                }

                ContextCahce.Remove(context);

                EntryCollection entry = GetEntry(context);

                for (int i = 0; i < entry.Count; i++)
                {
                    entry[i].Value = default(T);
                    //entry.Remove (entry [i]);
                }
            }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        protected override void OnSetup(IBehaviourContext context)
        {
            Action updateHandler = () =>
            {
                object[] valuesObjects = new object[Values.Length];

                for (int i = 0; i < Values.Length; i++)
                {
                    valuesObjects[i] = Values[i];
                }

                // Debug.Log ("Description: " + String.Format (Template, valuesObjects));
                DescriptionMap[context] = string.Format(Template, valuesObjects);
            };

            updateHandler();
        }
Ejemplo n.º 12
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var valueInput = Value[context];
            var minInput   = Min[context];
            var maxInput   = Max[context];
            var output     = Output[context];

            Action updateHandler = () =>
            {
                output.Value = Mathf.Lerp(minInput.Value, maxInput.Value, valueInput.Value);
            };

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

            updateHandler();
        }
Ejemplo n.º 13
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var statsCollection = new B();

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

            var inputsEnumerator = Inputs.GetEnumerator();

            foreach (var stat in GetStats(context))
            {
                inputsEnumerator.MoveNext();
                var currentInput = inputsEnumerator.Current[context];

                var modifier = stat.AddFlatModifier(currentInput.Value);
                currentInput.OnAfterChanged += () => modifier.Value = currentInput.Value;
            }
        }
Ejemplo n.º 14
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int> valueInput = Value[context];
            ConnectionEntry <int> minInput   = Min[context];
            ConnectionEntry <int> maxInput   = Max[context];
            ConnectionEntry <int> output     = Output[context];

            Action updateHandler = () =>
            {
                output.Value = Mathf.Clamp(valueInput.Value, minInput.Value, maxInput.Value);
            };

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

            updateHandler();
        }
Ejemplo n.º 15
0
		public EventEntry GetEntry (IBehaviourContext context)
		{
			if (contextCahce == null)
				contextCahce = new Dictionary<IBehaviourContext, EventEntry> ();

			EventEntry foundEntry;

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

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

				contextCahce.Add (context, foundEntry);
			}

			return foundEntry;
		}
Ejemplo n.º 16
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var eventInput     = Event[context];
            var characterInput = Character[context];

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

                var item = Item.Generate();

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

            eventInput.OnEventFired += updateHandler;
        }
Ejemplo n.º 17
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;
        }
Ejemplo n.º 18
0
        protected override void OnSetup(IBehaviourContext character)
        {
            ConnectionEntry <RPGCharacter> targetInput = Target.GetEntry(character);
            EventEntry activateInput = Activate.GetEntry(character);

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

                PulseEffect visualEffect = Instantiate(Effect) as PulseEffect;
                visualEffect.gameObject.SetActive(false);

                visualEffect.transform.SetParent(targetInput.Value.transform);
                visualEffect.gameObject.SetActive(true);
                visualEffect.transform.localPosition = Vector3.zero;
            };
        }
Ejemplo n.º 19
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var targetInput   = Target[context];
            var activateInput = Activate[context];

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

                var visualEffect = Instantiate(Effect) as PulseEffect;
                visualEffect.gameObject.SetActive(false);

                visualEffect.transform.SetParent(targetInput.Value.transform);
                visualEffect.gameObject.SetActive(true);
                visualEffect.transform.localPosition = Vector3.zero;
            };
        }
Ejemplo n.º 20
0
            public EntryCollection GetEntry(IBehaviourContext context)
            {
                if (ContextCahce == null)
                {
                    ContextCahce = new Dictionary <IBehaviourContext, EntryCollection> ();
                }

                EntryCollection foundEntry;

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

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

                    ContextCahce.Add(context, foundEntry);
                }

                return(foundEntry);
            }
Ejemplo n.º 21
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var conditionInput = Condition[context];
            var trueOutput     = True[context];
            var falseOutput    = False[context];

            Action eventHandler = () =>
            {
                if (conditionInput.Value)
                {
                    trueOutput.Invoke();
                }
                else
                {
                    falseOutput.Invoke();
                }
            };

            conditionInput.OnAfterChanged += eventHandler;
        }
Ejemplo n.º 22
0
        protected override void OnSetup(IBehaviourContext context)
        {
            var applyInput  = Apply[context];
            var targetInput = Target[context];

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

                var buff = targetInput.Value.Buffs.Find(Search);

                if (buff != null)
                {
                    // Debug.Log ("Removing: " + buff.buffTemplate.name);
                    buff.RemoveBuff();
                }
            };
        }
Ejemplo n.º 23
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry             eventInput     = Event[context];
            ConnectionEntry <bool> conditionInput = Condition[context];
            EventEntry             trueOutput     = True[context];
            EventEntry             falseOutput    = False[context];

            Action eventHandler = () =>
            {
                if (conditionInput.Value)
                {
                    trueOutput.Invoke();
                }
                else
                {
                    falseOutput.Invoke();
                }
            };

            eventInput.OnEventFired += eventHandler;
        }
Ejemplo n.º 24
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int> firesInput = Fires[context];
            var perSecondsInput = PerSeconds[context];
            var spacingInput    = Spacing[context];
            var eventInput      = Event[context];
            var limitedtOutput  = Limited[context];

            var   FiringTimes    = new Queue <float>();
            float lastFiringTime = float.MinValue;

            eventInput.OnEventFired += () =>
            {
                if (Time.time < lastFiringTime + spacingInput.Value)
                {
                    return;
                }

                if (FiringTimes.Count < firesInput.Value)
                {
                    FiringTimes.Enqueue(Time.time);
                    lastFiringTime = Time.time;
                    limitedtOutput.Invoke();
                }
                else
                {
                    float lastTime = FiringTimes.Peek();

                    if (Time.time > lastTime + perSecondsInput.Value)
                    {
                        FiringTimes.Dequeue();
                        FiringTimes.Enqueue(Time.time);
                        lastFiringTime = Time.time;
                        limitedtOutput.Invoke();
                    }
                }
            };
        }
Ejemplo n.º 25
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> targetInput = Target[context];
            ConnectionEntry <float>        valueInput  = Value[context];

            Action updateListener = () =>
            {
                valueInput.Value = targetInput.Value.Stats[entry].Value;
            };

            if (targetInput.Value != null)
            {
                targetInput.Value.Stats[entry].OnValueChanged += updateListener;

                updateListener();
            }

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

                targetInput.Value.Stats[entry].OnValueChanged -= updateListener;
            };

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

                targetInput.Value.Stats[entry].OnValueChanged += updateListener;
                updateListener();
            };
        }
Ejemplo n.º 26
0
        public EventEntry GetEntry(IBehaviourContext context)
        {
            if (SourceNode == null)
            {
                return(defaultEntry);
            }

            EventEntry foundEntry;

            if (ContextCahce == null)
            {
                ContextCahce = new Dictionary <IBehaviourContext, EventEntry> ();
            }

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

            var sourceOutput = (EventOutput)SourceSocket;

            var connectionEntry = sourceOutput[context];

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

                connectionEntry.OnEventFired += () =>
                {
                    if (foundEntry != null)
                    {
                        foundEntry.OnEventFired();
                    }
                };

                ContextCahce.Add(context, foundEntry);
            }

            return(foundEntry);
        }
Ejemplo n.º 27
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> targetInput = Target[context];
            ConnectionEntry <bool>         whilstInput = Whilst[context];

            ContinuousEffect visualEffect = Instantiate(Effect) as ContinuousEffect;

            visualEffect.gameObject.SetActive(false);

            Action changeHandler = () =>
            {
                if (targetInput.Value == null)
                {
                    visualEffect.transform.SetParent(null);
                    visualEffect.gameObject.SetActive(false);
                    return;
                }

                if (whilstInput.Value)
                {
                    visualEffect.transform.SetParent(targetInput.Value.transform);
                    visualEffect.gameObject.SetActive(true);
                    visualEffect.transform.localPosition = Vector3.zero;
                }
                else
                {
                    visualEffect.transform.SetParent(null);
                    visualEffect.gameObject.SetActive(false);
                }
            };

            changeHandler();

            targetInput.OnAfterChanged += changeHandler;
            whilstInput.OnAfterChanged += changeHandler;
        }
Ejemplo n.º 28
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> equippedOutput = Owner[context];
            EventEntry            onReceiveOutput         = OnReceive[context];
            EventEntry            onLooseOutput           = OnLoose[context];
            ConnectionEntry <int> stackSizeOutput         = StackSize[context];

            //equippedOutput.Value = character;
            equippedOutput.OnBeforeChanged += () =>
            {
                if (equippedOutput.Value != null)
                {
                    onLooseOutput.Invoke();
                }
            };

            equippedOutput.OnAfterChanged += () =>
            {
                if (equippedOutput.Value != null)
                {
                    onReceiveOutput.Invoke();
                }
            };
        }
Ejemplo n.º 29
0
 protected override void OnRemove(IBehaviourContext context)
 {
 }
Ejemplo n.º 30
0
 protected abstract void OnRemove(IBehaviourContext context);