private SoundsGeneral soundsGeneral; //script soundsManager do objeto soundsManager

    //inicializar antes do start
    private void Awake()
    {
        soundsGeneral = GameObject.FindObjectOfType <SoundsGeneral>(); //inicializar valores

        //rb2d = gameObject.GetComponent<Rigidbody2D>(); //inicializar valores
        anim = gameObject.GetComponent <Animator>();

        Initialize(); //inicializar variaveis
    }
Exemple #2
0
    //inicializar antes do start
    private void Awake()
    {
        soundsGeneral = GameObject.FindObjectOfType <SoundsGeneral>(); //inicializar valores

        currentSelectedButton = 0;                                     //inicializar valores
        currentOnPanel        = 0;
        currentOnSubPanel     = 0;

        buttonText[currentSelectedButton].fontSize = buttonHoverOnFontSize; //inicializar dados
        buttonText[currentSelectedButton].color    = buttonHoverOnColor;

        isStartExitSelected = false; //inicializar valores
        isVerticalInUse     = false;
        isHorizontalInUse   = false;
    }
    //inicializar antes do start
    private void Awake()
    {
        soundsGeneral = GameObject.FindObjectOfType <SoundsGeneral>(); //inicializar valores

        rectTransform = gameObject.GetComponent <RectTransform>();     //inicializar valores

        originalRectTransform.anchorMin = rectTransform.anchorMin;
        originalRectTransform.anchorMax = rectTransform.anchorMax;
        originalRectTransform.offsetMax = rectTransform.offsetMax;
        originalRectTransform.offsetMin = rectTransform.offsetMin;

        gameEnd2Panel.enabled = false;

        gameTimerText.text = "";
        gameEndText.text   = "";

        isVerticalInUse = false;
    }
    //inicializar antes do start
    private void Awake()
    {
        soundsGeneral = GameObject.FindObjectOfType <SoundsGeneral>(); //inicializar valores

        playersStruct           = new Player[numberOfPlayers];         //inicializar valores
        isAllCharactersSelected = false;
        actionFunction          = null;

        //Dados da UI
        Transform selectScenePanel      = gameObject.transform.Find("SelectScenePanel");
        Transform charactersPanel       = selectScenePanel.Find("CharactersPanel");
        Transform charactersSelectPanel = selectScenePanel.Find("CharactersSelectPanel");
        Transform scenarioPanel         = selectScenePanel.Find("ScenarioPanel");
        Transform scenarioSelectPanel   = selectScenePanel.Find("ScenarioSelectPanel");
        Transform initalTextPanel       = selectScenePanel.Find("InitialTextPanel");

        //Interface geral
        selectSceneText = initalTextPanel.Find("SelectSceneText").GetComponent <Text>();                                           //inicializar valores

        characterSelectPortraits = new Image[charactersSelectPanel.childCount];                                                    //inicializar array
        for (int j = 0; j < charactersSelectPanel.childCount; j++)                                                                 //para cada personagem inicializar valores necessarios
        {
            characterSelectPortraits[j] = charactersSelectPanel.Find("Character_" + (j + 1) + "/Portrait").GetComponent <Image>(); //encontrar personagem e inicializar valores

            characterSelectPortraits[j].enabled = false;
        }

        playerSelectingScenario  = 0;                                                                                      //jogador 1 que esta selecionando o cenario
        currentScenarioSelection = 0;                                                                                      //cenario 1 "selecionado" pelo jogador
        isScenarioSelected       = false;                                                                                  //o cenario "selecionado" ainda nao foi selecionado

        scenarioSelectedImage = scenarioPanel.gameObject.transform.Find("Scenario_Selected/Image").GetComponent <Image>(); //referencia para a imagem do cenario selecionado //inicializar valores
        scenarioSelectedtext  = scenarioPanel.gameObject.transform.Find("Scenario_Selected/Text").GetComponent <Text>();   //referencia para o texto/nome do cenario selecionado

        scenarioSelectPortraits = new Image[scenarioSelectPanel.childCount];                                               //inicializar array
        scenarioImage           = new Image[scenarioSelectPanel.childCount];                                               //inicializar array
        for (int j = 0; j < scenarioSelectPanel.childCount; j++)                                                           //para cada cenario inicializar valores necessarios
        {
            Transform scenarioArena = scenarioSelectPanel.Find("Scenario_Arena" + (j + 1));                                //encontrar cenario e inicializar valores

            scenarioImage[j]           = scenarioArena.Find("Image").GetComponent <Image>();                               //inicializar valores
            scenarioSelectPortraits[j] = scenarioArena.Find("Portrait").GetComponent <Image>();

            scenarioSelectPortraits[j].enabled = false;
        }

        //Interface de cada jogador
        for (int i = 0; i < numberOfPlayers; i++) //para cada jogador //inicializar valores
        {
            //Dados do jogador
            playersStruct[i].currentCharacterSelection = i;     //personagem "selecionado" pelo jogador
            playersStruct[i].isCharacterSelected       = false; //o personagem "selecionado" ainda nao foi selecionado

            //Dados da UI
            Transform characterSelected = charactersPanel.Find("Character_Selected" + (i + 1));
            playersStruct[i].characterSelectedImage    = characterSelected.Find("Image").GetComponent <Image>();    //imagem do personagem
            playersStruct[i].characterSelectedText     = characterSelected.Find("Text").GetComponent <Text>();      //texto/nome do personagem
            playersStruct[i].characterSelectedPortrait = characterSelected.Find("Portrait").GetComponent <Image>(); //"quadro" de selecao do personagem

            playersStruct[i].characterSelectedImage.sprite   = characterSO[playersStruct[i].currentCharacterSelection].playerSelectSceneSprite;
            playersStruct[i].characterSelectedText.text      = characterSO[playersStruct[i].currentCharacterSelection].characterName;
            playersStruct[i].characterSelectedPortrait.color = playerSelectedColor[i]; //inicializar valores

            Transform descriptionSelectedPanel = charactersPanel.Find("Description_Selected" + (i + 1));
            playersStruct[i].skillsQuantity            = descriptionSelectedPanel.childCount;
            playersStruct[i].descriptionSelectedSkills = new Skill[descriptionSelectedPanel.childCount]; //inicializar array da struct
            for (int j = 0; j < playersStruct[i].skillsQuantity; j++)                                    //para cada skill inicializar valores necessarios
            {
                Transform playerSkill = descriptionSelectedPanel.Find("Skill" + (j + 1) + "Panel");      //encontrar skill e inicializar valores
                playersStruct[i].descriptionSelectedSkills[j].skillPanelImage = playerSkill.Find("Image").GetComponent <Image>();
                playersStruct[i].descriptionSelectedSkills[j].skillPanelText  = playerSkill.Find("Text").GetComponent <Text>();

                playersStruct[i].descriptionSelectedSkills[j].skillPanelImage.sprite = characterSO[playersStruct[i].currentCharacterSelection].skillsSprites[j];     //ajustar imagem da skill
                playersStruct[i].descriptionSelectedSkills[j].skillPanelText.text    = characterSO[playersStruct[i].currentCharacterSelection].skillsDescription[j]; //ajustar texto/descricao da skill
            }

            characterSelectPortraits[playersStruct[i].currentCharacterSelection].color   = playerSelectedColor[i]; //inicializar valores
            characterSelectPortraits[playersStruct[i].currentCharacterSelection].enabled = true;

            if (i == playerSelectingScenario) //se for este jogador selecionando o cenario //inicializar valores
            {
                scenarioSelectPortraits[currentScenarioSelection].color   = playerSelectedColor[playerSelectingScenario];
                scenarioSelectPortraits[currentScenarioSelection].enabled = false; //true;

                scenarioSelectedImage.sprite = scenarioImage[currentScenarioSelection].sprite;
                scenarioSelectedtext.text    = scenarioName[currentScenarioSelection];
            }
        }
    }
    private SoundsGeneral soundsGeneral;   //script soundsManager do objeto soundsManager

    //inicializar antes do start
    private void Awake()
    {
        soundsGeneral = GameObject.FindObjectOfType <SoundsGeneral>(); //inicializar valores

        numberOfPlayers = players.Length;                              //inicializar valores

        playersStruct = new Player[numberOfPlayers];                   //inicializar array

        for (int i = 0; i < numberOfPlayers; i++)                      //para cada jogador referenciado (/na cena) //referenciar objetos
        {
            //Dados do Objeto
            playersStruct[i].characterSO      = players[i].GetComponent <PlayerController>().characterSO; //inicializar scriptableObject do jogador
            playersStruct[i].healthController = players[i].GetComponent <HealthController>();             //script healthController do jogador
            playersStruct[i].skillManager     = players[i].GetComponent <SkillManager>();                 //script skillManager do jogador

            //Dados da UI
            playersStruct[i].playerStatsPanel = gameObject.transform.Find("Player" + (i + 1) + "StatsPanel");

            playersStruct[i].playerStatsPanel.transform.Find("PlayerImage").GetComponent <Image>().sprite = playersStruct[i].characterSO.playerInGameSprite; //setar a image do jogador na interface dentro do jogo (/UIInGame)
            playersStruct[i].playerStatsPanel.gameObject.SetActive(true);                                                                                    // ativar painel de status do player //(para cada player na referenciado (/na cena))

            playersStruct[i].playerHpNumberText = playersStruct[i].playerStatsPanel.Find("HealthBarPanel/HpNumberText").GetComponent <Text>();

            Transform playerSkillsPanel = playersStruct[i].playerStatsPanel.Find("PlayerSkillsPanel");
            playersStruct[i].playerSkills = new Skill[playerSkillsPanel.childCount]; //inicializar array da struct
            for (int j = 0; j < playerSkillsPanel.childCount; j++)                   //para cada skill inicializar valores necessarios
            {
                Transform playerSkill = playerSkillsPanel.Find("Skill" + (j + 1));   //encontrar skill e inicializar valores
                playersStruct[i].playerSkills[j].iconBackgroundImage  = playerSkill.Find("IconBackgroundImage").GetComponent <Image>();
                playersStruct[i].playerSkills[j].iconSkillImage       = playerSkill.Find("IconCircleImage/IconSkillImage").GetComponent <Image>();
                playersStruct[i].playerSkills[j].skillBlurEffectImage = playerSkill.Find("IconCircleImage/SkillBlurEffectImage").GetComponent <Image>();
                playersStruct[i].playerSkills[j].skillCdTimeText      = playerSkill.Find("IconCircleImage/SkillCdTimeText").GetComponent <Text>();
                playersStruct[i].playerSkills[j].iconSkillLockImage   = playerSkill.Find("IconSkillLockImage").GetComponent <Image>();

                playersStruct[i].playerSkills[j].iconSkillImage.sprite = playersStruct[i].characterSO.skillsSprites[j]; //ajustar sprite da skill
            }
            //inicializar valores das skills de acordo com o nome dado no skillManager //(talvez padronizar nomes depois)
            playersStruct[i].playerSkills[0].skillCd = playersStruct[i].characterSO.skill1Cooldown;
            playersStruct[i].playerSkills[1].skillCd = playersStruct[i].characterSO.skill2Cooldown;
            playersStruct[i].playerSkills[2].skillCd = playersStruct[i].characterSO.mushCooldown;

            Transform playerLivesPanel      = playersStruct[i].playerStatsPanel.Find("PlayerLivesPanel");
            Transform healthBarSlidersPanel = playersStruct[i].playerStatsPanel.Find("HealthBarPanel/HealthBarSlidersPanel");

            int livesCount = playersStruct[i].characterSO.maxNumberOfLives;            //pegar numero de vidas de um jogador

            playersStruct[i].playerHealthBarSlider           = new Slider[livesCount]; //inicializar array da struct
            playersStruct[i].playerBackgroundHealthBarSlider = new Slider[livesCount]; //inicializar array da struct
            playersStruct[i].playerHealthBarFillImage        = new Image[livesCount];
            playersStruct[i].isAnimatingHealth                  = new bool[livesCount];
            playersStruct[i].isAnimatingHealthBackground        = new bool[livesCount];
            playersStruct[i].isBlinkingColor                    = new bool[livesCount];
            playersStruct[i].healthBackGroundCoroutineInstances = new Coroutine[livesCount];
            playersStruct[i].actualHealthAux                    = new int[livesCount];

            playersStruct[i].playerLives = new Image[livesCount]; //inicializar array da struct

            for (int j = 0; j < livesCount; j++)                  //para cada vida, criar e inicializar valores necessarios
            {
                //criar barras de vida
                GameObject newHealthBar = Instantiate(healthBarPrefab, healthBarSlidersPanel);                                                                                     //criar e referenciar cada uma das barras de vida (completa) do jogador
                newHealthBar.name = healthBarPrefab.name + (j + 1);                                                                                                                //renomear cada uma das barras de vidas

                playersStruct[i].playerHealthBarSlider[j]          = newHealthBar.transform.Find("HealthBarSlider").GetComponent <Slider>();                                       //inicializar valores e referenciar barras criadas
                playersStruct[i].playerHealthBarSlider[j].maxValue = playersStruct[i].characterSO.maxHealth;
                playersStruct[i].playerHealthBarSlider[j].value    = playersStruct[i].healthController.actualHealth[j];                                                            //inicializar com valores atuais de vida
                playersStruct[i].playerHealthBarFillImage[j]       = playersStruct[i].playerHealthBarSlider[j].gameObject.transform.Find("Fill Area/Fill").GetComponent <Image>(); //referenciar imagem que contem cor da barra de vida
                playersStruct[i].playerHealthBarFillImage[j].color = healthBarSlidersColors[j];                                                                                    //setar cor da barra de vida

                playersStruct[i].playerBackgroundHealthBarSlider[j]          = newHealthBar.transform.Find("BackgroundHealthBarSlider").GetComponent <Slider>();
                playersStruct[i].playerBackgroundHealthBarSlider[j].maxValue = playersStruct[i].characterSO.maxHealth;
                playersStruct[i].playerBackgroundHealthBarSlider[j].value    = playersStruct[i].playerHealthBarSlider[j].value;                                                                                                                                                                                              //inicializar com valores atuais de vida
                playersStruct[i].playerBackgroundHealthBarSlider[j].gameObject.transform.Find("Fill Area/Fill").GetComponent <Image>().color = new Color(healthBarSlidersColors[j].r, healthBarSlidersColors[j].g, healthBarSlidersColors[j].b, 230f / healthBackgroundShaderProportion) * healthBackgroundShaderProportion; //setar cor da barra "backround" de vida com a proporcao de "escurecer" aplicada

                playersStruct[i].actualHealthAux[j] = playersStruct[i].healthController.actualHealth[j];

                //criar vidas
                GameObject newLife = Instantiate(lifePrefab, playerLivesPanel);              //criar e referenciar cada uma das vidas do jogador
                newLife.name = lifePrefab.name + (j + 1);                                    //renomear cada uma das vidas
                RectTransform newLifeRectTransform = newLife.GetComponent <RectTransform>(); //inicializar valores
                newLifeRectTransform.anchorMin = new Vector2(/*(float)j / livesCount*/ 0.175f * j, newLifeRectTransform.anchorMin.y);
                newLifeRectTransform.anchorMax = new Vector2(/*(float)(j + 1) / livesCount*/ 0.25f + 0.175f * j, newLifeRectTransform.anchorMax.y);
                newLifeRectTransform.offsetMin = Vector2.zero;
                newLifeRectTransform.offsetMax = Vector2.zero;

                playersStruct[i].playerLives[j] = newLife.GetComponent <Image>(); //referenciar nova vida criada
            }
        }

        //dados do timer
        timerText = gameObject.transform.Find("TimerPanel/TimerText").GetComponent <Text>(); //inicializar valores //pegar text do timer
    }