/// <summary> /// 判断buff是否存在 /// </summary> /// <param name="buff">buff信息</param> /// <returns></returns> bool IsExitBuff(BuffDataBase buff) { BuffDataBase tempBuff = GetCurBuffData(buff.buffID); if (tempBuff != null) { switch (tempBuff.buffOverlap) { case BuffOverlap.AddTime: tempBuff.AddTime(buff.MaxLimit); break; case BuffOverlap.ResterTime: tempBuff.RestartTime(); break; case BuffOverlap.AddLayer: tempBuff.RestartTime(); tempBuff.AddLayer(tempBuff.NumData); break; case BuffOverlap.None: break; } return(true); } return(false); }
void ChangeCreatureByBuff(IEntity en, uint buffBaseID, bool isControl) { if (en == null) { return; } BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(buffBaseID); if (db == null) { // Log.Error("找不到Buff{0}的配置数据!", buffBaseID); return; } if (db.buffBigType == (int)BuffBigType.Control && db.buffSmallType == (int)BuffSmallType.XuanYun) { ICreature creature = en as ICreature; if (creature != null) { if (isControl) { creature.ChangeState(CreatureState.Contrl); } else { creature.ChangeState(CreatureState.Normal); } } } }
public void CancleBuffState(stCancelStateIcoListMagicUserCmd_S cmd) { BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(cmd.wdState); if (db != null) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("GetEntitySystem failed!"); } IEntity entity = EntitySystem.EntityHelper.GetEntity(cmd.byType, cmd.dwTempID); if (entity == null) { Engine.Utility.Log.Error("es.FindEntity useid is !" + cmd.dwTempID.ToString()); } else { Log.LogGroup("ZDY", "取消{0}身上的buff {1}===========", db.strName, entity.GetName()); } } else { Log.Error("找不到buff ===========" + cmd.wdState); } IBuffPart bp = GetBuffPart((GameCmd.SceneEntryType)cmd.byType, cmd.dwTempID); if (bp != null) { bp.CancleBuffState(cmd); } }
/// <summary> /// 通过[编号]二分快速查表 /// </summary> /// <param name="dwID">编号</param> /// <returns></returns> public static IEnumerable <BuffDataBase> Query(this List <BuffDataBase> sorted, uint dwID) { var key = new BuffDataBase() { dwID = dwID }; var comparer = new Comparer1(); var from = sorted.BinarySearch(key, comparer); if (from < 0) { yield break; } var to = from + 1; while (from > 0 && comparer.Compare(key, sorted[from - 1]) == 0) { from--; } while (to < sorted.Count && comparer.Compare(key, sorted[to]) == 0) { to++; } for (var i = from; i < to; i++) { yield return(sorted[i]); } }
void OnEeventAddBuff(int eventID, Client.stAddBuff state) { BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(state.buffid); if (db != null) { if (db.dwShield == 1) {//不显示的直接跳过 return; } } if (ClientGlobal.Instance().IsMainPlayer(state.uid)) { mainRoleBuffList.Insert(0, state); stShowBuffInfo info = new stShowBuffInfo(); info.IsMainRole = true; DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info); } else { Client.IEntity target = ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget(); if (target != null) { if (target.GetUID() == state.uid) { targetBuffList.Insert(0, state); stShowBuffInfo info = new stShowBuffInfo(); info.IsMainRole = false; DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info); } } } }
void CreateEffect(uint runID) { BuffDataBase db = GetBuffDataBase(runID); if (db == null) { // Log.Error("读取Buff配置数据出错:{0}", runID); return; } for (int i = 0; i < db.buffEffect.Count; i++) { var item = db.buffEffect[i]; if (item == 0) { continue; } FxResDataBase edb = GameTableManager.Instance.GetTableItem <FxResDataBase>(item); if (edb == null) { // Log.Error("get FxResDataBase is null id is " + item.ToString()); return; } if (!IsHideFx()) { int nEffectID = (int)EffectViewFactory.Instance().CreateEffect(m_Master.GetUID(), item); if (!effectDic.ContainsKey(runID)) { effectDic.Add(runID, nEffectID); } } } }
public void AddBuffDataBase(BuffDataBase _data) { if (BuffDataBaseList == null) { BuffDataBaseList = new List <BuffDataBase> (); } BuffDataBaseList.Add(_data); }
/// <summary> /// buff添加 /// </summary> /// <param name="buffData"></param> public void AddBuff(BuffDataBase buffData) { if (!buffs.Contains(buffData)) { buffs.Add(buffData); buffData.StartBuff(); } }
public override void OnInit(BuffDataBase buffData, Unit theUnitFrom, Unit theUnitBelongto) { //设置Buff来源Unit和归属Unit this.TheUnitFrom = theUnitFrom; this.TheUnitBelongto = theUnitBelongto; this.BuffData = buffData; BuffTimerAndOverlayHelper.CalculateTimerAndOverlay(this, this.BuffData); }
public void RemoveBuffDataBase(BuffDataBase _data) { if (BuffDataBaseList == null) { return; } BuffDataBaseList.Remove(_data); }
/// <summary> /// 检测Buff存在 /// </summary> /// <param name="buffID">id</param> /// <returns></returns> public bool IsExitBuff(int buffID) { BuffDataBase tempBuff = GetCurBuffData(buffID); if (tempBuff != null) { return(true); } return(false); }
/// <summary> /// 关闭Buff /// </summary> /// <param name="buffID">id</param> public virtual void CloseBuff(int buffID) { BuffDataBase tempBuff = GetCurBuffData(buffID); if (tempBuff != null) { tempBuff.CloseBuff(); buffs.Remove(tempBuff); } }
/// <summary> /// 获取当前Buff层数 /// </summary> /// <param name="buffID">id</param> /// <returns></returns> public int getBuffLayer(int buffID) { BuffDataBase tempBuff = GetCurBuffData(buffID); int count = 0; if (tempBuff != null) { count = tempBuff.CurLayer; } return(count); }
/// <summary> /// 通过[编号 + 等级]二分快速查表 /// </summary> /// <param name="dwID">编号</param> /// <param name="buffLevel">等级</param> /// <returns></returns> public static BuffDataBase Query(this List <BuffDataBase> sorted, uint dwID, uint buffLevel) { var key = new BuffDataBase() { dwID = dwID, buffLevel = buffLevel }; var comparer = new Comparer2(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(BuffDataBase)); }
public void InitBuffItemInfo(BuffDataBase db, long leftTime) { if (db == null) { return; } m_db = db; m_nLeftTime = leftTime; InitUI(); }
/// <summary> /// 外部调用执行Buff /// </summary> /// <param name="buffData">Buff信息</param> public virtual void DoBuff(BuffDataBase buffData) { if (buffData == null) { return; } if (!IsExitBuff(buffData)) { AddBuff(buffData); } }
void RefreshBuffIcon(Transform widget, ArrayList stateList) { if (widget == null) { return; } widget.gameObject.SetActive(true); for (int i = 0; i < totalBuffIconCount; i++) { int index = i + 1; if (m_nameDic.ContainsKey(index)) { buffname = m_nameDic[index]; } Transform buffTrans = widget.transform.Find(buffname.ToString()); if (buffTrans != null) { if (i < stateList.Count) { Client.stAddBuff st = (Client.stAddBuff)stateList[i]; BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid, (int)st.level); if (db != null) { UILabel label = buffTrans.Find("Label").GetComponent <UILabel>(); label.text = ""; if (db.dwShield == 0) { buffTrans.gameObject.SetActive(true); } else { buffTrans.gameObject.SetActive(false); } } BuffUICountDown bc = buffTrans.gameObject.GetComponent <BuffUICountDown>(); if (bc == null) { bc = buffTrans.gameObject.AddComponent <BuffUICountDown>(); } bc.InitLeftTime((uint)st.lTime, db); } else { buffTrans.gameObject.SetActive(false); } } } }
void RemoveBuffByClient(Client.stAddBuff st) { stRemoveBuff sb = new stRemoveBuff(); sb.uid = st.uid; sb.buffid = st.buffid; sb.buffThisID = st.buffThisID; BuffDataBase bdb = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid); if (bdb != null) { if (bdb.forever == 1) { return; } } OnEventRemoveBuff(0, sb); }
public void InitLeftTime(uint leftTime, BuffDataBase db) { m_nLeftTime = leftTime / 1000; if (db != null) { m_db = db; if (m_texture != null) { UIManager.GetTextureAsyn(db.buffIcon, ref m_buffTextureSeed, () => { if (null != m_texture) { m_texture.mainTexture = null; } }, m_texture, false); } } }
public BuffDataBase GetBuffDataBase(uint thisID) { stStateValue state = null; Dictionary <uint, stBuffData> .Enumerator iter = buffDic.GetEnumerator(); while (iter.MoveNext()) { if (iter.Current.Value.buffDataDic.TryGetValue(thisID, out state)) { BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(state.baseid, (int)state.level); if (db != null) { return(db); } else { Log.Error("buffdatabase is null id is {0}", state.baseid); return(null); } } } return(null); }
public void ReceiveBuffList(List <stStateValue> list) { IEntity en = m_Master; for (int i = 0; i < list.Count; i++) { var state = list[i]; ChangeCreatureByBuff(en, state.baseid, true); //客户端使用毫秒的精度 state.ltime = state.ltime * 1000; stBuffData buffData; if (buffDic.TryGetValue(state.thisid, out buffData)) { if (buffData.buffDataDic.ContainsKey(state.thisid)) { buffData.buffDataDic[state.thisid] = state; } else { buffData.buffDataDic.Add(state.thisid, state); } // Buff Update // 更新时间 } else { buffData = new stBuffData(); buffData.buffid = state.thisid; buffData.buffDataDic = new Dictionary <uint, stStateValue>(); buffData.buffDataDic.Add(state.thisid, state); buffDic.Add(state.thisid, buffData); AddBuffEffect(state.baseid, state.thisid); if (en != null) { stAddBuff addBuff = new stAddBuff(); addBuff.buffid = state.baseid; addBuff.uid = en.GetUID(); addBuff.level = state.level; addBuff.lTime = state.ltime; addBuff.buffThisID = state.thisid; EventEngine.Instance().DispatchEvent((int)GameEventID.BUFF_ADDTOTARGETBUFF, addBuff); } } } if (list.Count > 0) { int len = list.Count; stStateValue state = list[len - 1]; BuffDataBase bdb = GameTableManager.Instance.GetTableItem <BuffDataBase>(state.baseid); if (bdb != null) { string str = bdb.buffColor; Color c = SkillSystem.GetColorByStr(str); if (c == null) { return; } if (en != null) { m_buffColorEntity = en; en.SendMessage(EntityMessage.EntityCommond_SetColor, c); if (TimerAxis.Instance().IsExist(m_ucolorCountDownTimerID, this)) { TimerAxis.Instance().KillTimer(m_ucolorCountDownTimerID, this); } TimerAxis.Instance().SetTimer(m_ucolorCountDownTimerID, state.ltime, this, 1); } } } }
void RemoveEntityBuff(uint baseID, uint thisID) { uint stateID = baseID; ChangeCreatureByBuff(m_Master, stateID, false); BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(stateID); if (db != null) { if (db.dwShield == 1) {//不显示的直接跳过 return; } } uint cancleBuffThisID = thisID; BuffDataBase baseBuffData = GetBuffDataBase(cancleBuffThisID); if (baseBuffData == null) { // Log.Error("getbuffdatabase error buffthisid is " + cancleBuffThisID.ToString()); return; } if (baseBuffData.buffRemoveEffect != 0) { if (!IsHideFx()) { EffectViewFactory.Instance().CreateEffect(m_Master.GetUID(), baseBuffData.buffRemoveEffect); } } if (baseBuffData.buffBigType == (int)BuffBigType.Control) { if (m_Master != null) { //Log.Error( "buff cancle" ); if (!m_Master.IsDead()) { Engine.Utility.Log.LogGroup("ZDY", " CreatureState.Normal "); m_Master.ChangeState(CreatureState.Normal, null); } else { Engine.Utility.Log.LogGroup("ZDY", "CreatureState.Dead ****"); m_Master.ChangeState(CreatureState.Dead, null); } } } stBuffData buffData; if (buffDic.TryGetValue(cancleBuffThisID, out buffData)) { buffData.buffDataDic.Remove(cancleBuffThisID); } if (buffData.buffDataDic.Count <= 0) { RemoveBuffEffect(stateID, cancleBuffThisID); buffDic.Remove(cancleBuffThisID); if (m_Master != null) { stRemoveBuff removeBuff = new stRemoveBuff(); removeBuff.buffid = stateID; removeBuff.uid = m_Master.GetUID(); removeBuff.buffThisID = cancleBuffThisID; EventEngine.Instance().DispatchEvent((int)GameEventID.BUFF_DELETETARGETBUFF, removeBuff); } } }
void Awake() { instance = this; }
// 添加buff表现特效效果 void AddBuffEffect(uint buffID, uint runID) { if (m_Master == null) { return; } if (m_Master.GetNode() == null) { if (!m_unCreateEffectList.Contains(runID)) { m_unCreateEffectList.Add(runID); } } else { CreateEffect(runID); } BuffDataBase db = GetBuffDataBase(runID); if (db == null) { //Log.Error("读取Buff配置数据出错:{0}", buffID); return; } for (int i = 0; i < db.buffEffect.Count; i++) { var item = db.buffEffect[i]; if (item == 0) { continue; } FxResDataBase edb = GameTableManager.Instance.GetTableItem <FxResDataBase>(item); if (edb == null) { // Log.Error("get FxResDataBase is null id is " + item.ToString()); return; } string aniName = edb.targetAniName; if (string.IsNullOrEmpty(aniName)) { return; } PlayAni anim_param = new PlayAni(); anim_param.strAcionName = aniName; anim_param.fSpeed = 1; anim_param.nStartFrame = 0; anim_param.nLoop = edb.playAniTime; //if(db.buffBigType == (int)BuffBigType.Control) //{ // anim_param.nLoop = -1; //} //else //{ // anim_param.nLoop = 1; //} anim_param.fBlendTime = 0.2f; bool bRide = (bool)m_Master.SendMessage(EntityMessage.EntityCommond_IsRide, null); if (bRide) { return; } if (m_Master.GetCurState() == CreatureState.Contrl) {//眩晕不播放其他动画 anim_param.aniCallback = OnHitCallback; anim_param.callbackParam = m_Master; if (SkillSystem.GetClientGlobal().IsMainPlayer(m_Master.GetID())) { Engine.Utility.Log.Info("buff 播放眩晕动作 {0}", anim_param.strAcionName); } m_Master.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param); } else { if (m_Master.GetCurState() != CreatureState.Move) {//移动中不播放受击动作 Client.IControllerSystem cs = m_ClientGlobal.GetControllerSystem(); if (cs != null) { Client.ICombatRobot robot = cs.GetCombatRobot(); if (robot.Status == CombatRobotStatus.RUNNING) { if (SkillSystem.GetClientGlobal().IsMainPlayer(m_Master.GetID())) {//自动挂机 不播受击 return; } } } m_Master.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param); } } } }
BuffDataBase CreateBuffDataBaseByID(int index) { BuffDataBase _data = new BuffDataBase(); return(_data); }
public uint GetBuffEffectType() { uint type = 0; Dictionary <uint, stBuffData> .Enumerator iter = buffDic.GetEnumerator(); while (iter.MoveNext()) { var buff = iter.Current; BuffDataBase db = GetBuffDataBase(buff.Key); if (db != null) { string[] effectArray = db.effectid.Split('_'); for (int i = 0; i < effectArray.Length; i++) { string effectid = effectArray[i]; uint id = uint.Parse(effectid); StateDataBase stateBase = GameTableManager.Instance.GetTableItem <StateDataBase>(id); if (stateBase != null) { if (stateBase.typeid == (int)EffectType.DINGSHEN) { type |= (uint)BuffEffectType.CANNOT_MOVE; break; } } } } } Dictionary <uint, stBuffData> .Enumerator iterbuff = buffDic.GetEnumerator(); while (iterbuff.MoveNext()) { var buff = iterbuff.Current; BuffDataBase db = GetBuffDataBase(buff.Key); if (db != null) { string[] effectArray = db.effectid.Split('_'); for (int i = 0; i < effectArray.Length; i++) { string effectid = effectArray[i]; uint id = uint.Parse(effectid); StateDataBase stateBase = GameTableManager.Instance.GetTableItem <StateDataBase>(id); if (stateBase != null) { if (stateBase.typeid == (int)EffectType.JINGU) { type |= (uint)BuffEffectType.CANNOT_USEITEM; break; } } } } } Dictionary <uint, stBuffData> .Enumerator iterDic = buffDic.GetEnumerator(); while (iterDic.MoveNext()) { var buff = iterDic.Current; BuffDataBase db = GetBuffDataBase(buff.Key); if (db != null) { string[] effectArray = db.effectid.Split('_'); for (int i = 0; i < effectArray.Length; i++) { string effectid = effectArray[i]; uint id = uint.Parse(effectid); StateDataBase stateBase = GameTableManager.Instance.GetTableItem <StateDataBase>(id); if (stateBase != null) { if (stateBase.typeid == (int)EffectType.CHENMO) { type |= (uint)BuffEffectType.CANOT_USESKILL; break; } } } } } return(type); }
void ShowBuffInfo(Transform container, bool bMainRole) { if (container == null) { return; } int cellHegiht = 100; Transform buffMessage = container.transform.Find("BuffMessage"); if (buffMessage == null) { return; } ArrayList buffList = BuffManager.MainRoleBuffList; if (!bMainRole) { buffList = BuffManager.TargetBuffList; } if (buffList.Count == 0) { buffMessage.gameObject.SetActive(false); } else { // buffMessage.gameObject.SetActive(true); } if (!buffMessage.gameObject.activeSelf) { return; } int count = buffList.Count < totalBuffIconCount ? buffList.Count : totalBuffIconCount; Transform scrollTrans = buffMessage.Find("ScrollView"); if (scrollTrans == null) { return; } Transform bg = buffMessage.Find("Bg"); if (bg == null) { return; } UIScrollView sv = scrollTrans.GetComponent <UIScrollView>(); if (sv == null) { return; } UIPanel panel = sv.GetComponent <UIPanel>(); Vector4 baseVec = panel.baseClipRegion; panel.baseClipRegion = new Vector4(baseVec.x, -cellHegiht * (count) / 2 + cellHegiht / 2, baseVec.z, cellHegiht * count); panel.clipOffset = new UnityEngine.Vector2(0, 0); UISprite spr = bg.GetComponent <UISprite>(); if (spr != null) { spr.height = cellHegiht * count; } spr.transform.localPosition = new Vector3(0, -cellHegiht * (count - 1) / 2, 0); // sv.ResetPosition(); // Transform gridTrans = scrollTrans.Find("BuffGrid"); Transform gridTrans = scrollTrans; if (gridTrans == null) { return; } int childCount = gridTrans.childCount; for (int j = buffList.Count; j < childCount; j++) { string buffItemName = GetBuffItemName(j); Transform itemTrans = gridTrans.Find(buffItemName); if (itemTrans != null) { itemTrans.gameObject.SetActive(false); } } for (int i = 0; i < buffList.Count; i++) { Client.stAddBuff st = (Client.stAddBuff)buffList[i]; BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid, (int)st.level); if (db != null) { GameObject buffItem = null; string buffItemName = GetBuffItemName(i); Transform itemTrans = gridTrans.Find(buffItemName); if (itemTrans != null) { buffItem = itemTrans.gameObject; } else { buffItem = GameObject.Instantiate(m_trans_BuffItemInfo.gameObject) as GameObject; itemTrans = buffItem.transform; } buffItem.transform.parent = sv.transform;//gridTrans; itemTrans.localScale = Vector3.one; itemTrans.localRotation = Quaternion.identity; itemTrans.localPosition = new Vector3(0, -cellHegiht * i, 0); // UIGrid grid = gridTrans.GetComponent<UIGrid>(); buffItem.gameObject.SetActive(true); // grid.repositionNow = true; buffItem.name = buffItemName; UIDragScrollView dragScroll = buffItem.GetComponent <UIDragScrollView>(); if (dragScroll == null) { dragScroll = buffItem.AddComponent <UIDragScrollView>(); } dragScroll.scrollView = sv; BuffItemInfo info = buffItem.GetComponent <BuffItemInfo>(); if (info == null) { info = buffItem.AddComponent <BuffItemInfo>(); } info.InitBuffItemInfo(db, st.lTime); } } }