Exemple #1
0
        public int CountForInspector() => booleans.CountForInspector() + ints.CountForInspector();// + enumTags.CountForInspector + boolTags.CountForInspector;

        public virtual bool Inspect()
        {
            var changed = false;

            if (Application.isPlaying && icon.Refresh.Click("Add 1 to logic version (will cause conditions to be reevaluated)"))
            {
                LogicMGMT.AddLogicVersion();
            }

            pegi.nl();

            foreach (var bGr in booleans)
            {
                var group = TriggerGroup.all[booleans.currentEnumerationIndex];
                foreach (var b in bGr)
                {
                    group[b].Inspect_AsInList().nl(ref changed);
                }
            }

            foreach (var iGr in ints)
            {
                var group = TriggerGroup.all[ints.currentEnumerationIndex];
                foreach (var i in iGr)
                {
                    group[iGr.currentEnumerationIndex].Inspect_AsInList().nl(ref changed);
                }
            }


            return(changed);
        }
Exemple #2
0
        public override bool TryForceConditionValue(Values value, bool toTrue)
        {
            if (TestFor(value) == toTrue)
            {
                return(true);
            }

            if (toTrue)
            {
                switch (type)
                {
                case ConditionType.Above:                   SetInt(value, compareValue + 1);                                                break;

                case ConditionType.Below:                   SetInt(value, compareValue - 1);                                                break;

                case ConditionType.Equals:                  SetInt(value, compareValue);                                                    break;

                case ConditionType.NotEquals:               if (GetInt(value) == compareValue)
                    {
                        value.ints[groupIndex].Add(triggerIndex, 1);
                    }
                    break;

                case ConditionType.RealTimePassedAbove:     SetInt(value, LogicMGMT.RealTimeNow() - compareValue - 1);                      break;

                case ConditionType.RealTimePassedBelow:     SetInt(value, LogicMGMT.RealTimeNow());                                         break;

                case ConditionType.VirtualTimePassedAbove:  SetInt(value, (int)Time.time - compareValue - 1);                               break;

                case ConditionType.VirtualTimePassedBelow:  SetInt(value, (int)Time.time);                                                  break;
                }
            }
            else
            {
                switch (type)
                {
                case ConditionType.Above:                   SetInt(value, compareValue - 1);                                                break;

                case ConditionType.Below:                   SetInt(value, compareValue + 1);                                                break;

                case ConditionType.Equals:                  SetInt(value, compareValue + 1);                                                break;

                case ConditionType.NotEquals:               SetInt(value, compareValue);                                                    break;

                case ConditionType.RealTimePassedAbove:     SetInt(value, LogicMGMT.RealTimeNow());                                         break;

                case ConditionType.RealTimePassedBelow:     SetInt(value, LogicMGMT.RealTimeNow() - compareValue - 1);                      break;

                case ConditionType.VirtualTimePassedAbove:  SetInt(value, (int)Time.time);                                                 break;

                case ConditionType.VirtualTimePassedBelow:  SetInt(value, (int)Time.time - compareValue - 1);                               break;
                }
            }

            LogicMGMT.AddLogicVersion();

            return(true);
        }
Exemple #3
0
        public static void Apply(this List <Result> results, Values to)
        {
            if (results.Count <= 0)
            {
                return;
            }

            foreach (var r in results)
            {
                r.Apply(to);
            }

            LogicMGMT.AddLogicVersion();
        }
Exemple #4
0
        public static void Apply(this ResultType type, int updateValue, ValueIndex dest, Values so)
        {
            switch (type)
            {
            case ResultType.SetBool:        dest.SetBool(so, (updateValue > 0));                                break;

            case ResultType.Set:            dest.SetInt(so, updateValue);                                       break;

            case ResultType.Add:            so.ints[dest.groupIndex].Add(dest.triggerIndex, updateValue);       break;

            case ResultType.Subtract:       so.ints[dest.groupIndex].Add(dest.triggerIndex, -updateValue);      break;

            case ResultType.SetTimeReal:    dest.SetInt(so, LogicMGMT.RealTimeNow());                           break;

            case ResultType.SetTimeGame:    dest.SetInt(so, (int)Time.time);                                    break;
                //   case ResultType.SetTagBool:     so.SetTagBool(dest.groupIndex, dest.triggerIndex, updateValue > 0); break;
                //   case ResultType.SetTagInt:      so.SetTagEnum(dest.groupIndex, dest.triggerIndex, updateValue);     break;
            }
        }
Exemple #5
0
 public virtual void OnEnable() => instLogicMgmt = this;
Exemple #6
0
 public override bool TryForceConditionValue(Values values, bool toTrue)
 {
     SetBool(values, toTrue ? compareValue : !compareValue);
     LogicMGMT.AddLogicVersion();
     return(true);
 }
Exemple #7
0
        public override bool TestFor(Values st)
        {
            int timeGap;

            switch (type)
            {
            case ConditionType.Above:                   if (GetInt(st) > compareValue)
                {
                    return(true);
                }
                break;

            case ConditionType.Below:                   if (GetInt(st) < compareValue)
                {
                    return(true);
                }
                break;

            case ConditionType.Equals:                  if (GetInt(st) == compareValue)
                {
                    return(true);
                }
                break;

            case ConditionType.NotEquals:               if (GetInt(st) != compareValue)
                {
                    return(true);
                }
                break;

            case ConditionType.VirtualTimePassedAbove:
                timeGap = (int)Time.time - GetInt(st);
                if (timeGap > compareValue)
                {
                    return(true);
                }
                LogicMGMT.instLogicMgmt.AddTimeListener(compareValue - timeGap);         break;

            case ConditionType.VirtualTimePassedBelow:
                timeGap = (int)Time.time - GetInt(st);
                if (timeGap < compareValue)
                {
                    LogicMGMT.instLogicMgmt.AddTimeListener(compareValue - timeGap);
                    return(true);
                }
                break;

            case ConditionType.RealTimePassedAbove:
                timeGap = (LogicMGMT.RealTimeNow() - GetInt(st));
                if (timeGap > compareValue)
                {
                    return(true);
                }
                LogicMGMT.instLogicMgmt.AddTimeListener(compareValue - timeGap);     break;

            case ConditionType.RealTimePassedBelow:
                timeGap = (LogicMGMT.RealTimeNow() - GetInt(st));
                if (timeGap < compareValue)
                {
                    LogicMGMT.instLogicMgmt.AddTimeListener(compareValue - timeGap);
                    return(true);
                }
                break;
            }
            return(false);
        }