Esempio n. 1
0
        private bool CheckCondition(GVar _var, GVar _compareVar)
        {
            if (_var == null)
            {
                ACDebug.LogWarning("Cannot check state of variable since it cannot be found!");
                return(false);
            }

            if (_compareVar != null && _var != null && _compareVar.type != _var.type)
            {
                ACDebug.LogWarning("Cannot compare " + _var.label + " and " + _compareVar.label + " as they are not the same type!");
                return(false);
            }

            if (_var.type == VariableType.Boolean)
            {
                int fieldValue   = _var.val;
                int compareValue = (int)boolValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_var.type == VariableType.Integer || _var.type == VariableType.PopUp)
            {
                int fieldValue   = _var.val;
                int compareValue = intValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_var.type == VariableType.Float)
            {
                float fieldValue   = _var.floatVal;
                float compareValue = floatValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.floatVal;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_var.type == VariableType.String)
            {
                string fieldValue   = _var.textVal;
                string compareValue = AdvGame.ConvertTokens(stringValue);
                if (_compareVar != null)
                {
                    compareValue = _compareVar.textVal;
                }

                if (!checkCase)
                {
                    fieldValue   = fieldValue.ToLower();
                    compareValue = compareValue.ToLower();
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }