public void AddBuff(FightUnit caster, int tplId, int buffLevel) { JObject buffJson = JsonMgr.GetSingleton().GetBuff(tplId); if (buffJson == null) { EDebug.LogErrorFormat("BuffMgr.AddBuff, failed to get buff json, id:{0}", tplId); return; } int type = buffJson["type"].ToObject <int>(); int layers = buffJson["layers"].ToObject <int>(); int resid = buffJson["resid"].ToObject <int>(); bool onfoot = buffJson["onfoot"].ToObject <int>() != 0; int calType = buffJson["caltype"].ToObject <int>(); JArray buffParam = buffJson["buffparam"].ToObject <JArray>(); int buffPriority = buffJson["priority"].ToObject <int>(); Vector3 effectParam = AttrUtil.CalExpression(calType, buffParam, caster, this._unit, buffLevel); Buff buff = new Buff(this, caster, buffLevel, ++_uid, tplId, effectParam); if (checkPriority(buffPriority)) { int curLayer = getCurLayer(tplId); if (curLayer >= layers) { removeFirstBuff(tplId); } if (0 == getCurLayer(tplId) && resid > 0) { //通知显示层显示特效 ZEventSystem.Dispatch(EventConst.OnFightUnitAddBuff, this._unit, resid, onfoot, true); } if (type == (int)BuffType.Time) { TakeEffect(buff); } _allBuff.Add(buff); } }
private void _analyzeEffect(int effectId, ref HashSet <int> sound, ref HashSet <int> gos) { JObject jEffect = JsonMgr.GetSingleton().GetSkillEffect(effectId); if (jEffect == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeEffect failed, no such effect:{0}", effectId); return; } int hitEffect = jEffect["hiteffect"].ToObject <int>(); if (hitEffect != 0) { gos.Add(hitEffect); } int effect = jEffect["effect"].ToObject <int>(); int paramType = jEffect["paramtype"].ToObject <int>(); if (1 == paramType) { return; } Vector3 EffectParams = AttrUtil.CalExpression(paramType, jEffect["effectparam"].ToObject <JArray>()); switch (effect) { case (int)EffectType.BULLET: _analyzeBullet((int)EffectParams.y, ref sound, ref gos); break; case (int)EffectType.BUFF: _analyzeBuffRes((int)EffectParams.y, ref sound, ref gos); break; case (int)EffectType.Summon: _analyzeFighterRes((int)EffectParams.x, true, ref sound, ref gos); break; } }
private void _analyzeBuffRes(int buffId, ref HashSet <int> sound, ref HashSet <int> gos) { JObject jBuff = JsonMgr.GetSingleton().GetBuff(buffId); if (jBuff == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeBuff failed, no such buff:{0}", buffId); return; } int resId = jBuff["resid"].ToObject <int>(); if (resId != 0) { gos.Add(resId); } int effect = jBuff["effect"].ToObject <int>(); int calType = jBuff["caltype"].ToObject <int>(); if (1 == calType) { return; } Vector3 buffParams = AttrUtil.CalExpression(calType, jBuff["buffparam"].ToObject <JArray>()); switch (effect) { case (int)BuffEffect.UsePromotSkill: case (int)BuffEffect.UseSkill: _analyzeSkillRes((int)buffParams.y, ref sound, ref gos); break; case (int)BuffEffect.AddBuff: _analyzeBuffRes((int)buffParams.y, ref sound, ref gos); break; } }