198 lines
5.7 KiB
C#
198 lines
5.7 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
// 0元购活动item
|
|||
|
public class FreeBuyItem : UIItemBase {
|
|||
|
|
|||
|
public Image bg;
|
|||
|
public Sprite[] bgState; // 2个, 0已购买, 1未购买
|
|||
|
public Text itemName;
|
|||
|
public Text returnDay;
|
|||
|
public UIImgText returnMoney;
|
|||
|
public Text btnReturnMoney;
|
|||
|
public Image moneyType;
|
|||
|
public Image btnMoneyType;
|
|||
|
|
|||
|
public UICameraTexture model;
|
|||
|
public Image awardStateTips;
|
|||
|
public Sprite[] tipStates; // 2个,0已购买,1已领取
|
|||
|
public Button buyBtn; // 购买按钮
|
|||
|
public Button getAwardBtn; // 获得奖品按钮
|
|||
|
public GameObject cantBuyBtn; // 已领取/不能领取
|
|||
|
public Text cantBugBtnDes; // 不能购买时的按钮显示文字,若倒计时显示倒计时,如果没有则显示灰色购买
|
|||
|
public GameObject combatValueGO; // 战斗力显示控制
|
|||
|
public UIImgText combatValue; // 战斗力
|
|||
|
|
|||
|
private int actID;
|
|||
|
private int tagID;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if(buyBtn != null && getAwardBtn != null)
|
|||
|
{
|
|||
|
buyBtn.onClick.AddListener(OnBtnClick);
|
|||
|
getAwardBtn.onClick.AddListener(OnBtnClick);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Show(Hashtable hash)
|
|||
|
{
|
|||
|
MarketingActAwardTag info = hash["InitObj"] as MarketingActAwardTag;
|
|||
|
if(info != null)
|
|||
|
{
|
|||
|
actID = info.actID;
|
|||
|
tagID = info.tagID;
|
|||
|
ShowInfo(info);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ShowInfo(MarketingActAwardTag info)
|
|||
|
{
|
|||
|
if(info.awardItems.Count > 0)
|
|||
|
{
|
|||
|
Tab_CommonItem tab = TableManager.GetCommonItemByID(info.awardItems[0].awardSubType, 0);
|
|||
|
if(tab != null)
|
|||
|
{
|
|||
|
itemName.text = tab.Name;
|
|||
|
itemName.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
itemName.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
itemName.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
SetMoneyType(info.iconPath[0]);
|
|||
|
ShowDesc(info.descs);
|
|||
|
ShowModel(info.modleID);
|
|||
|
SetBtnState(info.state);
|
|||
|
SetCombatValue(info.otherDescs);
|
|||
|
}
|
|||
|
|
|||
|
private void SetCombatValue(List<string> otherDescs)
|
|||
|
{
|
|||
|
if(otherDescs.Count > 0 && !string.IsNullOrEmpty(otherDescs[0]))
|
|||
|
{
|
|||
|
combatValueGO.SetActive(true);
|
|||
|
combatValue.text = otherDescs[0];
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
combatValueGO.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 设置购买 / 奖励金币类型
|
|||
|
private void SetMoneyType(string moneyPath)
|
|||
|
{
|
|||
|
if(!string.IsNullOrEmpty(moneyPath))
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(moneyType, moneyPath);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(btnMoneyType, moneyPath);
|
|||
|
moneyType.gameObject.SetActive(true);
|
|||
|
btnMoneyType.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
moneyType.gameObject.SetActive(false);
|
|||
|
btnMoneyType.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 该活动需要显示的信息,必须超多4条,即使为空
|
|||
|
private void ShowDesc(List<string> descs)
|
|||
|
{
|
|||
|
cantBugBtnDes.text = StrDictionary.GetClientDictionaryString("#{6746}");
|
|||
|
if (descs != null && descs.Count >= 3)
|
|||
|
{
|
|||
|
// 0 - 返还数目
|
|||
|
if(!string.IsNullOrEmpty(descs[0]))
|
|||
|
{
|
|||
|
returnMoney.text = StrDictionary.GetServerDictionaryFormatString(descs[0]);
|
|||
|
btnReturnMoney.text = returnMoney.text;
|
|||
|
}
|
|||
|
|
|||
|
// 1 - 返还天数
|
|||
|
if (!string.IsNullOrEmpty(descs[1]))
|
|||
|
{
|
|||
|
returnDay.text = StrDictionary.GetServerDictionaryFormatString(descs[1]);
|
|||
|
}
|
|||
|
|
|||
|
// 2 - 剩余返还天数
|
|||
|
if (!string.IsNullOrEmpty(descs[2]))
|
|||
|
{
|
|||
|
cantBugBtnDes.text = StrDictionary.GetServerDictionaryFormatString(descs[2]);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ShowModel(int modelID)
|
|||
|
{
|
|||
|
if(modelID != 0)
|
|||
|
{
|
|||
|
Tab_CharModel tab = TableManager.GetCharModelByID(modelID, 0);
|
|||
|
if(tab != null)
|
|||
|
{
|
|||
|
model.gameObject.SetActive(true);
|
|||
|
model.InitModelPath(tab.ResPath, tab);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
model.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
itemName.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 类型: 0.不可领取 1.可购买 2.已购买 3.可领取 4.已领取
|
|||
|
private void SetBtnState(int state)
|
|||
|
{
|
|||
|
buyBtn.gameObject.SetActive(state == 1);
|
|||
|
cantBuyBtn.gameObject.SetActive(state == 0 || state == 2 || state == 4);
|
|||
|
getAwardBtn.gameObject.SetActive(state == 3);
|
|||
|
|
|||
|
if(state == 0 || state == 1)
|
|||
|
{
|
|||
|
bg.overrideSprite = bgState[1];
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bg.overrideSprite = bgState[0];
|
|||
|
}
|
|||
|
|
|||
|
if(state == 2)
|
|||
|
{
|
|||
|
awardStateTips.overrideSprite = tipStates[0];
|
|||
|
awardStateTips.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else if(state == 4)
|
|||
|
{
|
|||
|
awardStateTips.overrideSprite = tipStates[1];
|
|||
|
awardStateTips.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
awardStateTips.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 购买和领取走相同的请求协议
|
|||
|
private void OnBtnClick()
|
|||
|
{
|
|||
|
MarketingActAwardPageGetAward req = new MarketingActAwardPageGetAward();
|
|||
|
req.actID = actID;
|
|||
|
req.tagID = tagID;
|
|||
|
req.SendMsg();
|
|||
|
}
|
|||
|
}
|