using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class BeautyMMShowWin : UIBase
|
{
|
|
[SerializeField] Image qualityImg;
|
[SerializeField] Text qualityText1; // 品质分两字显示,注意海外版本
|
[SerializeField] Text qualityText2;
|
[SerializeField] Text nameText;
|
[SerializeField] Button descBtn;
|
[SerializeField] ImageEx roleImg;
|
[SerializeField] UIEffectPlayer roleUPEffect;
|
[SerializeField] Button leftBtn;
|
[SerializeField] Button rightBtn;
|
[SerializeField] Button skinBtn;
|
[SerializeField] Image skinRedImg;
|
|
[SerializeField] Transform trainRect;
|
[SerializeField] Transform activeRect;
|
|
[SerializeField] Text activeTipText;
|
[SerializeField] Button activeBtn;
|
|
[SerializeField] Text lvNameText;
|
[SerializeField] Text lvText;
|
[SerializeField] Text expText;
|
[SerializeField] Image process;
|
[SerializeField] ItemCell showAwardCell;
|
[SerializeField] Button[] awardBtns; //小奖励
|
[SerializeField] Image[] awardImgs;
|
[SerializeField] Button seeAttrBtn;
|
[SerializeField] Text nextAddAttrText;
|
[SerializeField] Text[] talentTexts;
|
[SerializeField] Transform nextLVTalentTipRect;
|
[SerializeField] Text nextLVTalentTip;
|
[SerializeField] ScrollerController loveScroller;
|
[SerializeField] Toggle onekeyToggle;
|
[SerializeField] Button giftBtn;
|
|
[SerializeField] Transform giftOPRect;
|
[SerializeField] Transform fullRect;
|
|
int mmID;
|
BeautyConfig mmConfig;
|
List<int> itemlist = new List<int>();
|
|
int beforeRank = 0;
|
protected override void InitComponent()
|
{
|
descBtn.AddListener(() =>
|
{
|
SmallTipWin.showText = mmConfig.Desc;
|
SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition);
|
SmallTipWin.isDownShow = true;
|
UIManager.Instance.OpenWindow<SmallTipWin>();
|
});
|
|
leftBtn.AddListener(() =>
|
{
|
var index = BeautyMMManager.Instance.beautyMMIDSortList.IndexOf(mmID);
|
if (index > 0)
|
{
|
mmID = BeautyMMManager.Instance.beautyMMIDSortList[index - 1];
|
}
|
else
|
{
|
mmID = BeautyMMManager.Instance.beautyMMIDSortList[BeautyMMManager.Instance.beautyMMIDSortList.Count - 1];
|
}
|
Display();
|
});
|
rightBtn.AddListener(() =>
|
{
|
var index = BeautyMMManager.Instance.beautyMMIDSortList.IndexOf(mmID);
|
if (index < BeautyMMManager.Instance.beautyMMIDSortList.Count - 1)
|
{
|
mmID = BeautyMMManager.Instance.beautyMMIDSortList[index + 1];
|
}
|
else
|
{
|
mmID = BeautyMMManager.Instance.beautyMMIDSortList[0];
|
}
|
Display();
|
});
|
|
skinBtn.AddListener(() =>
|
{
|
UIManager.Instance.OpenWindow<BeautyMMSkinWin>(mmID);
|
});
|
|
seeAttrBtn.AddListener(() =>
|
{
|
UIManager.Instance.OpenWindow<BeautyMMTalentWin>(mmID);
|
});
|
|
activeBtn.AddListener(ActiveMM);
|
giftBtn.AddListener(SendGift);
|
|
for (int i = 0; i < awardBtns.Length; i++)
|
{
|
awardBtns[i].AddListener(() =>
|
{
|
var pack = new CA504_tagCMPlayerGetReward();
|
pack.RewardType = 6;
|
pack.DataEx = (uint)mmID;
|
GameNetSystem.Instance.SendInfo(pack);
|
});
|
}
|
}
|
|
|
protected override void OnPreOpen()
|
{
|
mmID = functionOrder;
|
loveScroller.OnRefreshCell += OnRefreshCell;
|
BeautyMMManager.Instance.OnBeautyMMDataUpdate += OnBeautyMMDataUpdate;
|
PackManager.Instance.RefreshItemEvent += OnRefreshItemEvent;
|
|
Display(true);
|
}
|
|
|
protected override void OnPreClose()
|
{
|
loveScroller.OnRefreshCell -= OnRefreshCell;
|
BeautyMMManager.Instance.OnBeautyMMDataUpdate -= OnBeautyMMDataUpdate;
|
PackManager.Instance.RefreshItemEvent -= OnRefreshItemEvent;
|
}
|
|
void OnBeautyMMDataUpdate()
|
{
|
var mmData = BeautyMMManager.Instance.GetBeautyMMData(mmID);
|
var nowRank = mmData != null ? mmData.LV / BeautyMMManager.Instance.needLVForTalent : 0;
|
if (beforeRank != nowRank)
|
{
|
UIManager.Instance.OpenWindow<BeautyMMUpgradeWin>(mmID);
|
}
|
Display();
|
}
|
|
void OnRefreshItemEvent(PackType packType, int index, int itemID)
|
{
|
if (packType == PackType.Item)
|
{
|
if (itemlist.Contains(itemID))
|
{
|
loveScroller.m_Scorller.RefreshActiveCellViews();
|
}
|
}
|
}
|
|
void Display(bool isOpen = false)
|
{
|
mmConfig = BeautyConfig.Get(mmID);
|
qualityImg.SetSprite($"mmMark{mmConfig.BeautyQuality}");
|
string qualityStr = Language.Get($"CommonQuality{mmConfig.BeautyQuality}");
|
qualityText1.text = qualityStr[0].ToString();
|
qualityText2.text = qualityStr.Substring(1);
|
nameText.text = mmConfig.Name;
|
var skinID = BeautyMMManager.Instance.GetUsedSkinID(mmID);
|
var skinConfig = BeautySkinConfig.Get(skinID);
|
roleImg.SetOrgSprite(skinConfig.BigRole, "BeautyMMBigRole");
|
roleImg.SetNativeSize();
|
|
var isActive = BeautyMMManager.Instance.isActiveMM(mmID);
|
trainRect.SetActive(isActive);
|
activeRect.SetActive(!isActive);
|
activeTipText.text = !isActive ? GetActiveTip(mmConfig) : "";
|
|
var mmData = BeautyMMManager.Instance.GetBeautyMMData(mmID);
|
beforeRank = mmData != null ? mmData.LV / BeautyMMManager.Instance.needLVForTalent : 0;
|
lvNameText.text = Language.Get($"BeautyMMLVName{beforeRank + 1}");
|
lvText.text = mmData != null ? mmData.LV.ToString() : "0";
|
|
|
var maxLV = BeautyQualityLVConfig.GetBeautyQualityMaxLV(mmConfig.BeautyQuality);
|
bool isMaxLV = mmData != null && mmData.LV >= maxLV;
|
int needExp;
|
if (isMaxLV)
|
{
|
needExp = 0;
|
process.fillAmount = 1;
|
showAwardCell.SetActive(false);
|
nextAddAttrText.text = Language.Get("L1055");
|
nextLVTalentTipRect.SetActive(false);
|
fullRect.SetActive(true);
|
giftOPRect.SetActive(false);
|
}
|
else
|
{
|
int curLV = mmData != null ? mmData.LV : 0;
|
BeautyQualityLVConfig nextLVConfig;
|
BeautyQualityLVConfig.TryGetBeautyQualityLVConfig(mmConfig.BeautyQuality, curLV + 1, out nextLVConfig);
|
|
needExp = nextLVConfig.LVNeedExp;
|
expText.text = (mmData != null ? mmData.Exp.ToString() : "0") + "/" + needExp;
|
process.fillAmount = mmData != null ? mmData.Exp * 1.0f / needExp : 0;
|
showAwardCell.SetActive(true);
|
int itemID = nextLVConfig.AwardItemList[0][0];
|
showAwardCell.Init(new ItemCellModel(itemID, false, nextLVConfig.AwardItemList[0][1]));
|
showAwardCell.button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
|
var awardCnt = mmData != null ? mmData.LV - mmData.AwardLV : 0;
|
for (int i = 0; i < awardBtns.Length; i++)
|
{
|
if (mmData != null && i < awardCnt)
|
{
|
awardBtns[i].SetActive(true);
|
awardImgs[i].SetSprite(ItemConfig.Get(itemID).IconKey);
|
}
|
else
|
{
|
awardBtns[i].SetActive(false);
|
}
|
}
|
string format = "{0}" + UIHelper.AppendColor(TextColType.Green, "+{1}");
|
nextAddAttrText.text = Language.Get("BeautyMM23") + PlayerPropertyConfig.GetFullDescription(nextLVConfig.AttrIDList[0], nextLVConfig.AttrValueList[0], format);
|
|
ShowTalent();
|
nextLVTalentTipRect.SetActive(isActive);
|
nextLVTalentTip.text = Language.Get("BeautyMM26", (beforeRank + 1) * BeautyMMManager.Instance.needLVForTalent);
|
giftOPRect.SetActive(true);
|
fullRect.SetActive(false);
|
}
|
|
itemlist = BeautyMMManager.Instance.loveItemIDs.ToList();
|
if (isOpen)
|
{
|
BeautyMMManager.Instance.selectLoveItemID = itemlist[0];
|
}
|
CreateScroller();
|
skinRedImg.SetActive(BeautyMMManager.Instance.IsMMSkinRed(mmID));
|
}
|
|
|
|
// 解锁方式 方式值 所需数
|
// 1.物品解锁 碎片物品ID 数量
|
// 2.完成主线任务ID 任务ID
|
// 3.演武场胜利次数 无 次数
|
// 4.拥有监工数量 无 数量
|
// 5.白骨盈野过关 funcLineID
|
// 6.官职达到 官职ID
|
// 7.游历次数 无 次数
|
|
string GetActiveTip(BeautyConfig beauty)
|
{
|
TextColType colorType = TextColType.Red;
|
switch (beauty.UnlockWay)
|
{
|
case 1:
|
var cnt = PackManager.Instance.GetItemCountByID(PackType.Item, beauty.UnlockValue);
|
colorType = cnt >= beauty.UnlockNeedCnt ? TextColType.Green : TextColType.Red;
|
return UIHelper.AppendColor(colorType, Language.Get("BeautyMMUnLockTip1", ItemConfig.Get(beauty.UnlockValue).IconKey, cnt, beauty.UnlockNeedCnt));
|
case 2:
|
colorType = TaskConfig.Get(TaskManager.Instance.mainTask.TaskID).Index > TaskConfig.Get(beauty.UnlockValue).Index ? TextColType.Green : TextColType.Red;
|
return Language.Get("BeautyMMUnLockTip2", TaskConfig.Get(beauty.UnlockValue).Index) +
|
UIHelper.AppendColor(colorType, Language.Get("HeroFates11", TaskConfig.Get(TaskManager.Instance.mainTask.TaskID).Index, TaskConfig.Get(beauty.UnlockValue).Index));
|
case 3:
|
colorType = ArenaManager.Instance.totalWinCnt >= beauty.UnlockNeedCnt ? TextColType.Green : TextColType.Red;
|
return Language.Get("BeautyMMUnLockTip3", beauty.UnlockNeedCnt) +
|
UIHelper.AppendColor(colorType, Language.Get("HeroFates11", ArenaManager.Instance.totalWinCnt, beauty.UnlockNeedCnt));
|
case 4:
|
colorType = GoldRushManager.Instance.maxWorkerCount >= beauty.UnlockNeedCnt ? TextColType.Green : TextColType.Red;
|
return Language.Get("BeautyMMUnLockTip4", beauty.UnlockNeedCnt) +
|
UIHelper.AppendColor(colorType, Language.Get("HeroFates11", GoldRushManager.Instance.maxWorkerCount, beauty.UnlockNeedCnt));
|
case 5:
|
int dataMapID = BoneFieldManager.Instance.DataMapID;
|
if (DungeonManager.Instance.TryGetFBInfoByMapID(dataMapID, out var fbInfo))
|
{
|
colorType = fbInfo.PassLineID > beauty.UnlockValue ? TextColType.Green : TextColType.Red;
|
return Language.Get("BeautyMMUnLockTip5", beauty.UnlockValue) +
|
UIHelper.AppendColor(colorType, Language.Get("HeroFates11", fbInfo.PassLineID, beauty.UnlockValue));
|
}
|
return "";
|
case 6:
|
colorType = PlayerDatas.Instance.baseData.realmLevel >= beauty.UnlockValue ? TextColType.Green : TextColType.Red;
|
var config = RealmConfig.Get(beauty.UnlockValue);
|
return Language.Get("BeautyMMUnLockTip6", config.Name) +
|
UIHelper.AppendColor(colorType, Language.Get("HeroFates11", PlayerDatas.Instance.baseData.realmLevel, beauty.UnlockValue));
|
case 7:
|
colorType = BeautyMMManager.Instance.m_TravelCnt >= beauty.UnlockNeedCnt ? TextColType.Green : TextColType.Red;
|
return Language.Get("BeautyMMUnLockTip7", beauty.UnlockNeedCnt) +
|
UIHelper.AppendColor(colorType, Language.Get("HeroFates11", BeautyMMManager.Instance.m_TravelCnt, beauty.UnlockNeedCnt));
|
}
|
return "";
|
}
|
|
|
void ShowTalent()
|
{
|
//先显示天赋属性,再显示天赋特性
|
var attrs = BeautyMMManager.Instance.GetMMTalentAttrForUI(mmID, true);
|
int talentIndex = 0;
|
if (attrs.IsNullOrEmpty())
|
{
|
talentIndex = 0;
|
}
|
else
|
{
|
foreach (var attr in attrs)
|
{
|
if (talentIndex < talentTexts.Length)
|
{
|
talentTexts[talentIndex].SetActive(true);
|
string format = "{0}" + UIHelper.AppendColor(TextColType.Green, "+{1}");
|
talentTexts[talentIndex].text = PlayerPropertyConfig.GetFullDescription(attr.Key, attr.Value, format);
|
}
|
else
|
{
|
break;
|
}
|
talentIndex++;
|
}
|
}
|
|
|
var talentValue = BeautyMMManager.Instance.GetMMTalentEffectForUI(mmID);
|
for (int i = talentIndex; i < talentTexts.Length; i++)
|
{
|
if (i == talentIndex && mmConfig.EffType != 0)
|
{
|
//天赋效果约定最多一个
|
talentTexts[talentIndex].SetActive(true);
|
switch (mmConfig.EffType)
|
{
|
case 1:
|
talentTexts[i].text = Language.Get($"BeautyMMTalent1", talentValue);
|
break;
|
case 2:
|
talentTexts[i].text = Language.Get($"BeautyMMTalent2", talentValue / 100, ItemConfig.Get(mmConfig.EffTypeValue).ItemName);
|
break;
|
case 3:
|
talentTexts[i].text = Language.Get($"BeautyMMTalent3", talentValue);
|
break;
|
case 4:
|
talentTexts[i].text = Language.Get($"BeautyMMTalent4", ItemConfig.Get(mmConfig.EffTypeValue).ItemName, talentValue);
|
break;
|
}
|
}
|
else
|
{
|
talentTexts[i].SetActive(false);
|
}
|
}
|
}
|
|
void ActiveMM()
|
{
|
var state = BeautyMMManager.Instance.GetMMBaseState(mmConfig);
|
if (state <= 1)
|
{
|
if (mmConfig.UnlockWay == 1)
|
{
|
ItemTipUtility.Show(mmConfig.UnlockValue);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("BeautyMM1");
|
}
|
return;
|
}
|
var pack = new CB219_tagCSBeautyActivate();
|
pack.BeautyID = (ushort)mmID;
|
GameNetSystem.Instance.SendInfo(pack);
|
}
|
|
|
void CreateScroller()
|
{
|
loveScroller.Refresh();
|
|
if (mmConfig.ExclusiveItemID > 0)
|
{
|
itemlist.Add(mmConfig.ExclusiveItemID); //专属信物
|
}
|
|
for (int i = 0; i < itemlist.Count; i++)
|
{
|
loveScroller.AddCell(ScrollerDataType.Header, itemlist[i]);
|
}
|
loveScroller.Restart();
|
}
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetComponent<ItemCell>();
|
int itemID = cell.index;
|
var cnt = PackManager.Instance.GetItemCountByID(PackType.Item, itemID);
|
_cell.Init(new ItemCellModel(itemID, false, cnt));
|
_cell.button.AddListener(() =>
|
{
|
if (BeautyMMManager.Instance.selectLoveItemID != itemID)
|
{
|
BeautyMMManager.Instance.selectLoveItemID = itemID;
|
loveScroller.m_Scorller.RefreshActiveCellViews();
|
}
|
else
|
{
|
ItemTipUtility.Show(itemID);
|
}
|
});
|
|
if (BeautyMMManager.Instance.selectLoveItemID == itemID)
|
{
|
_cell.FindComponent("Image", "selectImage").SetActive(true);
|
}
|
else
|
{
|
_cell.FindComponent("Image", "selectImage").SetActive(false);
|
}
|
|
_cell.FindComponent("Image", "mask").SetActive(cnt == 0);
|
}
|
|
void SendGift()
|
{
|
var cnt = PackManager.Instance.GetItemCountByID(PackType.Item, BeautyMMManager.Instance.selectLoveItemID);
|
if (cnt == 0)
|
{
|
ItemTipUtility.Show(BeautyMMManager.Instance.selectLoveItemID, true);
|
TimingGiftManager.Instance.TryAddWhenInsufficient(5, PackType.Item, BeautyMMManager.Instance.selectLoveItemID, 1);
|
return;
|
}
|
//使用到可升级的数量,或者总数
|
var mmData = BeautyMMManager.Instance.GetBeautyMMData(mmID);
|
var maxLV = BeautyQualityLVConfig.GetBeautyQualityMaxLV(mmConfig.BeautyQuality);
|
bool isMaxLV = mmData != null && mmData.LV >= maxLV;
|
if (isMaxLV)
|
{
|
return;
|
}
|
else
|
{
|
int curLV = mmData != null ? mmData.LV : 0;
|
BeautyQualityLVConfig nextLVConfig;
|
BeautyQualityLVConfig.TryGetBeautyQualityLVConfig(mmConfig.BeautyQuality, curLV + 1, out nextLVConfig);
|
|
int needExp = nextLVConfig.LVNeedExp - mmData.Exp;
|
int value = BeautyMMManager.Instance.giftIDToLoveDict.ContainsKey(BeautyMMManager.Instance.selectLoveItemID) ?
|
BeautyMMManager.Instance.giftIDToLoveDict[BeautyMMManager.Instance.selectLoveItemID] : BeautyMMManager.Instance.specialGiftLove;
|
|
int useCnt = (int)Mathf.Min(Mathf.CeilToInt(needExp * 1.0f / value), cnt);
|
var pack = new CB220_tagCSBeautyLVUP();
|
pack.BeautyID = (ushort)mmID;
|
pack.ItemID = (uint)BeautyMMManager.Instance.selectLoveItemID;
|
pack.IsQuick = (byte)(onekeyToggle.isOn ? 1 : 0);
|
GameNetSystem.Instance.SendInfo(pack);
|
roleUPEffect.Play();
|
SysNotifyMgr.Instance.ShowTip("BeautyMM2", mmConfig.Name, useCnt * value);
|
|
// 如果正好消耗完,不触发固定概率的判定
|
if (!TimingGiftManager.Instance.TryAddWhenExactConsumption(5, PackType.Item, BeautyMMManager.Instance.selectLoveItemID, onekeyToggle.isOn ? useCnt : 1))
|
{
|
TimingGiftManager.Instance.TryAddWithFixedProbabilityWhenSufficient(5, PackType.Item, BeautyMMManager.Instance.selectLoveItemID, onekeyToggle.isOn ? useCnt : 1);
|
}
|
}
|
|
|
}
|
|
}
|