Ejemplo n.º 1
0
		public EventEntry GetEntry (IBehaviourContext character)
		{
			if (contextCahce == null)
				contextCahce = new Dictionary<IBehaviourContext, EventEntry> ();

			EventEntry foundEntry;

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

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

				contextCahce.Add (character, foundEntry);
			}

			return foundEntry;
		}
Ejemplo n.º 2
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.º 3
0
        public void TryUse(ItemSurrogate context, RPGCharacter character)
        {
            ConnectionEntry <int> manaCostInput     = ManaCost[context];
            ConnectionEntry <int> quantityCostInput = QuantityCost[context];
            EventEntry            onActivateOutput  = OnActivate[context];

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

                onActivateOutput.OnEventFired();

                if (ActivateSound != null)
                {
                    AudioManager.Play(ActivateSound);
                }
            }
        }
Ejemplo n.º 4
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <RPGCharacter> targetInput = Target[context];
            EventEntry activateInput = Activate[context];

            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.º 5
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <bool> conditionInput = Condition[context];
            EventEntry             trueOutput     = True[context];
            EventEntry             falseOutput    = False[context];

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

            conditionInput.OnAfterChanged += eventHandler;
        }
Ejemplo n.º 6
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry applyInput = Apply[context];
            ConnectionEntry <RPGCharacter> targetInput = Target[context];

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

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

                if (buff != null)
                {
                    // Debug.Log ("Removing: " + buff.buffTemplate.name);
                    buff.RemoveBuff();
                }
            };
        }
Ejemplo n.º 7
0
        protected override void OnSetup(IBehaviourContext context)
        {
            ConnectionEntry <int>   firesInput      = Fires[context];
            ConnectionEntry <float> perSecondsInput = PerSeconds.GetEntry(context);
            ConnectionEntry <float> spacingInput    = Spacing.GetEntry(context);
            EventEntry eventInput     = Event[context];
            EventEntry limitedtOutput = Limited[context];

            Queue <float> 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.º 8
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.º 9
0
        protected override void OnSetup(IBehaviourContext context)
        {
            EventEntry applyInput = Apply[context];
            ConnectionEntry <RPGCharacter> targetInput    = Target[context];
            ConnectionEntry <float>        durationInput  = Duration[context];
            ConnectionEntry <int>          stackSizeInput = StackSize[context];

            IntegerStack.Modifier modifier = null;

            BuffClockDecaying refreshClock = null;

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

                if (Mode == ApplyMode.AddNewBuff)
                {
                    BuffClock buffClock = new BuffClockDecaying(this, context);
                    modifier = buffClock.StackSize.AddFlatModifier(stackSizeInput.Value);

                    Buff buff = new Buff(BuffToApply, targetInput.Value, buffClock);

                    targetInput.Value.Buffs.Add(buff);
                }
                else if (Mode == ApplyMode.SeperateClock)
                {
                    BuffClock buffClock = new BuffClockDecaying(this, context);
                    modifier = buffClock.StackSize.AddFlatModifier(stackSizeInput.Value);

                    Buff buff = targetInput.Value.Buffs.Find(BuffToApply);

                    if (buff == null)
                    {
                        buff = new Buff(BuffToApply, targetInput.Value, buffClock);
                        targetInput.Value.Buffs.Add(buff);
                    }
                    else
                    {
                        buff.AddClock(buffClock);
                    }
                }
                else if (Mode == ApplyMode.Refresh || Mode == ApplyMode.RefreshAndAdd)
                {
                    Buff buff = targetInput.Value.Buffs.Find(BuffToApply);

                    if (buff == null)
                    {
                        buff = new Buff(this, context);
                        targetInput.Value.Buffs.Add(buff);
                    }

                    if (refreshClock == null)
                    {
                        refreshClock = new BuffClockDecaying(this, context);
                        modifier     = refreshClock.StackSize.AddFlatModifier(stackSizeInput.Value);

                        buff.AddClock(refreshClock);

                        refreshClock.OnRemove += () =>
                        {
                            refreshClock = null;
                        };
                    }

                    refreshClock.TimeRemaining = refreshClock.Duration;

                    if (Mode == ApplyMode.RefreshAndAdd)
                    {
                        refreshClock.StackSize.AddFlatModifier(stackSizeInput.Value);
                    }
                }
                else if (Mode == ApplyMode.Add)
                {
                    Buff buff = targetInput.Value.Buffs.Find(BuffToApply);

                    if (buff == null)
                    {
                        buff = new Buff(this, context);
                        targetInput.Value.Buffs.Add(buff);
                    }

                    if (refreshClock == null)
                    {
                        refreshClock = new BuffClockDecaying(this, context);
                        modifier     = refreshClock.StackSize.AddFlatModifier(stackSizeInput.Value);

                        buff.AddClock(refreshClock);

                        refreshClock.OnRemove += () =>
                        {
                            refreshClock = null;
                        };
                    }

                    refreshClock.StackSize.AddFlatModifier(stackSizeInput.Value);
                }
            };

            stackSizeInput.OnAfterChanged += () =>
            {
                if (Mode != ApplyMode.Refresh)
                {
                    return;
                }

                if (modifier != null)
                {
                    modifier.Value = stackSizeInput.Value;
                }
            };
        }