Exemplo n.º 1
0
        // Check to see if an integer meets certain conditions in an if statement
        // This is used by both If and Else If
        public int Execute(HeroKitObject hko)
        {
            // assign variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionID      = heroKitObject.heroStateData.action;
            int currentIndent = heroKitObject.heroState.heroEvent[eventID].actions[actionID].indent;

            // evaluate the if statement
            int  comparison = DropDownListValue.GetValue(heroKitObject, 2);
            int  value1     = IntegerFieldValue.GetValueB(heroKitObject, 1);
            int  value2     = DropDownListValue.GetValue(heroKitObject, 3);
            bool evaluation = HeroActionCommonRuntime.CompareValues(comparison, value1, value2);

            // next we need to get the action that we want the game loop to think just executed
            // this checks to see if the if statement should be run
            // if it should run, it disables the next conditional action if it is "Else" or "Else If"
            int thisAction = HeroActionCommonRuntime.RunConditionalIfAction(heroKitObject, eventID, actionID, currentIndent, evaluation);

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Result: " + evaluation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return the action that we want the game loop to think just executed
            return(thisAction);
        }
Exemplo n.º 2
0
        // Check to see if an integer meets certain conditions in an if statement
        // This is used by both If and Else If
        public int Execute(HeroKitObject hko)
        {
            // assign variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionID      = heroKitObject.heroStateData.action;
            int currentIndent = heroKitObject.heroState.heroEvent[eventID].actions[actionID].indent;
            int actionCount   = heroKitObject.heroState.heroEvent[eventID].actions.Count;
            int nextAction    = -99;

            // get the conditional action that follows this action in the if / if else / else / end sequence
            int nextConditionalAction = HeroActionCommonRuntime.GetNextConditionAction(heroKitObject, eventID, actionID, currentIndent);

            // evaluate the if statement
            int  comparison = DropDownListValue.GetValue(heroKitObject, 2);
            int  value1     = IntegerFieldValue.GetValueB(heroKitObject, 1);
            int  value2     = IntegerFieldValue.GetValueA(heroKitObject, 3);
            bool evaluation = HeroActionCommonRuntime.CompareIntegers(comparison, value1, value2);

            // if there are no actions inside a do while loop, show error message and break out of loop
            if (actionID == nextConditionalAction)
            {
                Debug.LogWarning("Loop has no actions! Breaking out of loop early.");
                heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionFields[0].bools[0] = false;
                return(-99);
            }

            // if the conditional action that follows is an End Do While, we need to set a value.
            if (nextConditionalAction != -99)
            {
                if (heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionTemplate.name == "End Do While")
                {
                    // Was beginning of do while a success? Assign this to the End Do While action.
                    heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionFields[0].bools[0] = evaluation;

                    // if sucess was true, what is the id assigned to beginning of do while?
                    heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionFields[0].ints[0] = actionID;
                }
            }

            // if evaluation is false, go to end of loop.
            if (!evaluation)
            {
                nextAction = nextConditionalAction;
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = heroKitObject.heroState.heroEvent[eventID].actions[actionID].name + " = " + evaluation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return the action that we want the game loop to think just executed
            return(nextAction);
        }
Exemplo n.º 3
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            int intA      = IntegerFieldValue.GetValueB(heroKitObject, 1);
            int intB      = IntegerFieldValue.GetValueA(heroKitObject, 3);
            int operation = DropDownListValue.GetValue(heroKitObject, 2);
            int result    = HeroActionCommonRuntime.PerformMathOnIntegers(operation, intA, intB);

            IntegerFieldValue.SetValueB(heroKitObject, 1, result);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "A: " + intA + "\n" +
                                      "B: " + intB + "\n" +
                                      "Result (A): " + result;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }