Exemplo n.º 1
0
    public void TakeEffect(Buff buff, bool inverse = false)
    {
        JObject cbuff      = JsonMgr.GetSingleton().GetBuff(buff.BuffId);
        int     buffeffect = cbuff["effect"].ToObject <int>();
        int     calType    = cbuff["caltype"].ToObject <int>();
        string  buffparam  = cbuff["buffparam"].ToString();

        float effectParamKey   = buff.EffectParam.x;
        float effectParamValue = (inverse ? -1 : 1) * buff.EffectParam.y;

        switch (buffeffect)
        {
        case (int)BuffEffect.AddHPMax:
            this._unit.MaxHP += (int)(effectParamValue * this._unit.BaseMaxHp);
            break;

        case (int)BuffEffect.AddVigour:
        {
            this._unit.AddVigour((int)effectParamValue);
            if (effectParamValue > 0)
            {
                ZEventSystem.Dispatch(EventConst.OnFightUnitPop, this._unit, new Vector2Int((int)EffectState.HealVigour, (int)effectParamValue));
            }
        }
        break;

        case (int)BuffEffect.AddAtk:
            this.Atk += effectParamValue;
            break;

        case (int)BuffEffect.AddMatk:
            this.Matk += effectParamValue;
            break;

        case (int)BuffEffect.AddDefRate:
            this.DefRate += effectParamValue;
            break;

        case (int)BuffEffect.AddMdefRate:
            this.MdefRate += effectParamValue;
            break;

        case (int)BuffEffect.AddDefBreak:
            this.DefBreak += effectParamValue;
            break;

        case (int)BuffEffect.AddMdefBreak:
            this.MdefBreak += effectParamValue;
            break;

        case (int)BuffEffect.AddDeSowRate:
            this.DeSowRate += effectParamValue;
            break;

        case (int)BuffEffect.AddDeFaintRate:
            this.DeFaintRate += effectParamValue;
            break;

        case (int)BuffEffect.AddDeSpoofRate:
            this.DeSpoofRate += effectParamValue;
            break;

        case (int)BuffEffect.AddHealRate:
            this.HealRate += effectParamValue;
            break;

        case (int)BuffEffect.AddHarmRate:
            this.HarmRate += effectParamValue;
            break;

        case (int)BuffEffect.AddAsp:
            this.AspRate += effectParamValue;
            break;

        case (int)BuffEffect.AddDodgeRate:
            this.DodgeRate += effectParamValue;
            break;

        case (int)BuffEffect.AddHitRate:
            this.HitRate += effectParamValue;
            break;

        case (int)BuffEffect.AddBlockRate:
            this.BlockRate += effectParamValue;
            break;

        case (int)BuffEffect.AddRoutRate:
            this.RoutRate += effectParamValue;
            break;

        case (int)BuffEffect.AddCritRate:
            this.CritRate += effectParamValue;
            break;

        case (int)BuffEffect.AddFirmRate:
            this.FirmRate += effectParamValue;
            break;

        case (int)BuffEffect.AddCritInc:
            this.CritInc += effectParamValue;
            break;

        case (int)BuffEffect.LastHeal:
        {
            if (buff.EffectParam.x == 0)
            {
                this._unit.HarmHp(new Vector2Int(0, (int)buff.EffectParam.y), buff.Caster, buff.SklId);
            }
            else
            {
                this._unit.HarmHp(AttrUtil.CalHarm(false, buff.EffectParam.x == 1, buff.EffectParam.y, buff.Caster, this._unit), buff.Caster, buff.SklId);
            }
        }
        break;

        case (int)BuffEffect.LastHarm:
        {
            if (buff.EffectParam.x == 0)
            {
                this._unit.HarmHp(new Vector2Int(0, -(int)buff.EffectParam.y), buff.Caster, buff.SklId);
            }
            else
            {
                this._unit.HarmHp(AttrUtil.CalHarm(false, buff.EffectParam.x == 1, -(int)buff.EffectParam.y, buff.Caster, this._unit), buff.Caster, buff.SklId);
            }
        }
        break;

        case (int)BuffEffect.Sow:
        {
            this._unit.CState = (inverse ? ControlState.None : ControlState.Sow);
        }
        break;

        case (int)BuffEffect.Faint:
        {
            this._unit.CState = (inverse ? ControlState.None : ControlState.Faint);
        }
        break;

        case (int)BuffEffect.Spoof:
        {
            this._unit.CState = (inverse ? ControlState.None : ControlState.Spoof);
            if (!inverse)
            {
                this._unit.PathFinderObj.StartFind();
            }
        }
        break;

        case (int)BuffEffect.Sneer:
        {
            this._unit.CState      = (inverse ? ControlState.None : ControlState.Sneer);
            this._unit.SneerTarget = !inverse ? buff.Caster : null;
        }
        break;

        case (int)BuffEffect.Scared:
        {
            if (inverse)
            {
                this._unit.RemoveSpecialState(SpecialState.Scared);
            }
            else
            {
                this._unit.AddSpecialState(SpecialState.Scared);
            }
        }
        break;

        case (int)BuffEffect.Betray:
        {
            this._unit.CState = (inverse ? ControlState.None : ControlState.Betray);
        }
        break;

        case (int)BuffEffect.Slient:
        {
            if (inverse)
            {
                this._unit.RemoveSpecialState(SpecialState.Slient);
            }
            else
            {
                this._unit.AddSpecialState(SpecialState.Slient);
            }
            this._unit.Interrupt();
        }
        break;

        case (int)BuffEffect.AddBuff:
        {
            this.AddBuff(buff.Caster, (int)effectParamValue, buff.BuffLevel);
        }
        break;

        case (int)BuffEffect.UsePromotSkill:
        {
            if (Random.Range(0, 1.0f) < effectParamKey)
            {
                Skill cskill = JsonMgr.GetSingleton().GetSkillByID((int)effectParamValue);
                if (cskill != null)
                {
                    this._unit.UseSKill(cskill, buff.BuffLevel);
                }
            }
        }
        break;

        case (int)BuffEffect.Invincible:
            this._unit.Invincible = !inverse;
            break;

        case (int)BuffEffect.DeInvincible:
            this._unit.DeInvincible = !inverse;
            break;

        case (int)BuffEffect.HpSuck:
            this.HpSuck += effectParamValue;
            break;

        case (int)BuffEffect.UseSkill:
        {
            Skill cskill = JsonMgr.GetSingleton().GetSkillByID((int)effectParamValue);
            if (cskill != null)
            {
                this._unit.UseSKill(cskill, buff.BuffLevel);
            }
        }
        break;

        default:
            break;
        }
    }