Files
JJBB/Assets/Project/Script/GUI/StroyCopy/CopyCtrBase.cs

1229 lines
49 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using GCGame.Table;
using System.Collections.Generic;
using Module.Log;
public class CopyCtrBase : MonoBehaviour {
public static CopyCtrBase Instance;
public static CopyCtrBase GetInstance()
{
if (Instance == null)
Instance = new CopyCtrBase();
return Instance;
}
public enum CopySceneItemType
{
Advance = 1, //进阶
MainMission = 2, //主线
}
public int curType; //当前所属类型
public Transform rewParent;
public GameObject rewPrefab;
public GameObject _OneKeySweepBtn;
public GameObject normalSweepBtn;
public GameObject advanceSweepBtn;
public Text _onekeyBtnDesc;
public Text _normalSweepBtnDesc;
public Text _advanceSweepBtnDesc;
public Text _OneKeySweepConditionDesc;
public Text _NormalSweepConditionDesc;
public Text _AdvanceSweepConditionDesc;
public GameObject fastMoneyObj;
public GameObject normalMoneyObj;
public GameObject advanceMoneyObj;
public Image fastMoneyIcon;
public Image normalMoneyIcon;
public Image advanceMonryIcon;
public Text fastMoneyValue;
public Text normalMoneyValue;
public Text advanceMoneyValue;
public virtual void Awake()
{
StartCoroutine(InitShowSweepBtn());
}
IEnumerator InitShowSweepBtn()
{
yield return new WaitForEndOfFrame();
var _AllCopyDic = TableManager.GetNewCopyBase().Values;
foreach (var copyBase in _AllCopyDic)
{
if (copyBase.Type == curType)
{
_OneKeySweepBtn.SetActive(false);
for (int index = 0; index < copyBase.getFastSweepConditionCount(); index++)
{
if(copyBase.GetFastSweepConditionbyIndex(index) != -1)
{
_OneKeySweepBtn.SetActive(true);
break;
}
}
normalSweepBtn.gameObject.SetActive(false);
for(int index = 0; index < copyBase.getNormalSweepConditionCount(); index++)
{
if(copyBase.GetNormalSweepConditionbyIndex(index) != -1)
{
normalSweepBtn.SetActive(true);
break;
}
}
advanceSweepBtn.SetActive(false);
for(int index = 0; index < copyBase.getAdvancedSweepConditionCount(); index++)
{
if(copyBase.GetAdvancedSweepConditionbyIndex(index) != -1)
{
advanceSweepBtn.SetActive(true);
break;
}
}
yield break;
}
}
yield break;
}
public int _CurSelectedCopyBaseId = -1;
public void OnCopyBaseItemClick(int _copyBaseId)
{
_CurSelectedCopyBaseId = _copyBaseId;
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(_copyBaseId, 0);
if(newCopyBase == null)
{
return;
}
_onekeyBtnDesc.text = newCopyBase.FastSweepButton;
_normalSweepBtnDesc.text = newCopyBase.NormalSweepButton;
_advanceSweepBtnDesc.text = newCopyBase.AdvancedSweepButton;
if(newCopyBase.Type == 1)
ShowConditionDesc();
ShowCanGainRewItem();
}
public void ShowConditionDesc()
{
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(_CurSelectedCopyBaseId, 0);
if (newCopyBase == null)
{
LogModule.ErrorLog("ERROR, NewCopyBase id is : " + _CurSelectedCopyBaseId);
return;
}
//快速
var fastConditionDesc = "";
var isFastConditionPassed = true;
for(int index = 0; index < newCopyBase.getFastSweepConditionCount(); index++)
{
if(newCopyBase.GetFastSweepConditionbyIndex(index) != -1)
{
var param = newCopyBase.GetFastSweepPrambyIndex(index);
switch (newCopyBase.GetFastSweepConditionbyIndex(index))
{
case 1:
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < param)
{
isFastConditionPassed = false;
fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44060}", param);
continue;
}
}
break;
case 2:
{
if(GameManager.gameManager.PlayerDataPool.VipCost < param)
{
fastConditionDesc += (StrDictionary.GetClientDictionaryString("#{6754}") + param);
continue;
}
//if (GlobalData.GetMaxPrivilegeLevel() < param)
//{
// isFastConditionPassed = false;
// switch(param)
// {
// case 1:
// fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44062}");
// break;
// case 2:
// fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44063}");
// break;
// case 3:
// fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44063}");
// break;
// }
// continue;
//}
}
break;
case 3:
{
if (GameManager.gameManager.PlayerDataPool.MonthlyCardDayRemain <= 0)
{
isFastConditionPassed = false;
fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44061}");
continue;
}
}
break;
case 4:
{
if (GlobalData.OpenServerDays < param)
{
isFastConditionPassed = false;
fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44065}", param);
continue;
}
}
break;
case 5:
{
if (GlobalData.CreateRoleDays < param)
{
isFastConditionPassed = false;
fastConditionDesc += StrDictionary.GetClientDictionaryString("#{44066}", param);
continue;
}
}
break;
}
}
}
if(isFastConditionPassed)
{
fastMoneyObj.SetActive(true);
_OneKeySweepConditionDesc.gameObject.SetActive(false);
LoadAssetBundle.Instance.SetImageSprite(fastMoneyIcon, UICurrencyItem.GetCurrencySprite((MONEYTYPE)newCopyBase.FastSweepConsumeSubType), delegate(bool isSucess, GameObject obj) {
fastMoneyIcon.SetNativeSize();
});
fastMoneyValue.text = newCopyBase.FastSweepConsumeNum.ToString();
}
else
{
fastMoneyObj.SetActive(false);
_OneKeySweepConditionDesc.gameObject.SetActive(true);
_OneKeySweepConditionDesc.text = fastConditionDesc;
}
//高级
var normalConditionDesc = "";
var isnormalConditionPassed = true;
for (int index = 0; index < newCopyBase.getNormalSweepConditionCount(); index++)
{
if (newCopyBase.GetNormalSweepConditionbyIndex(index) != -1)
{
var param = newCopyBase.GetNormalSweepPrambyIndex(index);
switch (newCopyBase.GetNormalSweepConditionbyIndex(index))
{
case 1:
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < param)
{
isnormalConditionPassed = false;
normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44060}", param);
continue;
}
}
break;
case 2:
{
if (GameManager.gameManager.PlayerDataPool.VipCost < param)
{
normalConditionDesc += (StrDictionary.GetClientDictionaryString("#{6754}") + param);
continue;
}
//if (GlobalData.GetMaxPrivilegeLevel() < param)
//{
// isnormalConditionPassed = false;
// switch (param)
// {
// case 1:
// normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44062}");
// break;
// case 2:
// normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44063}");
// break;
// case 3:
// normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44063}");
// break;
// }
// continue;
//}
}
break;
case 3:
{
if (GameManager.gameManager.PlayerDataPool.MonthlyCardDayRemain <= 0)
{
isnormalConditionPassed = false;
normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44061}");
continue;
}
}
break;
case 4:
{
if (GlobalData.OpenServerDays < param)
{
isnormalConditionPassed = false;
normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44065}", param);
continue;
}
}
break;
case 5:
{
if (GlobalData.CreateRoleDays < param)
{
isnormalConditionPassed = false;
normalConditionDesc += StrDictionary.GetClientDictionaryString("#{44066}", param);
continue;
}
}
break;
}
}
}
if (isnormalConditionPassed)
{
normalMoneyObj.SetActive(true);
_NormalSweepConditionDesc.gameObject.SetActive(false);
LoadAssetBundle.Instance.SetImageSprite(normalMoneyIcon, UICurrencyItem.GetCurrencySprite((MONEYTYPE)newCopyBase.NormalSweepConsumeSubType), delegate (bool isSucess, GameObject obj) {
normalMoneyIcon.SetNativeSize();
});
normalMoneyValue.text = newCopyBase.NormalSweepConsumeNum.ToString();
}
else
{
normalMoneyObj.SetActive(false);
_NormalSweepConditionDesc.gameObject.SetActive(true);
_NormalSweepConditionDesc.text = normalConditionDesc;
}
//进阶
var advanceConditionDesc = "";
var isadvacneConditionPassed = true;
for (int index = 0; index < newCopyBase.getAdvancedSweepPramCount(); index++)
{
if (newCopyBase.GetAdvancedSweepConditionbyIndex(index) != -1)
{
var param = newCopyBase.GetAdvancedSweepPrambyIndex(index);
switch (newCopyBase.GetAdvancedSweepConditionbyIndex(index))
{
case 1:
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < param)
{
isadvacneConditionPassed = false;
advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44060}", param);
continue;
}
}
break;
case 2:
{
if (GameManager.gameManager.PlayerDataPool.VipCost < param)
{
advanceConditionDesc += (StrDictionary.GetClientDictionaryString("#{6754}") + param);
continue;
}
//if (GlobalData.GetMaxPrivilegeLevel() < param)
//{
// isadvacneConditionPassed = false;
// switch (param)
// {
// case 1:
// advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44062}");
// break;
// case 2:
// advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44063}");
// break;
// case 3:
// advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44063}");
// break;
// }
// continue;
//}
}
break;
case 3:
{
if (GameManager.gameManager.PlayerDataPool.MonthlyCardDayRemain <= 0)
{
isadvacneConditionPassed = false;
advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44061}");
continue;
}
}
break;
case 4:
{
if (GlobalData.OpenServerDays < param)
{
isadvacneConditionPassed = false;
advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44065}", param);
continue;
}
}
break;
case 5:
{
if (GlobalData.CreateRoleDays < param)
{
isadvacneConditionPassed = false;
advanceConditionDesc += StrDictionary.GetClientDictionaryString("#{44066}", param);
continue;
}
}
break;
}
}
}
if (isadvacneConditionPassed)
{
advanceMoneyObj.SetActive(true);
_AdvanceSweepConditionDesc.gameObject.SetActive(false);
LoadAssetBundle.Instance.SetImageSprite(advanceMonryIcon, UICurrencyItem.GetCurrencySprite((MONEYTYPE)newCopyBase.AdvancedSweepConsumeSubType), delegate (bool isSucess, GameObject obj) {
advanceMonryIcon.SetNativeSize();
});
advanceMoneyValue.text = newCopyBase.AdvanceSweepConsumeNum.ToString();
}
else
{
advanceMoneyObj.SetActive(false);
_AdvanceSweepConditionDesc.gameObject.SetActive(true);
_AdvanceSweepConditionDesc.text = advanceConditionDesc;
}
}
[HideInInspector]
public List<int> _UnLockCopyList;
public Dictionary<int, int> _AllRewDic = new Dictionary<int, int>();
public void ShowCanGainRewItem()
{
StartCoroutine(ShowCanGainRewAsyc());
}
IEnumerator ShowCanGainRewAsyc()
{
yield return new WaitForEndOfFrame();
_AllRewDic.Clear();
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(_CurSelectedCopyBaseId, 0);
if (newCopyBase == null)
{
yield break ;
}
Tab_CopySceneReward rewTab = TableManager.GetCopySceneRewardByID(newCopyBase.NormalPassRewardId, 0);
if (rewTab == null)
{
yield break;
}
for (int rewIndex = 0; rewIndex < rewTab.getRewardItemIDCount(); rewIndex++)
{
if (rewTab.GetRewardItemIDbyIndex(rewIndex) == -1)
{
continue;
}
if (_AllRewDic.ContainsKey(rewTab.GetRewardItemIDbyIndex(rewIndex)))
{
_AllRewDic[rewTab.GetRewardItemIDbyIndex(rewIndex)] = rewTab.GetRewardCountbyIndex(rewIndex);
}else
{
_AllRewDic.Add(rewTab.GetRewardItemIDbyIndex(rewIndex), rewTab.GetRewardCountbyIndex(rewIndex));
}
}
yield return StartCoroutine(SetSweepCanGainRew());
yield break;
}
private List<GameObject> rewPrefabList = new List<GameObject>();
IEnumerator SetSweepCanGainRew()
{
yield return StartCoroutine(CreateRewItemPrefab(_AllRewDic.Count));
List<KeyValuePair<int, int>> _AllRewLis = new List<KeyValuePair<int, int>>(_AllRewDic);
for(int index = 0; index < _AllRewDic.Count; index++)
{
rewPrefabList[index].SetActive(true);
rewPrefabList[index].GetComponent<CopySceneRewardItem>().InitItem(_AllRewLis[index].Key, _AllRewLis[index].Value);
}
yield break;
}
IEnumerator CreateRewItemPrefab(int _TotalCount)
{
if(rewPrefabList.Count < _TotalCount)
{
for(int index = rewPrefabList.Count; index < _TotalCount; index++)
{
GameObject item = GameObject.Instantiate(rewPrefab);
item.transform.SetParent(rewParent);
item.transform.localPosition = Vector3.zero;
item.transform.localRotation = Quaternion.Euler(Vector3.zero);
item.transform.localScale = Vector3.one;
item.SetActive(false);
rewPrefabList.Add(item);
}
}
else
{
for(int index = _TotalCount; index < rewPrefabList.Count; index++)
{
rewPrefabList[index].SetActive(false);
}
}
yield break;
}
private void OnDisable()
{
//HideAllRewItem();
}
public void HideAllRewItem()
{
for(int index = 0; index < rewPrefabList.Count; index++)
{
rewPrefabList[index].SetActive(false);
}
}
//副本ID 已经购买了几次(用于判断当前购买次数所需消耗)
public static Tab_NewBuyCopyNum GetCopyBuyOnceConsumeTab(int copySceneId, int buyCount)
{
var buyDic = TableManager.GetNewBuyCopyNum().Values;
foreach(var info in buyDic)
{
if(info.FuBenId == copySceneId
&& buyCount < info.MaxNum)
{
return info;
}
}
return null;
}
private int _NeedCostMoneyType = -1;
private int _NeedCostMoneyValue = 0;
public virtual void OnOneKeySweepBtnClick()
{
//判断OneKey的条件
var copyBase = TableManager.GetNewCopyBaseByID(_CurSelectedCopyBaseId, 0);
if(copyBase != null)
{
for(int index = 0; index < copyBase.getFastSweepConditionCount(); index++)
{
if(copyBase.GetFastSweepConditionbyIndex(index) != -1)
{
switch (copyBase.GetFastSweepConditionbyIndex(index))
{
case 1: //等级
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < copyBase.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48105}", copyBase.GetFastSweepPrambyIndex(index)));
return;
}
}
break;
case 2: //特权VIP
{
if(GameManager.gameManager.PlayerDataPool.VipCost < copyBase.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44077}", copyBase.GetFastSweepPrambyIndex(index)));
return;
}
//bool hasFind = false;
//foreach (var vip in GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic)
//{
// if (vip.Value && vip.Key >= copyBase.GetFastSweepPrambyIndex(index))
// {
// hasFind = true;
// break;
// }
//}
//if(!hasFind)
//{
// switch(copyBase.GetFastSweepPrambyIndex(index))
// {
// case 1:
// GUIData.AddNotifyData("44054");
// break;
// case 2:
// GUIData.AddNotifyData("44055");
// break;
// case 3:
// GUIData.AddNotifyData("44056");
// break;
// }
// return;
//}
}
break;
case 3: //月卡
{
if(GameManager.gameManager.PlayerDataPool.MonthlyCardDayRemain <= 0)
{
GUIData.AddNotifyData("44057");
return;
}
}
break;
case 4: //开服天数
if (GlobalData.OpenServerDays < copyBase.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48106}", copyBase.GetFastSweepPrambyIndex(index) - GlobalData.OpenServerDays));
return;
}
break;
case 5: //创角天数
{
if (GlobalData.CreateRoleDays < copyBase.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData("44058");
return;
}
}
break;
}
}
}
}
_NeedCostMoneyType = -1;
_NeedCostMoneyValue = 0;
var _allCopy = TableManager.GetNewCopyBase().Values;
foreach (var info in _allCopy)
{
if (info.Type == curType)
{
var key = info.GetId();
if (IsUnLock(key))
_UnLockCopyList.Add(key);
}
}
var _CanOneKeySweepCopyList = new List<int>();
for (int index = 0; index <_UnLockCopyList.Count; index++)
{
if(CanSweep(SweepType.onekey, _UnLockCopyList[index]))
{
_CanOneKeySweepCopyList.Add(_UnLockCopyList[index]);
}
}
if(_CanOneKeySweepCopyList.Count > 0)
{
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(_CanOneKeySweepCopyList[0], 0);
if(newCopyBase != null)
{
if(newCopyBase.FastSweepConsumeType != (int)CONSUM_TYPE.MONEY) //不需要消耗
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{48306}"), "", delegate () {
ReqSweepCopy req = new ReqSweepCopy();
req._CopyId = _CurSelectedCopyBaseId;
req._sweepType = 3;
req.SendMsg();
UIManager.CloseUI(UIInfo.MessageBox);
return;
}, delegate () {
UIManager.CloseUI(UIInfo.MessageBox);
return;
});
return;
}else
{
if (_NeedCostMoneyType == -1)
_NeedCostMoneyType = newCopyBase.FastSweepConsumeSubType;
}
}
for (int index = 0; index < _CanOneKeySweepCopyList.Count; index++)
{
newCopyBase = TableManager.GetNewCopyBaseByID(_CanOneKeySweepCopyList[index], 0);
if (newCopyBase != null)
{
_NeedCostMoneyValue += newCopyBase.FastSweepConsumeNum;
}
}
if (JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)(_NeedCostMoneyType), _NeedCostMoneyValue))
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{48307}",
_NeedCostMoneyValue,
PlayerData.MONEY.GetMoneyStr((MONEYTYPE)_NeedCostMoneyType)),
"", delegate ()
{
ReqSweepCopy req = new ReqSweepCopy();
req._CopyId = _CurSelectedCopyBaseId;
req._sweepType = 3;
req.SendMsg();
UIManager.CloseUI(UIInfo.MessageBox);
}, delegate ()
{
UIManager.CloseUI(UIInfo.MessageBox);
});
}
}
else
{
GUIData.AddNotifyData("#{48100}");
return;
}
}
public virtual void OnAdvanceSweepBtnClick()
{
_NeedCostMoneyType = -1;
_NeedCostMoneyValue = 0;
if (!CanSweep(SweepType.advance, _CurSelectedCopyBaseId))
{
return;
}
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(_CurSelectedCopyBaseId, 0);
if (newCopyBase == null)
{
return;
}
if (newCopyBase.AdvancedSweepConsumeType == (int)CONSUM_TYPE.MONEY)
{
if (_NeedCostMoneyType == -1)
{
_NeedCostMoneyType = newCopyBase.AdvancedSweepConsumeSubType;
}
_NeedCostMoneyValue = newCopyBase.AdvanceSweepConsumeNum;
}
if (_NeedCostMoneyValue > 0)
{
if (JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)(_NeedCostMoneyType), _NeedCostMoneyValue))
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{44012}",
_NeedCostMoneyValue,
PlayerData.MONEY.GetMoneyStr((MONEYTYPE)_NeedCostMoneyType)),
"",
delegate ()
{
ReqSweepCopy req = new ReqSweepCopy();
req._CopyId = _CurSelectedCopyBaseId;
req._sweepType = 2;
req.SendMsg();
},
delegate ()
{
CloseMessageBox();
});
}
}
else
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{48104}"), "", delegate () {
ReqSweepCopy req = new ReqSweepCopy();
req._CopyId = _CurSelectedCopyBaseId;
req._sweepType = 2;
req.SendMsg();
}, delegate () {
CloseMessageBox();
});
}
}
public bool CanBuyCopyChallengeTimes(int copyBaseId)
{
if (GetCopySceneHasBuyTimes(copyBaseId) < GetCurCopySceneMaxBuyTimes(copyBaseId))//还可以购买次数
{
//金钱是否足够
var tab = GetCopyBuyOnceConsumeTab(copyBaseId, GetCopySceneHasBuyTimes(copyBaseId));
if (JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)tab.ConsumeSubType, tab.ConsumeNum))
{
if (tab != null)
{
//购买次数
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{44021}", tab.ConsumeNum,
PlayerData.MONEY.GetMoneyStr((MONEYTYPE)tab.ConsumeSubType)), "", delegate ()
{
CG_BUY_COPY_NUM req = (CG_BUY_COPY_NUM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_BUY_COPY_NUM);
req.SetFubenId(copyBaseId);
req.SendPacket();
}, delegate ()
{
UIManager.CloseUI(UIInfo.MessageBox);
});
}
}
}
else
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46224}"));
}
return false;
}
public virtual void OnNormalSweepBtnClick()
{
_NeedCostMoneyType = -1;
_NeedCostMoneyValue = 0;
if (!CanSweep(SweepType.normal, _CurSelectedCopyBaseId))
{
return;
}
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(_CurSelectedCopyBaseId, 0);
if (newCopyBase == null)
{
return;
}
if (newCopyBase.NormalSweepConsumeType == (int)CONSUM_TYPE.MONEY)
{
if (_NeedCostMoneyType == -1)
{
_NeedCostMoneyType = newCopyBase.NormalSweepConsumeSubType;
}
_NeedCostMoneyValue += newCopyBase.NormalSweepConsumeNum;
}
if (_NeedCostMoneyValue > 0)
{
if (JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)(_NeedCostMoneyType), _NeedCostMoneyValue))
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{48101}",
_NeedCostMoneyValue, PlayerData.MONEY.GetMoneyStr((MONEYTYPE)_NeedCostMoneyType)),"",
delegate ()
{
ReqSweepCopy req = new ReqSweepCopy();
req._CopyId = _CurSelectedCopyBaseId;
req._sweepType = 1;
req.SendMsg();
},
delegate ()
{
CloseMessageBox();
});
}
}
else
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{48103}"), "", delegate () {
ReqSweepCopy req = new ReqSweepCopy();
req._CopyId = _CurSelectedCopyBaseId;
req._sweepType = 1;
req.SendMsg();
}, delegate () {
CloseMessageBox();
});
}
}
public static Dictionary<int, int> CopyBuyTimesInfoDic = new Dictionary<int, int>();
public static void AddCopyBuyTimesInfoToDic(int copySceneId, int buyTimes)
{
if(CopyBuyTimesInfoDic.ContainsKey(copySceneId))
{
CopyBuyTimesInfoDic[copySceneId] = buyTimes;
}
else
{
CopyBuyTimesInfoDic.Add(copySceneId, buyTimes);
}
}
//获取当前副本已经购买的次数
public static int GetCopySceneHasBuyTimes(int copyScneId)
{
if (CopyBuyTimesInfoDic.ContainsKey(copyScneId))
{
return CopyBuyTimesInfoDic[copyScneId];
}
else
{
return 0;
}
}
//获取当前副本最大可购买次数
public static int GetCurCopySceneMaxBuyTimes(int copySceneId)
{
var CopyBuyTimesInfoDic = TableManager.GetNewBuyCopyNum().Values;
int maxBuyTimes = 0;
foreach (var info in CopyBuyTimesInfoDic)
{
if(info.FuBenId == copySceneId)
{
maxBuyTimes = maxBuyTimes < info.MaxNum ? info.MaxNum : maxBuyTimes;
}
}
return maxBuyTimes;
}
public List<GameObject> itemPrefabList = new List<GameObject>();
public bool IsPassOnce(int _BaseId)
{
switch(curType)
{
case (int)CopySceneItemType.MainMission:
{
for (int index = 0; index < itemPrefabList.Count; index++)
{
if (itemPrefabList[index].GetComponent<MainMissionCopySceneItem>().curBaseId == _BaseId)
{
if (itemPrefabList[index].GetComponent<MainMissionCopySceneItem>().isPassOnce)
{
return true;
}
}
}
return false;
}
default:
{
for (int index = 0; index < itemPrefabList.Count; index++)
{
if (itemPrefabList[index].GetComponent<AdvanceCopyItem>().curBseId == _BaseId)
{
if (itemPrefabList[index].GetComponent<AdvanceCopyItem>().isPassOnce)
{
return true;
}
}
}
return false;
}
}
}
public bool HasChallengeTimes(int _BaseId)
{
switch(curType)
{
case (int)CopySceneItemType.Advance:
{
for (int index = 0; index < itemPrefabList.Count; index++)
{
if (itemPrefabList[index].GetComponent<AdvanceCopyItem>().curBseId == _BaseId)
{
if (itemPrefabList[index].GetComponent<AdvanceCopyItem>().remainChallengeTimes > 0)
{
return true;
}
}
}
}
break;
case (int)CopySceneItemType.MainMission:
{
for (int index = 0; index < itemPrefabList.Count; index++)
{
if (itemPrefabList[index].GetComponent<MainMissionCopySceneItem>().curBaseId == _BaseId)
{
if (itemPrefabList[index].GetComponent<MainMissionCopySceneItem>().remainCanChallengeTimes > 0)
{
return true;
}
}
}
}
break;
}
return false;
}
public bool CanChallengeByLevel(int needLevel)
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= needLevel)
{
return true;
}
return false;
}
public void CloseMessageBox()
{
UIManager.CloseUI(UIInfo.MessageBox);
}
private bool IsUnLock(int baseId)
{
var copyBaseTab = TableManager.GetNewCopyBaseByID(baseId, 0);
if(copyBaseTab == null)
{
return true;
}
return GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= copyBaseTab.UnLockLevel;
}
public enum SweepType
{
onekey = 0,
normal = 1,
advance = 2
}
public bool CanSweep(SweepType type, int baseId)
{
if(GameManager.gameManager.ActiveScene.IsCopyScene())
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{70500}"));
return false;
}
var copyBaseTab = TableManager.GetNewCopyBaseByID(baseId, 0);
if (copyBaseTab == null)
{
return true;
}
//解锁等级是否满足
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < copyBaseTab.UnLockLevel)
{
if (type != SweepType.onekey)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44011}", copyBaseTab.UnLockLevel));
}
return false;
}
//手动通关过一次
if(!IsPassOnce(baseId))
{
if (type != SweepType.onekey)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44010}"));
}
return false;
}
//有剩余的挑战次数
if(!HasChallengeTimes(baseId)/* && !CopyCtrBase.GetInstance().CanBuyCopyChallengeTimes(_CurSelectedCopyBaseId)*/)
{
if (type != SweepType.onekey)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1333}"));
}
return false;
}
int _SweepCondition = -1;
for(int index = 0; index < copyBaseTab.getAdvancedSweepConditionCount(); index++)
{
switch (type)
{
case SweepType.onekey:
_SweepCondition = copyBaseTab.GetFastSweepConditionbyIndex(index);
break;
case SweepType.normal:
_SweepCondition = copyBaseTab.GetNormalSweepConditionbyIndex(index);
break;
case SweepType.advance:
_SweepCondition = copyBaseTab.GetAdvancedSweepConditionbyIndex(index);
break;
}
//无条件扫荡(按钮的显示只跟是否有奖励有关)
if (_SweepCondition == -1)
{
return true;
}
switch (_SweepCondition)
{
case 1: //等级
{
switch (type)
{
case SweepType.onekey:
if (type != SweepType.onekey && GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < copyBaseTab.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48105}", copyBaseTab.GetFastSweepPrambyIndex(index)));
return false;
}
break;
case SweepType.normal:
if (type != SweepType.onekey && GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < copyBaseTab.GetNormalSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48105}", copyBaseTab.GetNormalSweepPrambyIndex(index)));
return false;
}
break;
case SweepType.advance:
if (type != SweepType.onekey && GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < copyBaseTab.GetAdvancedSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48105}", copyBaseTab.GetAdvancedSweepPrambyIndex(index)));
return false;
}
break;
}
}
break;
case 2: //VIP等级
switch (type)
{
case SweepType.onekey:
if (type != SweepType.onekey && GameManager.gameManager.PlayerDataPool.VipCost< copyBaseTab.GetFastSweepPrambyIndex(index))
{
var param = copyBaseTab.GetFastSweepPrambyIndex(index);
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44077}", param));
//switch (param)
//{
// case 1:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48110}"));
// break;
// case 2:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48111}"));
// break;
// case 3:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48112}"));
// break;
//}
return false;
}
break;
case SweepType.normal:
if (type != SweepType.onekey && GameManager.gameManager.PlayerDataPool.VipCost < copyBaseTab.GetNormalSweepPrambyIndex(index))
{
var param = copyBaseTab.GetNormalSweepPrambyIndex(index);
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44077}", param));
//switch (param)
//{
// case 1:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48110}"));
// break;
// case 2:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48111}"));
// break;
// case 3:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48112}"));
// break;
//}
return false;
}
break;
case SweepType.advance:
if (type != SweepType.onekey && GameManager.gameManager.PlayerDataPool.VipCost < copyBaseTab.GetAdvancedSweepPrambyIndex(index))
{
var param = copyBaseTab.GetAdvancedSweepPrambyIndex(index);
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44077}", param));
//switch (param)
//{
// case 1:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48110}"));
// break;
// case 2:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48111}"));
// break;
// case 3:
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48112}"));
// break;
//}
return false;
}
break;
}
break;
case 3: //月卡
{
if(GameManager.gameManager.PlayerDataPool.MonthlyCardDayRemain <= 0)
{
GUIData.AddNotifyData("44057");
return false;
}
}
break;
case 4: //开服天数
switch (type)
{
case SweepType.onekey:
if (type != SweepType.onekey && GlobalData.OpenServerDays < copyBaseTab.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48107}", GlobalData.OpenServerDays - copyBaseTab.GetFastSweepPrambyIndex(index)));
return false;
}
break;
case SweepType.normal:
if (type != SweepType.onekey && GlobalData.OpenServerDays < copyBaseTab.GetNormalSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48107}", GlobalData.OpenServerDays - copyBaseTab.GetNormalSweepPrambyIndex(index)));
return false;
}
break;
case SweepType.advance:
if (type != SweepType.onekey && GlobalData.OpenServerDays < copyBaseTab.GetAdvancedSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48107}", GlobalData.OpenServerDays - copyBaseTab.GetAdvancedSweepPrambyIndex(index)));
return false;
}
break;
}
break;
case 5: //创角天数
switch (type)
{
case SweepType.onekey:
if (type != SweepType.onekey && GlobalData.CreateRoleDays < copyBaseTab.GetFastSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48107}", GlobalData.OpenServerDays - copyBaseTab.GetFastSweepPrambyIndex(index)));
return false;
}
break;
case SweepType.normal:
if (type != SweepType.onekey && GlobalData.CreateRoleDays < copyBaseTab.GetNormalSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48107}", GlobalData.OpenServerDays - copyBaseTab.GetNormalSweepPrambyIndex(index)));
return false;
}
break;
case SweepType.advance:
if (type != SweepType.onekey && GlobalData.CreateRoleDays < copyBaseTab.GetAdvancedSweepPrambyIndex(index))
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{48107}", GlobalData.OpenServerDays - copyBaseTab.GetAdvancedSweepPrambyIndex(index)));
return false;
}
break;
}
break;
}
}
return true;
}
}