Exemplo n.º 1
0
    public void HandleNode(EventNode node)
    {
        currentNode = node;

        if (node.GetType() == typeof(ImageNode))
        {
            imageHandler.DisplayImage((ImageNode)node);
        }
        else if (node.GetType() == typeof(TextNode))
        {
            textWriter.WriteText((TextNode)node);
            soundHandler.PlayVoice((TextNode)node);
        }
        else if (node.GetType() == typeof(LucidityAddNode))
        {
            int currentLucidity = PlayerPrefs.GetInt("Lucidity");
            PlayerPrefs.SetInt("Lucidity", currentLucidity + ((LucidityAddNode)node).amount);
        }
        else if (node.GetType() == typeof(SetVariableNode))
        {
            int currentLucidity = 0;

            string variable = ((SetVariableNode)node).variableName;

            if (((SetVariableNode)node).incrementation)
            {
                currentLucidity = PlayerPrefs.GetInt(variable);
            }

            PlayerPrefs.SetInt(variable, currentLucidity + ((SetVariableNode)node).amount);
        }
        else if (node.GetType() == typeof(WaitNode))
        {
            StartCoroutine(StartWait(((WaitNode)node).delay));
        }
        else if (node.GetType() == typeof(FadeNode))
        {
            if (((FadeNode)node).startFade)
            {
                fader.StartFade((FadeNode)node);
            }
            else
            {
                fader.StopFade((FadeNode)node);
            }
        }
        else if (node.GetType() == typeof(ChoiceNode))
        {
            choiceHandler.DisplayChoices((ChoiceNode)node);
        }
        else if (node.GetType() == typeof(DestroyNode))
        {
            if (((DestroyNode)node).isImage)
            {
                imageHandler.DestroyImage(((DestroyNode)node).toDestroyName);
            }
            else
            {
                imageHandler.DestroyObject(((DestroyNode)node).toDestroyName);
            }
        }
        else if (node.GetType() == typeof(ConditionNode))
        {
            EvaluateCondition((ConditionNode)node);
        }
        else if (node.GetType() == typeof(AnimationNode))
        {
            imageHandler.AnimateImage((AnimationNode)node);
        }
        else if (node.GetType() == typeof(PlaySoundNode))
        {
            soundHandler.PlaySound((PlaySoundNode)node);
        }
        else if (node.GetType() == typeof(StopSoundNode))
        {
            soundHandler.StopSound((StopSoundNode)node);
        }
        else if (node.GetType() == typeof(GameObjectNode))
        {
            imageHandler.InstantiateObject((GameObjectNode)node);
        }
    }