public override void read(ErlKVMessage message) { ErlArray itemData = message.getValue("msg") as ErlArray; int index = 0; int refreshTime; int multiple; int userRankAtRefresh; LaddersChestInfo chestItem; index = StringKit.toInt(itemData.Value [0].getValueString()); refreshTime = StringKit.toInt(itemData.Value [1].getValueString()); multiple = StringKit.toInt(itemData.Value [2].getValueString()); userRankAtRefresh = StringKit.toInt(itemData.Value [3].getValueString()); chestItem = new LaddersChestInfo(); chestItem.index = index; chestItem.multiple = multiple; chestItem.canReceiveRank = userRankAtRefresh; LaddersManagement.Instance.Chests.M_updateChest(index - 1, chestItem); LaddersManagement.Instance.M_updateChestStatus(); if (callback != null) { callback(); callback = null; } }
/// <summary> /// 根据索引 更新对应的宝箱数据 /// </summary> /// <param name="_index">_index.</param> /// <param name="_itemData">_item data.</param> public void M_udpateByIndex(int _index, LaddersChestInfo _itemData) { if (boxComponents == null || boxComponents.Length < 1) { M_creat(); } boxComponents[_index].M_update(_itemData); }
/// <summary> /// 点击宝箱 打开宝箱窗口 宝箱中的奖励是固定的 有money 和prestige构成,而这两种奖励的数据又是由公式计算而得 /// </summary> /// <param name="_item">_item.</param> private void M_openChest(LaddersChestInfo _item) { int money = LaddersManagement.Instance.M_chestMoney(_item); PrizeSample prize_1 = new PrizeSample(PrizeType.PRIZE_MONEY, 0, money); int prestige = LaddersManagement.Instance.M_chestPrestige(_item); PrizeSample prize_2 = new PrizeSample(PrizeType.PRIZE_PRESTIGE, 0, prestige); UiManager.Instance.openDialogWindow <LaddersChestsWindow> ((win) => { win.initAward(_item, new PrizeSample[] { prize_1, prize_2 }); }); }
/// <summary> /// 计算宝箱中的声望值 /// 获得的声望=INT(200*排名^(-1330/10000)*宝箱品质系数/100*称号加成/100*暴击系数/100) /// </summary> /// <returns>The prestige.</returns> /// <param name="chest">Chest.</param> public int M_chestPrestige(LaddersChestInfo chestInfo) { int prestigeSelf = UserManager.Instance.self.prestige; LaddersTitleSample titleSample = LaddersConfigManager.Instance.config_Title.M_getTitle(prestigeSelf); title = titleSample.factorNum; multiple = chestInfo.multiple; chest = LaddersConfigManager.Instance.config_Const.chestFactor.factors [chestInfo.index - 1]; int rank = chestInfo.receiveEnble ? chestInfo.canReceiveRank : currentPlayerRank; int prestige = (int)(v1 * Mathf.Pow(rank, (v2 / v3)) * chest / percent * (title + 10000) / v3 * multiple / percent); return(prestige); }
/// <summary> /// 点击宝箱事件处理 /// </summary> /// <param name="_item">_item.</param> public void M_onClickBox(Ladders_BoxItem _item) { int index = _item.data.index; if (_item.data.receiveEnble) { LaddersChestRefreshFPort fport = FPortManager.Instance.getFPort("LaddersChestRefreshFPort") as LaddersChestRefreshFPort; fport.apply(index, () => { LaddersChestInfo newChest = LaddersManagement.Instance.Chests.M_getChest(index - 1); M_openChest(newChest); }); } else { M_openChest(_item.data); } }
/// <summary> /// 初始化 宝箱中的奖励 /// </summary> /// <param name="chestInfo">Chest info.</param> /// <param name="_prizes">_prizes.</param> public void initAward(LaddersChestInfo chestInfo, PrizeSample[] _prizes) { this.prizes = _prizes; if (prizes != null && prizes.Length > 0) { for (int i = 0; i < prizes.Length; i++) { GameObject a = NGUITools.AddChild(gridContent.gameObject, goodsViewPrefab); a.name = StringKit.intToFixString(i + 1); GoodsView goodsButton = a.GetComponent <GoodsView> (); goodsButton.fatherWindow = this; goodsButton.onClickCallback = goodsButton.DefaultClickEvent; goodsButton.init(prizes[i]); } gridContent.repositionNow = true; } data = chestInfo; btn_receive.disableButton(!data.receiveEnble); updateChestName(); }
private void parseChest(ErlArray _data) { //[super_box,[[1,1,1,5501],[2,1,1,5501],[3,1,1,5501]]],index,refreshTimes,multiple,rankAtRefresh if (_data == null) { return; } ErlArray itemData; int index = 0; int refreshTime; int multiple; int userRankAtRefresh; int length = _data.Value.Length; LaddersChestInfo chestItem; LaddersChestInfo[] chests = new LaddersChestInfo[length]; LaddersManagement.Instance.Chests.M_clear(); for (int i = 0; i < length; i++) { itemData = _data.Value [i] as ErlArray; index = StringKit.toInt(itemData.Value [0].getValueString()); refreshTime = StringKit.toInt(itemData.Value [1].getValueString()); multiple = StringKit.toInt(itemData.Value [2].getValueString()); userRankAtRefresh = StringKit.toInt(itemData.Value [3].getValueString()); chestItem = new LaddersChestInfo(); chestItem.index = index; chestItem.multiple = multiple; chestItem.canReceiveRank = userRankAtRefresh; chests [i] = chestItem; LaddersManagement.Instance.Chests.M_updateChest(index - 1, chestItem); } //LaddersManagement.Instance.Chests.M_updateChest (chests); }
public void M_updateChest(int _index, LaddersChestInfo _id) { chests[_index] = _id; }
/// <summary> /// 传入 数据 /// </summary> /// <param name="_data">_data.</param> public void M_update(LaddersChestInfo _data) { data = _data; M_updateView(); }