Beispiel #1
0
    public void TurnOrder()
    {
        itemsParent.gameObject.GetComponent <Image>().enabled = false;
        foreach (InventorySlot slot in slots)
        {
            slot.gameObject.GetComponentInChildren <Button>().interactable = false;
            slot.removeButton.interactable = false;
            slot.removeButton.gameObject.GetComponent <Image>().enabled = false;

            slot.gameObject.GetComponentInChildren <Image>().enabled = false;
        }
        foreach (InventorySlot slot in slots)
        {
            slot.icon.enabled = false;
            slot.color.a      = 0;
        }
        foreach (GameObject button in lists.buttons)
        {
            button.GetComponent <Button>().interactable = false;
        }

        sortedStats = stats.OrderBy(s => s.speed).ToList();

        sortedStats.Reverse();


        for (int i = 0; i < sortedStats.Count; i++)
        {
            float lastSpeed = 0;
            if (i < 1)
            {
                lastSpeed = 0;
            }
            else
            {
                lastSpeed = sortedStats[i - 1].speed;
            }
            if (sortedStats[i].speed == lastSpeed)
            {
                sortedStats[i].speedUp = true;
                sortedStats[i].speed  += 1;
            }
            else
            {
            }
        }
        sortedStats = stats.OrderBy(s => s.speed).ToList();
        sortedStats.Reverse();
        int size = sortedStats.Count;

        stats = sortedStats;
        baseStats        currentCharTurn = sortedStats[currentActor];
        List <baseStats> enemyList       = new List <baseStats>();

        if (currentActor == 1)
        {
            stats = sortedStats;
        }
        foreach (baseStats stat in stats)
        {
            if (stat.gameObject.tag == "enemy")
            {
                enemyList.Add(stat);
            }
        }
        List <baseStats> heroList = new List <baseStats>();

        foreach (baseStats stat in stats)
        {
            if (stat.gameObject.tag == "Player")
            {
                heroList.Add(stat);
            }
        }
        // Take that turn

        if (enemyList.Count < 1)
        {
            Debug.Log("poggers");
            battleText.text = "POGGERS";
            FinishBattle();
        }
        else if (heroList.Count < 1)
        {
            Debug.Log("OmegaLOL");
            battleText.text = "OmegaLOL";
            GlobalManager.instance.GameOver();
        }
        else if (currentCharTurn.status != "")
        {
            StatusEffects.CheckStatus(currentCharTurn, this);
            StatusEffects.CheckBuff(currentCharTurn);
            attacker = currentCharTurn;
            Debug.Log("Turn:" + attacker.nameChar);
        }
        else if (currentCharTurn.gameObject.tag == "Player" && currentCharTurn.turn == false)
        {
            StatusEffects.CheckBuff(currentCharTurn);

            currentCharTurn.turn = true;
            attacker             = currentCharTurn;
            foreach (InventorySlot slot in slots)
            {
                slot.attacker = attacker;
            }
            Debug.Log("Turn:" + attacker.nameChar);
            playerTurn();
        }
        else if (currentCharTurn.gameObject.tag == "enemy" && currentCharTurn.turn == false)
        {
            StatusEffects.CheckBuff(currentCharTurn);
            currentCharTurn.turn = true;

            attacker = currentCharTurn;
            foreach (InventorySlot slot in slots)
            {
                slot.attacker = attacker;
            }
            Debug.Log("Turn:" + attacker.nameChar);
            attacker.gameObject.GetComponent <enemyDeath>().Die();
            attacker.character.spec.enemyAI(attacker);
        }

        if (size > sortedStats.Count)
        {
            sortedStats = stats.OrderBy(s => s.speed).ToList();

            sortedStats.Reverse();
            foreach (baseStats stat in sortedStats)
            {
                stat.turn = false;
            }
            currentActor = 0;
            Reset();
        }

        currentActor++;

        if (currentActor > sortedStats.Count - 1)
        {
            foreach (baseStats stat in sortedStats)
            {
                stat.turn = false;
            }
            currentActor = 0;
        }
    }