//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Friday, January 18, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
namespace vnxbqy.UI
|
{
|
|
public class SkyTowerWin : Window
|
{
|
[SerializeField] SkyTowerBehaviour m_TowerBehaviour;
|
|
[SerializeField] Button m_ViewBoss;
|
[SerializeField] UIEffect m_ViewBossEffect;
|
[SerializeField] Button m_ViewReward;
|
[SerializeField] UIEffect m_ViewRewardEffect;
|
|
[SerializeField] RectTransform m_BossContainer;
|
[SerializeField] PositionTween m_BossShowTween;
|
[SerializeField] Image m_BossRealm;
|
[SerializeField] Text m_BossName;
|
[SerializeField] Text m_BossLevel;
|
[SerializeField] RawImage m_BossPortrait;
|
[SerializeField] UIEffect m_BossEffect;
|
|
[SerializeField] RectTransform m_RewardContainer;
|
[SerializeField] PositionTween m_RewardShowTween;
|
[SerializeField] SkyTowerRewardPreviewGroup m_RewardBehaviour;
|
|
[SerializeField] RectTransform m_LevelContaienr;
|
[SerializeField] TextEx m_LevelLimit;
|
[SerializeField] RectTransform m_FightPowerContainer;
|
[SerializeField] TextEx m_FightPower;
|
|
[SerializeField] Button m_Challenge;
|
[SerializeField] TextEx m_ChallengeTitle;
|
[SerializeField] ImageEx m_ChallengeImage;
|
|
[SerializeField] Button m_Rank;
|
[SerializeField] Button m_Gift;
|
[SerializeField] Button m_NewSuccess;
|
|
SkyTowerModel model { get { return ModelCenter.Instance.GetModel<SkyTowerModel>(); } }
|
RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
|
|
ShowType showType = ShowType.None;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Challenge.SetListener(Challenge);
|
m_ViewBoss.SetListener(() => { DisplayBossInfo(false); });
|
m_ViewReward.SetListener(() => { DisplayRewardInfo(false); });
|
m_Rank.SetListener(() => {
|
rankModel.jumpRankType = 6;
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.GameRank);
|
});
|
|
m_Gift.SetListener(() => {
|
WindowJumpMgr.Instance.WindowJumpToEx("SkyTowerServerGift", 1, 0, model.GetChallengeAwardOrder());
|
});
|
|
m_NewSuccess.SetListener(() => {
|
ILAchievementModel.Instance.SetJumpSuccessGroup(201);
|
WindowJumpMgr.Instance.WindowJumpToEx("NewAchievementActivityWin");
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
showType = ShowType.None;
|
model.ConfirmRedpoint02();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
DisplayTowerInfo();
|
DisplayChallengeButton();
|
DisplayRewardInfo(false);
|
}
|
|
#endregion
|
|
private void DisplayTowerInfo()
|
{
|
m_TowerBehaviour.Display();
|
}
|
|
private void DisplayBossInfo(bool immediately)
|
{
|
if (showType == ShowType.Boss)
|
{
|
return;
|
}
|
|
showType = ShowType.Boss;
|
|
m_BossContainer.SetActive(true);
|
m_RewardContainer.SetActive(false);
|
|
m_ViewBoss.transform.localScale = Vector3.one;
|
m_ViewReward.transform.localScale = Vector3.one * 0.8f;
|
|
m_ViewBossEffect.Play();
|
m_ViewRewardEffect.Stop();
|
m_BossEffect.Play();
|
|
var towerConfig = SkyTowerConfig.Get(model.currentFloor);
|
var npcConfig = NPCConfig.Get(towerConfig.bossId);
|
|
if (npcConfig.Realm > 0 && RealmConfig.Has(npcConfig.Realm))
|
{
|
m_BossRealm.SetActive(true);
|
var realmConfig = RealmConfig.Get(npcConfig.Realm);
|
m_BossRealm.SetSprite(realmConfig.Img);
|
}
|
else
|
{
|
m_BossRealm.SetActive(false);
|
}
|
|
m_BossName.text = npcConfig.charName;
|
m_BossLevel.text = Language.Get("HeadUpName_Monster", npcConfig.NPCLV);
|
UI3DModelExhibition.Instance.ShowNPC(towerConfig.bossId, new Vector3(0, 30, 0), m_BossPortrait);
|
|
if (immediately)
|
{
|
m_BossShowTween.SetEndState();
|
}
|
else
|
{
|
m_BossShowTween.Play();
|
}
|
}
|
|
private void DisplayRewardInfo(bool immediately)
|
{
|
if (showType == ShowType.Reward)
|
{
|
return;
|
}
|
|
showType = ShowType.Reward;
|
|
m_BossContainer.SetActive(false);
|
m_RewardContainer.SetActive(true);
|
|
m_ViewBoss.transform.localScale = Vector3.one * 0.8f;
|
m_ViewReward.transform.localScale = Vector3.one;
|
|
m_ViewBossEffect.Stop();
|
m_ViewRewardEffect.Play();
|
m_BossEffect.Stop();
|
|
var config = SkyTowerConfig.Get(model.currentFloor);
|
m_RewardBehaviour.Display(config.rewards);
|
|
if (PlayerDatas.Instance.baseData.LV < config.levelLimit)
|
{
|
m_LevelContaienr.SetActive(true);
|
m_LevelLimit.text = config.levelLimit.ToString();
|
m_LevelLimit.colorType = PlayerDatas.Instance.baseData.LV >= config.levelLimit ? TextColType.Green : TextColType.Red;
|
}
|
else
|
{
|
m_LevelContaienr.SetActive(false);
|
}
|
|
if (PlayerDatas.Instance.baseData.LV >= config.levelLimit)
|
{
|
m_FightPowerContainer.SetActive(true);
|
var fightPower = NPCExConfig.Get(config.bossId).SuppressFightPower;
|
m_FightPower.text = fightPower.ToString();
|
m_FightPower.colorType = PlayerDatas.Instance.baseData.FightPoint >= (ulong)fightPower ? TextColType.Green : TextColType.Red;
|
}
|
else
|
{
|
m_FightPowerContainer.SetActive(false);
|
}
|
|
if (immediately)
|
{
|
m_RewardShowTween.SetEndState();
|
}
|
else
|
{
|
m_RewardShowTween.Play();
|
}
|
}
|
|
private void DisplayChallengeButton()
|
{
|
m_ChallengeTitle.text = Language.Get(model.allPassed ? "SkyTower4" : "Multiple_Challenge");
|
m_ChallengeImage.gray = !model.IsChallengable();
|
}
|
|
private void Challenge()
|
{
|
model.ConfirmRedpoint03();
|
if (model.allPassed)
|
{
|
return;
|
}
|
|
var config = SkyTowerConfig.Get(model.currentFloor);
|
var myFightPoint = PlayerDatas.Instance.baseData.FightPoint;
|
if (myFightPoint >= (ulong)NPCExConfig.Get(config.bossId).SuppressFightPower)
|
{
|
model.RequestChallenge();
|
}
|
else
|
{
|
ConfirmCancel.ShowPopConfirm(
|
Language.Get("Mail101"),
|
Language.Get("RuneTower25", NPCExConfig.Get(config.bossId).SuppressFightPower),
|
(bool ok) =>
|
{
|
if (ok)
|
{
|
model.RequestChallenge();
|
}
|
}
|
);
|
}
|
}
|
|
public enum ShowType
|
{
|
None,
|
Boss,
|
Reward,
|
}
|
|
}
|
|
}
|
|
|
|
|