public static void OnMessage_SC_GET_BATTLE_BOX_ACK(int iMsgID, ref CMessage msg) { CliProto.SC_GET_BATTLE_BOX_ACK refMSG = (CliProto.SC_GET_BATTLE_BOX_ACK)msg; if (refMSG.m_Result == (byte)HeaderProto.EReturnType.GS_RESULT_YES) { sdUICharacter.Instance.ShowSuccessPanel(); uint bid = refMSG.m_BattleboxID; for (int j = 1; j <= 16; j++) { for (int i1 = 0; i1 < 3; i1++) { for (int i2 = 0; i2 < 5; i2++) { BattleBoxItem box = battleInfos[j].rewardBox[i1, i2]; if (box != null && box.BoxID == bid) { NeedReflash = true; box.IsTake = true; j = i1 = i2 = 100; } } } } } }
public static void LoadLevelConfig(string level, string levelLang, string levelMeta, string levelBox) { SDCSV levelCSV = new SDCSV(); SDCSV levelLangCSV = new SDCSV(); SDCSV levelMetaCSV = new SDCSV(); SDCSV levelBoxCSV = new SDCSV(); levelCSV.CreateCSVFromStr(level, 0); levelLangCSV.CreateCSVFromStr(levelLang, 0); levelMetaCSV.CreateCSVFromStr(levelMeta, 1); levelBoxCSV.CreateCSVFromStr(levelBox, 0); //首先遍历level表的每一行,每一行又是一个HashTable... levelInfos = new LevelItem[levelCSV.csvTable.Count]; int count = 0; foreach (DictionaryEntry de in levelCSV.csvTable) { levelInfos[count] = new LevelItem(); string key = (string)de.Key; Hashtable valTable = (Hashtable)de.Value; levelInfos[count].levelID = int.Parse(key); //然后遍历行中的每一列,每一列是一个string foreach (DictionaryEntry de2 in valTable) { //获得名字.. string name = (string)de2.Key; string val = (string)de2.Value; //通过名字查找metaTable,获得数据类型.. Hashtable meta = (Hashtable)levelMetaCSV.csvTable[name]; string type = (string)meta["Type"]; if (type == "int") { levelInfos[count].levelProp.Add(name, int.Parse(val)); } else { levelInfos[count].levelProp.Add(name, val); } } //读取国际化表对应的行.. Hashtable langHash = (Hashtable)levelLangCSV.csvTable[key]; if (langHash != null) { foreach (DictionaryEntry de3 in langHash) { //获得名字.. string name = (string)de3.Key; string val = (string)de3.Value; //通过名字查找metaTable,获得数据类型.. Hashtable meta = (Hashtable)levelMetaCSV.csvTable[name]; string type = (string)meta["Type"]; if (type == "int") { levelInfos[count].levelProp[name] = int.Parse(val); } else { levelInfos[count].levelProp[name] = val; } } } count++; } for (count = 1; count <= 16; count++) { battleInfos[count] = new BattleItem(); } // 处理关卡领奖数据结构. foreach (DictionaryEntry de in levelBoxCSV.csvTable) { string key = (string)de.Key; Hashtable valTable = (Hashtable)de.Value; uint bid = 0; BattleBoxItem box = new BattleBoxItem(); box.BoxID = uint.Parse(key); foreach (DictionaryEntry de2 in valTable) { string name = (string)de2.Key; string val = (string)de2.Value; if (name == "BattleID") { bid = uint.Parse(val); } else if (name == "Job") { box.Job = uint.Parse(val); } else if (name == "NeedStar") { box.NeedStar = uint.Parse(val); } else if (name == "NonMoney") { box.NonMoney = uint.Parse(val); } else if (name == "NonCash") { box.NonCash = uint.Parse(val); } else if (name == "i1.TID") { box.Item1ID = uint.Parse(val); } else if (name == "i1.Count") { box.Item1Count = uint.Parse(val); } else if (name == "i2.TID") { box.Item2ID = uint.Parse(val); } else if (name == "i2.Count") { box.Item2Count = uint.Parse(val); } else if (name == "i3.TID") { box.Item3ID = uint.Parse(val); } else if (name == "i3.Count") { box.Item3Count = uint.Parse(val); } } // 总计16个战役,从1开始. if (bid >= 1 && bid <= 16) { if (box.NeedStar <= 18) { count = 0; } else if (box.NeedStar <= 36) { count = 1; } else { count = 2; } int job = 0; if (box.Job == 1) { job = 1; // 战士. } else if (box.Job == 4) { job = 2; // 法师. } else if (box.Job == 7) { job = 3; // 游侠. } else if (box.Job == 10) { job = 4; // 牧师. } //battleInfos[bid].rewardBox[count,job] = new BattleBoxItem(); battleInfos[bid].rewardBox[count, job] = box; } } }
public void ShowCampaign(int iBattleID) { // 初始化关卡贴图.. if (iBattleID != m_BattleID) { m_BattleID = iBattleID; string name = string.Format("UI/LevelUI/$Campaign_{0}/Campaign_{0}.prefab", m_BattleID); ResLoadParams param = new ResLoadParams(); sdResourceMgr.Instance.LoadResource(name, OnLoadAtlas, param, typeof(UIAtlas)); } int biID = sdLevelInfo.BattleInfoID(m_BattleID); // 从11,12,21,31的BattleID格式转换陈1~16的模式.. if (sdLevelInfo.battleInfos[biID] == null) { return; } m_BattleStars = sdLevelInfo.battleInfos[biID].starCount; m_CrystalShow.text = m_BattleStars + " / 54"; if (m_BattleStars < 18) { m_Star1Show.spriteName = "star0"; m_Star2Show.spriteName = "star0"; m_Star3Show.spriteName = "star0"; m_StarTextShow.SetActive(false); } else if (m_BattleStars < 36) { m_Star1Show.spriteName = "star1"; m_Star2Show.spriteName = "star0"; m_Star3Show.spriteName = "star0"; m_StarTextShow.SetActive(false); } else if (m_BattleStars < 54) { m_Star1Show.spriteName = "star1"; m_Star2Show.spriteName = "star1"; m_Star3Show.spriteName = "star0"; m_StarTextShow.SetActive(false); } else { m_Star1Show.spriteName = "star1"; m_Star2Show.spriteName = "star1"; m_Star3Show.spriteName = "star1"; m_StarTextShow.SetActive(true); } // 显示宝箱状态.. sdMainChar mc = sdGameLevel.instance.mainChar; if (mc != null) { int job = (int)mc.BaseJob; if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Warrior) { job = 1; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Magic) { job = 2; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Rogue) { job = 3; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Minister) { job = 4; } else { job = 0; } m_RewardBox1 = sdLevelInfo.battleInfos[biID].rewardBox[0, job]; if (m_RewardBox1 == null) { m_RewardBox1 = sdLevelInfo.battleInfos[biID].rewardBox[0, 0]; } m_RewardBox2 = sdLevelInfo.battleInfos[biID].rewardBox[1, job]; if (m_RewardBox2 == null) { m_RewardBox2 = sdLevelInfo.battleInfos[biID].rewardBox[1, 0]; } m_RewardBox3 = sdLevelInfo.battleInfos[biID].rewardBox[2, job]; if (m_RewardBox3 == null) { m_RewardBox3 = sdLevelInfo.battleInfos[biID].rewardBox[2, 0]; } } if (m_RewardFX1 == null) { m_RewardFX1 = GameObject.Find("Fx_lingjing01"); } UISprite sp = GameObject.Find("sp_reward1").GetComponent <UISprite>(); if (m_RewardBox1 != null && m_BattleStars >= m_RewardBox1.NeedStar) { if (m_RewardBox1.IsTake == true) { sp.spriteName = "xz1-3"; m_RewardFX1.SetActive(false); } else { sp.spriteName = "xz1-2"; m_RewardFX1.SetActive(true); } } else { sp.spriteName = "xz1"; m_RewardFX1.SetActive(false); } if (m_RewardFX2 == null) { m_RewardFX2 = GameObject.Find("Fx_lingjing02"); } sp = GameObject.Find("sp_reward2").GetComponent <UISprite>(); if (m_RewardBox2 != null && m_BattleStars >= m_RewardBox2.NeedStar) { if (m_RewardBox2.IsTake == true) { sp.spriteName = "xz2-3"; m_RewardFX2.SetActive(false); } else { sp.spriteName = "xz2-2"; m_RewardFX2.SetActive(true); } } else { sp.spriteName = "xz2"; m_RewardFX2.SetActive(false); } if (m_RewardFX3 == null) { m_RewardFX3 = GameObject.Find("Fx_lingjing03"); } sp = GameObject.Find("sp_reward3").GetComponent <UISprite>(); if (m_RewardBox3 != null && m_BattleStars >= m_RewardBox3.NeedStar) { if (m_RewardBox3.IsTake == true) { sp.spriteName = "xz3-3"; m_RewardFX3.SetActive(false); } else { sp.spriteName = "xz3-2"; m_RewardFX3.SetActive(true); } } else { sp.spriteName = "xz3"; m_RewardFX3.SetActive(false); } }
public static void OnMessage_SC_LEVEL_INFO(int iMsgID, ref CMessage msg) { CliProto.SC_LEVEL_INFO refMSG = (CliProto.SC_LEVEL_INFO)msg; if (refMSG.m_Count > 0) { for (int i = 0; i < refMSG.m_Count; i++) { int levelID = (int)refMSG.m_Info[i].m_LevelID; int crystal = (int)refMSG.m_Info[i].m_Crystal; ushort usedTimes = refMSG.m_Info[i].m_UsedTimes; for (int j = 0; j < levelInfos.Length; j++) { if (levelID == levelInfos[j].levelID) { levelInfos[j].crystal = crystal; levelInfos[j].usedTimes = usedTimes; levelInfos[j].valid = true; break; } } } // 更新已开启的战役ID. int level = 11011; for (int j = 0; j < levelInfos.Length; j++) { if (levelInfos[j].valid && levelInfos[j].levelID <100000 && levelInfos[j].levelID> level) { level = levelInfos[j].levelID; } } sdWorldMapPath.SetLevel(level / 1000, false); } if (refMSG.m_BattleCount > 0) { for (int i = 0; i < refMSG.m_BattleCount; i++) { int bid = (int)refMSG.m_BtInfo[i].m_BattleID; if (bid > 0 && bid <= 16) { battleInfos[bid].starCount = refMSG.m_BtInfo[i].m_GetStars; } } } if (refMSG.m_BoxCount > 0) { for (int i = 0; i < refMSG.m_BoxCount; i++) { uint bid = refMSG.m_GotBattleBox[i]; for (int j = 1; j <= 16; j++) { for (int i1 = 0; i1 < 3; i1++) { for (int i2 = 0; i2 < 5; i2++) { BattleBoxItem box = battleInfos[j].rewardBox[i1, i2]; if (box != null && box.BoxID == bid) { box.IsTake = true; j = i1 = i2 = 100; } } } } } } }
// 显示奖励领取界面. public void ShowLevelRewardWnd(BattleBoxItem box, int stars) { m_uBoxID = box.BoxID; // 根据当前星值情况显示提示信息. GameObject obj = GameObject.Find("lb_levelreward"); if (box.IsTake) { obj.GetComponent <UILabel>().text = "您已经领取了奖励宝箱。"; obj.GetComponentInChildren <UISprite>().spriteName = ""; GameObject.Find("lb_starneed").GetComponent <UILabel>().text = ""; } else if (stars >= box.NeedStar) { obj.GetComponent <UILabel>().text = "恭喜您已经获得" + (stars > 9?"":" ") + stars + " ,请领取奖励宝箱!"; UISprite spxx = obj.GetComponentInChildren <UISprite>(); spxx.spriteName = "x"; spxx.gameObject.transform.localPosition = new Vector3(-8.0f, 4.0f, 0); GameObject.Find("lb_starneed").GetComponent <UILabel>().text = ""; } else { obj.GetComponent <UILabel>().text = "再获得 即可领取奖励宝箱,加油哦。"; UISprite spxx = obj.GetComponentInChildren <UISprite>(); spxx.spriteName = "x"; spxx.gameObject.transform.localPosition = new Vector3(-114.0f, 4.0f, 0); GameObject.Find("lb_starneed").GetComponent <UILabel>().text = (box.NeedStar - stars).ToString(); } // 物品奖励. GameObject.Find("lb_rewarditem1").GetComponent <UILabel>().text = box.NonMoney.ToString(); GameObject.Find("lb_rewarditem2").GetComponent <UILabel>().text = box.NonCash.ToString(); UILabel lb = GameObject.Find("lb_rewarditem3").GetComponent <UILabel>(); UISprite sp = GameObject.Find("sp_rewarditem3").GetComponent <UISprite>(); DropoutButton bt = GameObject.Find("btn_rewarditem3").GetComponent <DropoutButton>(); UISprite sf = bt.transform.Find("sp_frame").GetComponent <UISprite>(); if (box.Item1ID > 0) { bt.transform.FindChild("Background").localScale = Vector3.one; Hashtable tab = sdConfDataMgr.Instance().GetItemById(box.Item1ID.ToString()); if (tab != null) { bt.m_ItemID = box.Item1ID.ToString(); lb.text = (string)tab["ShowName"]; if (box.Item1Count > 1) { lb.text += "x" + box.Item1Count; } lb.color = SDGlobal.QualityColor[int.Parse(tab["Quility"].ToString())]; sp.spriteName = (string)tab["IconPath"]; sf.spriteName = "IconFrame" + tab["Quility"]; m_bHasAtlas = false; m_iItemAtlasID = int.Parse((string)tab["IconID"]); sdConfDataMgr.Instance().LoadItemAtlas(m_iItemAtlasID.ToString(), OnSetAtlas); } } else { bt.m_ItemID = ""; lb.text = ""; sp.spriteName = ""; sf.spriteName = ""; bt.transform.FindChild("Background").localScale = Vector3.zero; } // 是否可用领奖的状态. if (box.IsTake) { m_btReward.SetActive(false); m_spHaveReward.SetActive(true); } else { m_btReward.SetActive(true); m_spHaveReward.SetActive(false); if (stars < box.NeedStar) { m_btReward.GetComponent <UIButton>().enabled = false; } else { m_btReward.GetComponent <UIButton>().enabled = true; } } this.gameObject.SetActive(true); }