void OnSkillUse(GameObject go) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.MAINBTN_ONTOGGLE, new Client.stMainBtnSet() { pos = 1, isShow = false }); if (parent != null) { Client.IPlayer mainPlayer = ClientGlobal.Instance().MainPlayer; if (mainPlayer == null) { Log.Error("mainPlayer is null"); return; } if (IsCDing) { Log.Error("IsCDing"); return; } bool bRide = DataManager.Manager <RideManager>().IsRide; if (bRide) {//使用任何一个技能都下马 if (m_skillBtnIndex != 0) { parent.ReqUseSkill((uint)m_skillid); } else { DataManager.Instance.Sender.RideDownRide(); parent.ReqUseSkill((uint)m_skillid); } } else { if (m_skillBtnIndex != 10) { LearnSkillDataManager skilldata = DataManager.Manager <LearnSkillDataManager>(); uint commonSkill = skilldata.GetCommonSkillIDByJob(); if (commonSkill != m_skillid) {//普工不走cd if (m_skillBtnIndex == 9) { if (CheckItem()) { var cmd = new GameCmd.stMultiAttackUpMagicUserCmd_C(); cmd.wdSkillID = (uint)m_skillid; Client.IController cs = GetController(); if (cs != null) { IEntity target = cs.GetCurTarget(); if (target != null) { stMultiAttackUpMagicUserCmd_C.Item item = new stMultiAttackUpMagicUserCmd_C.Item(); item.byEntryType = (target.GetEntityType() == EntityType.EntityType_Player ? SceneEntryType.SceneEntry_Player : SceneEntryType.SceneEntry_NPC); item.dwDefencerID = target.GetID(); cmd.data.Add(item); ReqUsePetSkill(cmd); } else { SkillDatabase db = GameTableManager.Instance.GetTableItem <SkillDatabase>(m_skillid); if (db != null) { if (db.targetType != 0) { ReqUsePetSkill(cmd); } else { if (db.targetParam == 4 || db.targetParam == 7 || db.targetParam == 8) { ReqUsePetSkill(cmd); } else { TipsManager.Instance.ShowTips("该技能需要目标"); } } } } } //宠物技能使用 } } else { parent.ReqUseSkill((uint)m_skillid); } } } else { parent.ChangeSkill(this.gameObject); } } parent.OnClickSkillBtn(go, 50010); } else { Log.Error("parent is null"); } }
// 同步技能消息 public void SyncSkill(uint uSkillID, Client.IEntity target, Vector3 targetPos) { if(uSkillID == 0) { Log.Error("SyncSkill skillid is 0"); return; } // 填充数据 Vector3 pos = m_Master.GetPos(); SkillDatabase database = GetSkillDataBase(uSkillID); Client.IControllerSystem ctrlSys = m_ClientGlobal.GetControllerSystem(); if (ctrlSys == null) { return; } Client.IController ctrl = ctrlSys.GetActiveCtrl(); if (ctrl == null) { return; } if (targetPos == Vector3.zero) { int skillerror = 0; bool bCanUse = ctrl.FindTargetBySkillID(CurSkillID, ref targetPos, ref target, out skillerror); if (!bCanUse) { Log.LogGroup("ZDY", "不符合规则 不能放技能"); return; } } var cmd = new GameCmd.stMultiAttackUpMagicUserCmd_C(); cmd.dwAttackerID = (uint)m_ClientGlobal.MainPlayer.GetID(); cmd.wdSkillID = uSkillID; cmd.byEntryType = SceneEntryType.SceneEntry_Player; cmd.srcx = (uint)(pos.x); cmd.srcy = (uint)(-pos.z); Vector3 rot = m_Master.GetRotate(); cmd.byDirect = (uint)rot.y; Vector3 sendTargetPos = GetSendTargetPos(database, targetPos); cmd.x = (uint)(sendTargetPos.x * 100); cmd.y = (uint)(-sendTargetPos.z * 100); if (target != null) { stMultiAttackUpMagicUserCmd_C.Item item = new stMultiAttackUpMagicUserCmd_C.Item(); if (target != null) { item.byEntryType = (target.GetEntityType() == EntityType.EntityType_Player ? SceneEntryType.SceneEntry_Player : SceneEntryType.SceneEntry_NPC); item.dwDefencerID = (uint)target.GetID(); } else { item.dwDefencerID = 0; } cmd.data.Add(item); } m_uDamageID++; cmd.tmpid = m_uDamageID; // 填充数据 m_ClientGlobal.netService.Send(cmd); }