public void RemoveThisIf(VariableSet variableSet)
        {
            if (GameLevel == null)
            {
                return;
            }

            LevelVariable conditionVariable = variableSet.Variables[0];
            LevelVariable levelVariable     = GameLevel.GetVariable(conditionVariable.Name);

            if (levelVariable == null ||
                levelVariable.AsString() != conditionVariable.DataValue)
            {
                return;
            }

            HideCaption();

            AudioClip destroyAudio = conditionVariable.ObjectValue as AudioClip;

            if (destroyAudio != null)
            {
                PlayOneShotAudio(destroyAudio);
            }

            Destroy(this.gameObject);
        }
        public void SetVariable(string name, string value)
        {
            LevelVariable newVariable = new LevelVariable();

            newVariable.Name      = name;
            newVariable.DataValue = value;
            SetVariable(newVariable);
        }
        private IEnumerator EvaludateSleep(GameLevel gameLevel)
        {
            LevelVariable variable  = gameLevel.GetVariable(this.Arguments[0]);
            int           sleepTime = (variable != null)
                ? int.Parse(variable.DataValue)
                : int.Parse(this.Arguments[0]);

            yield return(new WaitForSeconds(sleepTime));
        }
        public void SetVariable(LevelVariable newVariable)
        {
            if (!this.variableLookup.ContainsKey(newVariable.Name))
            {
                this.variableLookup.Add(newVariable.Name, newVariable);
            }
            else
            {
                this.variableLookup[newVariable.Name] = newVariable;
            }

            UpdateLevelCode();
        }
        public void DecrementVariable(string variableName)
        {
            if (GameLevel == null)
            {
                return;
            }

            LevelVariable levelVariable = GameLevel.GetVariable(variableName);

            if (levelVariable != null && int.TryParse(levelVariable.DataValue, out int value))
            {
                levelVariable.DataValue = (value - 1).ToString();
                GameLevel.UpdateLevelCode();
            }
        }
Exemplo n.º 6
0
        public string ToString(GameLevel gameLevel, string forIterator = null)
        {
            string conditionVariable = forIterator != null
                                           ? forIterator
                                           : this.VariableName;
            string        valueString   = this.Value;
            LevelVariable valueVariable = gameLevel.GetVariable(this.Value);

            if (valueVariable != null)
            {
                valueString = valueVariable.Name;
            }

            return
                ($"{conditionVariable} {StringValueAttribute.StringEnum.GetStringValue(this.Is)} {valueString}");
        }
        private IEnumerator EvaluateAssignment(GameLevel gameLevel)
        {
            LevelVariable variable           = gameLevel.GetVariable(this.Arguments[0]);
            LevelVariable assignmentVariable = gameLevel.GetVariable(this.Arguments[1]);

            if (assignmentVariable != null)
            {
                variable.DataValue   = assignmentVariable.DataValue;
                variable.ObjectValue = assignmentVariable.ObjectValue;
            }
            else
            {
                variable.DataValue = this.Arguments[1];
            }

            yield return(null);
        }
        private IEnumerator EvaluateMethod(GameLevel gameLevel)
        {
            LevelVariable[] variables = new LevelVariable[this.Arguments.Length];
            for (int i = 0; i < variables.Length; i++)
            {
                variables[i] = gameLevel.GetVariable(this.Arguments[i]);
                if (variables[i] == null)
                {
                    variables[i]           = new LevelVariable();
                    variables[i].Name      = "argument";
                    variables[i].DataValue = this.Arguments[i];
                }
            }

            this.InvokeMethod.Invoke(variables);
            yield return(null);
        }
Exemplo n.º 9
0
        public bool ShouldContinue(GameLevel gameLevel, string leftValue = null)
        {
            // TODO: Shoddy for loop.
            if (this.VariableName == null)
            {
                return(false);
            }

            if (leftValue == null)
            {
                LevelVariable leftVariable = gameLevel.GetVariable(this.VariableName);
                if (leftVariable == null)
                {
                    return(false);
                }
                leftValue = leftVariable.AsString();
            }

            LevelVariable rightVariable = gameLevel.GetVariable(this.Value);
            string        rightValue    = rightVariable != null
                                    ? rightVariable.AsString()
                                    : this.Value;

            switch (this.Is)
            {
            case Evaluator.Equals:
                return(leftValue == rightValue);

            case Evaluator.LessThan:
                return(int.Parse(leftValue) < int.Parse(rightValue));

            case Evaluator.MoreThan:
                return(int.Parse(leftValue) > int.Parse(rightValue));

            case Evaluator.Not:
                return(leftValue != rightValue);
            }

            return(false);
        }
        public void IncrementVariable(string variableName)
        {
            if (GameLevel == null)
            {
                return;
            }

            LevelVariable levelVariable = GameLevel.GetVariable(variableName);

            if (levelVariable == null)
            {
                levelVariable           = new LevelVariable();
                levelVariable.Name      = variableName;
                levelVariable.DataValue = "1";
                GameLevel.SetVariable(levelVariable);
            }

            else if (int.TryParse(levelVariable.DataValue, out int value))
            {
                levelVariable.DataValue = (value + 1).ToString();
                GameLevel.UpdateLevelCode();
            }
        }
        public void ContinueRitualSummoning()
        {
            if (GameLevel == null)
            {
                return;
            }

            LevelVariable levelVariable = GameLevel.GetVariable("summoningProgress");

            if (levelVariable == null)
            {
                levelVariable           = new LevelVariable();
                levelVariable.Name      = "summoningProgress";
                levelVariable.DataValue = "1";
                GameLevel.SetVariable(levelVariable);
            }

            else if (int.TryParse(levelVariable.DataValue, out int value))
            {
                levelVariable.DataValue = (value + 1).ToString();
                GameLevel.UpdateLevelCode();
            }
        }