public override void Update(float deltaTime) { if (mStartExpFlash) { mExpBar.fillAmount += 0.02f; int lv = mGoalLv - mExpFlashRunTimes; LevelConfigInfo leveinfo = ConfigReader.GetLevelInfo(lv); if (leveinfo == null) { Debug.LogError("levelinfo is null" + lv); return; } int exp = (int)(leveinfo.LevelUpExp * mExpBar.fillAmount); SetExpLabel(exp, ConfigReader.GetLevelInfo(lv).LevelUpExp); if (mExpBar.fillAmount >= 1f)//升一级 { SetExpLabel(ConfigReader.GetLevelInfo(lv).LevelUpExp, ConfigReader.GetLevelInfo(lv).LevelUpExp); mExpFlashRunTimes -= 1; mExpBar.fillAmount = 0f; mLevel.text = (lv + 1).ToString(); if (mGoalLv == mMaxLv) { mLevel.text = (mMaxLv + 1).ToString(); } } if (mExpFlashRunTimes < 0 || (mExpFlashRunTimes == 0 && mExpLast <= mExpBar.fillAmount)) { mExpBar.fillAmount = mExpLast; SetExpLabel(mExpValue, ConfigReader.GetLevelInfo(mGoalLv).LevelUpExp); mStartExpFlash = false; } } }
public void SetCurrentDate(uint headID, string pszNickName, int UserLv, int UserTotalExp, int UserCurLvExp, int TotalGameInns, int TotalWinInns, int HeroKills, int BuidingDemolishNum, int DeadTimes, int MaxAchNum, int AchNum) { headId = headID.ToString(); gameNick = pszNickName; gameCount = TotalGameInns.ToString(); gameLevel = UserLv.ToString(); gameWinCount = TotalWinInns.ToString(); gameKillCount = HeroKills.ToString(); gameBuildingDestroyCount = BuidingDemolishNum.ToString(); gameDeadCount = DeadTimes.ToString(); gameAchieveCount = AchNum.ToString(); gameHead = GameUserModel.Instance.GameUserHead.ToString(); gameMaxAchieve = MaxAchNum.ToString(); AchNum = 0; if (AchNum <= 0) { gameAchieveCount = "N"; gameMaxAchieve = "A"; } if (UserTotalExp <= 0) { LevelConfigInfo info = ConfigReader.GetLevelInfo(UserLv); if (info == null) { return; } UserTotalExp = (int)info.LevelUpExp; } float value = (float)UserCurLvExp / (float)UserTotalExp; gameExp = UserCurLvExp.ToString(); gameMaxExp = UserTotalExp.ToString(); }
///////////////////////////////////////////////////////////////////////////// //主页切换 public void OnHomePageChange() { mLevel.text = GameUserModel.Instance.UserLevel.ToString(); //等级 mNickName.text = GameUserModel.Instance.GameUserNick; //昵称 mHeadIcon.spriteName = GameUserModel.Instance.GameUserHead.ToString(); //头像名称 mGold.text = GameUserModel.Instance.mGameUserGold.ToString(); //金币 mDiamond.text = GameUserModel.Instance.mGameUserDmd.ToString(); //钻石 VipSignLevel.text = "VIP " + GameUserModel.Instance.GameUserVipLevel.ToString(); //VIP int level = GameUserModel.Instance.UserLevel; mLevel.text = level.ToString(); //VIP等级 LevelConfigInfo leveinfo = ConfigReader.GetLevelInfo(level); if (leveinfo != null) { mExp.text = GameUserModel.Instance.GameUserExp + "/" + leveinfo.LevelUpExp; //经验值 mExp.transform.parent.GetComponent <UISprite>().fillAmount = GameUserModel.Instance.GameUserExp / leveinfo.LevelUpExp; //经验条 if (level >= 29 && GameUserModel.Instance.GameUserExp >= leveinfo.LevelUpExp) { level = 30;//最大等级 mLevel.text = level.ToString(); mExp.gameObject.SetActive(false); mExp.transform.parent.GetComponent <UISprite>().fillAmount = 1f; } } if (mHomepage.value) { GameLog.Instance.AddUIEvent(GameLog.UIEventType.UIEventType_HomePage); HomePageCtrl.Instance.Enter();//显示UI } else { HomePageCtrl.Instance.Exit(); } }
//显示 public override void OnEnable() { mHeadIcon.spriteName = GameUserModel.Instance.GameUserHead.ToString(); mNickName.text = GameUserModel.Instance.GameUserNick; mGameInning.text = PresonInfoCtrl.Instance.mGameInning.ToString(); mWinInning.text = PresonInfoCtrl.Instance.mWinInning.ToString(); mKillAll.text = PresonInfoCtrl.Instance.mKillAll.ToString(); mDestrucBuild.text = PresonInfoCtrl.Instance.mDestrucBuild.ToString(); mDeathAll.text = PresonInfoCtrl.Instance.mDeathAll.ToString(); mAchievement.text = PresonInfoCtrl.Instance.mAchievement; mAssistAll.text = PresonInfoCtrl.Instance.mAssistAll.ToString(); mBelongGuild.text = PresonInfoCtrl.Instance.mBelongGuild; int vipintegral = GameUserModel.Instance.GameUserVipIntegral; mIntegral.text = vipintegral.ToString(); int vipLevel = GameUserModel.Instance.GameUserVipLevel; if (vipLevel < 0 || vipLevel > 10) { Debug.LogError("Vip异常"); return; } mVipLevel.spriteName = vipLevel.ToString(); VipLevelConfigInfo vipLevelInfo = ConfigReader.GetVipLevelInfo(++vipLevel); VIPLevelUp.text = /*"再累积" + (vipLevelInfo.VipIntegral - vipintegral) + "积分VIP" +vipLevel*/ ""; short level = GameUserModel.Instance.UserLevel; mLevel.text = level.ToString(); if (BlGame.Ctrl.PresonInfoCtrl.Instance.GetTimeExp()) { ChangeExpTime(); } if (BlGame.Ctrl.PresonInfoCtrl.Instance.GetTimeGold()) { ChangeGoldTime(); } LevelConfigInfo leveinfo = ConfigReader.GetLevelInfo(level); if (leveinfo != null) { mExp.text = GameUserModel.Instance.GameUserExp + "/" + leveinfo.LevelUpExp; mExp.transform.parent.GetComponent <UISprite>().fillAmount = PresonInfoCtrl.Instance.mExp / leveinfo.LevelUpExp; } if (level >= 30) { mExp.transform.parent.gameObject.SetActive(false); mExp.transform.parent.GetComponent <UISprite>().fillAmount = 1; } }
void GetUpExp(ref int lv, ref int exp) { LevelConfigInfo leveinfo = ConfigReader.GetLevelInfo(lv); if (exp >= (int)leveinfo.LevelUpExp) { exp -= (int)leveinfo.LevelUpExp; lv += 1; if (lv >= mMaxLv) { lv = mMaxLv; return; } GetUpExp(ref lv, ref exp); } }
void SetLv() { int curLv = ScoreCtrl.Instance.mLevel; int curExp = ScoreCtrl.Instance.mExp; int gotExp = ScoreCtrl.Instance.mGotExp; LevelConfigInfo leveinfo = ConfigReader.GetLevelInfo(curLv); if (leveinfo == null) { mLevel.text = curLv.ToString(); mExpNum.transform.gameObject.SetActive(false); Debug.LogError(" LevelConfigInfo = null" + curLv); return; } if (curLv <= 0 || gotExp <= 0) { SetExpLabel(curExp, leveinfo.LevelUpExp); mLevel.text = curLv.ToString(); mExpBar.fillAmount = (float)curExp / leveinfo.LevelUpExp; return; } if (curLv >= mMaxLv && curExp >= leveinfo.LevelUpExp) { mLevel.text = (mMaxLv + 1).ToString(); mExpNum.transform.gameObject.SetActive(false); curExp = (int)leveinfo.LevelUpExp; SetExpLabel(curExp, leveinfo.LevelUpExp); mExpBar.fillAmount = 1f; return; } mStartExpFlash = true; mGoalLv = curLv; mExpBar.fillAmount = (float)curExp / (float)leveinfo.LevelUpExp; mExpValue = curExp + gotExp; GetUpExp(ref mGoalLv, ref mExpValue); leveinfo = ConfigReader.GetLevelInfo(mGoalLv); mExpFlashRunTimes = mGoalLv - curLv;//升几级 if (mGoalLv >= mMaxLv && mExpValue > leveinfo.LevelUpExp) { mExpValue = (int)leveinfo.LevelUpExp; } mExpLast = (float)mExpValue / (float)leveinfo.LevelUpExp; //升级后slider的value mLevel.text = curLv.ToString(); }
public ReadLevelConfig(string xmlFilePath) { //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset; ResourceUnit xmlfileUnit = ResourcesManager.Instance.loadImmediate(xmlFilePath, ResourceType.ASSET); TextAsset xmlfile = xmlfileUnit.Asset as TextAsset; if (!xmlfile) { //Debug.LogError(" error infos: 没有找到指定的xml文件:" + xmlFilePath); } xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlfile.text); XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("WildMonsterCfg").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++)//XmlNode xNode in infoNodeList) { if ((infoNodeList[i] as XmlElement).GetAttributeNode("UserLevel") == null) { continue; } string level = (infoNodeList[i] as XmlElement).GetAttributeNode("UserLevel").InnerText; LevelConfigInfo levelInfo = new LevelConfigInfo(); levelInfo.UserLevel = Convert.ToInt32(level); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { #region 搜索 switch (xEle.Name) { case "LevelUpExp": levelInfo.LevelUpExp = Convert.ToSingle(xEle.InnerText); break; } #endregion } //Debug.LogError("levelInfo.UserLevel " + levelInfo.UserLevel + " levelInfo " + levelInfo.LevelUpExp); ConfigReader.levelXmlInfoDict.Add(levelInfo.UserLevel, levelInfo); } }