public void SettingKeyCodeInfo(EntityView view, bool isForceDefault = false) { nSpellTypeState = (int)SlotKeyCodeConfig.Instance.CurrentSpellMode; if (this.gameObject.activeInHierarchy && nSpellTypeState >= 1) { spellState.NotifyToggleOn(spellStateToggleGroup[nSpellTypeState - 1]); } if (EntityFactory.MainHero == null) { return; } SkillCtrl skillCtrl = EntityFactory.MainHero.GetComponent <SkillCtrl>(); foreach (KeyValuePair <int, SlotKeyCodeData> kv in SlotKeyCodeConfig.Instance.CurrentSlotMap) { foreach (var temp in m_KeyCodeMap) { if (kv.Key == temp.keyIndex && temp.keyCodeText != null) { temp.keyCodeText.text = kv.Value.szKeySequence.ToUpper(); } if (kv.Key == temp.keyIndex && temp.keyCodeToggleBtn != null && temp.toggleText != null) { int maxSlotIndexForEachType = 1000; //一类slot最多有多少个index,用于将index和type合并编码 int nSlotID = kv.Value.nSlotType * maxSlotIndexForEachType + kv.Value.nSlotIndex; SpellMode useType = SpellMode.ST_Normal; List <PlayerSlotItem> slotList = null; 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 (skillCtrl != null) { OrderData odata = skillCtrl.GetCurOrderData(nSlotID); if (odata == null || odata.nAdvanceUseType == 0) { useType = SpellMode.ST_Normal; } else { useType = (SpellMode)Enum.Parse(typeof(SpellMode), (odata.nAdvanceUseType).ToString()); } } } temp.useType = (int)useType; switch (useType) { case SpellMode.ST_Normal: //常规施法 temp.toggleText.text = SKILL_USE_TYPE_TEXT[temp.useType]; break; case SpellMode.ST_Speed: //快捷施法 temp.toggleText.text = SKILL_USE_TYPE_TEXT[temp.useType]; break; case SpellMode.ST_Smart: //推荐施法 temp.toggleText.text = SKILL_USE_TYPE_TEXT[temp.useType]; break; default: //默认施法(不会是这个) temp.toggleText.text = ""; break; } } } } bFirstLoad = false; }
/// <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; } } }