Example #1
0
        public static void GetSpawnOptionsForObject(DynamicObject obj, out bool ground, out bool navigate, out bool unIntersect)
        {
            // jsut true if player object has colliders...
            ground      = !obj.isPlayer;
            unIntersect = !obj.isPlayer;

            navigate = obj.GetObjectScript <NavMeshAgent>() != null;
        }
Example #2
0
 protected override void OnEffectUpdate(DynamicObject caster, DynamicObject target, float deltaTime, float timeAdded, float currentTime, float magnitude, float duration, out bool removeEffect)
 {
     removeEffect = false;
     if (byTime)
     {
         target.GetObjectScript <GameValuesContainer>().ModifyValue(valueName, componentToModify, behavior, magnitude * deltaTime);
     }
 }
Example #3
0
        protected override bool OnEffectStart(DynamicObject caster, DynamicObject affectedObject, float magnitude, float duration)
        {
            GameValuesContainer container = affectedObject.GetObjectScript <GameValuesContainer>();

            if (byTime)
            {
                return(true);
            }
            return(container.ModifyValue(valueName, componentToModify, behavior, magnitude));
        }
Example #4
0
        protected override bool EffectValid(DynamicObject caster, DynamicObject affectedObject)
        {
            GameValuesContainer container = affectedObject.GetObjectScript <GameValuesContainer>();

            if (container == null)
            {
                return(false);
            }

            // if the user wants to be affected by delta time
            if (byTime)
            {
                // return true if we can actually modify based on delta time, if we not, we dont do anything
                return(usesDeltaTime);
            }

            return(true);
        }
Example #5
0
        public override void OnEffectRemove(DynamicObject caster, DynamicObject target, float magnitude, float duration)
        {
            if (byTime)
            {
                return;
            }

            GameValuesContainer container = target.GetObjectScript <GameValuesContainer>();

            if (container != null)
            {
                if (behavior == GameValueModifierBehavior.Multiply)
                {
                    container.ModifyValue(valueName, componentToModify, behavior, 1f / magnitude);
                }
                else if (behavior == GameValueModifierBehavior.Add)
                {
                    container.ModifyValue(valueName, componentToModify, behavior, -magnitude);
                }
            }
        }
 protected override bool OnEffectStart(DynamicObject caster, DynamicObject obj, float magnitude, float duration)
 {
     obj.GetObjectScript <GameEffectsHandler>().RemoveEffects(keywords);
     return(true);
 }
 protected override bool EffectValid(DynamicObject caster, DynamicObject obj)
 {
     return(obj.GetObjectScript <GameEffectsHandler>() != null);
 }
Example #8
0
        public static void TriggerEffects(GameEffectCollection effects, DynamicObject caster, Vector3 pos, DynamicObject obj, bool isCast, bool isFromRadiusRecast = false)
        {
            ModifierEntryPoints casterEntryPoints = null;

            if (caster != null)
            {
                casterEntryPoints = caster.GetObjectScript <ModifierEntryPoints>();
            }

            EffectContext context = isCast ? effects.cast : effects.dispell;

            float radius = context.radius;

            if (!isFromRadiusRecast && radius > 0)
            {
                if (casterEntryPoints != null)
                {
                    radius = casterEntryPoints.ModifyValue("EffectRadius", radius, new Dictionary <string, object>()
                    {
                        { "Caster", caster }, { "EffectCollection", effects }
                    });
                }

                RetriggerEffectsForArea(effects, caster, pos, radius, context.mask, context.checkLOSOnRadiusCast, isCast);
                return;
            }

            if (obj == null)
            {
                return;
            }

            GameEffectsHandler targetEffectsHandler = obj.GetObjectScript <GameEffectsHandler>();

            if (targetEffectsHandler != null && targetEffectsHandler.IsAffectedBy(effects))
            {
                return;
            }

            Dictionary <string, object> epRunSubjects = new Dictionary <string, object>()
            {
                { "Caster", caster }, { "AffectedObject", obj }, { "EffectCollection", effects }, { "Effect", null }
            };
            Dictionary <string, object> runSubjects = new Dictionary <string, object>()
            {
                { "Caster", caster }, { "AffectedObject", obj }
            };

            List <GameEffect> effectsToHold = new List <GameEffect>();
            List <float>      magnitudes    = new List <float>();
            List <float>      durations     = new List <float>();

            for (int i = 0; i < context.effects.Length; i++)
            {
                GameEffectItem effectItem = context.effects[i];
                GameEffect     effect     = effectItem.effect;

                if (effect.PlayerOnly() && !obj.isPlayer)
                {
                    continue;
                }

                bool needsToBeAdded = effect.AddToEffectsList();

                if (needsToBeAdded)
                {
                    if (isCast)
                    {
                        if (targetEffectsHandler == null)
                        {
                            Debug.LogWarning("'" + obj.name + "' Doesnt have a GameEffectsHandler, and game effect '" + effect.name + " Needs To Be Kept In An Effect Handler List");
                            continue;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Game effect '" + effect.name + " Needs To Be Kept In An Effect Handler List, So It Cant Be Used As a Dispell Effect....");
                        continue;
                    }
                }
                if (!effect.EffectValid(caster, obj))
                {
                    continue;
                }

                if (!Conditions.ConditionsMet(effectItem.conditions, runSubjects))
                {
                    continue;
                }
                if (!Conditions.ConditionsMet(effect.conditions, runSubjects))
                {
                    continue;
                }

                float magnitude = effectItem.magnitude;
                float duration  = effectItem.duration;
                if (casterEntryPoints != null)
                {
                    epRunSubjects["Effect"] = effectItem.effect;
                    magnitude = casterEntryPoints.ModifyValue("EffectMagnitude", magnitude, epRunSubjects);
                    if (duration > 0)
                    {
                        duration = casterEntryPoints.ModifyValue("EffectDuration", duration, epRunSubjects);
                    }
                }


                /*
                 *  TODO: figure out garbage created by create copy
                 */
                // if dispell we should already be out by now if needsToBeAdded...
                if (needsToBeAdded && effect.CreateCopy())
                {
                    effect = Object.Instantiate(effect);
                }

                // in case there was a problem with the effect start
                // return out before we add the effect possibly
                if (!effect.OnEffectStart(caster, obj, magnitude, duration))
                {
                    continue;
                }

                if (needsToBeAdded)
                {
                    effectsToHold.Add(effect);
                    magnitudes.Add(magnitude);
                    durations.Add(duration);
                }
            }

            if (effectsToHold.Count > 0)
            {
                targetEffectsHandler.AddEffectsToList(effects, caster, effectsToHold, magnitudes, durations);
            }

            // TODO: choose scheme for msg...
            if (obj.isPlayer)
            {
                if (!string.IsNullOrEmpty(context.message))
                {
                    UIEvents.ShowMessage(0, context.message, false, UIColorScheme.Normal, false);
                }
            }
        }