//兑换 private void Fun_17_1(INetData data) { Log.debug(this, "服务器返回17_1培养面板的信息"); GrowattrInfoMsg_17_1 message = new GrowattrInfoMsg_17_1(); message.read(data.GetMemoryStream()); Singleton <GrowMode> .Instance.UpdateGrowPannelInfo(message); Log.info(this, "Fun_17_1"); }
//**************************************服务器返回信息**************************** public void UpdateGrowPannelInfo(GrowattrInfoMsg_17_1 msg) { isInit = true; Log.debug(this, "服务器返回17_1的协议"); GrowAttrInfo = msg; //付费剩余次数 LeftTimes = VipGrowCount - (int)msg.payTimes; uint maxTime = GrowAttrInfo.lv1Cd; maxTime = maxTime < GrowAttrInfo.lv2Cd ? GrowAttrInfo.lv2Cd : maxTime; maxTime = maxTime < GrowAttrInfo.lv3Cd ? GrowAttrInfo.lv3Cd : maxTime; vp_Timer.CancelAll("UpdateCDTime"); vp_Timer.In(0f, UpdateCDTime, (int)(maxTime + 1), 1f); DataUpdate(UPDATE_PANNEL_INFO); DataUpdate(this.UPDATE_TIPS); }
// 0 表示未开启, 1 表示CD没到,但有付费次数, 2 表示CD没到(有免费次数), 3 表示没有免费次数 // 4 表示 // 0 表示未开启, 1 表示CD没到, 2表示CD到了, 3表示剩余免费次数为0,4表示剩余付费次数为0 private void UpdateCDTime() { GrowattrInfoMsg_17_1 growInfo = GrowMode.Instance.GrowAttrInfo; List <uint> CDList = new List <uint>(); List <uint> FreeTimes = new List <uint>(); List <uint> CostTimes = new List <uint>(); //方便迭代 CDList.Add(growInfo.lv1Cd); //CD时间 CDList.Add(growInfo.lv2Cd); CDList.Add(growInfo.lv3Cd); FreeTimes.Add(growInfo.lv1Free); //剩余免费次数 FreeTimes.Add(growInfo.lv2Free); FreeTimes.Add(growInfo.lv3Free); int free; //可免费次数 int total; //总次数 string cd1format = LanguageManager.GetWord("Grow.CD1"); string cd2format = LanguageManager.GetWord("Grow.CD2"); cd1format = cd1format.Replace(@"\n", "\n"); cd2format = cd2format.Replace(@"\n", "\n"); string cdformat = null; string freeString = LanguageManager.GetWord("Grow.Free"); string unOpen = LanguageManager.GetWord("Grow.UnOpen"); UILabel cdLabel; int[] freeCount = { 5, 2, 1 }; //三种培育的免费次数 int[] vipRequire = { 0, 4, 6 }; //vip开启 UIWidgetContainer wc; UILabel valueLabel; //花费文本 ItemContainer ic; int leftTime; //剩余付费次数 int leftFree; //剩余免费次数 for (int i = 0; i < 3; i++) { //0 表示未开启, //1 表示CD没到,但有付费次数, 2 表示CD没到(有免费次数)没有付费次数, 3 表示CD时间到,有免费次数, //4 表示没有免费次数,有付费次数 5 表示没有免费次数,没有付费次数 int state = GrowMode.Instance.GetGrowState(i + 1); wc = costList[i]; //花费 ic = buttonList[i]; //按钮 cdLabel = cdList[i]; //CD 文本 valueLabel = wc.FindInChild <UILabel>("value"); free = (int)FreeTimes[i]; leftFree = freeCount[i] - free; int buttonState = 0; //按钮状态 int costState = 0; //钻石信息显示状态 int cdState = 0; //cd显示状态 if (state == 0) //没有开启 { //Log.info(this, "没有开启"); cdState = 1; buttonState = 1; costState = 1; } else if (state == 5) { //Log.info(this, "免费次数和付费次数都用完了"); cdState = 4; buttonState = 2; costState = 2; } else if (state == 4) { //Log.info(this, "没有免费次数,有付费次数"); cdState = 4; buttonState = 2; costState = 2; } else if (state == 3) //免费 { //Log.info(this, "表示CD时间到,有免费次数"); cdState = 3; buttonState = 2; costState = 1; } else if (state == 2) { cdState = 2; buttonState = 2; costState = 2; } else if (state == 1) //付费 { //Log.info(this, "表示CD没到,但有付费次数"); cdState = 2; buttonState = 2; costState = 2; } if (cdState == 1) // 未开启 { cdLabel.text = string.Format(LanguageManager.GetWord("Grow.VIPOpen").Replace(@"\n", "\n"), vipRequire[i]); cdLabel.color = Color.yellow; } else if (cdState == 2) //cd 时间未到 { vp_TimeUtility.Units units = vp_TimeUtility.TimeToUnits(CDList[i]); string timeStr = string.Format("{0:D2}:{1:D2}:{2:D2}", units.hours, units.minutes, units.seconds); cdLabel.text = string.Format(cd1format, timeStr, string.Format(ColorConst.GREEN_FORMAT, free + "/" + freeCount[i])); //cdLabel.color = Color.white; } else if (cdState == 3) //CD时间到 { cdLabel.text = string.Format(cd2format, string.Format(ColorConst.GREEN_FORMAT, free + "/" + freeCount[i])); //cdLabel.color = Color.white; } else if (cdState == 4) //免费用完 { cdLabel.text = string.Format(cd2format, string.Format(ColorConst.RED_FORMAT, free + "/" + freeCount[i])); //cdLabel.color = Color.red; } if (buttonState == 1) //未开启 { ic.FindInChild <UISprite>("background").spriteName = "anniuh1"; ic.FindInChild <UILabel>("label").effectColor = ColorConst.YellowOutline; ic.buttonType = Button.ButtonType.None; ic.SetHighLightState(false); } else if (buttonState == 2) //开启可点击 { ic.FindInChild <UISprite>("background").spriteName = "anniulv"; ic.FindInChild <UILabel>("label").effectColor = ColorConst.BlueOutline; ic.buttonType = Button.ButtonType.Toggle; } else if (buttonState == 3) //开启不可点击 { ic.FindInChild <UISprite>("background").spriteName = "anniulv"; ic.buttonType = Button.ButtonType.None; ic.SetHighLightState(false); } if (costState == 2) //显示 { wc.SetActive(true); ic.FindInChild <UILabel>("label").cachedTransform.localPosition = new Vector3(6.3f, 19f, 0f); valueLabel.text = string.Empty + GrowMode.Instance.GrowCost[i]; } else if (costState == 1) //不显示 { wc.SetActive(false); ic.FindInChild <UILabel>("label").cachedTransform.localPosition = new Vector3(6.3f, -4.0f, 0f); } ic.Id = (uint)state; } }