예제 #1
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);
        }
예제 #2
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;
            }
        }
예제 #3
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);
        }