Ejemplo n.º 1
0
    public void Change_screen(GameObject target, bool isMenu)
    {
        current_screen.SetActive(true);

        if (!isMenu)
        {
            if (current_screen.GetComponent <Screen_script>().order < target.GetComponent <Screen_script>().order)
            {
                current_screen.GetComponent <Animator>().Play("Screen_to_inactive_left_anim");
            }

            else if (current_screen.GetComponent <Screen_script>().order > target.GetComponent <Screen_script>().order)
            {
                current_screen.GetComponent <Animator>().Play("Screen_to_inactive_right_anim");
            }
        }

        closeOpenedWindows();


        target.SetActive(true);

        if (isMenu)
        {
            current_screen.GetComponent <Animator>().Play("Screen_to_inactive_left_anim");
            target.GetComponent <Animator>().Play("Screen_to_active_right_anim");
        }

        if (current_screen.GetComponent <Screen_script>().order < target.GetComponent <Screen_script>().order)
        {
            target.GetComponent <Animator>().Play("Screen_to_active_left_anim");
        }
        else if (current_screen.GetComponent <Screen_script>().order > target.GetComponent <Screen_script>().order)
        {
            target.GetComponent <Animator>().Play("Screen_to_active_right_anim");
        }

        current_screen = target;

        navigationBarVisibility();



        if (current_screen == GameObject.Find("Main_screen"))
        {
            //isNewCharacter = true;
        }
        else if (current_screen == GameObject.Find("Character_customization_screen"))
        {
            //GameObject.Find("Customization_controller").GetComponent<Character_customization_script>().initializeCustomization(isNewCharacter);
        }
        else if (current_screen == GameObject.Find("Character_screen_UI"))
        {
            _characterStats.updateStats();

            GameObject.Find("experience_bar").GetComponent <Bar_script>().updateXP();
            gameObject.GetComponent <Spell_script>().actualizeSpells();
        }
        else if (current_screen == GameObject.Find("Quest_screen_UI"))
        {
            gameObject.GetComponent <Quest_manager_script>().updateQuestSlots();
            _characterStats.updateMoneyStat();
        }
        else if (current_screen == GameObject.Find("Store_screen_UI"))
        {
            _characterStats.updateMoneyStat();
        }
        else if (current_screen == GameObject.Find("Map_screen_UI"))
        {
            _characterStats.updateMoneyStat();
        }
        else if (current_screen == GameObject.Find("Combat_screen_UI"))
        {
            GameObject.Find("Game manager").GetComponent <Combat_manager_script>().initializeBattle(UnityEngine.Random.Range(0, 6));

            _characterStats.Player_health   = _characterStats.Player_max_health;
            _characterStats.Player_resource = _characterStats.Player_max_resource;
            GameObject.Find("Spell_preview").GetComponent <Visibility_script>().setInvisible();
        }
        else if (current_screen == GameObject.Find("Spell_screen_UI"))
        {
            GameObject.Find("spellpoints_text").GetComponent <Text_animation>().startAnim("Available skill points: " + _characterStats.Player_spell_points, 0.05f);
            GameObject.Find("Spellbar").GetComponent <Animator>().Play("Spellbar_talent_slide_in_anim");
            _spellScript.setupAttributes();
            _spellScript.checkRowAvailability();



            ArrayList slots = new ArrayList();
            slots.AddRange(_spellScript.firstRow);
            slots.AddRange(_spellScript.secondRow);
            slots.AddRange(_spellScript.thirdRow);

            foreach (GameObject slot in slots)
            {
                slot.GetComponent <Talent_slot_script>().spell_points_text.GetComponent <Text_animation>().startAnim(_spellScript.spells[slot.GetComponent <Talent_slot_script>().spell_id].current_spell_points + "/" + _spellScript.spells[slot.GetComponent <Talent_slot_script>().spell_id].max_spell_points, 0.05f);
            }
            _characterStats.updateMoneyStat();
        }

        Text_animation[] allText = target.GetComponentsInChildren <Text_animation>();
        foreach (Text_animation child in allText)
        {
            child.restartAnim();
        }
    }