Exemple #1
0
    //get true or false value if if
    public bool getValue()
    {
        if (ifType == Logic.NONE) //if there is no logic for this if
        {
            return(ifLHS.getValue());
        }

        if (compareValues == Variable.VariableType.BOOL)    //compare booleans
        {
            return(CompareBools());
        }
        else if (compareValues == Variable.VariableType.FLOAT) //compare float, int or vec3
        {
            if (lhs != "")
            {
                nbr_lhsvalue = LhsValue();
            }
            else if (mathLHS != null)
            {
                nbr_lhsvalue = mathLHS.Calculate();
            }

            if (rhs != "")
            {
                nbr_rhsvalue = RhsValue();
            }
            else if (mathRHS != null)
            {
                nbr_rhsvalue = mathRHS.Calculate();
            }

            return(CompareFloats(nbr_lhsvalue, nbr_rhsvalue));
        }
        else if (compareValues == Variable.VariableType.STRING)  //compare strings
        {
            if (lhs != "")
            {
                str_lhsvalue = Controller.allVars[Controller.currentZomb][lhs].str_value;
            }

            if (rhs != "")
            {
                str_rhsvalue = Controller.allVars[Controller.currentZomb][rhs].str_value;
            }

            switch (ifType)
            {
            case Logic.EQUAL:
                return(str_lhsvalue == str_rhsvalue);

            case Logic.NOT:
                return(str_lhsvalue != str_rhsvalue);
            }
        }

        //if all else fails to return anything return false
        return(false);
    }
Exemple #2
0
 //Coroutine to stop infinite loops
 public IEnumerator NotInfinite()
 {
     while (checkCase.getValue() && !Controller.stop) //while check case is true and the program is still running
     {
         //run the methods within the while loop
         checkCase.Compute();
         yield return(new WaitForEndOfFrame());
     }
 }
Exemple #3
0
    //helper method to compare bools
    private bool CompareBools()
    {
        //get lhs bool
        bool boolLHS = false;

        if (ifLHS != null)
        {
            boolLHS = ifLHS.getValue();
        }
        else if (lhs == "")
        {
            boolLHS = bl_lhsvalue;
        }
        else
        {
            boolLHS = Controller.allVars[Controller.currentZomb][lhs].bool_value;
        }

        //get rhs bool
        bool boolRHS = false;

        if (ifRHS != null)
        {
            boolRHS = ifRHS.getValue();
        }
        else if (rhs == "")
        {
            boolRHS = bl_rhsvalue;
        }
        else
        {
            boolRHS = Controller.allVars[Controller.currentZomb][rhs].bool_value;
        }

        //compare bools
        switch (ifType)
        {
        case Logic.AND:
            return(boolLHS && boolRHS);

        case Logic.EQUAL:
            return(boolLHS == boolRHS);

        case Logic.NOT:
            return(boolLHS != boolRHS);

        case Logic.OR:
            return(boolLHS || boolRHS);
        }
        return(false);
    }