//Player Coroutines

    IEnumerator PlayerAttack()
    {
        playerUnit.basicAbility(enemyUnit);
        bool isAlive = enemyUnit.isAlive();

        enemyHUD.setHP(enemyUnit.currentHP);

        if (enemyUnit.blocking)
        {
            dialouge.text = enemyUnit.unitName + " has blocked the attack!";
            enemyUnit.endBlock();
        }
        else
        {
            dialouge.text = playerUnit.unitName + " has attacked!";
        }
        yield return(new WaitForSeconds(2f));

        if (!isAlive)
        {
            state = battleStates.WIN;
            EndBattle();
        }
        else
        {
            state = battleStates.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }
    }
Beispiel #2
0
 void onGUI()
 {
     if (guiLayout.Button("next state"))
     {
         if (currentState == battleStates.start)
         {
             currentState = battleStates.playerChoice;
         }
         else if (currentState == battleStates.playerChoice)
         {
             currentState == battleStates.enemyChoice;
         }
         else if (currentState == battleStates.enemyChoice)
         {
             currentState == battleStates.lose;
         }
         else if (currentState == battleStates.lose)
         {
             currentState == battleStates.win;
         }
         else if (currentState == battleStates.win)
         {
             currentState == battleStates.start;
         }
     }
 }
    IEnumerator SetupBattle()
    {
        //Spawn Player and Enemy
        GameObject playerGO = Instantiate(keeper.getPlayerOne(), playerStation);

        playerUnit = playerGO.GetComponent <Unit>();

        GameObject enemyGO = Instantiate(enemy, enemyStation);

        enemyUnit = enemyGO.GetComponent <Unit>();

        dialouge.text = enemyUnit.unitName + " has appeared!";


        //Set Player Ablities
        btnOne.text   = playerUnit.basicAbilityName;
        btnTwo.text   = playerUnit.specialAbilityOneName;
        btnThree.text = playerUnit.specialAbilityTwoName;

        playerHUD.setHUD(playerUnit);
        enemyHUD.setHUD(enemyUnit);

        yield return(new WaitForSeconds(2f));

        state = battleStates.PLAYERTURN;
        playerTurn();
    }
    //End Player Coroutines


    IEnumerator EnemyTurn()
    {
        dialouge.text = enemyUnit.makeDesicion(playerUnit);
        if (playerUnit.blocking)
        {
            dialouge.text = playerUnit.unitName + " has blocked!";
            playerUnit.endBlock();
        }

        bool isAlive = playerUnit.isAlive();

        playerHUD.setHP(playerUnit.currentHP);

        yield return(new WaitForSeconds(2f));

        if (!isAlive)
        {
            state = battleStates.LOSS;
            EndBattle();
        }
        else
        {
            state = battleStates.PLAYERTURN;
            playerTurn();
        }
    }
Beispiel #5
0
 void PlayerMove()
 {
     state = battleStates.PlayerAction;
     dialogueBox.enableASelector(false);
     dialogueBox.enableDialogue(false);
     dialogueBox.enableMoveSelectoe(true);
 }
    // Start is called before the first frame update
    void Start()
    {
        state = battleStates.START;

        //FIND HOW TO GET ACTIVE GAME MANGER!
        keeper = GameObject.Find("GameManager");
        StartCoroutine(SetupBattle());
    }
    IEnumerator PlayerBlock()
    {
        playerUnit.specialAbilityTwo(enemyUnit);
        dialouge.text = playerUnit.unitName + " moving to defensive position!";
        yield return(new WaitForSeconds(2f));

        state = battleStates.ENEMYTURN;
        StartCoroutine(EnemyTurn());
    }
    IEnumerator PlayerHeal()
    {
        playerUnit.specialAbilityOne(enemyUnit);
        playerHUD.setHP(playerUnit.currentHP);
        dialouge.text = playerUnit.unitName + " is recovering!";
        yield return(new WaitForSeconds(2f));

        state = battleStates.ENEMYTURN;
        StartCoroutine(EnemyTurn());
    }
    public void GetPlayerOneResults(string p2H, string p1T, bool isDead)
    {
        p2Health  = p2H;
        p1Type    = p1T;
        p2Dead    = isDead;
        isAttack1 = false;

        if (!isAttack1 && !isAttack2)
        {
            curBattleState = battleStates.Results;
        }
    }
    //gets battle results from both player states
    public void GetPlayerTwoResults(string p1H, string p2T, bool isDead)
    {
        p1Health  = p1H;
        p2Type    = p2T;
        p1Dead    = isDead;
        isAttack2 = false;

        if (!isAttack1 && !isAttack2)
        {
            curBattleState = battleStates.Results;
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (curBattleState)
        {
        case battleStates.Wait:
            curBattleState = battleStates.TakeAction;
            break;

        case battleStates.TakeAction:
            ActivateTroop();
            break;

        case battleStates.Results:
            DisplayResults();
            break;
        }
    }
    //print results
    public void DisplayResults()
    {
        if (p1Dead && playerOne.Count != 0)
        {
            playerOne.Dequeue();

            print("Player one " + p1Type + " was killed");
        }
        else if (p2Dead && playerTwo.Count != 0)
        {
            playerTwo.Dequeue();

            print("Player two " + p2Type + " was killed");
        }
        else if (playerOne.Count == 0)
        {
            print("PLAYER TWO IS THE WINNER!!!");

            foreach (GameObject go in playerTwo)
            {
                print(go.gameObject.GetComponent <PlayerTwoStates> ().troop.name + " " + go.gameObject.GetComponent <PlayerTwoStates> ().troop.health);
            }
        }
        else if (playerTwo.Count == 0)
        {
            print("PLAYER ONE IS THE WINNER!!!");

            foreach (GameObject go in playerOne)
            {
                print(go.gameObject.GetComponent <PlayerOneStates> ().troop.name + " " + go.gameObject.GetComponent <PlayerOneStates> ().troop.health);
            }
        }
        else
        {
            print("Round: " + round + " Player 1 " + p1Type + " (Health = " + p1Health + ") " + " vs Player 2 " + p2Type + " (Health = " + p2Health + ")");
        }

        DeactivateTroop();

        PerformList.Clear();

        curBattleState = battleStates.Wait;
    }
    // Use this for initialization
    void Start()
    {
        curBattleState = battleStates.Wait;

        //instantiates 20 troops from the troop list;
        GameObject spawn;

        GameObject player1 = GameObject.Find("PlayerOne");

        GameObject player2 = GameObject.Find("PlayerTwo");

        for (int i = 0; i < 20; i++)
        {
            int troopIndex = Random.Range(0, 3);
            spawn = Instantiate(p1Troops [troopIndex], player1.transform, false);
            spawn.transform.localPosition = new Vector3(0, 0, 0);
        }
        for (int i = 0; i < 20; i++)
        {
            int troopIndex = Random.Range(0, 3);
            spawn = Instantiate(p2Troops [troopIndex], player2.transform, false);
            spawn.transform.localPosition = new Vector3(0, 0, 0);
        }

        //adds all the troops in a queue for rotation
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player1"))
        {
            go.SetActive(false);
            playerOne.Enqueue(go);
        }
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player2"))
        {
            go.SetActive(false);
            playerTwo.Enqueue(go);
        }
    }
Beispiel #14
0
 //Used for initialization
 void Start()
 {
     currentState = battleStates.start;
 }
Beispiel #15
0
 public void PlayerAct()
 {
     state = battleStates.PlayerAction;
     StartCoroutine(dialogueBox.typingDialogue("Choose an action."));
     dialogueBox.enableASelector(true);
 }
Beispiel #16
0
	// Use this for initialization
	void Start () 
	{
		currentState = battleStates.START;
	}