示例#1
0
    /** LaunchSpell : public override void Method
     * The LauncheSpell Method is called by the abstract Class Classe when the player press the key associated to the spell.
     * First at all, we launch the mother method to initialize the spell launching.
     * If the spell is Launcheable, we create a new List that will contains the targets freshly affected by new IgniteStatus.
     * Then, we explode every targets already affected by an IgniteStatus (making damage to this target).
     * In order to get the new targets that are getting new igniteStatus, we use an overlapSphere.
     * For every collider touched by the overlap sphere we only want to get Colliders of Monsters that have not explosed and are not explosable.
     * Once we get the correct targets, We first apply an explosion damage.
     * Then, we launch a random to instantiate or not ignite on the correct target.
     * Please note that the random can be ignored if CritSuccess was set to true by the FireBlessingSpell.
     * If the random is a success, we instantiate a fresh Ignite child of the target (by adding a new one or reseting the current one).
     * After that, we add the new Frsh targets with fresh ignites to the targetsToAdd List. Then, we refresh the targetsExploded list, by adding the target that just exploded
     * These steps ensures that targets can not explode 2 times and get a new fresh igniteStatus after an explosion.
     * Then, we clear the old ignites on explosed targets and we add the new fresh targets to the target List. We also ensure that CritSuccess is reset to false and we clear the FireBlessingSpell Status.
     * Finally we call the OnSpellLaunched mother method to tell the spell is not in use anymore.
     **/
    public override void LaunchSpell()
    {
        base.LaunchSpell();

        if (!IsSpellLauncheable())
        {
            return;
        }

        List <IgniteStatus> targetsToAdd = new List <IgniteStatus>();

        foreach (IgniteStatus target in Targets)
        {
            EntityLivingBase entity = target.GetComponentInParent <EntityLivingBase>();
            entity.DamageFor(Damages[0]);
            Collider[] cols = Physics.OverlapSphere(entity.transform.position, 10f);
            TargetsExploded.Add(target.GetComponent <Collider>());
            target.ExplodeIgniteStatus();

            foreach (Collider col in cols)
            {
                if (col.gameObject.GetComponent <EntityLivingBase>() &&
                    !col.isTrigger &&
                    !TargetsExploded.Contains(col) &&
                    !Targets.Contains(col.GetComponent <IgniteStatus>()))
                {
                    col.gameObject.GetComponent <EntityLivingBase>().DamageFor(Damages[0]);
                    if (Random.Range(0, 100) < int.Parse(OtherValues[0]) || CritSuccess)
                    {
                        IgniteStatus ignite = col.gameObject.GetComponentInChildren <IgniteStatus>();
                        if (ignite != null)
                        {
                            ignite.ResetStatus();
                        }
                        else
                        {
                            GameObject newIgnite = ApplyStatus(GetComponent <FireBallSpell>().Status[0], col.transform);
                            ignite = newIgnite.GetComponentInChildren <IgniteStatus>();
                        }
                        targetsToAdd.Add(ignite);
                    }
                }
            }
        }
        TargetsExploded.Clear();
        Targets.Clear();
        Targets = targetsToAdd;

        if (CritSuccess)
        {
            GetComponentInChildren <FavorOfFireStatus>().DestroyStatus();
        }

        CritSuccess = false;
        base.OnSpellLaunched();
    }
示例#2
0
    /** ApplyEffectOnHit, public void Method
     * @Params : EntityLivingBase
     * When the instance of FireBall hits an entity, this method is launched.
     * It applies damage and refresh Ignite on the target.
     **/
    public void ApplyEffectOnHit(EntityLivingBase entityHit)
    {
        entityHit.DamageFor(Damages[0]);
        IgniteStatus igniteStatus = entityHit.GetComponentInChildren <IgniteStatus>();

        if (igniteStatus != null)
        {
            igniteStatus.ResetStatus();
        }
        else
        {
            GameObject statusObj = ApplyStatus(Status[0], entityHit.transform);
            GetComponent <ConflagrationSpell>().Targets.Add(statusObj.GetComponent <IgniteStatus>());
        }
    }