void ChangePetBody(uint suitID, uint petID) { PetDataManager pm = DataManager.Manager <PetDataManager>(); if (pm != null) { //if (pm.CurFightingPet != 0) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es != null) { INPC npc = es.FindNPC(petID); if (npc != null) { if (suitID != 0) { SuitDataBase sdb = GameTableManager.Instance.GetTableItem <SuitDataBase>(suitID, 1); if (sdb != null) { Client.ChangeBody cb = new Client.ChangeBody(); cb.resId = (int)sdb.resid; cb.modleScale = sdb.sceneModleScale; npc.SendMessage(EntityMessage.EntityCommand_Change, cb); } } else { npc.SendMessage(EntityMessage.EntityCommand_Restore); } } } } } }
/// <summary> /// 通过[ID]二分快速查表 /// </summary> /// <param name="base_id">ID</param> /// <returns></returns> public static IEnumerable <SuitDataBase> Query(this List <SuitDataBase> sorted, uint base_id) { var key = new SuitDataBase() { base_id = base_id }; 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]); } }
/// <summary> /// /// </summary> /// <param name="baseID">等于0时为第一次初始化</param> /// <returns></returns> int GetPetResID(int baseID = 0) { int resID = 0; List <SuitDataBase> petList = GetPetSuitData(); SuitDataBase petData = null; if (baseID == 0) { if (petList.Count == 0) { return(resID); } petData = petList[0]; PetDataManager pm = DataManager.Manager <PetDataManager>(); if (pm != null) { if (pm.CurFightingPet != 0) { IPet pet = pm.GetPetByThisID(pm.CurFightingPet); if (pet != null) { uint petBaseID = pet.PetBaseID; PetDataBase db = GameTableManager.Instance.GetTableItem <PetDataBase>(petBaseID); if (db != null) { resID = (int)db.modelID; } } } else { resID = (int)petData.resid; } } } else { for (int i = 0; i < petList.Count; i++) { if (baseID == petList[i].base_id) { petData = petList[i]; break; } } if (petData == null) { return(resID); } resID = (int)petData.resid; } return(resID); }
/// <summary> /// 通过[ID + 时装档次]二分快速查表 /// </summary> /// <param name="base_id">ID</param> /// <param name="suitLv">时装档次</param> /// <returns></returns> public static SuitDataBase Query(this List <SuitDataBase> sorted, uint base_id, uint suitLv) { var key = new SuitDataBase() { base_id = base_id, suitLv = suitLv }; var comparer = new Comparer2(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(SuitDataBase)); }
public void SetSuitDataOnChangePos() { List <ClientSuitData> list = GetSortListData(); if (list != null) { if (list.Count > 0) { ClientSuitData cd = list[0]; SuitDataBase db = GameTableManager.Instance.GetTableItem <SuitDataBase>(cd.suitBaseID, 1); if (db != null) { CurSuitDataBase = db; } } } }
protected override void OnShow(object data) { base.OnShow(data); if (data != null && data is SuitDataBase) { SuitDataBase db = data as SuitDataBase; InitDataBase(db); } if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.PropPanel)) { Transform trans = this.transform.Find("ColliderMask"); if (trans != null) { trans.gameObject.SetActive(false); } } }
public override void SetGridData(object data) { base.SetGridData(data); if (data != null && data is ClientSuitData) { m_CurSuitData = (ClientSuitData)data; SuitBaseID = m_CurSuitData.suitBaseID; m_suitDataBase = GameTableManager.Instance.GetTableItem <SuitDataBase>(m_CurSuitData.suitBaseID, 1); if (m_suitDataBase == null) { Engine.Utility.Log.Error("m_suitDataBase is null id is " + m_CurSuitData.suitBaseID); return; } if (null != m_lab_name) { m_lab_name.text = m_suitDataBase.name; } if (m_sp_icon != null) { UIManager.GetTextureAsyn(m_suitDataBase.icon, ref m_iconCASD, () => { if (null != m_sp_icon) { m_sp_icon.mainTexture = null; } }, m_sp_icon); } if (m_CurSuitData.suitState == SuitState.NoBuy) { SetPrice(); m_trans_priceContent.gameObject.SetActive(true); m_label_countdown.gameObject.SetActive(false); } else { m_trans_priceContent.gameObject.SetActive(false); m_label_countdown.gameObject.SetActive(true); SetCountDown(m_CurSuitData.leftTime); } ShowActiveSign(m_CurSuitData.suitState); } }
List <SuitDataBase> GetPetSuitData() { List <SuitDataBase> resultList = new List <SuitDataBase>(); List <ClientSuitData> sortList = m_suitDataManager.GetSortListData(); for (int i = 0; i < sortList.Count; i++) { ClientSuitData cd = sortList[i]; SuitDataBase db = GameTableManager.Instance.GetTableItem <SuitDataBase>(cd.suitBaseID, 1); if (db != null) { if (db.type == (uint)GameCmd.EquipSuitType.Magic_Pet_Type) { resultList.Add(db); } } } return(resultList); }
public void InitDataBase(SuitDataBase db) { m_suitDataBase = db; if (db != null) { m_suitID = db.base_id; m_label_tipssuitname.text = db.name; m_label_tipsdes.text = db.desc; m_label_getwaydes.text = db.activeWay; ShowAttr(); SuitDataManager dm = DataManager.Manager <SuitDataManager>(); SuitState st = dm.GetSuitState(m_suitID); FashionTipsType ft = FashionTipsType.ShowBuy; if (st == SuitState.Show) { ft = FashionTipsType.None; } else if (st == SuitState.Equip) { ft = FashionTipsType.ShowUnLoad; } else if (st == SuitState.HasBuy) { ft = FashionTipsType.ShowEquip; } else if (st == SuitState.NoEffect) { ft = FashionTipsType.ShowAddTime; } else if (st == SuitState.Active) { ft = FashionTipsType.None; } else { ft = FashionTipsType.ShowBuy; } ShowBtn(ft); } }
public bool IsPlayerEquipCloth(IPlayer player, out uint suitID) { suitID = 0; if (player == null) { return(false); } List <GameCmd.SuitData> suitList = null; player.GetSuit(out suitList); bool bEquip = false; if (suitList != null) { for (int i = 0; i < suitList.Count; i++) { SuitData data = suitList[i]; if (data.suit_type == EquipSuitType.Clothes_Type) { suitID = data.baseid; if (data.baseid != 0) { SuitDataBase sdb = GameTableManager.Instance.GetTableItem <SuitDataBase>(data.baseid); if (sdb != null) { if (sdb.typeMask == 1) { return(true); } } } } } } return(false); }
void InitCost() { int count = m_trans_CostGroup.childCount; for (int i = 0; i < count; i++) { name = "Cost_" + (i + 1); Transform costTrans = m_trans_CostGroup.Find(name); int lv = 3 + i; SuitDataBase needDb = GameTableManager.Instance.GetTableItem <SuitDataBase>(CurDataBase.base_id, lv); if (needDb != null) { string moneyStr = needDb.buyPrice; List <uint> typeMoney = StringUtil.GetSplitStringList <uint>(moneyStr, '_'); if (typeMoney.Count == 2) { int type = (int)typeMoney[0]; uint cost = typeMoney[1]; if (costTrans != null) { Transform iconTrans = costTrans.Find("moneySpr"); if (iconTrans != null) { UISprite spr = iconTrans.GetComponent <UISprite>(); if (spr != null) { spr.spriteName = MainPlayerHelper.GetMoneyIconByType(type); } } Transform labelTrans = costTrans.Find("moneyCost"); if (labelTrans != null) { Transform lineTrans = costTrans.Find("RedLine"); if (lineTrans != null) { UILabel label = labelTrans.GetComponent <UILabel>(); if (label != null) { label.text = cost.ToString(); if (m_opType == SuitOPType.SuitOPType_Renew) { lineTrans.gameObject.SetActive(true); } else { lineTrans.gameObject.SetActive(false); } } } } Transform renewlabelTrans = costTrans.Find("renewMoney"); if (renewlabelTrans != null) { if (m_opType == SuitOPType.SuitOPType_Renew) { renewlabelTrans.gameObject.SetActive(true); } else { renewlabelTrans.gameObject.SetActive(false); } UILabel label = renewlabelTrans.GetComponent <UILabel>(); if (label != null) { label.text = needDb.renewalPrice; } } Transform dayTrans = costTrans.Find("Day_7"); if (dayTrans != null) { UILabel dayLabel = dayTrans.GetComponent <UILabel>(); if (dayLabel != null) { dayLabel.text = m_SuitData.GetLeftTimeStringMin((int)needDb.time); } } } } } } }
public List <ClientSuitData> GetSortListData() { int job = MainPlayerHelper.GetMainPlayerJob(); List <SuitDataBase> allList = GetAllSuitByJob(job); List <ClientSuitData> showList = new List <ClientSuitData>(); List <ClientSuitData> noEffectList = new List <ClientSuitData>(); List <ClientSuitData> effectList = new List <ClientSuitData>(); List <ClientSuitData> equipList = new List <ClientSuitData>(); if (MainPlayerHelper.GetMainPlayer() == null) { return(null); } Dictionary <uint, ClientSuitData> myDic = m_dicSuitData[MainPlayerHelper.GetPlayerID()]; var iter = myDic.GetEnumerator(); while (iter.MoveNext()) { uint baseID = iter.Current.Key; ClientSuitData data = iter.Current.Value; if (data.suitState == SuitState.NoEffect) { if (!noEffectList.Contains(data)) { noEffectList.Add(data); } } else if (data.suitState == SuitState.HasBuy) { if (!effectList.Contains(data)) { effectList.Add(data); } } else if (data.suitState == SuitState.Equip) { if (!equipList.Contains(data)) { equipList.Add(data); } } else if (data.suitState == SuitState.Show || data.suitState == SuitState.Active) { if (!showList.Contains(data)) { showList.Add(data); } } } List <ClientSuitData> allClientList = new List <ClientSuitData>(); allClientList.AddRange(showList); allClientList.AddRange(equipList); allClientList.AddRange(effectList); allClientList.AddRange(noEffectList); List <ClientSuitData> noHaveList = new List <ClientSuitData>(); for (int i = 0; i < allList.Count; i++) { SuitDataBase db = allList[i]; bool bContain = false; for (int j = 0; j < allClientList.Count; j++) { ClientSuitData sd = allClientList[j]; if (sd.suitBaseID == db.base_id) { bContain = true; } } if (!bContain) { ClientSuitData cd = new ClientSuitData(); cd.suitBaseID = db.base_id; cd.leftTime = db.time; cd.suitState = SuitState.NoBuy; if (!noHaveList.Contains(cd)) { noHaveList.Add(cd); } } } allClientList.AddRange(noHaveList); List <ClientSuitData> sortList = new List <ClientSuitData>(); for (int i = 0; i < allClientList.Count; i++) { ClientSuitData cd = allClientList[i]; SuitDataBase db = GameTableManager.Instance.GetTableItem <SuitDataBase>(cd.suitBaseID, 1); if (db != null) { if (db.type == (uint)m_curSuitType) { sortList.Add(cd); } } } return(sortList); }