//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, September 20, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
|
namespace Snxxz.UI
|
{
|
public class TrialDungeonEntranceWin : Window
|
{
|
[SerializeField]
|
Text m_Title;
|
[SerializeField]
|
Text m_LevelLimit;
|
[SerializeField]
|
Text m_GradeLimit;
|
[SerializeField]
|
Text m_ChallengeTimes;
|
[SerializeField]
|
Text m_DropItemTxt;
|
|
[SerializeField]
|
Button m_GroupStart;
|
[SerializeField]
|
Button m_SingleStart;
|
[SerializeField]
|
Button m_AutoGroupStart;
|
[SerializeField]
|
Button m_CloseWin;
|
|
[SerializeField]
|
RawImage m_BossPortrayal;
|
|
[SerializeField] Image m_BossRealm;
|
[SerializeField] Text m_BossName;
|
|
[SerializeField] RectTransform m_ContainerGroup;
|
[SerializeField] Button m_Group;
|
|
[SerializeField] TrialRewardsBehaviour[] m_RewardBehaviours;
|
[SerializeField] ScrollRect m_RewardScroller;
|
|
DungeonModel m_Model;
|
DungeonModel model {
|
get {
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>());
|
}
|
}
|
|
TeamModel m_TeamModel;
|
TeamModel teamModel {
|
get {
|
return m_TeamModel ?? (m_TeamModel = ModelCenter.Instance.GetModel<TeamModel>());
|
}
|
}
|
|
DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
|
TrialDungeonModel trialDungeonModel { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_GroupStart.AddListener(ChallengeDungeonGroup);
|
m_SingleStart.AddListener(ChallengeDungeon);
|
m_AutoGroupStart.AddListener(AutoGroupChallenge);
|
m_CloseWin.AddListener(CloseClick);
|
m_Group.AddListener(OpenGroup);
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.dungeonRecordChangeEvent += UpdateDungeonTimes;
|
|
m_GroupStart.image.material = CheckChallenge() ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial();
|
m_SingleStart.image.material = CheckChallenge() ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial();
|
m_AutoGroupStart.image.material = CheckChallenge() ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial();
|
m_Group.image.material = CheckChallenge() ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial();
|
m_ContainerGroup.gameObject.SetActive(false);
|
|
DrawDungeonBaseInfo();
|
DrawRewards();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
model.dungeonRecordChangeEvent -= UpdateDungeonTimes;
|
UI3DModelExhibition.Instance.StopShow();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
private void OpenGroup()
|
{
|
if (!CheckChallenge())
|
{
|
return;
|
}
|
var openGroup = m_ContainerGroup.gameObject.activeSelf;
|
m_ContainerGroup.gameObject.SetActive(!openGroup);
|
}
|
|
private void DrawDungeonBaseInfo()
|
{
|
var dungeonId = model.GetDungeonId(model.selectedTrialDungeon);
|
var dungeonConfig = Config.Instance.Get<DungeonConfig>(dungeonId);
|
m_Title.text = dungeonConfig.FBName;
|
m_DropItemTxt.text = Language.Get(StringUtility.Contact("TrialDungeon_Drop", dungeonConfig.LineID));
|
|
var dungeonOpenTimeConfig = Config.Instance.Get<DungeonOpenTimeConfig>(model.selectedTrialDungeon.mapId);
|
var fbType = dungeonOpenTimeConfig.FBType;
|
m_GroupStart.gameObject.SetActive(fbType == 2 || fbType == 3);
|
m_SingleStart.gameObject.SetActive(fbType == 1 || fbType == 2);
|
m_AutoGroupStart.gameObject.SetActive(fbType == 2 || fbType == 3);
|
m_Group.gameObject.SetActive(fbType == 2 || fbType == 3);
|
|
var playerLevel = PlayerDatas.Instance.baseData.LV;
|
m_LevelLimit.gameObject.SetActive(playerLevel < dungeonConfig.LVLimitMin);
|
|
DungeonRecord dungeonRecord;
|
model.TryGetRecord(dungeonConfig.MapID, out dungeonRecord);
|
int star = 1;
|
if (dungeonConfig.LineID > 0)
|
{
|
dungeonRecord.lineGrades.TryGetValue(dungeonConfig.LineID - 1, out star);
|
}
|
else
|
{
|
star = 5;
|
}
|
|
m_GradeLimit.gameObject.SetActive(star < GeneralConfig.Instance.munekadolockLimit);
|
if (star < GeneralConfig.Instance.munekadolockLimit)
|
{
|
m_GradeLimit.text = Language.Get("TrialDungeonGradeLimit2", UIHelper.GetGrade(GeneralConfig.Instance.munekadolockLimit));
|
}
|
|
UpdateDungeonTimes(model.GetTrialMaps()[0]);
|
|
if (dungeonConfig.BossActorID != null && dungeonConfig.BossActorID.Length > 0)
|
{
|
DisplayBossInfo(dungeonConfig.BossActorID[0]);
|
}
|
else
|
{
|
m_BossName.gameObject.SetActive(false);
|
m_BossRealm.gameObject.SetActive(false);
|
}
|
}
|
|
void DisplayBossInfo(int _npcId)
|
{
|
m_BossName.gameObject.SetActive(true);
|
UI3DModelExhibition.Instance.ShowNPC(_npcId, Vector3.zero, m_BossPortrayal);
|
var npcConfig = Config.Instance.Get<NPCConfig>(_npcId);
|
if (npcConfig != null)
|
{
|
if (Config.Instance.ContainKey<RealmConfig>(npcConfig.ClientRealm))
|
{
|
m_BossRealm.gameObject.SetActive(true);
|
var realmConfig = Config.Instance.Get<RealmConfig>(npcConfig.ClientRealm);
|
if (realmConfig != null)
|
{
|
m_BossRealm.SetSprite(realmConfig.Img);
|
}
|
}
|
else
|
{
|
m_BossRealm.gameObject.SetActive(false);
|
}
|
|
m_BossName.text = npcConfig.charName;
|
}
|
}
|
|
private void UpdateDungeonTimes(int mapID)
|
{
|
int trialMapID = model.GetTrialMaps()[0];
|
if (trialMapID != mapID) return;
|
DungeonOpenTimeConfig dungeonOpenTimeModel = Config.Instance.Get<DungeonOpenTimeConfig>(trialMapID);
|
var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes((int)DailyQuestType.Trial);
|
var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes((int)DailyQuestType.Trial);
|
m_ChallengeTimes.text = Language.Get("TrialChallengeCnt", UIHelper.GetTextColorByItemColor(completedTimes >= totalTimes ?
|
TextColType.Red : TextColType.LightYellow, completedTimes.ToString(), true), totalTimes);
|
}
|
|
private void DrawRewards()
|
{
|
m_RewardScroller.verticalNormalizedPosition = 1;
|
var dongeonId = model.GetDungeonId(model.selectedTrialDungeon);
|
var config = Config.Instance.Get<DungeonConfig>(dongeonId);
|
for (int i = 0; i < m_RewardBehaviours.Length; i++)
|
{
|
var behaviour = m_RewardBehaviours[i];
|
Item[] rewards = null;
|
if (trialDungeonModel.TryGetTrialRewards(config.LineID, m_RewardBehaviours[i].grade, out rewards))
|
{
|
behaviour.gameObject.SetActive(true);
|
behaviour.Display(rewards);
|
}
|
else
|
{
|
behaviour.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void ChallengeDungeon()
|
{
|
if (!CheckChallenge()) return;
|
model.SingleChallenge(model.selectedTrialDungeon);
|
}
|
|
private void AutoGroupChallenge()
|
{
|
if (!CheckChallenge()) return;
|
teamModel.RequestAutoMatchTeam(new TeamMission(model.selectedTrialDungeon.mapId, model.selectedTrialDungeon.lineId));
|
WindowCenter.Instance.Open<TeamFrameWin>(false, 1);
|
}
|
|
private void ChallengeDungeonGroup()
|
{
|
if (!CheckChallenge()) return;
|
model.GroupChallenge(model.selectedTrialDungeon);
|
}
|
|
private bool CheckChallenge()
|
{
|
var dongeonId = model.GetDungeonId(model.selectedTrialDungeon);
|
var config = Config.Instance.Get<DungeonConfig>(dongeonId);
|
|
var playerLevel = PlayerDatas.Instance.baseData.LV;
|
if (playerLevel < config.LVLimitMin)
|
{
|
//MessageWin.Inst.ShowFixedTip(Language.Get("L1005"));
|
return false;
|
}
|
|
var jobRank = PlayerDatas.Instance.baseData.ExAttr1;
|
if (jobRank < config.JobRankLimit)
|
{
|
//MessageWin.Inst.ShowFixedTip("转职等级不足");
|
return false;
|
}
|
|
DungeonRecord dungeonRecord;
|
model.TryGetRecord(config.MapID, out dungeonRecord);
|
int star = 1;
|
if (config.LineID > 0)
|
{
|
dungeonRecord.lineGrades.TryGetValue(config.LineID - 1, out star);
|
}
|
else
|
{
|
star = 5;
|
}
|
if (star < GeneralConfig.Instance.munekadolockLimit)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
}
|
|
}
|
|
|
|
|