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);
        }
Exemple #2
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);
        }