/// <summary> /// Setup /// </summary> protected void Start() { GameConditionHelper.InitialiseGameConditions(_conditionReferences); GameActionHelper.InitialiseGameActions(_actionReferencesConditionMet); GameActionHelper.InitialiseGameActions(_actionReferencesConditionNotMet); GameConditionHelper.AddListeners(_conditionReferences, EvaluateConditionChanges); RunMethod(true); }
/// <summary> /// Evaluate the current condition /// </summary> /// <returns></returns> public override bool EvaluateCondition(MonoBehaviour monoBehaviour) { var gameItem = GameItem; if (gameItem) { return(GameConditionHelper.CompareNumbers(GameItem.Score, Comparison, Value)); } return(false); }
/// <summary> /// Evaluate the current condition /// </summary> /// <returns></returns> public override bool Evaluate() { var gameItem = GameItem; if (gameItem) { return(GameConditionHelper.CompareNumbers(GameItem.Coins, Comparison, Value)); } return(false); }
/// <summary> /// Called by the base class from start and optionally if a condition might have changed. /// </summary> /// <param name="isStart"></param> public void RunMethod(bool isStart = true) { var newIsConditionMet = GameConditionHelper.AllConditionsMet(_conditionReferences, this); if (isStart || newIsConditionMet != _isConditionMet) { _isConditionMet = newIsConditionMet; if (_isConditionMet) { GameActionHelper.PerformActions(_actionReferencesConditionMet, this); } else { GameActionHelper.PerformActions(_actionReferencesConditionNotMet, this); } } }
/// <summary> /// Evaluate the current condition /// </summary> /// <returns></returns> public override bool EvaluateCondition(MonoBehaviour monoBehaviour) { var gameItem = GameItem; if (gameItem) { var counterReference = GameItem.GetCounter(Counter); Assert.IsNotNull(counterReference, string.Format("The specified Counter '{0}' was not found. Check that is exists in the game configuration.", Counter)); if (counterReference.Configuration.CounterType == ObjectModel.CounterConfiguration.CounterTypeEnum.Int) { return(GameConditionHelper.CompareNumbers(counterReference.IntAmount, Comparison, IntAmount)); } else { return(GameConditionHelper.CompareNumbers(counterReference.FloatAmount, Comparison, FloatAmount)); } } return(false); }
/// <summary> /// Evaluate the current condition /// </summary> /// <returns></returns> public override bool Evaluate() { Assert.IsTrue(GameManager.IsActive, "To use the Game Stars Total Condition, ensure that you have a GameManager added to your scene."); return(GameConditionHelper.CompareNumbers(GameManager.Instance.StarsTotal, Comparison, Value)); }
/// <summary> /// Destroy /// </summary> protected void OnDestroy() { GameConditionHelper.RemoveListeners(_conditionReferences, EvaluateConditionChanges); }
/// <summary> /// Evaluate the current condition /// </summary> /// <returns></returns> public override bool Evaluate() { Assert.IsTrue(GameManager.IsActive, "To use the Player Score Condition, ensure that you have a GameManager added to your scene."); Assert.IsNotNull(GameManager.Instance.Players, "To use the Player Score Game Condition, ensure that you have configured Players to be setup in your scene."); return(GameConditionHelper.CompareNumbers(GameManager.Instance.Players.Selected.Score, Comparison, Value)); }
/// <summary> /// Evaluate the current condition /// </summary> /// <returns></returns> public override bool EvaluateCondition(MonoBehaviour monoBehaviour) { Assert.IsTrue(GameManager.IsActive, "To use the Level Coins Condition, ensure that you have a GameManager added to your scene."); Assert.IsNotNull(GameManager.Instance.Levels, "To use the Level Coins Game Condition, ensure that you have configured Levels to be setup in your scene."); return(GameConditionHelper.CompareNumbers(GameManager.Instance.Levels.Selected.Coins, Comparison, Value)); }