using System.Collections.Generic;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class FairySiegeSummonDragonWin : Window
|
{
|
[SerializeField] ButtonEx btnAutoAtk; //自动攻击上次目标
|
[SerializeField] ButtonEx btnFlzt; //飞龙在天
|
[SerializeField] ButtonEx btnLtwj; //雷霆万钧
|
[SerializeField] ButtonEx btnReward; //查看奖励
|
[SerializeField] ButtonEx btnWatch; //观看他人动画
|
[SerializeField] ImageEx imgAutoAtk;
|
[SerializeField] ImageEx imgFlztItem; //使用技能的物品
|
[SerializeField] ImageEx imgLtwjItem; //使用技能的物品
|
[SerializeField] ImageEx imgWatch;
|
[SerializeField] TextEx txtAutoAtk;
|
[SerializeField] TextEx txtFlztCnt;
|
[SerializeField] RichText txtFlztInfo;
|
[SerializeField] TextEx txtLtwjCnt;
|
[SerializeField] RichText txtLtwjInfo;
|
[SerializeField] RedpointBehaviour rpFlzt;
|
[SerializeField] RedpointBehaviour rpLtwj;
|
|
FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
#region Build-in
|
|
protected override void AddListeners()
|
{
|
btnReward.SetListener(() => WindowCenter.Instance.Open<FairySiegeSummonDragonAwardWin>());
|
btnFlzt.SetListener(FlztClick);
|
btnLtwj.SetListener(LtwjClick);
|
btnWatch.SetListener(WatchClick);
|
btnAutoAtk.SetListener(AutoAtkClick);
|
}
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
rpFlzt.redpointId = model.GetRedpointId(FairySiegeRedPointType.SummonDragonFLZT);
|
rpLtwj.redpointId = model.GetRedpointId(FairySiegeRedPointType.SummonDragonLTWJ);
|
packModel.refreshItemCountEvent += OnRefreshItemCountEvent;
|
Display();
|
}
|
|
protected override void OnPreClose()
|
{
|
packModel.refreshItemCountEvent -= OnRefreshItemCountEvent;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
#endregion
|
|
private void OnRefreshItemCountEvent(PackType type, int arg2, int arg3)
|
{
|
if (type != PackType.Item || model.flztSkillItemId != arg3 || model.ltwjSkillItemId != arg3!)
|
return;
|
Display();
|
}
|
|
private void Display()
|
{
|
imgAutoAtk.SetActive(model.isSummonDragonAutoAtk);
|
imgWatch.SetActive(model.isSummonDragonWatch);
|
|
var itemId = model.flztSkillItemId;
|
var iconKey = ItemConfig.Get(itemId).IconKey;
|
imgFlztItem.SetSprite(iconKey);
|
var hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
|
var needCnt = model.flztSkillNeedCnt;
|
txtFlztCnt.text = StringUtility.Contact(hasCnt, "/", needCnt);
|
txtFlztCnt.color = UIHelper.GetUIColor(hasCnt >= needCnt ? TextColType.Green : TextColType.Red);
|
var fightPoint = UIHelper.ReplaceLargeNum(PlayerDatas.Instance.baseData.FightPoint * (ulong)model.flztSkillRate);
|
var formula = Language.Get("FairySiege035", model.flztSkillRate);
|
txtFlztInfo.text = StringUtility.Contact(Language.Get("FairySiege152", model.flztSkillAtkCityCnt, fightPoint), "</r>", formula);
|
|
itemId = model.ltwjSkillItemId;
|
iconKey = ItemConfig.Get(itemId).IconKey;
|
imgLtwjItem.SetSprite(iconKey);
|
hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
|
needCnt = model.ltwjSkillNeedCnt;
|
txtLtwjCnt.text = StringUtility.Contact(hasCnt, "/", needCnt);
|
txtLtwjCnt.color = UIHelper.GetUIColor(hasCnt >= needCnt ? TextColType.Green : TextColType.Red);
|
fightPoint = UIHelper.ReplaceLargeNum(PlayerDatas.Instance.baseData.FightPoint * (ulong)model.ltwjSkillRate);
|
formula = Language.Get("FairySiege035", model.ltwjSkillRate);
|
txtLtwjInfo.text = StringUtility.Contact(Language.Get("FairySiege152", model.ltwjSkillAtkCityCnt, fightPoint), "</r>", formula);
|
if (model.isSummonDragonLastAtkFamilyId == model.BossCityId)
|
{
|
txtAutoAtk.text = Language.Get("FairySiege036", Language.Get("FairySiege150"));
|
}
|
else
|
{
|
txtAutoAtk.text = model.isSummonDragonLastAtkFamilyId > 0 && model.TryGetFairySiegeFamilyInfo((uint)model.isSummonDragonLastAtkFamilyId, out var fairySiegeFamilyInfo) ? Language.Get("FairySiege036", fairySiegeFamilyInfo.Name) : Language.Get("FairySiege110");
|
}
|
}
|
|
private void FlztClick()
|
{
|
var itemId = model.flztSkillItemId;
|
var hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
|
var needCnt = model.flztSkillNeedCnt;
|
|
// 所需物品数量不足
|
if (hasCnt < needCnt)
|
{
|
SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_3");
|
return;
|
}
|
//仅能攻击自己所在分组城池
|
if (!model.TryGetNowBatTypeAndGroup(model.myFamilyID, out int myBattleType, out int myBattleGroup))
|
return;
|
if (model.showBatType != myBattleType || model.showBatGroup != myBattleGroup)
|
{
|
SysNotifyMgr.Instance.ShowTip("FairySiege20");
|
return;
|
}
|
|
//没勾选自动攻击上次目标
|
if (!model.isSummonDragonAutoAtk)
|
{
|
OpenSummonDragonChooseWin();
|
return;
|
}
|
|
//修罗城
|
if (model.TryGetBossCityData(model.showBatType, model.showBatGroup, out FairySiegeBatSceneCity bossCityData))
|
{
|
if (model.isSummonDragonLastAtkFamilyId == model.BossCityId)
|
{
|
model.SendAtk(2, (uint)model.isSummonDragonLastAtkFamilyId, 0);
|
CloseClick();
|
return;
|
}
|
}
|
|
//本地记录的仙盟Id不是当前组的
|
if (!model.IsFamilyIdInCurrentMatchRound((uint)model.isSummonDragonLastAtkFamilyId))
|
{
|
model.isSummonDragonLastAtkFamilyId = 0;
|
OpenSummonDragonChooseWin();
|
return;
|
}
|
|
//本地记录的仙盟Id城池已被击毁
|
if (!model.TryGetBatSceneCityInfo(model.showBatType, model.showBatGroup, (uint)model.isSummonDragonLastAtkFamilyId, out FairySiegeBatSceneCity batSceneCity) ||
|
batSceneCity == null || batSceneCity.HP <= 0
|
)
|
{
|
model.isSummonDragonLastAtkFamilyId = 0;
|
OpenSummonDragonChooseWin();
|
SysNotifyMgr.Instance.ShowTip("FairySiege08");
|
return;
|
}
|
|
model.SendAtk(2, (uint)model.isSummonDragonLastAtkFamilyId, 0);
|
CloseClick();
|
}
|
|
//打开选择攻击名单界面
|
private void OpenSummonDragonChooseWin()
|
{
|
WindowCenter.Instance.Open<FairySiegeSummonDragonChooseWin>();
|
WindowCenter.Instance.Close<FairySiegeSummonDragonWin>();
|
}
|
|
public bool IsCityAllDead()
|
{
|
if (model.TryGetBossCityData(model.showBatType, model.showBatGroup, out FairySiegeBatSceneCity bossCityData))
|
return false;
|
if (model.TryGetRegularCityDataList(model.showBatType, model.showBatGroup, out List<FairySiegeBatSceneCity> regularCityDataList))
|
{
|
// 0 未摧毁-默认状态 1 未摧毁-被攻击 2 已被摧毁
|
foreach (var item in regularCityDataList)
|
{
|
if (item.CityID == model.myFamilyID)
|
continue;
|
if (item.HP > 0)
|
return false;
|
}
|
}
|
return true;
|
}
|
|
private void LtwjClick()
|
{
|
var itemId = model.ltwjSkillItemId;
|
var hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
|
var needCnt = model.ltwjSkillNeedCnt;
|
// 所需物品数量不足
|
if (hasCnt < needCnt)
|
{
|
SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_3");
|
return;
|
}
|
//所有城池都被击毁
|
if (IsCityAllDead())
|
{
|
SysNotifyMgr.Instance.ShowTip("FairySiege19");
|
return;
|
}
|
//仅能攻击自己所在分组城池
|
if (!model.TryGetNowBatTypeAndGroup(model.myFamilyID, out int myBattleType, out int myBattleGroup))
|
return;
|
if (model.showBatType != myBattleType || model.showBatGroup != myBattleGroup)
|
{
|
SysNotifyMgr.Instance.ShowTip("FairySiege20");
|
return;
|
}
|
|
model.SendAtk(3, 0, 0);
|
CloseClick();
|
}
|
|
private void WatchClick()
|
{
|
model.isSummonDragonWatch = !model.isSummonDragonWatch;
|
imgWatch.SetActive(model.isSummonDragonWatch);
|
}
|
|
private void AutoAtkClick()
|
{
|
model.isSummonDragonAutoAtk = !model.isSummonDragonAutoAtk;
|
imgAutoAtk.SetActive(model.isSummonDragonAutoAtk);
|
}
|
}
|
}
|