Beispiel #1
0
    IEnumerator SetupBattle()
    {
        GameObject playerGO = Instantiate(playerPrefab);

        playerUnit = playerGO.GetComponent <Unit>();

        GameObject enemyGO = Instantiate(enemyPrefab);

        enemyUnit = enemyGO.GetComponent <Unit>();
        battleUI.scenarioImage.sprite = enemyUnit.cBase.scenario;
        battleUI.enemyImage.sprite    = enemyUnit.cBase.combatImage;
        RectTransform enemyImageTransform = battleUI.enemyImage.GetComponent <RectTransform>();

        combatAnim = battleUI.enemyImage.GetComponent <Animator>();

        string path;

        if (enemyUnit.cBase.race == CharacterBase.CharacterRace.Elfa)
        {
            RectTransform enemyImageTransformTo = battleUI.ElfaPos.GetComponent <RectTransform>();
            battleUI.enemyImage.transform.position = battleUI.ElfaPos.position;
            battleUI.enemyImage.transform.rotation = battleUI.ElfaPos.rotation;
            enemyImageTransform.sizeDelta          = enemyImageTransformTo.sizeDelta;
            path = "ElfaController";
        }
        else if (enemyUnit.cBase.race == CharacterBase.CharacterRace.Humano)
        {
            RectTransform enemyImageTransformTo = battleUI.HumPos.GetComponent <RectTransform>();
            battleUI.enemyImage.transform.position = battleUI.HumPos.position;
            battleUI.enemyImage.transform.rotation = battleUI.HumPos.rotation;
            enemyImageTransform.sizeDelta          = enemyImageTransformTo.sizeDelta;
            path = "HumanoController";
        }
        else if (enemyUnit.cBase.race == CharacterBase.CharacterRace.Sereia)
        {
            RectTransform enemyImageTransformTo = battleUI.SereiaPos.GetComponent <RectTransform>();
            battleUI.enemyImage.transform.position = battleUI.SereiaPos.position;
            battleUI.enemyImage.transform.rotation = battleUI.SereiaPos.rotation;
            enemyImageTransform.sizeDelta          = enemyImageTransformTo.sizeDelta;
            path = "SereiaController";
        }
        else
        {
            RectTransform enemyImageTransformTo = battleUI.orcPos.GetComponent <RectTransform>();
            battleUI.enemyImage.transform.position = battleUI.orcPos.position;
            battleUI.enemyImage.transform.rotation = battleUI.orcPos.rotation;
            enemyImageTransform.sizeDelta          = enemyImageTransformTo.sizeDelta;
            path = "OrcController";
        }
        combatAnim.runtimeAnimatorController = Resources.Load(path) as RuntimeAnimatorController;

        battleUI.StartCoroutine(battleUI.showText(enemyUnit.cBase.name + " se aproxima..."));

        battleUI.playerHUD.SetHUD(playerUnit);
        battleUI.enemyHUD.SetHUD(enemyUnit);
        battleUI.turnText.text = "TURNO\n" + curTurn + "/" + maxTurn;
        battleUI.DecisionAttackButton.SetActive(false);
        battleUI.DecisionQuitButton.SetActive(false);
        yield return(new WaitForSeconds(1.5f));

        state = BattleState.PLAYERTURN;
        StartTurn();
    }