コード例 #1
0
    IEnumerator SetupBattle()
    {
        //Instantiate both player and enemy into the battle
        enemiesAlive = 3;
        global       = GameObject.Find("GlobalObject");
        actions      = GameObject.Find("Actions");
        actions.SetActive(false);

        GameObject    player       = Instantiate(playerPrefab, playerBattleStation);
        GlobalControl globalObject = global.GetComponent <GlobalControl>();

        GameObject enemyOne   = (GameObject)Instantiate(Resources.Load("Capling"), enemyBattleStation);
        GameObject enemyTwo   = (GameObject)Instantiate(Resources.Load("Capling"), enemyBattleStation2);
        GameObject enemyThree = (GameObject)Instantiate(Resources.Load("Capling"), enemyBattleStation3);

        //Get the information about the enemy and player
        playerUnit = player.GetComponent <Player>();

        enemyUnitOne   = enemyOne.GetComponent <Enemy>();
        enemyUnitTwo   = enemyTwo.GetComponent <Enemy>();
        enemyUnitThree = enemyThree.GetComponent <Enemy>();

        playerLevel = player.GetComponent <PlayerLevel>();

        LoadPlayerData();

        playerHUD.SetPlayerHUD(playerUnit);

        storeMobility = playerLevel.stats[4];

        Debug.Log("Current player level: " + playerLevel.Level);
        Debug.Log("Player's HP when level is set: " + playerUnit.currentHP);
        playerUnit.attackList = new List <Attack>();

        setPlayerSkills();

        Debug.Log(playerUnit.attackList.Count);

        for (int i = 0; i < playerUnit.attackList.Count; i++)
        {
            GameObject newButton = Instantiate(skillPrefab, skillContent);
            Attack     toAdd     = newButton.GetComponent <Attack>();
            toAdd.SetValue(playerUnit.attackList[i].damage, playerUnit.attackList[i].type,
                           playerUnit.attackList[i].name, playerUnit.attackList[i].isSkill, playerUnit.attackList[i].spCost);
            newButton.GetComponentInChildren <Text>().text = toAdd.name;
            newButton.SetActive(true);
            print(toAdd.type);
        }

        print(playerUnit.attackList.Count);

        //StartCoroutine(ReadDialogue("Three Caplings appear in front of you!"));
        dialogueText.text = "Three Caplings appear in front of you!";

        playerUnit.unitLevel = playerLevel.Level;
        //passes in the information about player and enemy unit to set their hud displays
        playerHUD.SetPlayerHUD(playerUnit);

        enemyHUD.SetEnemyHUD(enemyUnitOne);
        enemyHUD2.SetEnemyHUD(enemyUnitTwo);
        enemyHUD3.SetEnemyHUD(enemyUnitThree);

        //This waits a second to progress
        yield return(new WaitForSeconds(2f));

        //Attack: 0
        //Defense: 1
        //Skill: 2
        //Technique: 3
        //Mobility: 4
        Debug.Log("Current Attack stat: " + playerLevel.stats[0]);
        Debug.Log("Current Defense stat: " + playerLevel.stats[1]);
        Debug.Log("Current Skill stat: " + playerLevel.stats[2]);
        Debug.Log("Current Technique stat: " + playerLevel.stats[3]);
        Debug.Log("Current Mobility stat: " + playerLevel.stats[4]);

        turnOrder   = new string[4];
        currentTurn = -1;

        if (playerLevel.stats[4] >= enemyUnitOne.stats[4])
        {
            turnOrder[0] = "Player";
            turnOrder[1] = "EnemyOne";
            turnOrder[2] = "EnemyTwo";
            turnOrder[3] = "EnemyThree";
            Debug.Log("Player attacks first");
            state = DimragStateOne.PLAYERTURN;
            PlayerTurn();
        }
        else
        {
            turnOrder[0] = "EnemyOne";
            turnOrder[1] = "EnemyTwo";
            turnOrder[2] = "EnemyThree";
            turnOrder[3] = "Player";
            Debug.Log("Enemy attacks first");
            state = DimragStateOne.FIRSTENEMYTURN;
            StartCoroutine(FirstEnemyTurn());
        }
    }
コード例 #2
0
    IEnumerator SetupBattle()
    {
        //Instantiate both player and enemy into the battle
        global    = GameObject.Find("GlobalObject");
        isLoading = false;

        GameObject    player       = Instantiate(playerPrefab, playerBattleStation);
        GlobalControl globalObject = global.GetComponent <GlobalControl> ();
        GameObject    enemy        = (GameObject)Instantiate(Resources.Load(globalObject.nextFight), enemyBattleStation);

        //Get the information about the enemy and player
        playerUnit = player.GetComponent <Player> ();
        enemyUnit  = enemy.GetComponent <Enemy> ();

        playerLevel = player.GetComponent <PlayerLevel> ();

        LoadPlayerData();
        //playerStats = player.GetComponent<PlayerStats> ();
        playerHUD.SetPlayerHUD(playerUnit);

        storeMobility = playerLevel.stats [4];

        Debug.Log("Current player level: " + playerLevel.Level);
        Debug.Log("Player's HP when level is set: " + playerUnit.currentHP);
        playerUnit.attackList = new List <Attack> ();

        Attack trash = gameObject.AddComponent <Attack>();

        trash.damage  = 1;
        trash.type    = "trash";
        trash.name    = "Dump";
        trash.spCost  = 3;
        trash.isSkill = true;

        Attack recycle = gameObject.AddComponent <Attack>();

        recycle.damage  = 1;
        recycle.type    = "recycle";
        recycle.name    = "Shred";
        recycle.spCost  = 3;
        recycle.isSkill = true;

        Attack compost = gameObject.AddComponent <Attack>();

        compost.damage  = 1;
        compost.type    = "compost";
        compost.name    = "Worm Strike";
        compost.spCost  = 3;
        compost.isSkill = true;

        playerUnit.addAttack(trash);
        playerUnit.addAttack(recycle);
        playerUnit.addAttack(compost);

        Debug.Log(playerUnit.attackList.Count);

        for (int i = 0; i < playerUnit.attackList.Count; i++)
        {
            GameObject newButton  = Instantiate(skillPrefab, skillContent);
            Attack     thisAttack = newButton.GetComponent <Attack>();
            thisAttack.SetValue(playerUnit.attackList [i].damage, playerUnit.attackList [i].type,
                                playerUnit.attackList [i].name, playerUnit.attackList [i].isSkill, playerUnit.attackList[i].spCost);
            newButton.GetComponentInChildren <Text> ().text = thisAttack.name;
            newButton.SetActive(true);
            print(thisAttack.type);
        }

        print(playerUnit.attackList.Count);

        dialogueText.text = enemyUnit.unitName + " is here to fight!";

        playerUnit.unitLevel = playerLevel.Level;
        //passes in the information about player and enemy unit to set their hud displays
        playerHUD.SetPlayerHUD(playerUnit);
        enemyHUD.SetEnemyHUD(enemyUnit);

        //This waits a small amount of time before giving the dialogue to the player that they should choose an action
        yield return(new WaitForSeconds(2f));

        //Attack: 0
        //Defense: 1
        //Skill: 2
        //Technique: 3
        //Mobility: 4
        Debug.Log("Current Attack stat: " + playerLevel.stats[0]);
        Debug.Log("Current Defense stat: " + playerLevel.stats[1]);
        Debug.Log("Current Skill stat: " + playerLevel.stats[2]);
        Debug.Log("Current Technique stat: " + playerLevel.stats[3]);
        Debug.Log("Current Mobility stat: " + playerLevel.stats[4]);


        //Now the state is set to player's turn, and we move on to the PlayerTurn function
        if (playerLevel.stats [4] >= enemyUnit.stats [4])
        {
            Debug.Log("Player attacks first");
            state = BattleState.PLAYERTURN;
            PlayerTurn();
        }
        else
        {
            state = BattleState.ENEMYTURN;
            StartCoroutine(EnemyTurn());
            Debug.Log("Enemy attacks first");
        }
    }