You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

418 lines
15 KiB

using IVServerFormat;
using IVDataFormat;
using System.Numerics;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
public class GoodsAttendItem : GoodsItem
{
#region UI
Button selfBtn;
protected TextMeshProUGUI txtDay;
protected GameObject objLock;
protected GameObject badge;
protected Image imgIcon_2;
#endregion
int thisDay = 0;
protected override void Init()
{
base.Init();
txtDay = transform.Find("txtDay").GetComponent<TextMeshProUGUI>();
objLock = transform.Find("lock").gameObject;
badge = transform.Find("badge").gameObject;
selfBtn = GetComponent<Button>();
imgIcon_2 = transform.Find("icon (1)").GetComponent<Image>();
}
public void SetDay(int day)
{
if (txtDay == null)
Init();
txtDay.text = FormatString.StringFormat(LocalizationText.GetText("attend_day"), day);
thisDay = day;
}
public bool SetIconWithDay(bool isNotCkeck, int day)
{
selfBtn.interactable = false;
badge.SetActive(false);
if (thisDay <= day)
{
objLock.SetActive(true);
}
else
{
objLock.SetActive(false);
}
if (isNotCkeck)
{
if (thisDay - 1 == day)
{
//objLock.SetActive(false);
badge.SetActive(true);
selfBtn.interactable = true;
}
}
return badge.activeSelf;
}
public bool GetBadge()
{
return badge.activeSelf;
}
public override void SetGoods(int itype, int icode, BigInteger icount, bool bpvp = false)
{
if (imgIcon == null)
Init();
if (icount < 0L)
txtCount.text = null;
else
txtCount.text = icount.ToString();
imgIcon.sprite = AddressableMgr.GetIcon(itype, icode);
switch (itype)
{
case cGoods.TCurrency:
case cGoods.TExp:
case cGoods.TBagTreasure:
imgIcon.enabled = true;
//imgBg.color = Global.CLR_RarityBack[cGoods.RNone];
imgRarity.enabled = false;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.enabled = false;
break;
case cGoods.TBagWeapon:
case cGoods.TBagArmorCape:
case cGoods.TBagArmorHat:
case cGoods.TBagArmorShoes:
case cGoods.TBagAcceEar:
case cGoods.TBagAcceNeck:
case cGoods.TBagAcceRing:
dGear gear = DataHandler.GetGearEquip(itype, icode);
imgIcon.enabled = true;
//imgBg.color = Global.CLR_RarityBack[gear.rarity];
imgRarity.color = Global.CLR_RarityFront[gear.rarity];
imgRarity.enabled = true;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = i < gear.grade;
txtRarity.text = Global.STR_Rarity[gear.rarity];
txtRarity.enabled = true;
break;
case cGoods.TPet:
int ipetrarity = DataHandler.GetPetRarity(icode);
//imgBg.color = Global.CLR_RarityBack[ipetrarity];
imgRarity.color = Global.CLR_RarityFront[ipetrarity];
imgRarity.enabled = true;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.text = Global.STR_Rarity[ipetrarity];
txtRarity.enabled = true;
break;
case cGoods.TPetSpirit:
imgIcon.enabled = true;
if (icode < 0)
{
//imgBg.color = Global.CLR_BackPetSpirit;
imgRarity.enabled = false;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.enabled = false;
}
else
{
int ispiritrarity = DataHandler.GetPetRarity(icode);
//imgBg.color = Global.CLR_RarityBack[ispiritrarity];
imgRarity.color = Global.CLR_RarityFront[ispiritrarity];
imgRarity.enabled = true;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.text = Global.STR_Rarity[ispiritrarity];
txtRarity.enabled = true;
}
break;
case cGoods.TSkillActive:
case cGoods.TSkillPassive:
imgIcon.enabled = true;
int iskillrarity = DataHandler.GetSkillRarity(itype, icode);
//imgBg.color = Global.CLR_RarityBack[iskillrarity];
imgRarity.color = Global.CLR_RarityFront[iskillrarity];
imgRarity.enabled = true;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.text = Global.STR_Rarity[iskillrarity];
txtRarity.enabled = true;
break;
case cGoods.TCosClrHair:
case cGoods.TCosClrTop:
case cGoods.TCosClrEye:
imgIcon.enabled = false;
//imgBg.color = DataHandler.GetColor(icode);
imgRarity.enabled = false;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.enabled = false;
break;
case cGoods.TCosCloth:
case cGoods.TCosWeapon:
imgIcon.enabled = true;
//imgBg.color = Global.CLR_BackCos;
imgRarity.enabled = false;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.enabled = false;
break;
case cGoods.TBox:
dBox box = DataHandler.SysBoxes[icode];
imgIcon.enabled = true;
//imgBg.color = Global.CLR_RarityBack[box.rarity];
imgSpirit.enabled = false;
// 희귀도 없음.
if (box.rarity <= cGoods.RNone)
{
imgRarity.enabled = false;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.enabled = false;
}
else
{
imgRarity.color = Global.CLR_RarityFront[box.rarity];
imgRarity.enabled = true;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = i < box.grade;
txtRarity.text = Global.STR_Rarity[box.rarity];
txtRarity.enabled = true;
}
break;
default:
imgIcon.enabled = true;
//imgBg.color = Global.CLR_RarityBack[cGoods.RNone];
imgRarity.enabled = false;
for (int i = 0; i < imgStars.Length; i++)
imgStars[i].enabled = false;
txtRarity.enabled = false;
break;
}
if (bpvp)
imgBg.color = Color.clear;
}
public void SetSecendGoods(int itype, int icode, BigInteger icount)
{
if (imgIcon == null)
Init();
//if (icount < 0L)
// txtCount.text = null;
//else
// txtCount.text = icount.ToString();
imgIcon_2.sprite = AddressableMgr.GetIcon(itype, icode);
imgIcon_2.gameObject.SetActive(true);
switch (itype)
{
case cGoods.TCurrency:
case cGoods.TExp:
case cGoods.TBagTreasure:
imgIcon_2.enabled = true;
//imgBg.color = Global.CLR_RarityBack[cGoods.RNone];
//imgRarity.enabled = false;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.enabled = false;
break;
case cGoods.TBagWeapon:
case cGoods.TBagArmorCape:
case cGoods.TBagArmorHat:
case cGoods.TBagArmorShoes:
case cGoods.TBagAcceEar:
case cGoods.TBagAcceNeck:
case cGoods.TBagAcceRing:
dGear gear = DataHandler.GetGearEquip(itype, icode);
imgIcon_2.enabled = true;
//imgBg.color = Global.CLR_RarityBack[gear.rarity];
//imgRarity.color = Global.CLR_RarityFront[gear.rarity];
//imgRarity.enabled = true;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = i < gear.grade;
//txtRarity.text = Global.STR_Rarity[gear.rarity];
//txtRarity.enabled = true;
break;
case cGoods.TPet:
//int ipetrarity = DataHandler.GetPetRarity(icode);
//imgBg.color = Global.CLR_RarityBack[ipetrarity];
//imgRarity.color = Global.CLR_RarityFront[ipetrarity];
//imgRarity.enabled = true;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.text = Global.STR_Rarity[ipetrarity];
//txtRarity.enabled = true;
break;
case cGoods.TPetSpirit:
imgIcon.enabled = true;
if (icode < 0)
{
//imgBg.color = Global.CLR_BackPetSpirit;
//imgRarity.enabled = false;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.enabled = false;
}
else
{
//int ispiritrarity = DataHandler.GetPetRarity(icode);
//imgBg.color = Global.CLR_RarityBack[ispiritrarity];
//imgRarity.color = Global.CLR_RarityFront[ispiritrarity];
//imgRarity.enabled = true;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.text = Global.STR_Rarity[ispiritrarity];
//txtRarity.enabled = true;
}
break;
case cGoods.TSkillActive:
case cGoods.TSkillPassive:
imgIcon.enabled = true;
//int iskillrarity = DataHandler.GetSkillRarity(itype, icode);
//imgBg.color = Global.CLR_RarityBack[iskillrarity];
//imgRarity.color = Global.CLR_RarityFront[iskillrarity];
//imgRarity.enabled = true;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.text = Global.STR_Rarity[iskillrarity];
//txtRarity.enabled = true;
break;
case cGoods.TCosClrHair:
case cGoods.TCosClrTop:
case cGoods.TCosClrEye:
imgIcon.enabled = false;
//imgBg.color = DataHandler.GetColor(icode);
//imgRarity.enabled = false;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.enabled = false;
break;
case cGoods.TCosCloth:
case cGoods.TCosWeapon:
imgIcon.enabled = true;
//imgBg.color = Global.CLR_BackCos;
//imgRarity.enabled = false;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.enabled = false;
break;
case cGoods.TBox:
dBox box = DataHandler.SysBoxes[icode];
imgIcon.enabled = true;
//imgBg.color = Global.CLR_RarityBack[box.rarity];
//imgSpirit.enabled = false;
// 희귀도 없음.
//if (box.rarity <= cGoods.RNone)
//{
// imgRarity.enabled = false;
// for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
// txtRarity.enabled = false;
//}
//else
//{
// imgRarity.color = Global.CLR_RarityFront[box.rarity];
// imgRarity.enabled = true;
// for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = i < box.grade;
// txtRarity.text = Global.STR_Rarity[box.rarity];
// txtRarity.enabled = true;
//}
break;
default:
imgIcon.enabled = true;
//imgBg.color = Global.CLR_RarityBack[cGoods.RNone];
//imgRarity.enabled = false;
//for (int i = 0; i < imgStars.Length; i++)
// imgStars[i].enabled = false;
//txtRarity.enabled = false;
break;
}
}
public void CheckAttend()//원래 이 부분에서 통신을 하고 통신에서 정산해야 함
{
AttendTypeRequest attendReq = new AttendTypeRequest();
attendReq.attendType = (int)AttendMgr.CurrentAttendType + 1;
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
CoverCamera.Hold();
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.AttendGet), typeof(AttendInfoReturn), AAttendCheckSucc, AAttendCheckFail, attendReq, true);
}
private void AAttendCheckSucc(object result, object request)
{
AttendInfoReturn data = result as AttendInfoReturn;
AttendTypeRequest attendReq = request as AttendTypeRequest;
if (data == null)
{
AAttendCheckFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
return;
}
List<nGoods> rewards = new List<nGoods>();
foreach (var reward in DataHandler.GetSysAttend()[(int)AttendMgr.CurrentAttendType].rewards[thisDay - 1].rewards)
{
if (reward.rewardType == cGoods.TCurrency && reward.rewardId == cGoods.CGold)
{
DataHandler.AddGold(reward.rewardCount);
}
rewards.Add(new nGoods(reward));
}
nGoods[] toArr = rewards.ToArray();
DataHandler.AddGoods(toArr, data.playCurrency, false);
GameUIMgr.SOpenPopupGoods(toArr);
badge.SetActive(false);
selfBtn.interactable = false;
objLock.SetActive(true);
if (attendReq.attendType == (int)AttendMgr.AttendType.AttendTen + 1)
{
EventMgr.AttendTenBadgeOff();
}
if (attendReq.attendType == (int)AttendMgr.AttendType.AttendRepeat + 1)
{
AttendMgr.AttendBadgeOff();
DataHandler.AddRecord(eCondition.PlayAtttend);
}
CoverCamera.Release();
}
private void AAttendCheckFail(SvError error, object request)
{
CoverCamera.Release();
}
}