Ejemplo n.º 1
0
    public void runAI()
    {
        for (int x = 1; x <= 9; x++)
        {
            BattleClick temp  = GameObject.Find("Character " + x).GetComponent <BattleClick>();
            BattleClick temp2 = GameObject.Find("Enemy " + x).GetComponent <BattleClick>();
            if (temp.active)
            {
                temp.selectable = true;
                temp.applyDebuffs();
                temp.unselected();
                temp.updateDebuffs();
            }
            if (temp2.active)
            {
                temp2.applyDebuffs();
                temp2.updateDebuffs();
            }
        }

        List <string> symptoms = new List <string>();

        for (int x = 1; x <= 9; x++)
        {
            BattleClick temp = GameObject.Find("Enemy " + x).GetComponent <BattleClick>();
            if (temp.canAttack())
            {
                GameObject.Find("Player HP Bar").GetComponent <Slider>().value -= temp.maxDamage;
                if (temp.symptoms.Contains("Pain"))
                {
                    symptoms.Add("Pain");
                }
                if (temp.symptoms.Contains("Fever"))
                {
                    symptoms.Add("Fever");
                }
                if (temp.symptoms.Contains("Diarrhea"))
                {
                    symptoms.Add("Diarrhea");
                }
                if (temp.symptoms.Contains("Cold"))
                {
                    symptoms.Add("Cold");
                }
            }
        }

        for (int x = 0; x < symptoms.Count; x++)
        {
            int newRand;
            do
            {
                newRand = UnityEngine.Random.Range(1, 10);
            }while (!GameObject.Find("Character " + newRand).GetComponent <BattleClick>().active);

            if (symptoms[x] == "Pain")
            {
                GameObject.Find("Character " + newRand).GetComponent <BattleClick>().addDebuff("Pain", 1);
            }
            else if (symptoms[x] == "Fever")
            {
                GameObject.Find("Character " + newRand).GetComponent <BattleClick>().addDebuff("Fever", 3);
            }
            else if (symptoms[x] == "Diarrhea")
            {
                GameObject.Find("Character " + newRand).GetComponent <BattleClick>().addDebuff("Diarrhea", 2);
            }
            else if (symptoms[x] == "Cold")
            {
                GameObject.Find("Character " + newRand).GetComponent <BattleClick>().addDebuff("Cold", 1);
            }
        }

        for (int x = 1; x <= 9; x++)
        {
            BattleClick temp = GameObject.Find("Character " + x).GetComponent <BattleClick>();
            if (temp.active)
            {
                temp.countdown = 60;
                temp.updateDisplayText();
            }
        }
    }