Preview:
    //Use the ability if it is ready.
    public bool Use(int abilityNum)
    {
        //Is it ready?
        if (IsReady() == false)
            return false;
        //Use the power.
        ParentHero.UsePower(PowerUsed);
        //Apply the damage (or healing is the damage is negative).
        if (ParentHero.Target.TakeDamage(DamageDone) == true)
            ParentHero.Target = ParentHero.FindTarget(); //If the target is dead, find a new one.

        //TODO: Add needed flags or other functionality for abilities that don't just do
        //damage or affect more than one target (AoE, heals, dodges, blocks, stuns, etc.)
        abilityUses += 1.0f;
        
        //if the ability is the Flipper Smash, Knockback the enemy
        if(abilityNum == 2)
        {
            //change position of enemy 2 units to the right
            ParentHero.Target.transform.position = new Vector3(ParentHero.Target.transform.position.x + 2.0f, ParentHero.Target.transform.position.y, ParentHero.Target.transform.position.z);
        }

        //if ability is Fur Bomb, AoE attack
        if(abilityNum == 5)
        {
            //find all enemies
            var enemies = FindObjectsOfType<Enemy>();
            //go check all the enemies in round
            foreach (Enemy enemy in enemies)
            {
                //if there are other enemies within range
                if (enemy.transform.position.x <= (ParentHero.transform.position.x + 10.0f) && enemy.transform.position.x >= (ParentHero.transform.position.x - 10.0f))
                {
                    //and is not the already targetted enemy
                    if(enemy != ParentHero.Target)
                    {
                        //take decreased damage
                        enemy.TakeDamage(DamageDone - 5.0f);
                    }
                }
            }
        }

        //Put the ability on cooldown.
        CooldownLeft = CooldownTime;
        return true;
    }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter