示例#1
0
        public static bool CheckGameValues(string debugName, GameValuesContainer container, GameValueCheck[] checks)
        {
            if (container == null)
            {
                Debug.LogError(debugName + " doesnt have an attached GameValuesContainer!");
                return(false);
            }
            bool checksOK = true;

            for (int i = 0; i < checks.Length; i++)
            {
                GameValue gv = container.GetGameValueObject(checks[i].name);
                if (gv == null)
                {
                    checksOK = false;
                }
                else
                {
                    if (gv.useBaseModifiers != checks[i].useBaseModifiers)
                    {
                        Debug.LogError(debugName + " Needs Game Value Named '" + checks[i].name + "' To " + (checks[i].useBaseModifiers ? "" : "Not") + " Use Base Modifiers");
                        checksOK = false;
                    }
                    if (gv.isRangedValue != checks[i].isRangedValue)
                    {
                        Debug.LogError(debugName + " Needs Game Value Named '" + checks[i].name + "' To " + (checks[i].isRangedValue ? "" : "Not") + " Be A Ranged Value");
                        checksOK = false;
                    }
                }
            }
            return(checksOK);
        }
示例#2
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));
        }
示例#3
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);
        }
示例#4
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);
                }
            }
        }
示例#5
0
        void OnPlayerCreate()
        {
            OnPlayerDestroy();

            container = DynamicObject.playerObject.GetObjectScript <GameValuesContainer>();

            if (useRewards)
            {
                if (GameValueChecker.CheckGameValues(name, container, new GameValueCheck[] {
                    new GameValueCheck(pointsName, false, false),
                    new GameValueCheck(levelName, false, false),
                    new GameValueCheck(highestLevelName, false, false),
                    new GameValueCheck(rewardName, false, false),
                }))
                {
                    levelV        = container.GetGameValueObject(levelName);
                    pointsV       = container.GetGameValueObject(pointsName);
                    highestLevelV = container.GetGameValueObject(highestLevelName);
                    rewardsV      = container.GetGameValueObject(rewardName);

                    pointsV.AddChangeListener(OnPointsChange, false);
                    levelV.AddChangeListener(OnLevelChange, false);
                    highestLevelV.AddChangeListener(OnHighestLevelChange, false);
                }
            }
            else
            {
                if (GameValueChecker.CheckGameValues(name, container, new GameValueCheck[] {
                    new GameValueCheck(pointsName, false, false),
                    new GameValueCheck(levelName, false, false),
                }))
                {
                    levelV  = container.GetGameValueObject(levelName);
                    pointsV = container.GetGameValueObject(pointsName);

                    pointsV.AddChangeListener(OnPointsChange, false);
                    levelV.AddChangeListener(OnLevelChange, false);
                }
            }
        }