896 lines
27 KiB
C#
896 lines
27 KiB
C#
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Games.Item;
|
||
using GCGame.Table;
|
||
using Module.Log;
|
||
|
||
public class EquipQianghuaRoot : UIControllerBase<EquipQianghuaRoot>
|
||
{
|
||
// 新增 - 等待恢复时间
|
||
// 每次强化在没收到服务器的确认协议的等待时间
|
||
// 等待时间内状态若有更新,则尝试恢复自动强化
|
||
private float waitTime = 2.0f;
|
||
|
||
void OnEnable()
|
||
{
|
||
IsEquipUpdate = true;
|
||
IsOptSucess = true;
|
||
SetInstance(this);
|
||
|
||
GUIData.delMoneyChanged += UpdateMoney;
|
||
}
|
||
|
||
void OnDisable()
|
||
{
|
||
SetInstance(null);
|
||
|
||
GUIData.delMoneyChanged -= UpdateMoney;
|
||
}
|
||
|
||
// Use this for initialization
|
||
void Start()
|
||
{
|
||
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
|
||
}
|
||
|
||
public void CloseWindow()
|
||
{
|
||
UIManager.ShowUI(UIInfo.EquipEnhance);
|
||
UIManager.CloseUI(UIInfo.EquipQianghua);
|
||
}
|
||
|
||
private bool IsEquipUpdate = true;
|
||
private bool IsOptSucess = true;
|
||
|
||
public void UpdateEquip()
|
||
{
|
||
IsEquipUpdate = true;
|
||
TryAutoRestart();
|
||
}
|
||
|
||
public void OptResult(GC_EQUIP_ENCHANCE_RET packet)
|
||
{
|
||
if (packet.Success > 0)
|
||
{
|
||
IsOptSucess = true;
|
||
TryAutoRestart();
|
||
|
||
var selectedObj = _QianghuaPerfects.GetSelectedItem();
|
||
EquipQianghuaLevelItem selectedItem = selectedObj as EquipQianghuaLevelItem;
|
||
if (selectedItem != null)
|
||
{
|
||
selectedItem.PlayEffect();
|
||
}
|
||
}
|
||
|
||
var strengLevel = _SelectedItem.StrengthLevel;
|
||
var strengValue = _SelectedItem.GetTotalStrengthVal();
|
||
|
||
string optStr = "";
|
||
string valueResult = "";
|
||
string valueStr = Mathf.Abs(strengValue - _QianghuaValueTotal).ToString();
|
||
if (strengLevel > _QianghuaPreLevel)
|
||
{
|
||
optStr = StrDictionary.GetClientDictionaryString("#{1878}");
|
||
}
|
||
else
|
||
{
|
||
optStr = StrDictionary.GetClientDictionaryString("#{5319}");
|
||
}
|
||
|
||
string tipStr = "";
|
||
if (strengValue > _QianghuaValueTotal)
|
||
{
|
||
tipStr = StrDictionary.GetClientDictionaryString("#{5329}", optStr, valueResult, valueStr);
|
||
}
|
||
else
|
||
{
|
||
tipStr = StrDictionary.GetClientDictionaryString("#{5434}");
|
||
}
|
||
|
||
GUIData.AddNotifyData(tipStr);
|
||
if (_SinglePanel.activeSelf)
|
||
{
|
||
ShowQianghuaSingle(_SelectedItem);
|
||
}
|
||
else
|
||
{
|
||
ShowQianghuaAuto(_SelectedItem);
|
||
}
|
||
}
|
||
|
||
#region show
|
||
|
||
|
||
public static void Show(GameItem selectedItem, bool isAuto)
|
||
{
|
||
Hashtable hash = new Hashtable();
|
||
hash.Add("SelectedItem", selectedItem);
|
||
hash.Add("IsAuto", isAuto);
|
||
|
||
UIManager.ShowUI(UIInfo.EquipQianghua, EquipQianghuaRoot.ShowUIOver, hash);
|
||
}
|
||
|
||
static void ShowUIOver(bool bSuccess, object param)
|
||
{
|
||
if (bSuccess)
|
||
{
|
||
Hashtable hash = param as Hashtable;
|
||
if (EquipQianghuaRoot.Instance() != null)
|
||
{
|
||
EquipQianghuaRoot.Instance().ShowInner((GameItem)hash["SelectedItem"], (bool)hash["IsAuto"]);
|
||
}
|
||
}
|
||
}
|
||
|
||
void ShowInner(GameItem selectedItem, bool isAuto)
|
||
{
|
||
if (isAuto)
|
||
{
|
||
_TargetLevel = 0;
|
||
_AutoTarget.text = StrDictionary.GetClientDictionaryString("#{5395}");
|
||
ShowQianghuaAuto(selectedItem);
|
||
}
|
||
else
|
||
{
|
||
_QianghuaLevel = -1;
|
||
ShowQianghuaSingle(selectedItem);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region single
|
||
|
||
public UIContainerSelect _QianghuaPerfects;
|
||
public CommonItemEquipItem _EquipItemSlot;
|
||
public CommonItemMaterialSlot _MaterialSlot;
|
||
public EquipStarProcess _StarProcess;
|
||
public Text _QianghuaAttr;
|
||
public Toggle _UseYuanbao;
|
||
public Toggle _UseItemCombine;
|
||
public GameObject _SinglePanel;
|
||
public GameObject _AutoPanel;
|
||
public GameObject _DownArrow;
|
||
public GameObject _UpArrow;
|
||
public GameObject _MaterialPanel;
|
||
public GameObject _YuanbaoPanel;
|
||
public Text _CostToggleTip;
|
||
public Text _AutoTip;
|
||
public UICurrencyItem _CostYuanbao;
|
||
public UICurrencyItem _OwnYuanbao;
|
||
public Text _BtnQianghuaText;
|
||
|
||
private GameItem _SelectedItem;
|
||
private int _QianghuaLevel = -1;
|
||
private int _QianghuaMaxLevel;
|
||
private int _QianghuaValueTotal;
|
||
private int _QianghuaPreLevel;
|
||
private bool singGotNext;
|
||
private bool isSingleAdd;
|
||
|
||
public void ShowQianghuaSingle(GameItem selectedItem)
|
||
{
|
||
_SelectedItem = selectedItem;
|
||
|
||
_SinglePanel.SetActive(true);
|
||
_AutoPanel.SetActive(false);
|
||
|
||
InitEquip();
|
||
|
||
List<QianghuaLvInfo> lvInfo = new List<QianghuaLvInfo>();
|
||
int qianghuaLevelCnt = TableManager.GetEquipEnchanceRandRate().Count;
|
||
if (qianghuaLevelCnt != _SelectedItem.StrengPerfect.Count)
|
||
{
|
||
qianghuaLevelCnt = _SelectedItem.StrengPerfect.Count + 1;
|
||
}
|
||
_QianghuaMaxLevel = qianghuaLevelCnt;
|
||
for (int i = 0; i < qianghuaLevelCnt; ++i)
|
||
{
|
||
var qianghua = selectedItem.GetEquipStarRate(i + 1);
|
||
QianghuaLvInfo qianghuaInfo = new QianghuaLvInfo();
|
||
qianghuaInfo.Level = i + 1;
|
||
qianghuaInfo.CurPerfect = (int)qianghua.x;
|
||
qianghuaInfo.MinPerfect = (int)qianghua.y;
|
||
qianghuaInfo.MaxPerfect = (int)qianghua.z;
|
||
if (qianghuaLevelCnt - 1 == i && i > 0)
|
||
{
|
||
var lastInfo = lvInfo[lvInfo.Count - 1];
|
||
if (lastInfo.CurPerfect >= lastInfo.MaxPerfect)
|
||
{
|
||
qianghuaInfo.IsCanSelect = true;
|
||
}
|
||
else
|
||
{
|
||
qianghuaInfo.IsCanSelect = false;
|
||
}
|
||
qianghuaInfo.IsCanSelect = true;
|
||
|
||
}
|
||
else
|
||
{
|
||
qianghuaInfo.IsCanSelect = true;
|
||
}
|
||
|
||
lvInfo.Add(qianghuaInfo);
|
||
}
|
||
|
||
|
||
SetQianghuaLvInfos(lvInfo);
|
||
}
|
||
|
||
private void InitEquip()
|
||
{
|
||
_EquipItemSlot.InitItem(_SelectedItem);
|
||
_StarProcess.Value = _SelectedItem.GetStrengthPerfect();
|
||
if (_QianghuaLevel < 0)
|
||
{
|
||
_QianghuaLevel = _SelectedItem.StrengthLevel + 1;
|
||
//if (_QianghuaLevel == 0)
|
||
//{
|
||
// _QianghuaLevel = 1;
|
||
//}
|
||
}
|
||
_QianghuaValueTotal = _SelectedItem.GetTotalStrengthVal();
|
||
_QianghuaPreLevel = _SelectedItem.StrengthLevel;
|
||
_QianghuaAttr.text = _SelectedItem.GetTotalStrengthVal() + "%";
|
||
|
||
//UpdateCost();
|
||
}
|
||
|
||
private void SetQianghuaLvInfos(List<QianghuaLvInfo> lvInfo)
|
||
{
|
||
QianghuaLvInfo selectInfo = null;
|
||
for (int i = 0; i < lvInfo.Count; ++i)
|
||
{
|
||
//if (lvInfo[i].CurPerfect < lvInfo[i].MaxPerfect)
|
||
//{
|
||
// if (_QianghuaLevel != -1 && i + 1 == _QianghuaLevel)
|
||
// {
|
||
// selectInfo = lvInfo[i];
|
||
// Debug.LogError("_QianghuaLevel : " + _QianghuaLevel);
|
||
// Debug.LogError(" i : " + i);
|
||
// break;
|
||
// }
|
||
// selectInfo = lvInfo[i];
|
||
//}
|
||
if (_SinglePanel.activeSelf)
|
||
{
|
||
if (_QianghuaLevel != -1 && i + 1 == _QianghuaLevel)
|
||
{
|
||
if (singGotNext)
|
||
{
|
||
if (lvInfo[i].CurPerfect < lvInfo[i].MaxPerfect)
|
||
{
|
||
selectInfo = lvInfo[i];
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
if (_QianghuaLevel < lvInfo.Count)
|
||
_QianghuaLevel += 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (lvInfo[i].CurPerfect <= 0)
|
||
{
|
||
selectInfo = lvInfo[i];
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
if (_QianghuaLevel < lvInfo.Count)
|
||
_QianghuaLevel += 1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (_QianghuaLevel != -1 && i + 1 == _QianghuaLevel)
|
||
{
|
||
if (lvInfo[i].CurPerfect < lvInfo[i].MaxPerfect)
|
||
{
|
||
selectInfo = lvInfo[i];
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
if (_QianghuaLevel < lvInfo.Count)
|
||
_QianghuaLevel += 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
//if (_QianghuaLevel - 1 >= 0 && _QianghuaLevel - 1 < lvInfo.Count)
|
||
//{
|
||
// if (lvInfo[_QianghuaLevel - 1].CurPerfect != lvInfo[_QianghuaLevel - 1].MaxPerfect)
|
||
// {
|
||
// selectInfo = lvInfo[_QianghuaLevel - 1];
|
||
// }
|
||
// else
|
||
// {
|
||
// int height = _QianghuaLevel;
|
||
// int low = _QianghuaLevel - 2;
|
||
// while (height < lvInfo.Count || low >= 0)
|
||
// {
|
||
// if (height < lvInfo.Count)
|
||
// {
|
||
// if (lvInfo[height].CurPerfect < lvInfo[height].MaxPerfect)
|
||
// {
|
||
// selectInfo = lvInfo[height];
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// if (low >= 0)
|
||
// {
|
||
// if (lvInfo[low].CurPerfect < lvInfo[low].MaxPerfect)
|
||
// {
|
||
// selectInfo = lvInfo[low];
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// ++height;
|
||
// --low;
|
||
// }
|
||
|
||
// }
|
||
//}
|
||
|
||
if (selectInfo == null)
|
||
{
|
||
_QianghuaPerfects.InitSelectContent(lvInfo, new List<QianghuaLvInfo>() { lvInfo[0] }, OnSelectQianghua);
|
||
}
|
||
else
|
||
{
|
||
_QianghuaPerfects.InitSelectContent(lvInfo, new List<QianghuaLvInfo>() { selectInfo }, OnSelectQianghua);
|
||
}
|
||
}
|
||
|
||
public void OnSelectQianghua(object qianghuaObj)
|
||
{
|
||
var qianghuaInfo = qianghuaObj as QianghuaLvInfo;
|
||
if (qianghuaInfo == null)
|
||
return;
|
||
if (qianghuaInfo.Level > _SelectedItem.StrengPerfect.Count)
|
||
{
|
||
_BtnQianghuaText.text = StrDictionary.GetClientDictionaryString("#{4237}");
|
||
}
|
||
else
|
||
{
|
||
_BtnQianghuaText.text = StrDictionary.GetClientDictionaryString("#{5319}");
|
||
}
|
||
isSingleAdd = qianghuaInfo.Level <= _SelectedItem.StrengPerfect.Count;
|
||
_QianghuaLevel = qianghuaInfo.Level;
|
||
//_QianghuaValueTotal = _SelectedItem.GetTotalStrengthVal();
|
||
//_QianghuaPreLevel = _SelectedItem.StrengthLevel;
|
||
UpdateCost();
|
||
}
|
||
|
||
public void IsUseYuanbao(bool isUse)
|
||
{
|
||
UpdateCost();
|
||
}
|
||
|
||
public void IsUseCombine(bool isUse)
|
||
{
|
||
UpdateCost();
|
||
}
|
||
|
||
private void UpdateCost()
|
||
{
|
||
var qianhuaTab = TableManager.GetEquipEnchanceRandRateByID(_QianghuaLevel, 0);
|
||
if (qianhuaTab != null)
|
||
{
|
||
int itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(qianhuaTab.ConsumeSubType);
|
||
if (_UseItemCombine.isOn)
|
||
{
|
||
itemCount += GetCombineItem(qianhuaTab.ConsumeSubType);
|
||
}
|
||
_MaterialSlot.InitMaterial(qianhuaTab.ConsumeSubType, qianhuaTab.ConsumeNum, false, itemCount);
|
||
|
||
//if(_QianghuaLevel >= 11)
|
||
//{
|
||
// _CostToggleTip.text = StrDictionary.GetClientDictionaryString("#{5386}") + PlayerData.MONEY.GetMoneyStr(MONEYTYPE.MONEYTYPE_YUANBAO);
|
||
//}
|
||
//else
|
||
//{
|
||
// _CostToggleTip.text = StrDictionary.GetClientDictionaryString("#{5386}") + PlayerData.MONEY.GetMoneyStr(MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
//}
|
||
_CostToggleTip.text = StrDictionary.GetClientDictionaryString("#{5386}");
|
||
_AutoTip.text = StrDictionary.GetClientDictionaryString("#{5440}");
|
||
|
||
if (!_MaterialSlot.IsMaterialEnough() && _UseYuanbao.isOn)
|
||
{
|
||
//bool materialInShop = false;
|
||
|
||
//var shopItems = TableManager.GetYuanBaoShop().Values;
|
||
//foreach (var shopItem in shopItems)
|
||
//{
|
||
// if (shopItem.ItemID == qianhuaTab.ConsumeSubType)
|
||
// {
|
||
// materialInShop = true;
|
||
int costMoney = GetItemPrice(qianhuaTab.ConsumeSubType) * (qianhuaTab.ConsumeNum - itemCount);
|
||
if (_UseItemCombine.isOn)
|
||
{
|
||
costMoney = GetComsumeMoney(qianhuaTab.ConsumeSubType, qianhuaTab.ConsumeNum);
|
||
}
|
||
_CostYuanbao.ShowCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, costMoney);
|
||
_OwnYuanbao.ShowOwnCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
// break;
|
||
// }
|
||
//}
|
||
|
||
//if (materialInShop == false)
|
||
//{
|
||
// _CostYuanbao.ShowCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, 0);
|
||
// _OwnYuanbao.ShowOwnCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
|
||
// CG_ASK_SHOP_SYS_ITEM packet = (CG_ASK_SHOP_SYS_ITEM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_SHOP_SYS_ITEM);
|
||
// packet.ItemClassId = -1;
|
||
// packet.ItemSubClassId = -1;
|
||
// packet.DataId = qianhuaTab.ConsumeSubType;
|
||
// packet.SendPacket();
|
||
//}
|
||
|
||
_MaterialPanel.SetActive(false);
|
||
_YuanbaoPanel.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
_MaterialPanel.SetActive(true);
|
||
_YuanbaoPanel.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
public int GetCombineItem(int itemDataID)
|
||
{
|
||
var comsumeTab = TableManager.GetItemCombineByID(itemDataID);
|
||
if (comsumeTab == null)
|
||
return 0;
|
||
|
||
int combineCnt = 0;
|
||
|
||
int srcItem = comsumeTab.GetSrcItemIDbyIndex(0);
|
||
if (srcItem > 0 && comsumeTab.GetNeedNumbyIndex(0) > 1)
|
||
{
|
||
int itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(srcItem);
|
||
itemCount += GetCombineItem(srcItem);
|
||
combineCnt += itemCount / comsumeTab.GetNeedNumbyIndex(0);
|
||
}
|
||
|
||
return combineCnt;
|
||
}
|
||
|
||
#region strength item price
|
||
|
||
private Dictionary<int, int> _StrengthItemPriceDict = new Dictionary<int, int>();
|
||
|
||
public int GetItemPrice(int itemDataID)
|
||
{
|
||
if (_StrengthItemPriceDict.ContainsKey(itemDataID))
|
||
return _StrengthItemPriceDict[itemDataID];
|
||
|
||
var shopItems = TableManager.GetYuanBaoShop().Values;
|
||
foreach (var shopItem in shopItems)
|
||
{
|
||
if (shopItem.ItemID == itemDataID)
|
||
{
|
||
_StrengthItemPriceDict.Add(itemDataID, shopItem.PriceForever);
|
||
return shopItem.PriceForever;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
#endregion
|
||
|
||
public int GetComsumeMoney(int itemDataID, int costNum)
|
||
{
|
||
int itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(itemDataID);
|
||
if (itemCount >= costNum)
|
||
return 0;
|
||
|
||
var comsumeTab = TableManager.GetItemCombineByID(itemDataID);
|
||
if (comsumeTab != null)
|
||
{
|
||
int srcItem = comsumeTab.GetSrcItemIDbyIndex(0);
|
||
if (srcItem > 0 && comsumeTab.GetNeedNumbyIndex(0) > 1)
|
||
{
|
||
int needNum = (costNum - itemCount) * comsumeTab.GetNeedNumbyIndex(0);
|
||
return GetComsumeMoney(srcItem, needNum);
|
||
}
|
||
}
|
||
|
||
return GetItemPrice(itemDataID) * (costNum - itemCount);
|
||
}
|
||
|
||
public void UpdateMoney()
|
||
{
|
||
UpdateCost();
|
||
}
|
||
|
||
public void UpdateCost(GC_UPDATE_SHOP_SYS_ITEM packet)
|
||
{
|
||
if (packet.shopItemsList.Count > 0)
|
||
_CostYuanbao.ShowCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, packet.shopItemsList[0].CurPrice * _MaterialSlot.NeedNum);
|
||
|
||
_OwnYuanbao.ShowOwnCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
//_CostToggleTip.text = StrDictionary.GetClientDictionaryString("#{5386}") + PlayerData.MONEY.GetMoneyStr(MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
_CostToggleTip.text = StrDictionary.GetClientDictionaryString("#{5386}");
|
||
}
|
||
|
||
public void OnStrengthClick()
|
||
{
|
||
LogModule.DebugLog("OnStrengthClick:" + _QianghuaLevel);
|
||
if (!IsEquipUpdate || !IsOptSucess)
|
||
{
|
||
LogModule.DebugLog("异常:结果未返回,请重试");
|
||
return;
|
||
}
|
||
|
||
if (_QianghuaLevel <= 0 || _QianghuaLevel > _QianghuaMaxLevel)
|
||
return;
|
||
|
||
if (_MaterialPanel.activeSelf)
|
||
{
|
||
if (!_MaterialSlot.IsMaterialEnough())
|
||
{
|
||
GUIData.AddNotifyData("#{5320}");
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bool isMoneyEnough = true;
|
||
//if (_QianghuaLevel <= 10)
|
||
{
|
||
isMoneyEnough = JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, _CostYuanbao.CurrencyIntValue);
|
||
}
|
||
//else
|
||
//{
|
||
// isMoneyEnough = JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO, _CostYuanbao.CurrencyIntValue);
|
||
//}
|
||
if (!isMoneyEnough)
|
||
return;
|
||
//if (_QianghuaLevel <= 10)
|
||
//{
|
||
// int ownYuanbao = GameManager.gameManager.PlayerDataPool.GetIntPropty((int)CONSUM_TYPE.MONEY, (int)MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
// if (ownYuanbao < _CostYuanbao.CurrencyIntValue)
|
||
// {
|
||
// ResourceLackLogic.Show(MONEYTYPE.MONEYTYPE_YUANBAO_BIND);
|
||
// return;
|
||
// }
|
||
//}
|
||
//else
|
||
//{
|
||
// int ownYuanbao = GameManager.gameManager.PlayerDataPool.GetIntPropty((int)CONSUM_TYPE.MONEY, (int)MONEYTYPE.MONEYTYPE_YUANBAO);
|
||
// if (ownYuanbao < _CostYuanbao.CurrencyIntValue)
|
||
// {
|
||
// ResourceLackLogic.Show(MONEYTYPE.MONEYTYPE_YUANBAO);
|
||
// return;
|
||
// }
|
||
//}
|
||
}
|
||
singGotNext = isSingleAdd;
|
||
if (!_SelectedItem.BindFlag)
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(5351, -1, OnStrengthClickOK);
|
||
TotalAutoStop();
|
||
}
|
||
else
|
||
{
|
||
OnStrengthClickOK();
|
||
}
|
||
}
|
||
|
||
public void OnStrengthClickOK()
|
||
{
|
||
CG_EQUIP_ENCHANCE packet = (CG_EQUIP_ENCHANCE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_EQUIP_ENCHANCE);
|
||
if (_SelectedItem.IsPlayerEquiped())
|
||
{
|
||
packet.Packtype = (int)GameItemContainer.Type.TYPE_EQUIPPACK;
|
||
}
|
||
else
|
||
{
|
||
packet.Packtype = (int)GameItemContainer.Type.TYPE_BACKPACK;
|
||
}
|
||
packet.Equipguid = _SelectedItem.Guid;
|
||
packet.Enchancelvl = _QianghuaLevel;
|
||
packet.Autopayment = _UseYuanbao.isOn ? 1 : 0;
|
||
packet.Autocompose = _UseItemCombine.isOn ? 1 : 0;
|
||
packet.SendPacket();
|
||
}
|
||
#endregion
|
||
|
||
#region auto
|
||
|
||
public GameObject _AutoTargetPanel;
|
||
public Text _AutoTarget;
|
||
public UIDialPanel _AutoSelect;
|
||
public UIContainerSelect _AutoSelectContainer;
|
||
public EquipAutoOpt _AutoOpt;
|
||
|
||
private int _TargetLevel;
|
||
private int _SpeedIdx;
|
||
|
||
public void ShowQianghuaAuto(GameItem selectedItem)
|
||
{
|
||
_SelectedItem = selectedItem;
|
||
|
||
_SinglePanel.SetActive(false);
|
||
_AutoPanel.SetActive(true);
|
||
|
||
|
||
InitEquip();
|
||
|
||
List<QianghuaLvInfo> lvInfo = new List<QianghuaLvInfo>();
|
||
int qianghuaLevelCnt = TableManager.GetEquipEnchanceRandRate().Count;
|
||
_QianghuaMaxLevel = qianghuaLevelCnt;
|
||
for (int i = 0; i < qianghuaLevelCnt; ++i)
|
||
{
|
||
var qianghua = selectedItem.GetEquipStarRate(i + 1);
|
||
QianghuaLvInfo qianghuaInfo = new QianghuaLvInfo();
|
||
qianghuaInfo.Level = i + 1;
|
||
qianghuaInfo.CurPerfect = (int)qianghua.x;
|
||
qianghuaInfo.MinPerfect = (int)qianghua.y;
|
||
qianghuaInfo.MaxPerfect = (int)qianghua.z;
|
||
|
||
if (lvInfo.Count > 0)
|
||
{
|
||
var lastInfo = lvInfo[lvInfo.Count - 1];
|
||
if (lastInfo.CurPerfect >= lastInfo.MaxPerfect)
|
||
{
|
||
qianghuaInfo.IsCanSelect = true;
|
||
}
|
||
else
|
||
{
|
||
qianghuaInfo.IsCanSelect = false;
|
||
}
|
||
qianghuaInfo.IsCanSelect = true;
|
||
|
||
}
|
||
else
|
||
{
|
||
qianghuaInfo.IsCanSelect = true;
|
||
}
|
||
|
||
lvInfo.Add(qianghuaInfo);
|
||
}
|
||
SetQianghuaLvInfos(lvInfo);
|
||
}
|
||
|
||
public void OnShowAutoTarget()
|
||
{
|
||
// 再次点击关闭选择面板
|
||
if (_AutoTargetPanel.activeSelf == true)
|
||
{
|
||
OnHideAutoTarget();
|
||
return;
|
||
}
|
||
|
||
_AutoTargetPanel.SetActive(true);
|
||
_DownArrow.SetActive(false);
|
||
_UpArrow.SetActive(true);
|
||
//int autoMinLevel = 1;
|
||
//int qianghuaLevelCnt = 10;
|
||
//for (int i = 0; i < qianghuaLevelCnt; ++i)
|
||
//{
|
||
// var qianghua = _SelectedItem.GetEquipStarRate(i + 1);
|
||
// if (qianghua.x == qianghua.z)
|
||
// {
|
||
// continue;
|
||
// }
|
||
// autoMinLevel = i + 1;
|
||
// break;
|
||
//}
|
||
//_AutoSelect.InitNum(autoMinLevel, qianghuaLevelCnt);
|
||
|
||
List<int> autoLevels = new List<int>();
|
||
int qianghuaLevelCnt = TableManager.GetEquipEnchanceRandRate().Count;
|
||
_QianghuaMaxLevel = qianghuaLevelCnt;
|
||
for (int i = 0; i < qianghuaLevelCnt; ++i)
|
||
{
|
||
var qianghua = _SelectedItem.GetEquipStarRate(i + 1);
|
||
if ((int)qianghua.x != (int)qianghua.z)
|
||
{
|
||
autoLevels.Add(i + 1);
|
||
}
|
||
}
|
||
//if (autoLevels.Count == 0)
|
||
//{
|
||
// for (int i = 10; i < qianghuaLevelCnt; ++i)
|
||
// {
|
||
// var qianghua = _SelectedItem.GetEquipStarRate(i + 1);
|
||
// if ((int)qianghua.x != (int)qianghua.z)
|
||
// {
|
||
// autoLevels.Add(i + 1);
|
||
// }
|
||
// }
|
||
//}
|
||
List<int> selectedList = new List<int>();
|
||
if (_TargetLevel > 0)
|
||
{
|
||
selectedList.Add(_TargetLevel);
|
||
}
|
||
_AutoSelectContainer.InitSelectContent(autoLevels, selectedList, SelectAutoTarget);
|
||
}
|
||
|
||
public void SelectAutoTarget(object autoObj)
|
||
{
|
||
int autoLevel = (int)autoObj;
|
||
|
||
_TargetLevel = autoLevel;
|
||
_AutoTarget.text = StrDictionary.GetClientDictionaryString("#{5302}", _TargetLevel);
|
||
//_AutoTargetPanel.SetActive(false);
|
||
LogModule.DebugLog("_TargetLevel:" + _TargetLevel);
|
||
}
|
||
|
||
|
||
|
||
public void OnHideAutoTarget()
|
||
{
|
||
//_TargetLevel = _AutoSelect.GetSelectedNum();
|
||
//_AutoTarget.text = StrDictionary.GetClientDictionaryString("#{5302}", _TargetLevel);
|
||
_AutoTargetPanel.SetActive(false);
|
||
_DownArrow.SetActive(true);
|
||
_UpArrow.SetActive(false);
|
||
//LogModule.DebugLog("_TargetLevel:" + _TargetLevel);
|
||
}
|
||
|
||
public void OnAutoQianghuaStart()
|
||
{
|
||
IsEquipUpdate = true;
|
||
IsOptSucess = true;
|
||
}
|
||
|
||
public void OnAutoQianghua()
|
||
{
|
||
LogModule.DebugLog("OnAutoQianghua");
|
||
if (_TargetLevel <= 0 || _TargetLevel > _QianghuaMaxLevel)
|
||
{
|
||
GUIData.AddNotifyData("#{5321}");
|
||
TotalAutoStop();
|
||
return;
|
||
}
|
||
|
||
int needStrengLevel = 0;
|
||
int qianghuaLevelCnt = TableManager.GetEquipEnchanceRandRate().Count;
|
||
for (int i = 0; i < qianghuaLevelCnt; ++i)
|
||
{
|
||
var qianghua = _SelectedItem.GetEquipStarRate(i + 1);
|
||
if (qianghua.x < qianghua.z)
|
||
{
|
||
needStrengLevel = i + 1;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (needStrengLevel > _TargetLevel)
|
||
{
|
||
GUIData.AddNotifyData("#{5326}");
|
||
TotalAutoStop();
|
||
return;
|
||
}
|
||
|
||
if (_MaterialPanel.activeSelf)
|
||
{
|
||
if (!_MaterialSlot.IsMaterialEnough())
|
||
{
|
||
GUIData.AddNotifyData("#{5320}");
|
||
TotalAutoStop();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bool isMoneyEnough = true;
|
||
//if (_QianghuaLevel <= 10)
|
||
{
|
||
isMoneyEnough = JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, _CostYuanbao.CurrencyIntValue);
|
||
}
|
||
//else
|
||
//{
|
||
// isMoneyEnough = JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO, _CostYuanbao.CurrencyIntValue);
|
||
//}
|
||
if (!isMoneyEnough)
|
||
{
|
||
TotalAutoStop();
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (!IsEquipUpdate || !IsOptSucess)
|
||
{
|
||
//GUIData.AddNotifyData("#{5385}");
|
||
TempAutoStop();
|
||
return;
|
||
}
|
||
IsEquipUpdate = false;
|
||
IsOptSucess = false;
|
||
_QianghuaLevel = needStrengLevel;
|
||
if (!_SelectedItem.BindFlag)
|
||
{
|
||
TotalAutoStop();
|
||
MessageBoxLogic.OpenOKCancelBox(5351, -1, OnStrengthAutoClickOK, TotalAutoStop);
|
||
}
|
||
else
|
||
{
|
||
OnStrengthClickOK();
|
||
}
|
||
|
||
//CG_EQUIP_ENCHANCE packet = (CG_EQUIP_ENCHANCE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_EQUIP_ENCHANCE);
|
||
//if (_SelectedItem.IsPlayerEquiped())
|
||
//{
|
||
// packet.Packtype = (int)GameItemContainer.Type.TYPE_EQUIPPACK;
|
||
//}
|
||
//else
|
||
//{
|
||
// packet.Packtype = (int)GameItemContainer.Type.TYPE_BACKPACK;
|
||
//}
|
||
//packet.Equipguid = _SelectedItem.Guid;
|
||
//packet.Enchancelvl = needStrengLevel;
|
||
//packet.Autopayment = _UseYuanbao.isOn ? 1 : 0;
|
||
//packet.Autocompose = _UseItemCombine.isOn ? 1 : 0;
|
||
//packet.SendPacket();
|
||
//LogModule.DebugLog("OnAutoQianghua Level:" + needStrengLevel);
|
||
//TestResult();
|
||
}
|
||
|
||
public void OnStrengthAutoClickOK()
|
||
{
|
||
OnStrengthClickOK();
|
||
_AutoOpt.StartAuto();
|
||
}
|
||
|
||
// 完全立刻停止,无需等待服务器的确认
|
||
public void TotalAutoStop()
|
||
{
|
||
_AutoOpt.StopAuto();
|
||
}
|
||
|
||
// 尝试停止,等待服务器的状态更新
|
||
private void TempAutoStop()
|
||
{
|
||
_AutoOpt.TryStop(waitTime);
|
||
}
|
||
|
||
// 尝试恢复自动强化,需要考虑期间已被玩家手动暂停的情况
|
||
private void TryAutoRestart()
|
||
{
|
||
if (IsEquipUpdate && IsOptSucess)
|
||
{
|
||
_AutoOpt.Restart();
|
||
}
|
||
}
|
||
|
||
private void TestResult()
|
||
{
|
||
++_SelectedItem.StrengthLevel;
|
||
_SelectedItem.StrengPerfect.Add(3);
|
||
UpdateEquip();
|
||
IsOptSucess = true;
|
||
}
|
||
|
||
public void OnCombineHelp()
|
||
{
|
||
MessageHelpLogic.ShowHelpMessage(65);
|
||
}
|
||
|
||
#endregion
|
||
}
|