Ejemplo n.º 1
0
    public override bool ApplyInstant(FormationUnit performer, FormationUnit target, Effect effect)
    {
        if (target == null)
        {
            return(false);
        }

        float poisonChance = effect.IntegerParams[EffectIntParams.Chance].HasValue ?
                             (float)effect.IntegerParams[EffectIntParams.Chance].Value / 100 : 1;

        poisonChance -= target.Character.GetSingleAttribute(AttributeType.Poison).ModifiedValue;
        if (performer != null && performer.Character is Hero)
        {
            poisonChance += performer.Character.GetSingleAttribute(AttributeType.PoisonChance).ModifiedValue;
        }

        poisonChance = Mathf.Clamp(poisonChance, 0, 0.95f);
        if (RandomSolver.CheckSuccess(poisonChance))
        {
            var poisonStatus = (PoisonStatusEffect)target.Character.GetStatusEffect(StatusType.Poison);
            var newDot       = new DamageOverTimeInstanse
            {
                TickDamage  = DotPoison,
                TicksAmount = effect.IntegerParams[EffectIntParams.Duration] ?? 3
            };
            newDot.TicksLeft = newDot.TicksAmount;
            poisonStatus.AddInstanse(newDot);
            return(true);
        }
        return(false);
    }
    public override void ReadStatusData(BinaryReader br)
    {
        int dotCount = br.ReadInt32();

        doTs.Clear();
        for (int i = 0; i < dotCount; i++)
        {
            var newDot = new DamageOverTimeInstanse();
            newDot.TickDamage  = br.ReadInt32();
            newDot.TicksAmount = br.ReadInt32();
            newDot.TicksLeft   = br.ReadInt32();
            doTs.Add(newDot);
        }
    }
 public void AddInstanse(DamageOverTimeInstanse newInstance)
 {
     doTs.Add(newInstance);
 }