コード例 #1
0
ファイル: DialoguerUtils.cs プロジェクト: chickenlegs0/Luka
        private static string substituteStringVariable(string input, VariableEditorScopes scope, VariableEditorTypes type, int dialogueId)
        {
            string output = string.Empty;

            string[] subStartString = new string[] { "<" + scopeStrings[scope] + typeStrings[type] + ">" };
            string[] subEndString   = new string[] { "</" + scopeStrings[scope] + typeStrings[type] + ">" };


            //char[] subStartChars = new char[4]{'<',scopeStrings[scope],typeStrings[type],'>'};
            //char[] subEndChars = new char[5]{'<','/',scopeStrings[scope],typeStrings[type],'>'};

            //Debug.Log ("[DialoguerUtils] startString: "+string.Join("",subStartString)+" - endString: "+string.Join("",subEndString));

            string[] pieces = input.Split(subStartString, StringSplitOptions.None);

            //Debug.Log ("[DialoguerUtils] pieces count: "+pieces.Length+" - (should be 2)");

            for (int i = 0; i < pieces.Length; i += 1)
            {
                string[] subPieces = pieces[i].Split(subEndString, StringSplitOptions.None);

                //Debug.Log("[DialoguerUtils] subPieces[0] = "+subPieces[0]);

                int  variableId;
                bool success = int.TryParse(subPieces[0], out variableId);
                if (success)
                {
                    switch (scope)
                    {
                    case VariableEditorScopes.Global:
                        switch (type)
                        {
                        case VariableEditorTypes.Boolean:
                            subPieces[0] = Dialoguer.GetGlobalBoolean(variableId).ToString();
                            break;

                        case VariableEditorTypes.Float:
                            subPieces[0] = Dialoguer.GetGlobalFloat(variableId).ToString();
                            break;

                        case VariableEditorTypes.String:
                            subPieces[0] = Dialoguer.GetGlobalString(variableId);
                            break;
                        }
                        break;

                    case VariableEditorScopes.Local:
                        Debug.Log("Local Variable string substitutions not yet supported");
                        switch (type)
                        {
                        case VariableEditorTypes.Boolean:

                            break;

                        case VariableEditorTypes.Float:

                            break;

                        case VariableEditorTypes.String:

                            break;
                        }
                        break;
                    }
                }
                else
                {
                    //subPieces[0] = "_invalid_variable_id_";
                }

                output += string.Join("", subPieces);
            }

            return(output);
        }
コード例 #2
0
        protected override void onStart()
        {
            bool success = false;

            switch (type)
            {
            case VariableEditorTypes.Boolean:
                success = bool.TryParse(setValue, out _setBool);
                switch (equation)
                {
                case VariableEditorSetEquation.Equals:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.booleans[variableId] = _setBool;
                    }
                    else
                    {
                        Dialoguer.SetGlobalBoolean(variableId, _setBool);
                    }
                    break;

                case VariableEditorSetEquation.Toggle:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.booleans[variableId] = !_localVariables.booleans[variableId];
                    }
                    else
                    {
                        Dialoguer.SetGlobalBoolean(variableId, !Dialoguer.GetGlobalBoolean(variableId));
                    }
                    success = true;
                    break;
                }
                break;

            case VariableEditorTypes.Float:
                success = float.TryParse(setValue, out _setFloat);
                switch (equation)
                {
                case VariableEditorSetEquation.Equals:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.floats[variableId] = _setFloat;
                    }
                    else
                    {
                        Dialoguer.SetGlobalFloat(variableId, _setFloat);
                    }
                    break;

                case VariableEditorSetEquation.Add:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.floats[variableId] += _setFloat;
                    }
                    else
                    {
                        Dialoguer.SetGlobalFloat(variableId, Dialoguer.GetGlobalFloat(variableId) + _setFloat);
                    }
                    break;

                case VariableEditorSetEquation.Subtract:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.floats[variableId] -= _setFloat;
                    }
                    else
                    {
                        Dialoguer.SetGlobalFloat(variableId, Dialoguer.GetGlobalFloat(variableId) - _setFloat);
                    }
                    break;

                case VariableEditorSetEquation.Multiply:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.floats[variableId] *= _setFloat;
                    }
                    else
                    {
                        Dialoguer.SetGlobalFloat(variableId, Dialoguer.GetGlobalFloat(variableId) * _setFloat);
                    }
                    break;

                case VariableEditorSetEquation.Divide:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.floats[variableId] /= _setFloat;
                    }
                    else
                    {
                        Dialoguer.SetGlobalFloat(variableId, Dialoguer.GetGlobalFloat(variableId) / _setFloat);
                    }
                    break;
                }
                break;

            case VariableEditorTypes.String:
                success    = true;
                _setString = setValue;
                switch (equation)
                {
                case VariableEditorSetEquation.Equals:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.strings[variableId] = _setString;
                    }
                    else
                    {
                        Dialoguer.SetGlobalString(variableId, _setString);
                    }
                    break;

                case VariableEditorSetEquation.Add:
                    if (scope == VariableEditorScopes.Local)
                    {
                        _localVariables.strings[variableId] += _setString;
                    }
                    else
                    {
                        Dialoguer.SetGlobalString(variableId, Dialoguer.GetGlobalString(variableId) + _setString);
                    }
                    break;
                }
                break;
            }

            if (!success)
            {
                Debug.LogWarning("[SetVariablePhase] Could not parse setValue");
            }

            Continue(0);
            state = PhaseState.Complete;
        }
コード例 #3
0
        protected override void onStart()
        {
            bool success = true;

            switch (type)
            {
            case VariableEditorTypes.Boolean:
                success = bool.TryParse(getValue, out _parsedBool);
                if (!success)
                {
                    Debug.LogError("[ConditionalPhase] Could Not Parse Bool: " + getValue);
                }
                if (scope == VariableEditorScopes.Local)
                {
                    _checkBool = _localVariables.booleans[variableId];
                }
                else
                {
                    _checkBool = Dialoguer.GetGlobalBoolean(variableId);
                }
                break;

            case VariableEditorTypes.Float:
                success = float.TryParse(getValue, out _parsedFloat);
                if (!success)
                {
                    Debug.LogError("[ConditionalPhase] Could Not Parse Float: " + getValue);
                }
                if (scope == VariableEditorScopes.Local)
                {
                    _checkFloat = _localVariables.floats[variableId];
                }
                else
                {
                    _checkFloat = Dialoguer.GetGlobalFloat(variableId);
                }
                break;

            case VariableEditorTypes.String:
                _parsedString = getValue;
                if (scope == VariableEditorScopes.Local)
                {
                    _checkString = _localVariables.strings[variableId];
                }
                else
                {
                    _checkString = Dialoguer.GetGlobalString(variableId);
                }
                break;
            }

            bool isTrue = false;

            switch (type)
            {
            case VariableEditorTypes.Boolean:
                switch (equation)
                {
                case VariableEditorGetEquation.Equals:
                    if (_parsedBool == _checkBool)
                    {
                        isTrue = true;
                    }
                    break;

                case VariableEditorGetEquation.NotEquals:
                    if (_parsedBool != _checkBool)
                    {
                        isTrue = true;
                    }
                    break;
                }
                break;

            case VariableEditorTypes.Float:
                switch (equation)
                {
                case VariableEditorGetEquation.Equals:
                    if (_checkFloat == _parsedFloat)
                    {
                        isTrue = true;
                    }
                    break;

                case VariableEditorGetEquation.NotEquals:
                    if (_checkFloat != _parsedFloat)
                    {
                        isTrue = true;
                    }
                    break;

                case VariableEditorGetEquation.EqualOrGreaterThan:
                    if (_checkFloat >= _parsedFloat)
                    {
                        isTrue = true;
                    }
                    break;

                case VariableEditorGetEquation.EqualOrLessThan:
                    if (_checkFloat <= _parsedFloat)
                    {
                        isTrue = true;
                    }
                    break;

                case VariableEditorGetEquation.GreaterThan:
                    if (_checkFloat > _parsedFloat)
                    {
                        isTrue = true;
                    }
                    //Debug.Log ("[ConditionalPhase] " +_checkFloat+" > "+_parsedFloat+" = "+isTrue);
                    break;

                case VariableEditorGetEquation.LessThan:
                    if (_checkFloat < _parsedFloat)
                    {
                        isTrue = true;
                    }
                    break;
                }
                break;

            case VariableEditorTypes.String:
                switch (equation)
                {
                case VariableEditorGetEquation.Equals:
                    if (_parsedString == _checkString)
                    {
                        isTrue = true;
                    }
                    break;

                case VariableEditorGetEquation.NotEquals:
                    if (_parsedString != _checkString)
                    {
                        isTrue = true;
                    }
                    break;
                }
                break;
            }

            if (isTrue)
            {
                //Debug.Log ("[ConditionalPhase] Continue 0");
                Continue(0);
            }
            else
            {
                //Debug.Log ("[ConditionalPhase] Continue 1");
                Continue(1);
            }

            state = PhaseState.Complete;
        }
コード例 #4
0
 // Update is called once per frame
 void Update()
 {
     a.SetFloat(varName, Dialoguer.GetGlobalFloat(2));
 }