void UpdateUI() { timesLeft_.text = ActivitySystem.Instance.petTempTimes_.ToString(); Dictionary <int, PetActivityData> metaData = PetActivityData.GetMetaData(); GameObject go = null; PetTempleBossInfo bossInfo = null; int index = 0; bool isNew = false; foreach (PetActivityData data in metaData.Values) { if (itemPool_.Count > index) { go = itemPool_[index]; } else { isNew = true; go = (GameObject)GameObject.Instantiate(bossPrefab_) as GameObject; go.transform.parent = grid_.transform; go.transform.localScale = Vector3.one; go.transform.localPosition = Vector3.zero; go.SetActive(true); itemPool_.Add(go); } bossInfo = go.GetComponent <PetTempleBossInfo>(); bossInfo.SetData(data, index++); if (isNew) { // bossInfo.OnSelect += OnSelect; } } grid_.Reposition(); }
// Use this for initialization void Start() { DaliyActivityData dad = DaliyActivityData.GetData(ActivityType.ACT_Pet); ActivitySystem.Instance.petTempTimes_ = dad.maxCount_; SkillItem.SetActive(false); if (ActivitySystem.Instance.petTempTimes_ - ActivitySystem.Instance.GetCount(ActivityType.ACT_Pet) <= 0) { catchBtn_.isEnabled = false; } else { catchBtn_.isEnabled = true; } crtSelectIdx_ = -1; diffPanel_.gameObject.SetActive(false); if (itemPool_ == null) { itemPool_ = new List <GameObject>(); } UIManager.SetButtonEventHandler(catchBtn_.gameObject, EnumButtonEvent.OnClick, OnCatch, 0, 0); UIManager.SetButtonEventHandler(closeBtn_.gameObject, EnumButtonEvent.OnClick, OnClose, 0, 0); pdata = PetActivityData.GetData(1); BabyData baby = BabyData.GetData(pdata.monsterID_); if (baby != null) { nameLable.text = baby._Name; decLable.text = baby._Desc; GameManager.Instance.GetActorClone((ENTITY_ID)baby._AssetsID, (ENTITY_ID)0, EntityType.ET_Baby, (GameObject go, ParamData pData) => { if (destroyed_) { Destroy(go); return; } go.transform.parent = mopos; go.transform.localScale = Vector3.one * EntityAssetsData.GetData(pData.iParam).zoom_ * 0.7f; go.transform.localPosition = new Vector3(0f, 0f, -90f); go.transform.localScale = new Vector3(550, 550, 550); go.transform.Rotate(Vector3.up, 180f); }, new ParamData(baby._AssetsID), "UI"); for (int i = 0; i < pdata.skillIDs_.Length; i++) { GameObject go = GameObject.Instantiate(SkillItem) as GameObject; go.SetActive(true); go.transform.parent = skillGrid.transform; go.transform.localScale = Vector3.one; UITexture tex = go.GetComponentInChildren <UITexture>(); HeadIconLoader.Instance.LoadIcon(SkillData.GetMinxiLevelData(int.Parse(pdata.skillIDs_[i]))._ResIconName, tex); Listener = UIEventListener.Get(go); Listener.parameter = pdata.skillIDs_[i]; Listener.onPress = buttonPress; } } UpdateUI(); }
public void UpdateUI(PetActivityData data) { if (itemPool_ == null) { itemPool_ = new List <GameObject>(); } string[] diffc = data.difficults_; GameObject go = null; PetDifficultItem pdiffc = null; bool isNew = false; for (int i = 0; i < diffc.Length; ++i) { if (i < itemPool_.Count) { go = itemPool_[i]; } else { isNew = true; go = (GameObject)GameObject.Instantiate(item_) as GameObject; go.transform.parent = grid_.transform; go.transform.localScale = Vector3.one; go.transform.localPosition = Vector3.zero; go.SetActive(true); itemPool_.Add(go); } pdiffc = go.GetComponent <PetDifficultItem>(); int lvLmt = 0; if (data.levels_.Length > i) { lvLmt = int.Parse(data.levels_[i]); } pdiffc.SetData(i, int.Parse(diffc[i]), lvLmt); if (isNew) { pdiffc.OnSelectDifficult += OnSelectDifficult; } } grid_.Reposition(); }
public static void ParseData(string content, string fileName) { metaData = new Dictionary <int, PetActivityData>(); CSVParser parser = new CSVParser(); if (!parser.Parse(content)) { ClientLog.Instance.LogError("PetActivityData" + ConfigLoader.Instance.csvext + "解析错误"); return; } int recordCounter = parser.GetRecordCounter(); PetActivityData data = null; for (int i = 0; i < recordCounter; ++i) { data = new PetActivityData(); data.id_ = parser.GetInt(i, "ID"); data.monsterID_ = parser.GetInt(i, "MonsterID"); string metaStr = parser.GetString(i, "Skills"); data.skillIDs_ = metaStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); metaStr = parser.GetString(i, "OpenTimeDesc"); data.openTimeDesc_ = metaStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); metaStr = parser.GetString(i, "Difficults"); data.difficults_ = metaStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); metaStr = parser.GetString(i, "Levels"); data.levels_ = metaStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (metaData.ContainsKey(data.id_)) { ClientLog.Instance.LogError("PetActivityData" + ConfigLoader.Instance.csvext + "ID重复"); return; } metaData[data.id_] = data; } parser.Dispose(); parser = null; }
public void SetData(PetActivityData data, int index) { if (itemPool_ == null) { itemPool_ = new List <GameObject>(); } padata_ = data; BabyData baby = BabyData.GetData(data.monsterID_); if (baby != null) { name_.text = baby._Name; desc_.text = baby._Desc; GameManager.Instance.GetActorClone((ENTITY_ID)baby._AssetsID, (ENTITY_ID)0, EntityType.ET_Baby, (GameObject go, ParamData pData) => { if (destroyed_) { Destroy(go); return; } go.transform.parent = modelRoot_; go.transform.localScale = Vector3.one * EntityAssetsData.GetData(pData.iParam).zoom_ * 0.7f; go.transform.localPosition = new Vector3(0f, 0f, -150f); go.transform.Rotate(Vector3.up, 180f); disableMask_.transform.localPosition = new Vector3(0f, 0f, go.transform.localPosition.z * 2f); }, new ParamData(baby._AssetsID), "UI"); } string[] skills = data.skillIDs_; SkillData skill = null; GameObject skillGo = null; SkillCellUI icon = null; for (int i = 0; i < skills.Length; ++i) { skill = SkillData.GetMinxiLevelData(int.Parse(skills[i])); if (skill == null) { continue; } if (i >= itemPool_.Count) { skillGo = new GameObject("Skill_" + skill._Id); skillGo.AddComponent <UISprite>().depth = 0; icon = UIManager.Instance.AddSkillCellUI(skillGo.GetComponent <UISprite>(), skill, 0f, 0f, 0.7f); icon.showTips = true; skillGo.transform.parent = skillGrid_.transform; skillGo.transform.localScale = Vector3.one; itemPool_.Add(skillGo); } else { itemPool_[i].name = "Skill_" + skill._Id; icon = UIManager.Instance.AddSkillCellUI(itemPool_[i].GetComponent <UISprite>(), skill); icon.showTips = true; } } skillGrid_.GetComponent <UIGrid>().Reposition(); bool todayOpen = false; string desc = ""; for (int i = 0; i < data.openTimeDesc_.Length; ++i) { desc += "周" + ConvertUpper(int.Parse(data.openTimeDesc_[i])); int compareDay = int.Parse(data.openTimeDesc_[i]); if (compareDay == 7) { compareDay = 0; } if ((int)System.DateTime.Today.DayOfWeek == compareDay) { todayOpen = true; } } desc += "开启"; timeBegin_.text = string.Format("[b]{0}[-]", desc); disableMask_.SetActive(!todayOpen); index_ = index; }