Ejemplo n.º 1
0
 public void ability9(BattleClick unit, List <BattleClick> targets)
 {
     for (int x = 0; x < targets.Count; x++)
     {
         if (targets[x].currentHealth > 0)
         {
             targets[x].addDebuff("Poison", 3);
         }
     }
 }
Ejemplo n.º 2
0
 public void ability7(BattleClick unit, List <BattleClick> targets)
 {
     for (int x = 0; x < targets.Count; x++)
     {
         if (targets[x].currentHealth > 0)
         {
             targets[x].takeDamage(100, unit);
         }
     }
 }
Ejemplo n.º 3
0
    public void takeDamage(int dmg, BattleClick unit)
    {
        countdown = 60;
        double newDmg = dmg;

        if (unit.type.Contains(weakness))
        {
            newDmg *= weaknessMultiplier;
        }
        if (unit.type.Contains(resistance))
        {
            newDmg *= resistanceMultiplier;
        }
        if (hasDebuff("Marked"))
        {
            newDmg *= 1.5;
        }
        if (hasDebuff("Vulnerable"))
        {
            if ((float)maxHealth / (float)currentHealth > 2)
            {
                newDmg *= 2;
            }
        }

        Debug.Log("Damage Taken: " + (int)newDmg);
        int healthBefore = currentHealth;

        currentHealth -= (int)newDmg;

        if (hasDebuff("Heals"))
        {
            if (currentHealth < 0)
            {
                GameObject.Find("Player HP Bar").GetComponent <Slider>().value += (float)(healthBefore / 2);
            }
            else
            {
                GameObject.Find("Player HP Bar").GetComponent <Slider>().value += (float)(newDmg / 2);
            }
        }

        if (currentHealth <= 0)
        {
            setAsDead();
        }

        updateDisplayText();
    }
Ejemplo n.º 4
0
    public void setState(GameObject set)
    {
        if (state != null && state.GetComponent <BattleAbility>() != null)
        {
            state.GetComponent <BattleAbility>().unselected();
        }
        else if (state != null && state.GetComponent <BattleClick>() != null)
        {
            state.GetComponent <BattleClick>().unselected();
        }

        if ((set != null && set.GetComponent <BattleAbility>() != null) || (state != null && state.GetComponent <BattleAbility>() != null))
        {
            abilityHandler(set);
        }
        else if (state == null)
        {
            if (set.name.Contains("Character"))
            {
                BattleClick temp = set.GetComponent <BattleClick>();
                Debug.Log("Selected " + temp.name + ", HP: " + temp.currentHealth + ", DMG: " + temp.maxDamage + ", Type: " + temp.type);
                state = set;
            }
        }
        else if (state.GetComponent <BattleClick>() != null)
        {
            if (set.GetComponent <BattleClick>() != null)
            {
                if (state.name == set.name)
                {
                    state = null;
                    Debug.Log("Deselected Unit");
                }
                else
                {
                    autoHandler(set);
                }
            }
        }

        if (state != null && state.GetComponent <BattleAbility>() != null)
        {
            state.GetComponent <BattleAbility>().selected();
        }
        else if (state != null && state.GetComponent <BattleClick>() != null)
        {
            state.GetComponent <BattleClick>().selected();
        }
    }
Ejemplo n.º 5
0
    public void tryAI()
    {
        bool playerDone = true;

        for (int x = 1; x <= 9; x++)
        {
            BattleClick temp = GameObject.Find("Character " + x).GetComponent <BattleClick>();
            if (temp.active)
            {
                if (temp.canAttack())
                {
                    playerDone = false;
                }
            }
        }
        if (playerDone)
        {
            runAI();
        }
    }
Ejemplo n.º 6
0
    private void autoHandler(GameObject set)
    {
        BattleClick setbcComponent   = set.GetComponent <BattleClick>();
        BattleClick statebcComponent = null;

        if (state != null)
        {
            statebcComponent = state.GetComponent <BattleClick>();
        }
        if (state.name.Contains("Character"))
        {
            if (set.name.Contains("Character"))
            {
                Debug.Log("Selected " + setbcComponent.name + ", HP: " + setbcComponent.currentHealth + ", DMG: " + setbcComponent.maxDamage + ", Type: " + setbcComponent.type);
                state = set;
            }
            else if (set.name.Contains("Enemy"))
            {
                bool attackable = false;
                if (statebcComponent.type.Contains("Antibiotic"))
                {
                    attackable = inRange(2, setbcComponent.charPosition);
                }
                else if (statebcComponent.type.Contains("ImmuneCell"))
                {
                    attackable = inRange(1, setbcComponent.charPosition);
                }
                if (attackable)
                {
                    Debug.Log(statebcComponent.name + " Attacked " + set.name + " of type " + setbcComponent.type + " with " + setbcComponent.currentHealth + " hp");
                    setbcComponent.autoTakeDamage(statebcComponent);
                    Debug.Log("Enemy Health Left: " + setbcComponent.currentHealth);
                    statebcComponent.ability.charge++;
                    statebcComponent.selectable = false;
                    state = null;
                    tryAI();
                }
            }
        }
    }
Ejemplo n.º 7
0
 public void autoTakeDamage(BattleClick unit)
 {
     takeDamage(unit.getDmg(), unit);
 }
Ejemplo n.º 8
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();
            }
        }
    }
Ejemplo n.º 9
0
 public void ability8(BattleClick unit, List <BattleClick> targets)
 {
     targets[0].takeDamage(250, unit);
 }