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); }
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)); }
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); }
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); } } }
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); } } }