Beispiel #1
0
    public void NextTurn()
    {
        if (OverStatus())
        {
            return;
        }
        UnitStats stats = unitsQueue.Front;

        unitsQueue.Pop();
        if (!stats.isDead())
        {
            GameObject unit = stats.gameObject;
            SkillHit.transform.parent = unit.transform;
            stats.CalculateNextActTurn();
            unitsQueue.Push(stats);
            Debug.Log(unit.tag + " acting" + "\nNextTurn: " + stats.NextActTurn.ToString());
            if (unit.tag == "EnemyUnit")
            {
                nowStatus = GameStatus.EnemyAct;
                nextUnit  = unit;
            }
            else if (unit.tag == "PlayerUnit")
            {
                nowStatus = GameStatus.PlayerAct;
                nextUnit  = unit;
            }
        }
        else
        {
            NextTurn();
        }
    }
    // Use this for initialization
    void Start()
    {
        unitsStats = new List <UnitStats> ();

        // Add player units to the list.
        GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit");
        foreach (GameObject playerUnit in playerUnits)
        {
            UnitStats currentUnitStats = playerUnit.GetComponent <UnitStats> ();
            currentUnitStats.CalculateNextActTurn(0);
            unitsStats.Add(currentUnitStats);
        }

        // Add enemy units to the list.
        GameObject[] enemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit");
        foreach (GameObject enemyUnit in enemyUnits)
        {
            UnitStats currentUnitStats = enemyUnit.GetComponent <UnitStats> ();
            currentUnitStats.CalculateNextActTurn(0);
            unitsStats.Add(currentUnitStats);
        }

        // Sort the list based on the speeds.
        unitsStats.Sort();

        actionsMenu.SetActive(false);
        enemyUnitsMenu.SetActive(false);

        NextTurn();
    }
Beispiel #3
0
    public void StartTurns()
    {
        unitsStats = new List <UnitStats>();
        GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit");
        foreach (GameObject playerUnit in playerUnits)
        {
            UnitStats currentUnitStats = playerUnit.GetComponent <UnitStats>();
            currentUnitStats.CalculateNextActTurn(0);
            unitsStats.Add(currentUnitStats);
        }

        GameObject[] enemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit");
        foreach (GameObject enemyUnit in enemyUnits)
        {
            UnitStats currentUnitStats = enemyUnit.GetComponent <UnitStats>();
            currentUnitStats.CalculateNextActTurn(0);
            unitsStats.Add(currentUnitStats);
        }

        unitsStats.Sort();

        actionsMenu.SetActive(false);
        enemyUnitsMenu.SetActive(false);
        StartNextTurn();
    }
Beispiel #4
0
    public IEnumerator NextTurn()
    {
        Debug.Log("Turn start");
        GameObject[] remainingEnemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit");
        if (remainingEnemyUnits.Length == 0)
        {
            //enemyEncounter.GetComponent<CollectReward>().collectReward();
            Debug.Log("No enemies left; leaving battle.");
            Controller.LoadNextScene();
        }

        GameObject[] remainingPlayerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit");
        if (remainingPlayerUnits.Length == 0)
        {
            Debug.Log("No player units. Game over.");
            Controller.GameOver();
            yield break;
        }
        Debug.Log($"Number of units: {unitsStats.Count}");
        UnitStats currentUnitStats = unitsStats[0];

        unitsStats.Remove(currentUnitStats);

        if (!currentUnitStats.IsDead())
        {
            GameObject currentUnit = currentUnitStats.gameObject;
            Debug.Log($"Current unit is {currentUnit.name}");

            currentUnitStats.CalculateNextActTurn(currentUnitStats.NextActTurn);
            unitsStats.Add(currentUnitStats);
            //unitsStats.Sort();

            if (currentUnit.tag == "PlayerUnit")
            {
                Debug.Log("PlayerUnit acting");
                Controller.DarkenOtherPlayerUnits(currentUnit);
                Controller.SelectCurrentUnit(currentUnit);
                Controller.ActionsMenu.SetActive(true);
                CheckManaAvailability(currentUnit.GetComponent <UnitStats>());
                currentUnit.GetComponent <PlayerUnitAction>().UpdateHud();
                yield break;
            }
            else if (currentUnit.tag == "EnemyUnit")
            {
                Debug.Log("EnemyUnit acting");
                currentUnit.GetComponent <EnemyUnitAction>().Act();
                yield return(new WaitForSeconds(3));

                Debug.Log("EnemyUnit action finished");
            }
            else
            {
                Debug.Log($"Unrecognised unit! {currentUnit.tag}");
            }
        }
        Debug.Log($"Next turn: {unitsStats[0]}");
        yield return(NextTurn());
    }
    public void NextTurn()
    {
        // Check if we beat all enemies.
        GameObject[] remainingEnemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit");
        if (remainingEnemyUnits.Length == 0)
        {
            enemyEncounter.GetComponent <CollectReward> ().GetReward();
            SceneManager.LoadScene("Town");
        }

        // Check if game over.
        GameObject[] remainingPlayerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit");
        if (remainingPlayerUnits.Length == 0)
        {
            SceneManager.LoadScene("Title");
        }

        UnitStats currentUnitStats = unitsStats [0];

        unitsStats.Remove(currentUnitStats);

        if (!currentUnitStats.IsDead())
        {
            GameObject currentUnit = currentUnitStats.gameObject;

            currentUnitStats.CalculateNextActTurn(currentUnitStats.nextActTurn);
            unitsStats.Add(currentUnitStats);
            unitsStats.Sort();

            if (currentUnit.tag == "PlayerUnit")
            {
                GameObject.Find("PlayerParty").GetComponent <SelectUnit> ().SelectCurrentUnit(currentUnit.gameObject);
            }
            else
            {
                currentUnit.GetComponent <EnemyUnitAction> ().Act();
            }
        }
        else
        {
            NextTurn();
        }
    }
Beispiel #6
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit");
        foreach (GameObject unit in playerUnits)
        {
            UnitStats stats = unit.GetComponent <UnitStats>();
            stats.CalculateNextActTurn(0);
            unitsQueue.Push(stats);
        }
        GameObject[] enemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit");
        foreach (GameObject unit in enemyUnits)
        {
            UnitStats stats = unit.GetComponent <UnitStats>();
            stats.CalculateNextActTurn(0);
            unitsQueue.Push(stats);
        }

        playerParty    = GameObject.Find("PlayerParty");
        enemyEncounter = GameObject.Find("EnemyEncounter");

        StartCoroutine(SendMsgWait("敌人拦在了你面前!", delegate { NextTurn(); }));
    }