public void MatchSlotData(int slotType, int slotIndex) { if (EntityFactory.MainHero == null) { return; } SkillCtrl sc = EntityFactory.MainHero.GetComponent <SkillCtrl>(); int index = slotType * m_maxSlotPerType + slotIndex; if (!sc || !CurrentSlotMap.ContainsKey(index)) { return; } sc.SetSlotKeyCode(CurrentSlotMap[index].nSlotType, CurrentSlotMap[index].nSlotIndex, CurrentSlotMap[index].nReleaseCondition, CurrentSlotMap[index].szKeySequence); cmd_entity_set_smart_cast data = new cmd_entity_set_smart_cast(); data.nSlotIndex = CurrentSlotMap[index].nSlotIndex; data.nSlotType = CurrentSlotMap[index].nSlotType; data.nSmartCast = CurrentSlotMap[index].nAutoCasting; slotSmartDatas[0] = data; SendSmartDataToLogic(); slotSmartDatas.Clear(); }
/// <summary> /// 修改槽位方法 /// </summary> /// <param name="nIndex">槽位索引 槽位类型(slotType) * 每类槽位最大数量(1000)+当前槽位索引(slotIndex)</param> /// <param name="nAuto">智能施法状态(0:默认;1:快捷 ;2:常规;3:推荐)</param> /// <param name="szKeyCode">槽位键值</param> public void ChangeSlotData(int nIndex, int nAuto, string szKeyCode) { if (CurrentSlotMap.ContainsKey(nIndex)) { int index = CurrentSlotMap[nIndex].nSlotIndex; int type = CurrentSlotMap[nIndex].nSlotType; if (szKeyCode != CurrentSlotMap[nIndex].szKeySequence) { CurrentSlotMap[nIndex].szKeySequence = szKeyCode; if (type == (int)SlotType.Function) { FuntionShortCutCtrl.GetInstance().ChangeKeyCodeToDic(index, szKeyCode, 0); } else { if (!EntityFactory.MainHero) { return; } SkillCtrl sc = EntityFactory.MainHero.GetComponent <SkillCtrl>(); if (sc != null) { sc.SetSlotKeyCode(type, index, CurrentSlotMap[nIndex].nReleaseCondition, szKeyCode); UIMsgCmdData uiPlayerProgress = new UIMsgCmdData((int)WndMsgID.WND_MSG_WARBUTTOMCENTER_SETSHORTCUT, type, szKeyCode.ToUpper(), IntPtr.Zero, index); UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_WARBUTTOMCENTER_SETSHORTCUT, uiPlayerProgress); } } } if (nAuto != CurrentSlotMap[nIndex].nAutoCasting) { if (type == (int)SlotType.Function) { return; } CurrentSlotMap[nIndex].nAutoCasting = nAuto; cmd_entity_set_smart_cast data = new cmd_entity_set_smart_cast(); data.nSlotIndex = index; data.nSlotType = type; data.nSmartCast = nAuto; slotSmartDatas[0] = data; SendSmartDataToLogic(); slotSmartDatas.Clear(); } } }
/// <summary> /// 设置槽位信息 /// </summary> public void SetSlotData(bool isForceDefault = false) { if (!EntityFactory.MainHero) { return; } SkillCtrl sc = EntityFactory.MainHero.GetComponent <SkillCtrl>(); if (!sc) { return; } int vocationID = EntityFactory.MainHeroView.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_VOCATION); foreach (KeyValuePair <int, SlotKeyCodeData> kv in CurrentSlotMap) { switch (kv.Value.nSlotType) { case (int)SlotType.Equip: case (int)SlotType.Skill: { sc.SetSlotKeyCode(kv.Value.nSlotType, kv.Value.nSlotIndex, kv.Value.nReleaseCondition, kv.Value.szKeySequence); UIMsgCmdData uiPlayerProgress = new UIMsgCmdData((int)WndMsgID.WND_MSG_WARBUTTOMCENTER_SETSHORTCUT, kv.Value.nSlotType, kv.Value.szKeySequence.ToUpper(), IntPtr.Zero, kv.Value.nSlotIndex); UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_WARBUTTOMCENTER_SETSHORTCUT, uiPlayerProgress); cmd_entity_set_smart_cast data = new cmd_entity_set_smart_cast(); List <PlayerSlotItem> slotList = null; int maxSlotIndexForEachType = 1000; //一类slot最多有多少个index,用于将index和type合并编码 int nSlotID = kv.Value.nSlotType * maxSlotIndexForEachType + kv.Value.nSlotIndex; SpellMode useType = SpellMode.ST_Normal; bool hasUserConfig = PlayerSlotSettingConfig.Instance.GetLocalData(EntityFactory.MainHeroView.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_VOCATION), out slotList); if (hasUserConfig && !isForceDefault) //如果用户配置了就使用用户的配置 { for (int i = 0; i < slotList.Count; i++) { if (nSlotID == slotList[i].slotID) { useType = (SpellMode)Enum.Parse(typeof(SpellMode), slotList[i].useType.ToString()); } } } else //默认施法:使用策划在技能编辑器的配置 { if (sc != null) { OrderData odata = sc.GetCurOrderData(nSlotID); if (odata == null) { useType = SpellMode.ST_Normal; } else { useType = (SpellMode)Enum.Parse(typeof(SpellMode), (odata.nAdvanceUseType).ToString()); } } } kv.Value.nAutoCasting = (int)useType; data.nSlotIndex = kv.Value.nSlotIndex; data.nSlotType = kv.Value.nSlotType; data.nSmartCast = kv.Value.nAutoCasting; slotSmartDatas[0] = data; SendSmartDataToLogic(); slotSmartDatas.Clear(); } break; case (int)SlotType.Function: FuntionShortCutCtrl.GetInstance().SaveKeyCodeToDic(kv.Value.nSlotIndex, kv.Value.szKeySequence); break; default: break; } } }