Пример #1
0
    IEnumerator SetupBattle(string enemyName)
    {
        // Add player.
        player = Instantiate(playerPrefab, playerSpawnPoint).GetComponent <Unit>();

        // Add enemy.

        if (enemyDataMap.ContainsKey(enemyName))
        {
            currentEnemy = Instantiate(enemyDataMap[enemyName], enemySpawnPoint).GetComponent <Unit>();
        }
        else
        {
            Debug.LogError("Enemy GameObject not found, MayDay!! MayDay!!");
        }

        yield return(new WaitForSeconds(1f));

        playerHUD.SetupHUD(player);
        enemyHUD.SetupHUD(currentEnemy);

        buttonsGameObject.SetActive(false);

        dialogueText.gameObject.SetActive(true);

        string dialogue = "A wild " + currentEnemy.unitName + " approaches...";

        dialogueText.text = dialogue;

        yield return(new WaitForSeconds(1f));

        state = BattleState.PLAYERTURN;
        PlayerTurn();
    }
Пример #2
0
    // Start is called before the first frame update
    IEnumerator Start()
    {
        battleState = BattleState.START;
        inputState  = InputState.STALL;

        GameObject playerGO = Instantiate(playerPrefab, playerBattleStation);
        GameObject enemyGO  = Instantiate(enemyPrefab, enemyBattleStation);

        playerUnit = playerGO.GetComponent <Unit>();
        enemyUnit  = enemyGO.GetComponent <Unit>();

        dialogueText.text = "Fighting a " + enemyUnit.unitName + "...";

        playerBattleHUD.SetupHUD(playerUnit);
        enemyBattleHUD.SetupHUD(enemyUnit);

        yield return(new WaitForSeconds(2f));

        battleState = BattleState.PLAYERTURN;
        StartOneTurn();
    }