319 lines
9.8 KiB
C#
319 lines
9.8 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
// 日常副本
|
|||
|
// 进入副本提示文字ID:
|
|||
|
public class DailyCopySceneRootCtr : MonoBehaviour
|
|||
|
{
|
|||
|
|
|||
|
private static DailyCopySceneRootCtr instance;
|
|||
|
public static DailyCopySceneRootCtr Instance
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return instance;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public Image BG;
|
|||
|
public UIContainerSelect menu;
|
|||
|
public UIContainerBase awardsContainer;
|
|||
|
public Text tip;
|
|||
|
public Button play;
|
|||
|
public Button multiPlay;
|
|||
|
public Button addRemainTime;
|
|||
|
public UIImgText remainTime;
|
|||
|
|
|||
|
public Image _ItemQuality;
|
|||
|
public Image _ItemIcon;
|
|||
|
public Text _ItemCount;
|
|||
|
public GameObject _ItemGetBtn;
|
|||
|
|
|||
|
public Dictionary<int, int> remainTimeDic = new Dictionary<int, int>();
|
|||
|
|
|||
|
private DailyCopyMenuItem.DailyCopyMenuItemData selectData;
|
|||
|
public Dictionary<int, int> hasBuyTime = new Dictionary<int, int>();
|
|||
|
|
|||
|
private List<DailyCopyMenuItem.DailyCopyMenuItemData> datas = new List<DailyCopyMenuItem.DailyCopyMenuItemData>();
|
|||
|
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (instance == null)
|
|||
|
{
|
|||
|
instance = this;
|
|||
|
}
|
|||
|
|
|||
|
play.onClick.AddListener(OnPlayBtnClick);
|
|||
|
multiPlay.onClick.AddListener(OnMultiPlayBtnClick);
|
|||
|
addRemainTime.onClick.AddListener(OnAddRemainTimeBtnClick);
|
|||
|
menu.SetShowItemFinishCallFun(ReqInfo);
|
|||
|
}
|
|||
|
|
|||
|
private void OnAddRemainTimeBtnClick()
|
|||
|
{
|
|||
|
BuyDailyCopyTimePanelCtr.Show(selectData.tab.Id, hasBuyTime[selectData.tab.Id]);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
if (instance != null)
|
|||
|
{
|
|||
|
instance = null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
var tab = TableManager.GetDailyCopy();
|
|||
|
datas.Clear();
|
|||
|
var selectItem = new List<DailyCopyMenuItem.DailyCopyMenuItemData>();
|
|||
|
//var lv = GameManager.gameManager.PlayerDataPool.GetPropInt(PropID.PropertyID.LEVEL);
|
|||
|
var lv = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|||
|
if (tab.Count > 0)
|
|||
|
{
|
|||
|
foreach (var item in tab)
|
|||
|
{
|
|||
|
DailyCopyMenuItem.DailyCopyMenuItemData newData = new DailyCopyMenuItem.DailyCopyMenuItemData();
|
|||
|
newData.isLock = lv < item.Value.OpenLv;
|
|||
|
|
|||
|
newData.tab = item.Value;
|
|||
|
datas.Add(newData);
|
|||
|
}
|
|||
|
|
|||
|
selectItem.Add(datas[0]);
|
|||
|
|
|||
|
menu.InitSelectContent(datas, selectItem, OnMenuSelect);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ReqInfo()
|
|||
|
{
|
|||
|
ReqDailyCopyInfo req = new ReqDailyCopyInfo();
|
|||
|
req.SendMsg();
|
|||
|
}
|
|||
|
|
|||
|
private void OnMenuSelect(object info)
|
|||
|
{
|
|||
|
var data = info as DailyCopyMenuItem.DailyCopyMenuItemData;
|
|||
|
var awards = new List<TestingRewardItemInfo>();
|
|||
|
|
|||
|
if (data != null)
|
|||
|
{
|
|||
|
selectData = data;
|
|||
|
SetText(tip, selectData.tab.PlayDesc);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(BG, selectData.tab.BGPath);
|
|||
|
addRemainTime.gameObject.SetActive(selectData.tab.BuyRuleID != -1);
|
|||
|
|
|||
|
Tab_CopySceneReward tab = TableManager.GetCopySceneRewardByID(data.tab.AwardTabID);
|
|||
|
if (tab != null)
|
|||
|
{
|
|||
|
var rewardIDNum = tab.getRewardItemIDCount();
|
|||
|
for (int i = 0; i < rewardIDNum; ++i)
|
|||
|
{
|
|||
|
int itemID = tab.GetRewardItemIDbyIndex(i);
|
|||
|
if (itemID == -1)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var newAward = new TestingRewardItemInfo(itemID, 1, false);
|
|||
|
awards.Add(newAward);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
InitCostItem(data.tab.CostItem);
|
|||
|
play.gameObject.SetActive(data.tab.CanSingleChallenge == 1);
|
|||
|
multiPlay.gameObject.SetActive(data.tab.CanTeamChallenge == 1);
|
|||
|
}
|
|||
|
|
|||
|
awardsContainer.InitContentItem(awards);
|
|||
|
UpdateRemainTime();
|
|||
|
}
|
|||
|
|
|||
|
private int _CostItemId = -1;
|
|||
|
void InitCostItem(int itemId)
|
|||
|
{
|
|||
|
_CostItemId = itemId;
|
|||
|
var commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("CommonItem找不到 : " + itemId);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
|||
|
|
|||
|
var backPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|||
|
if (backPack != null)
|
|||
|
{
|
|||
|
var count = backPack.GetItemCountByDataId(itemId);
|
|||
|
if (count > 0)
|
|||
|
_ItemCount.text = "<color=#FFFFFFFF>" + count.ToString() + "</color>";
|
|||
|
else
|
|||
|
_ItemCount.text = "<color=#FF3434FF>" + count.ToString() + "</color>";
|
|||
|
_ItemGetBtn.SetActive(count <= 0);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LogModule.ErrorLog("backPack is null");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemIcon()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_CostItemId, ItemTooltipsLogic.ShowType.Info, _ItemIcon.transform.position);
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemGetBtn()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_CostItemId, ItemTooltipsLogic.ShowType.GetPath, _ItemIcon.transform.position);
|
|||
|
}
|
|||
|
|
|||
|
private void OnPlayBtnClick()
|
|||
|
{
|
|||
|
if (GlobalData.IsInSpecialScene())
|
|||
|
return;
|
|||
|
MessageBoxLogic.OpenOKCancelBox(6773, -1,
|
|||
|
() =>
|
|||
|
{
|
|||
|
ReqOpenDailyCopy req = new ReqOpenDailyCopy();
|
|||
|
req.copyid = selectData.tab.Id;
|
|||
|
req.issingle = 1;
|
|||
|
|
|||
|
req.SendMsg();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
private void OnMultiPlayBtnClick()
|
|||
|
{
|
|||
|
if (GlobalData.IsInSpecialScene())
|
|||
|
return;
|
|||
|
var tab = TableManager.GetFubenByID(selectData.tab.Id);
|
|||
|
if (tab != null && JudgeMyTeamInfo(tab.PlayerDemandMin, selectData.tab.TeamTargetId))
|
|||
|
{
|
|||
|
MessageBoxLogic.OpenOKCancelBox(6773, -1,
|
|||
|
() =>
|
|||
|
{
|
|||
|
ReqOpenDailyCopy req = new ReqOpenDailyCopy();
|
|||
|
req.copyid = selectData.tab.Id;
|
|||
|
req.issingle = 0;
|
|||
|
|
|||
|
req.SendMsg();
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void SetText(Text text, string info)
|
|||
|
{
|
|||
|
string resultString = info.Replace("#r", "\n");
|
|||
|
if (text.text != resultString)
|
|||
|
{
|
|||
|
text.text = resultString;
|
|||
|
}
|
|||
|
|
|||
|
text.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
private bool JudgeMyTeamInfo(int minCount, int teamTargetId)
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() >= minCount)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string tip = StrDictionary.GetClientDictionaryString("#{65201}", minCount);
|
|||
|
MessageBoxLogic.OpenOKCancelBox(tip, null, delegate ()
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash["index"] = teamTargetId;
|
|||
|
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.SELECTTEAMCREATEWNDITEM, hash);
|
|||
|
|
|||
|
UIManager.ShowUI(UIInfo.TeamInfoRoot);
|
|||
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|||
|
}, delegate ()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|||
|
});
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{9004}"));
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string tip = StrDictionary.GetClientDictionaryString("#{65201}", minCount);
|
|||
|
MessageBoxLogic.OpenOKCancelBox(tip, null, delegate ()
|
|||
|
{
|
|||
|
//GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(teamTargetId, -1, -1);
|
|||
|
//UIManager.ShowUI(UIInfo.TeamInfoRoot);
|
|||
|
UIManager.ShowUI(UIInfo.TeamCreateRoot, delegate (bool bSucess, object param)
|
|||
|
{
|
|||
|
if (bSucess)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash["index"] = teamTargetId;
|
|||
|
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.SELECTTEAMCREATEWNDITEM, hash);
|
|||
|
}
|
|||
|
});
|
|||
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|||
|
}, delegate ()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|||
|
});
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateRemainTime()
|
|||
|
{
|
|||
|
int count = 0;
|
|||
|
if (remainTimeDic.TryGetValue(selectData.tab.Id, out count))
|
|||
|
{
|
|||
|
remainTime.gameObject.SetActive(true);
|
|||
|
remainTime.text = count.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
remainTime.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
menu.ForeachActiveItem<DailyCopyMenuItem>(
|
|||
|
(item) =>
|
|||
|
{
|
|||
|
if (remainTimeDic.ContainsKey(item.CopyID))
|
|||
|
{
|
|||
|
item.SetRemainTime(remainTimeDic[item.CopyID]);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void ShowPage(int pageIndex)
|
|||
|
{
|
|||
|
if (pageIndex > 0 && pageIndex < datas.Count)
|
|||
|
{
|
|||
|
List<DailyCopyMenuItem.DailyCopyMenuItemData> tempSelect = new List<DailyCopyMenuItem.DailyCopyMenuItemData>();
|
|||
|
tempSelect.Add(datas[pageIndex]);
|
|||
|
menu.SetSelect(tempSelect);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|