Files
JJBB/Assets/Project/Script/LuaScripts/UI/OpenServiceCS/OpenServiceChallengListPageCS.cs

289 lines
9.5 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
using GCGame.Table;
using Module.Log;
using GCGame;
// 排行榜显示界面
public class OpenServiceChallengListPageCS : MarketingUIBaseCS {
public Image banner; // 横幅图片
public List<Text> descList; // 文字描述
public Button btnAdvance; // 提升按钮位于横幅图片右下角可能更具不同的项目前往不同的UI
public Text btnAdvanceUnderline; // 提升按钮下的下划线
public Text curAdvanceLevel; // 当前进阶项阶数
public Button btnCheckRank; // 查看排行榜按钮(更具当前显示的项目,会查看不同的排行榜)
public UICameraTexture model; // 显示3D模型
public AdvanceAnimation sequence; // 显示序列帧动画模型
public UIContainerBase firstContainer; // 第一名显示的奖品列表
public UIContainerBase otherContainer; // 第二名到第四名奖品列表
//public UIContainerBase selfContainer; // 自己的、可点击领取的列表
private Text btnAdvanceDesc; // 提升按钮的文字描述
private int advanceType = -1; // 实际代表的进阶类型
private void Awake()
{
// 按钮监听绑定
if(btnAdvance != null)
{
btnAdvance.onClick.AddListener(OnBtnAdvanceClick);
btnAdvanceDesc = btnAdvance.GetComponentInChildren<Text>();
}
if(btnCheckRank != null)
{
btnCheckRank.onClick.AddListener(OnBtnCheckRandClick);
}
}
private void OnEnable()
{
AskForInfo();
}
private void OnDisable()
{
advanceType = -1;
}
private void SetDesc(List<string> descs)
{
for(int i = 0; i < descList.Count; i++)
{
if(i < descs.Count && !string.IsNullOrEmpty(descs[i]))
{
descList[i].text = StrDictionary.GetServerDictionaryFormatString(descs[i]);
descList[i].gameObject.SetActive(true);
}
else
{
descList[i].gameObject.SetActive(false);
}
}
//Ride = 0, // 坐骑
//GodWeapon = 1, // 神石 -> 竖琴
//Wing = 2, // 翅膀
//Wish = 3, // 神环 -> 神戒
//Seal = 4, // 王冠 -> 魂器
//Mask = 5, // 面具
//Crown = 6, // 战旗 -> 火炮
// 设置前往进阶的按钮文字
if (btnAdvanceDesc != null)
{
string desc = "前往进阶";
switch (advanceType)
{
case 0:
desc = StrDictionary.GetClientDictionaryString("#{62907}");
break;
case 1:
desc = StrDictionary.GetClientDictionaryString("#{62910}");
break;
case 2:
desc = StrDictionary.GetClientDictionaryString("#{62908}");
break;
case 3:
desc = StrDictionary.GetClientDictionaryString("#{62911}");
break;
case 4:
desc = StrDictionary.GetClientDictionaryString("#{62913}");
break;
case 5:
desc = StrDictionary.GetClientDictionaryString("#{62909}");
break;
case 6:
desc = StrDictionary.GetClientDictionaryString("#{62912}");
break;
}
btnAdvanceDesc.text = desc;
btnAdvanceUnderline.text = "";
for(int i = 0; i < btnAdvanceDesc.text.Length; ++i)
{
btnAdvanceUnderline.text += "__";
}
}
}
private void SetBanner()
{
if(banner != null)
{
Tab_ActInfoClient tab = TableManager.GetActInfoClientByID(this._ActID, 0);
if(tab != null)
{
LoadAssetBundle.Instance.SetImageSprite(banner, tab.Icon);
banner.gameObject.SetActive(true);
}
else
{
banner.gameObject.SetActive(false);
}
}
}
// 显示模型
// modelID - 需要显示的模型ID
// seqID - 需要显示的序列帧动画ID
// 需要显示时值不为 0 二者必有一个为0
private void SetModel(int modelID, int seqID)
{
if(model != null && sequence != null)
{
if(modelID != 0)
{
Tab_CharModel tab = TableManager.GetCharModelByID(modelID, 0);
model.InitModelPath(tab.Name, tab);
model.gameObject.SetActive(true);
sequence.gameObject.SetActive(false);
}
else if(seqID != 0)
{
sequence.ShowAnimationByModelID(seqID);
model.gameObject.SetActive(false);
sequence.gameObject.SetActive(true);
}
else
{
model.gameObject.SetActive(false);
sequence.gameObject.SetActive(false);
}
}
}
// 显示有点特殊
// 分三部分,第一名的,二 - 四名的以及自己可领取一共三部分。
private void SetItems(List<MarketingActAwardTag> tags)
{
if(tags != null && tags.Count >= 3)
{
if (firstContainer != null)
{
List<MarketingActAwardTag> firstTag = new List<MarketingActAwardTag>();
firstTag.Add(tags[0]);
firstContainer.InitContentItem(firstTag);
}
if (otherContainer != null)
{
List<MarketingActAwardTag> otherTags = tags.GetRange(1, tags.Count - 1);
otherContainer.InitContentItem(otherTags);
}
//if (selfContainer != null)
//{
// List<MarketingActAwardTag> selfTag = new List<MarketingActAwardTag>();
// selfTag.Add(tags[tags.Count - 1]);
// selfContainer.InitContentItem(selfTag);
//}
}
}
#region
// 进阶跳转
public void OnBtnAdvanceClick()
{
if(advanceType != -1)
{
// 事先检查进阶项是否开启
if (!AdvanceCanadvanceCtr.Instance.IsAdvanceFuncOpen(advanceType))
{
GUIData.AddNotifyData("#{2182}");
return;
}
int tempType = advanceType;
UIManager.ShowUI(UIInfo.AdvanceMountPanel, delegate (bool bSucess, object param) {
if (bSucess)
{
AdvanceMountPanelCtr.Instance.SetAdvanceType(tempType);
AdvanceMountPanelCtr.Instance.menuItemPanelCtr.OnMenuItemClick(AdvanceMenuItemPanelCtr.MenuItemOptType.Advance); //打开进阶界面
}
});
}
}
// 排行榜跳转
public void OnBtnCheckRandClick()
{
//Ride = 0, // 坐骑
//GodWeapon = 1, // 神石 -> 竖琴
//Wing = 2, // 翅膀
//Wish = 3, // 神环 -> 神戒 -> 麒麟臂
//Seal = 4, // 王冠 -> 魂器
//Mask = 5, // 面具
//Crown = 6, // 战旗 -> 火炮
// int rankID = 101 + advanceType;
int rankID = 71 + advanceType;
//请求排行榜信息
//CG_REQ_RANK_LIST send = (CG_REQ_RANK_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_RANK_LIST);
//send.Ranktype = rankID;
//send.SendPacket();
RankWindowNew.ShowPage((RankWindowNew.RankType_T)rankID);
if (OpenServiceRootCS.Instance)
{
OpenServiceRootCS.Instance.Close();
}
}
#endregion
#region
public void AskForInfo()
{
MarketingActAwardPageReq req = new MarketingActAwardPageReq();
req.actID = this._ActID;
req.updateOrInit = 1;
req.SendMsg();
}
// 新数据接口
protected override void MarketingActPageAwardRetDelInner(object packet)
{
MarketingActAwardPageRet p = packet as MarketingActAwardPageRet;
if (p == null)
return;
LogModule.DebugLog(this.gameObject.name + " : Recieve message.");
advanceType = p.subGiftType;
int advanceLevel = GameManager.gameManager.PlayerDataPool.m_AdvanceData.GetAdvanceGrade(advanceType);
if(advanceLevel != -1 && advanceLevel != 0)
{
curAdvanceLevel.gameObject.SetActive(true);
curAdvanceLevel.text = StrDictionary.GetClientDictionaryString("#{" + (66005 + advanceType) + "}", GetNum(advanceLevel));
}
else
{
curAdvanceLevel.gameObject.SetActive(false);
}
SetBanner();
SetDesc(p.descList);
SetModel(p.awardTags[0].modleID, p.awardTags[0].SequenceID);
SetItems(p.awardTags);
}
#endregion
/// <summary>
/// 输入数字,获得中文数字字符
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
private string GetNum(int num)
{
//return StrDictionary.GetClientDictionaryString("#{" + (66012 + num) + "}");
var numb = Utils.NumStr(num);
return numb;
}
}