712 lines
23 KiB
C#
712 lines
23 KiB
C#
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using Games.LogicObj;
|
|
using Games.Item;
|
|
using GCGame;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using Games.GlobeDefine;
|
|
using System;
|
|
using Module.Log;
|
|
|
|
public class BackPackLogic : UIControllerBase<BackPackLogic>
|
|
{
|
|
const int MAX_PLOT_LINE = 5; // 每行格子数
|
|
|
|
public GameObject[] panels; // 子页面
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
|
|
//初始化交易市场
|
|
Market.AskShopInfo();
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
SetInstance(this);
|
|
|
|
_TagPanel.ShowPage(0);
|
|
InitBackPack();
|
|
AskForItemLimitInfo();
|
|
}
|
|
|
|
public void AskForItemLimitInfo()
|
|
{
|
|
GameManager.gameManager.PlayerDataPool.ItemLimitInfo.AskForItemLimitInfo();
|
|
}
|
|
|
|
private Dictionary<int, int> _everyPrivilegeVipNeedLevelDic;
|
|
public void GetOpenBoxNeedVipLevel()
|
|
{
|
|
_everyPrivilegeVipNeedLevelDic = new Dictionary<int, int>();
|
|
foreach(var info in TableManager.GetPrivilegeFunction().Values)
|
|
{
|
|
if(info.PrivilegeId == 2 )
|
|
{
|
|
if(!_everyPrivilegeVipNeedLevelDic.ContainsKey(info.PrivilegeVipType))
|
|
{
|
|
var count = info.getVipCount();
|
|
for (int index = 0; index < count; index++)
|
|
{
|
|
if(int.Parse(info.GetVipbyIndex(index)) > 0)
|
|
{
|
|
_everyPrivilegeVipNeedLevelDic.Add(info.PrivilegeVipType, index);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int m_lastPage = 0;
|
|
public void TagShowPage(int page)
|
|
{
|
|
if (m_lastPage != page)
|
|
{
|
|
if (page == 0)
|
|
{
|
|
_CurrencyPanel.SetActive(true);
|
|
|
|
panels[m_lastPage].SetActive(false);
|
|
panels[page].SetActive(true);
|
|
m_lastPage = page;
|
|
}
|
|
else if (page == 3)
|
|
{
|
|
|
|
int _OpenVipLevel = 0;
|
|
foreach(var tab in TableManager.GetPrivilegeFunction())
|
|
{
|
|
if(tab.Value.PrivilegeId == 6)
|
|
{
|
|
for(int index = 0; index < tab.Value.getVipCount(); index++)
|
|
{
|
|
if(int.Parse(tab.Value.GetVipbyIndex(index)) > 0)
|
|
{
|
|
_OpenVipLevel = index;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
string tip = "";
|
|
var _isVipCostEnough = false;
|
|
if (GameManager.gameManager.PlayerDataPool.VipCost >= _OpenVipLevel)
|
|
_isVipCostEnough = true;
|
|
else
|
|
_isVipCostEnough = false;
|
|
|
|
//if (_everyPrivilegeVipNeedLevelDic == null)
|
|
// GetOpenBoxNeedVipLevel();
|
|
|
|
//_TagPanel.ShowPage(m_lastPage);
|
|
// -1代表无限次
|
|
int remaintTime = GameManager.gameManager.PlayerDataPool.FastOPenCangKuLeaveTimes;
|
|
if (remaintTime == 0 && remaintTime != -1)
|
|
{
|
|
//foreach (var state in GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic)
|
|
//{
|
|
// if (state.Value)
|
|
// {
|
|
// if (_everyPrivilegeVipNeedLevelDic.ContainsKey(state.Key))
|
|
// {
|
|
// if (GameManager.gameManager.PlayerDataPool.VipCost >= _everyPrivilegeVipNeedLevelDic[state.Key])
|
|
// {
|
|
// _isVipCostEnough = true;
|
|
// }
|
|
// else
|
|
// {
|
|
// _isVipCostEnough = false;
|
|
// }
|
|
// }
|
|
// break;
|
|
// }
|
|
//}
|
|
|
|
if (_isVipCostEnough)
|
|
{
|
|
tip = StrDictionary.GetClientDictionaryString("#{41007}");
|
|
}
|
|
else
|
|
{
|
|
tip = StrDictionary.GetClientDictionaryString("#{41006}");
|
|
}
|
|
|
|
MessageBoxLogic.OpenOKCancelBox(tip, null, delegate ()
|
|
{
|
|
FailedOpenFastCangku();
|
|
}, () => _TagPanel.ShowPage(m_lastPage));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
_CurrencyPanel.SetActive(true);
|
|
panels[m_lastPage].SetActive(false);
|
|
panels[page].SetActive(true);
|
|
m_lastPage = page;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_CurrencyPanel.SetActive(false);
|
|
panels[m_lastPage].SetActive(false);
|
|
panels[page].SetActive(true);
|
|
m_lastPage = page;
|
|
}
|
|
}
|
|
|
|
//if (page == 0)
|
|
//{
|
|
// InitBackPack();
|
|
// _CurrencyPanel.SetActive(true);
|
|
//}
|
|
//else if (page == 3)
|
|
//{
|
|
// _CurrencyPanel.SetActive(true);
|
|
// _TagPanel.ShowPage(m_lastPage);
|
|
|
|
// if (GameManager.gameManager.PlayerDataPool.FastOPenCangKuLeaveTimes == 0)
|
|
// {
|
|
// string tip = StrDictionary.GetClientDictionaryString("#{41007}");
|
|
// if(GameManager.gameManager.PlayerDataPool.VipCost <= 0)
|
|
// tip = StrDictionary.GetClientDictionaryString("#{41006}");
|
|
|
|
// MessageBoxLogic.OpenOKCancelBox(tip, null, delegate ()
|
|
// {
|
|
// FailedOpenFastCangku();
|
|
// }, () => _TagPanel.ShowPage(m_lastPage));
|
|
// return;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// _CurrencyPanel.SetActive(false);
|
|
//}
|
|
}
|
|
|
|
void FailedOpenFastCangku()
|
|
{
|
|
Vector4 pos = SystemParam.GetSystemParam_Vector(1);
|
|
AutoSearchPoint point = new AutoSearchPoint(SystemParam.GetSystemParam_INT(0), pos.x, pos.z, 0, AutoSearchPoint.ChangeMap_Type.WORLDMAP, Games.GlobeDefine.GlobeVar.INVALID_GUID);
|
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|
{
|
|
GameManager.gameManager.AutoSearch.BuildPath(point);
|
|
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(SystemParam.GetSystemParam_INT(2), 0);
|
|
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
|
|
{
|
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
|
|
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
|
|
}
|
|
}
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
if (_AnalyzeGame != null)
|
|
_AnalyzeGame.ClearList();
|
|
SetInstance(null);
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
UIManager.CloseUI(UIInfo.BackPackRoot);
|
|
}
|
|
|
|
public UITagPanel _TagPanel;
|
|
|
|
#region backpack page
|
|
|
|
public AnalyzeGame _AnalyzeGame;
|
|
public PlayerEquipInfo _PlayerEquipInfo;
|
|
public UICurrencyItem[] _CurrencyItems;
|
|
public GameObject _CurrencyPanel;
|
|
public UIContainerSelect _ItemsContainer;
|
|
public UIContainerSelect _BuyBacksContainer;
|
|
public GameObject _BackPackInfoPanel;
|
|
public GameObject _SellInfoPanel;
|
|
public UIButtonTime _BtnSortTime;
|
|
public int _BtnSortDisableTime;
|
|
public Text _CurrSuitLevel;
|
|
public int _ShopID;
|
|
|
|
|
|
private bool _IsShowSell = false;
|
|
|
|
public void InitBackPack()
|
|
{
|
|
_PlayerEquipInfo.UpdateInfo();
|
|
_PlayerEquipInfo.UpdateShowModel();
|
|
UpdateCurrency();
|
|
UpdateBackPackItems();
|
|
|
|
OnBackSellClick();
|
|
_BackPackInfoPanel.SetActive(true);
|
|
_SellInfoPanel.SetActive(false);
|
|
CloseUnlockPanel();
|
|
|
|
UpdateSuitLevel();
|
|
}
|
|
|
|
public void UpdateSuitLevel()
|
|
{
|
|
var tabCurLevel = TableManager.GetEquipEnchanceSuitByID(GameManager.gameManager.PlayerDataPool.EquipSuitID, 0);
|
|
if (tabCurLevel != null)
|
|
{
|
|
_CurrSuitLevel.text = tabCurLevel.EnchanceLevel.ToString();
|
|
}
|
|
else
|
|
{
|
|
_CurrSuitLevel.text = "0";
|
|
}
|
|
}
|
|
|
|
public void UpdateEquipCombatTips()
|
|
{
|
|
_ItemsContainer.ForeachActiveItem<CommonItemBackPackItem>((backPackItem) =>
|
|
{
|
|
backPackItem.UpdateEquipCombat();
|
|
});
|
|
}
|
|
|
|
public void UpdateBackPackItems()
|
|
{
|
|
GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|
//List<GameItem> itemlist = ItemTool.ItemFilter(BackPack, 0);
|
|
List<GameItem> itemlist = BackPack.Items;
|
|
List<CommonItemBackPackItem.BackPackItem> showItems = new List<CommonItemBackPackItem.BackPackItem>();
|
|
List<CommonItemBackPackItem.BackPackItem> SelList = new List<CommonItemBackPackItem.BackPackItem>();
|
|
// 背包中存在存在三种状态的装备栏,他们的数量如下
|
|
// 有装备的,开了的,还锁着的
|
|
for (int nIndex = 0; nIndex < GameItemContainer.MAXSIZE_BACKPACK; ++nIndex)
|
|
{
|
|
if (nIndex < BackPack.ContainerSize)
|
|
{
|
|
if (nIndex < itemlist.Count)
|
|
{
|
|
showItems.Add(new CommonItemBackPackItem.BackPackItem() { GameItem = itemlist[nIndex], IsPosLock= false });
|
|
|
|
if (_AnalyzeGame != null && _AnalyzeGame.IsGameItemInAnalyList(itemlist[nIndex]))
|
|
SelList.Add(showItems[showItems.Count - 1]);
|
|
}
|
|
else
|
|
{
|
|
showItems.Add(new CommonItemBackPackItem.BackPackItem() { GameItem = null, IsPosLock = false });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
showItems.Add(new CommonItemBackPackItem.BackPackItem() { GameItem = null, IsPosLock = true });
|
|
}
|
|
}
|
|
|
|
_ItemsContainer.InitSelectContent(showItems, SelList, ItemClick);
|
|
}
|
|
|
|
public void UpdateBuyBackPack()
|
|
{
|
|
if (_AnalyzeGame == null)
|
|
return;
|
|
|
|
}
|
|
|
|
private void UpdateCurrency()
|
|
{
|
|
_CurrencyItems[0].SetColor("<color=#303030FF>");
|
|
_CurrencyItems[0].ShowCurrency(MONEYTYPE.MONEYTYPE_COIN_BIND, GameManager.gameManager.PlayerDataPool.Money.GetMoney_CoinBind());
|
|
_CurrencyItems[1].SetColor("<color=#303030FF>");
|
|
_CurrencyItems[1].ShowCurrency(MONEYTYPE.MONEYTYPE_COIN, GameManager.gameManager.PlayerDataPool.Money.GetMoney_Coin());
|
|
_CurrencyItems[2].SetColor("<color=#303030FF>");
|
|
_CurrencyItems[2].ShowCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, GameManager.gameManager.PlayerDataPool.Money.GetMoney_YuanBaoBind());
|
|
_CurrencyItems[3].SetColor("<color=#303030FF>");
|
|
_CurrencyItems[3].ShowCurrency(MONEYTYPE.MONEYTYPE_YUANBAO, GameManager.gameManager.PlayerDataPool.Money.GetMoney_YuanBao());
|
|
|
|
}
|
|
|
|
public void ItemClick(object obj)
|
|
{
|
|
if (_IsShowSell)
|
|
return;
|
|
|
|
CommonItemBackPackItem.BackPackItem backPackItem = obj as CommonItemBackPackItem.BackPackItem;
|
|
if (!backPackItem.IsPosLock)
|
|
{
|
|
if (backPackItem.GameItem != null && backPackItem.GameItem.IsValid())
|
|
{
|
|
ShowTooltips(backPackItem.GameItem);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowUnlockPanel();
|
|
}
|
|
}
|
|
|
|
public void BuyBackItemClick(object obj)
|
|
{
|
|
CommonItemBackPackItem.BackPackItem backPackItem = obj as CommonItemBackPackItem.BackPackItem;
|
|
if (!backPackItem.IsPosLock)
|
|
{
|
|
if (backPackItem.GameItem != null && backPackItem.GameItem.IsValid())
|
|
{
|
|
if (backPackItem.GameItem.IsEquipMent())
|
|
{
|
|
EquipTooltipsLogic.ShowEquipTooltip(backPackItem.GameItem, ItemTooltipsLogic.ShowType.BuyBack, transform.position);
|
|
}
|
|
else
|
|
{
|
|
ItemTooltipsLogic.ShowItemTooltip(backPackItem.GameItem, ItemTooltipsLogic.ShowType.BuyBack, transform.position);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnShowSuitTips()
|
|
{
|
|
int enhanceLevel = 0;
|
|
var tab = TableManager.GetEquipEnchanceSuitByID(GameManager.gameManager.PlayerDataPool.EquipSuitID, 0);
|
|
if (tab != null)
|
|
{
|
|
enhanceLevel = tab.EnchanceLevel;
|
|
}
|
|
|
|
EquipQianghuaSuitTips.Show(enhanceLevel, GameManager.gameManager.PlayerDataPool.NextSuitEquipCnt);
|
|
}
|
|
|
|
private void ShowTooltips(GameItem gameItem)
|
|
{
|
|
if (gameItem != null && gameItem.IsValid())
|
|
{
|
|
if (gameItem.IsEquipMent())
|
|
{
|
|
EquipTooltipsLogic.ShowEquipTooltip(gameItem, ItemTooltipsLogic.ShowType.UnEquiped, transform.position);
|
|
}
|
|
else if(gameItem.IsMagicMent())
|
|
{
|
|
MagicTooltipLogic.ShowEquipTooltip(gameItem, ItemTooltipsLogic.ShowType.UnEquiped);
|
|
}
|
|
else if (gameItem.IsAdvanceMent())
|
|
{
|
|
UIManager.ShowUI(UIInfo.AdvanceEquipTips, delegate(bool bSucess, object pram) {
|
|
if(bSucess)
|
|
{
|
|
AdvanceEquipTip.Instance.ShowAdvanceEquipTip(gameItem, ItemTooltipsLogic.ShowType.UnEquiped, transform.position);
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
ItemTooltipsLogic.ShowItemTooltip(gameItem, ItemTooltipsLogic.ShowType.Normal, transform.position);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public void UpdateBackPack()
|
|
{
|
|
if (gameObject.activeSelf == false)
|
|
return;
|
|
if(BackPackUiTag.Instance()!=null)
|
|
{
|
|
BackPackUiTag.Instance()._TagPanel.OnToggleOn(true);
|
|
}
|
|
else
|
|
{
|
|
UpdateBackPackItems();
|
|
}
|
|
}
|
|
|
|
public void UpdateBackPackByIndex(int index)
|
|
{
|
|
if (gameObject.activeSelf == false)
|
|
return;
|
|
_ItemsContainer.RefreshItems();
|
|
return;
|
|
}
|
|
|
|
public void UpdatePlayerInfo()
|
|
{
|
|
_PlayerEquipInfo.UpdateInfo();
|
|
}
|
|
|
|
public void UpdateMoneyInfo()
|
|
{
|
|
UpdateCurrency();
|
|
}
|
|
|
|
public void UpdateEquipPack()
|
|
{
|
|
_PlayerEquipInfo.UpdateInfo();
|
|
}
|
|
|
|
public void UpdatePlayerEquipView()
|
|
{
|
|
_PlayerEquipInfo.UpdateShowModel();
|
|
}
|
|
|
|
public void AddAnalyGameItem(GameItem gameItem)
|
|
{
|
|
if(_AnalyzeGame!=null && gameItem!=null && gameItem.IsValid())
|
|
{
|
|
_AnalyzeGame.AddAnalyzeGameItem(gameItem);
|
|
}
|
|
}
|
|
|
|
public void DelAnalyGameItem(GameItem gameItem)
|
|
{
|
|
if (_AnalyzeGame != null && gameItem != null && gameItem.IsValid())
|
|
{
|
|
_AnalyzeGame.DelAnalyzeGameItem(gameItem);
|
|
}
|
|
}
|
|
|
|
public void UnSelectAnalyGameItem(GameItem gameItem)
|
|
{
|
|
if (gameItem == null || gameItem.IsValid() == false || _IsShowSell == false)
|
|
return;
|
|
List<CommonItemBackPackItem.BackPackItem> commonItemBackPackItems = _ItemsContainer.GetSelecteds<CommonItemBackPackItem.BackPackItem>();
|
|
for(int i=0;i<commonItemBackPackItems.Count;i++)
|
|
{
|
|
if(commonItemBackPackItems[i].GameItem!=null && commonItemBackPackItems[i].GameItem == gameItem)
|
|
{
|
|
_ItemsContainer.OnSelectedObj(commonItemBackPackItems[i]);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnSellClick()
|
|
{
|
|
_IsShowSell = true;
|
|
_ItemsContainer.ForeachActiveItem<CommonItemBackPackItem>((backPackItem) =>
|
|
{
|
|
backPackItem.ShowSell(true);
|
|
});
|
|
_BackPackInfoPanel.SetActive(false);
|
|
|
|
_CurrencyPanel.SetActive(false);
|
|
_ItemsContainer.ClearSelect();
|
|
_ItemsContainer._IsMultiSelect = true;
|
|
UpdateBuyBackPack();
|
|
_SellInfoPanel.SetActive(true);
|
|
}
|
|
|
|
public void OnBackSellClick()
|
|
{
|
|
_IsShowSell = false;
|
|
_ItemsContainer.ForeachActiveItem<CommonItemBackPackItem>((backPackItem) =>
|
|
{
|
|
backPackItem.ShowSell(false);
|
|
});
|
|
_BackPackInfoPanel.SetActive(true);
|
|
_SellInfoPanel.SetActive(false);
|
|
_CurrencyPanel.SetActive(true);
|
|
_ItemsContainer.ClearSelect();
|
|
_ItemsContainer._IsMultiSelect = false;
|
|
|
|
}
|
|
|
|
public void OnToggleClick()
|
|
{
|
|
if (_AnalyzeGame == null)
|
|
return;
|
|
int index = 0;
|
|
for (; index < _AnalyzeGame.toggles.Length; index++)
|
|
{
|
|
if (_AnalyzeGame.toggles[index].isOn)
|
|
break;
|
|
}
|
|
if (index == 0)
|
|
OnSelectSell(true, (int)ItemQuality.QUALITY_BLUE);
|
|
else if (index == 1)
|
|
OnSelectSell(true, (int)ItemQuality.QUALITY_PURPLE);
|
|
else
|
|
{
|
|
OnSelectSell(false, -1);
|
|
}
|
|
}
|
|
|
|
public void OnSelectSell(bool isSelect, int type)
|
|
{
|
|
if (isSelect)
|
|
{
|
|
GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|
List<GameItem> itemlist = BackPack.Items;
|
|
List<CommonItemBackPackItem.BackPackItem> showItems = new List<CommonItemBackPackItem.BackPackItem>();
|
|
_ItemsContainer.ForeachActiveItem<CommonItemBackPackItem>((backPackItem) =>
|
|
{
|
|
if (backPackItem._ItemBackPack.GameItem != null
|
|
&& backPackItem._ItemBackPack.GameItem.IsValid()
|
|
&& backPackItem._ItemBackPack.GameItem.SellPrice() > 0
|
|
&& backPackItem._ItemBackPack.GameItem.IsEquipMent()
|
|
&& (int)backPackItem._ItemBackPack.GameItem.GetQuality() <= (type > 0 ? type:1000))
|
|
{
|
|
showItems.Add(backPackItem._ItemBackPack);
|
|
}
|
|
});
|
|
|
|
_ItemsContainer.SetSelect(showItems);
|
|
}
|
|
else
|
|
{
|
|
_ItemsContainer.ClearSelect();
|
|
}
|
|
}
|
|
|
|
public void OnBtnAutoPick()
|
|
{
|
|
AutoPickLogic.ShowAutoPick();
|
|
}
|
|
|
|
public void OnBtnSort()
|
|
{
|
|
int pageCount = BackPackUiTag.Instance().pageCount;
|
|
if (pageCount==0)
|
|
{
|
|
CG_REQ_TIDY_PACK packet = (CG_REQ_TIDY_PACK)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_TIDY_PACK);
|
|
packet.PackType = 0;
|
|
packet.IsSort = 1;
|
|
packet.SendPacket();
|
|
_BtnSortTime.SetBtnDisableTime(_BtnSortDisableTime);
|
|
LogModule.DebugLog("Send sort packet");
|
|
}
|
|
if (pageCount == 1)
|
|
{
|
|
BackPackUiTag.Instance().ShowPlayerEquip();
|
|
}
|
|
if (pageCount == 2)
|
|
{
|
|
BackPackUiTag.Instance().ShowPlayergem();
|
|
}
|
|
if (pageCount == 3)
|
|
{
|
|
BackPackUiTag.Instance().ShowPlayer();
|
|
}
|
|
}
|
|
|
|
public void OnBtnShop()
|
|
{
|
|
SysShopController.ShowShop(_ShopID, true);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region unlock pack
|
|
|
|
public GameObject _UnlockPanel;
|
|
public Toggle[] _Toggles;
|
|
public Text[] _ToggleTextes;
|
|
|
|
private int _UnlockIdx;
|
|
private int _LineSize;
|
|
private int _TotalSize;
|
|
|
|
public void ShowUnlockPanel()
|
|
{
|
|
_UnlockPanel.SetActive(true);
|
|
|
|
int size = GameManager.gameManager.PlayerDataPool.BackPack.ContainerSize;
|
|
|
|
_UnlockIdx = size - GameItemContainer.SIZE_BACKPACK;
|
|
_LineSize = MAX_PLOT_LINE - (size % MAX_PLOT_LINE);
|
|
_TotalSize = GameItemContainer.MAXSIZE_BACKPACK - size;
|
|
|
|
var singleCost = TableManager.GetBackPackUnlockByID(_UnlockIdx, 0);
|
|
string costStr = singleCost.Price + StrDictionary.GetClientStrMoneyType((MONEYTYPE)singleCost.MoneyType);
|
|
_ToggleTextes[0].text = StrDictionary.GetClientDictionaryString("#{5000}", costStr);
|
|
|
|
Dictionary<int, int> prices = new Dictionary<int, int>();
|
|
string priceStr = "";
|
|
for (int i = _UnlockIdx; i < _UnlockIdx + _LineSize; ++i)
|
|
{
|
|
var tabCost = TableManager.GetBackPackUnlockByID(i, 0);
|
|
if (prices.ContainsKey(tabCost.MoneyType))
|
|
{
|
|
prices[tabCost.MoneyType] += tabCost.Price;
|
|
}
|
|
else
|
|
{
|
|
prices.Add(tabCost.MoneyType,tabCost.Price);
|
|
}
|
|
}
|
|
foreach (var price in prices)
|
|
{
|
|
priceStr += price.Value + StrDictionary.GetClientStrMoneyType((MONEYTYPE)price.Key);
|
|
}
|
|
_ToggleTextes[1].text = StrDictionary.GetClientDictionaryString("#{5001}", priceStr);
|
|
|
|
Dictionary<int, int> prices2 = new Dictionary<int, int>();
|
|
string priceStr2 = "";
|
|
for (int i = _UnlockIdx; i < _UnlockIdx + _TotalSize; ++i)
|
|
{
|
|
var tabCost = TableManager.GetBackPackUnlockByID(i, 0);
|
|
if (prices2.ContainsKey(tabCost.MoneyType))
|
|
{
|
|
prices2[tabCost.MoneyType] += tabCost.Price;
|
|
}
|
|
else
|
|
{
|
|
prices2.Add(tabCost.MoneyType, tabCost.Price);
|
|
}
|
|
}
|
|
foreach (var price in prices2)
|
|
{
|
|
priceStr2 += price.Value + StrDictionary.GetClientStrMoneyType((MONEYTYPE)price.Key);
|
|
}
|
|
_ToggleTextes[2].text = StrDictionary.GetClientDictionaryString("#{5002}", priceStr2);
|
|
}
|
|
|
|
public void CloseUnlockPanel()
|
|
{
|
|
_UnlockPanel.SetActive(false);
|
|
}
|
|
|
|
//确认解锁
|
|
public void UnlockOk()
|
|
{
|
|
int unlockNum = 0;
|
|
if (_Toggles[0].isOn)
|
|
unlockNum = 1;
|
|
else if (_Toggles[1].isOn)
|
|
unlockNum = _LineSize;
|
|
else if (_Toggles[2].isOn)
|
|
unlockNum = _TotalSize;
|
|
|
|
Dictionary<int, int> prices = new Dictionary<int, int>();
|
|
for (int i = _UnlockIdx; i < _UnlockIdx + unlockNum; ++i)
|
|
{
|
|
var tabCost = TableManager.GetBackPackUnlockByID(i, 0);
|
|
if (prices.ContainsKey(tabCost.MoneyType))
|
|
{
|
|
prices[tabCost.MoneyType] += tabCost.Price;
|
|
}
|
|
else
|
|
{
|
|
prices.Add(tabCost.MoneyType, tabCost.Price);
|
|
}
|
|
}
|
|
foreach (var price in prices)
|
|
{
|
|
if (!JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)price.Key, price.Value))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
CG_BACKPACK_UNLOCK unlock = (CG_BACKPACK_UNLOCK)PacketDistributed.CreatePacket(MessageID.PACKET_CG_BACKPACK_UNLOCK);
|
|
unlock.SetUnlocknum(unlockNum);
|
|
unlock.SendPacket();
|
|
|
|
CloseUnlockPanel();
|
|
}
|
|
//取消解锁
|
|
public void UnlockCancel()
|
|
{
|
|
CloseUnlockPanel();
|
|
}
|
|
#endregion
|
|
} |