Exemplo n.º 1
0
    void Start()
    {
        miniGame = false;

        miniGamesController = transform.parent.GetComponent <MiniGamesController>();
        miniGamesController.SetDialogAndNamePanelMiniGame(false);
        miniGamesController.SetCharactersMiniGame(false);

        Transform answerOptions = transform.GetChild(1).GetChild(0);

        AnswerOptions = new Image[answerOptions.childCount];

        for (int i = 0; i < AnswerOptions.Length; i++)
        {
            AnswerOptions[i] = answerOptions.GetChild(i).GetComponent <Image>();
        }

        CurShadow = transform.GetChild(1).GetChild(1).GetComponent <Image>();

        TextAsset   shadowGames = Resources.Load <TextAsset>("Text/ShadowGames");
        XmlDocument xDoc        = new XmlDocument();

        xDoc.LoadXml(shadowGames.text);
        XmlElement root = xDoc.DocumentElement;

        XmlNodeList answers = root.ChildNodes.Item(0).LastChild.ChildNodes;

        Answers = new string[answers.Count];

        for (int i = 0; i < Answers.Length; i++)
        {
            Answers[i] = answers.Item(i).Attributes["name"].Value;
        }

        rounds = new Dictionary <string, XmlNode>();

        XmlNodeList roundsNodeList = root.ChildNodes.Item(0).FirstChild.ChildNodes;

        foreach (XmlNode round in roundsNodeList)
        {
            rounds.Add(round.Name, round);
        }

        StartCoroutine(IEShowGameElements(transform));

        StartRound();

        StartCoroutine(IEShowGameElements(transform.GetChild(1), 2f));
    }
Exemplo n.º 2
0
    void Start()
    {
        controllerSoundButton = FindObjectOfType <ControllerSoundButton>();

        musicController = FindObjectOfType <MusicController>();

        miniGamesController = transform.parent.GetComponent <MiniGamesController>();
        miniGamesController.SetDialogAndNamePanelMiniGame(false);

        currentNumberGame = miniGamesController.CurrentNumberGame;

        miniGame    = false;
        timerActive = false;

        CurRoundNum               = 0;
        CurArrowNum               = 0;
        CountErrorsIngredients    = 0;
        MaxCountErrorsIngredients = 3;

        Timer         = transform.GetChild(1).GetChild(1).GetComponent <Text>();
        CurIngredient = transform.GetChild(0).GetChild(3).GetComponent <Image>();

        Bubbles = transform.GetChild(0).GetChild(1).GetComponent <Animator>();

        TimerAnimation = transform.GetChild(0).GetChild(2).GetComponent <Animator>();

        SkipMiniGameButton = transform.GetChild(1).GetChild(5).gameObject;

        SkipMiniGameButton.GetComponent <Image>().sprite = Resources.Load <Sprite>("Images/MiniGames/PotionMaker/Sprites/Interface/Skip_" + Singleton <ToolBox> .Instance.GameLanguage);

        Transform arrows = transform.GetChild(1).GetChild(3);

        Arrows = new Image[arrows.childCount];

        for (int i = 0; i < Arrows.Length; i++)
        {
            Arrows[i] = arrows.GetChild(i).GetComponent <Image>();
        }

        Transform ingredients = transform.GetChild(1).GetChild(4);

        Ingredients = new GameObject[ingredients.childCount];

        for (int i = 0; i < Ingredients.Length; i++)
        {
            Ingredients[i] = ingredients.GetChild(i).gameObject;
        }

        CountIngredients = Ingredients.Length;

        TextAsset   potionMaker = Resources.Load <TextAsset>("Text/PotionMaker");
        XmlDocument xDoc        = new XmlDocument();

        xDoc.LoadXml(potionMaker.text);

        XmlNodeList ingredientsNodeList = xDoc.DocumentElement.ChildNodes.Item(currentNumberGame).ChildNodes.Item(1).ChildNodes;

        string nameIngredient;

        for (int i = 0; i < Ingredients.Length; i++)
        {
            nameIngredient = ingredientsNodeList.Item(i).Attributes["name"].Value;
            Ingredients[i].transform.GetChild(0).GetComponent <Image>().sprite =
                Resources.Load <Sprite>("Images/Inventory/" + nameIngredient);
        }

        rounds = new Dictionary <string, XmlNode>();

        XmlNodeList roundsNodeList = xDoc.DocumentElement.ChildNodes.Item(currentNumberGame).ChildNodes.Item(0).ChildNodes;

        foreach (XmlNode round in roundsNodeList)
        {
            rounds.Add(round.Name, round);
        }

        if (Singleton <GameState> .Instance.miniGame != "PotionMaker")
        {
            Singleton <GameState> .Instance.miniGame = "PotionMaker";
        }
        else
        {
            SkipMiniGameButton.SetActive(true);
        }

        musicController.LoadSound("BoilingCauldron");

        StartCoroutine(IEContinueMiniGame());
    }