//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Friday, May 04, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI {
|
|
public class TreasureStageUpTriggerWin : Window
|
{
|
[SerializeField] RawImage m_RawScreenShot;
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
[SerializeField] RectTransform m_FlyContainer;
|
[SerializeField] RectTransform m_FurnacesFlyContainer;
|
[SerializeField] Vector2 m_SkillPosition;
|
[SerializeField] float m_FurnacesScale = 8f;
|
FunctionUnlockFlyObject flyObject;
|
|
public static Texture2D screenShotCut = null;
|
|
TreasureModel m_Model;
|
TreasureModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TreasureModel>());
|
}
|
}
|
|
Treasure m_Treasure;
|
|
bool flying = false;
|
float timer = 0f;
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
flying = false;
|
timer = 0f;
|
m_AlphaTween.SetStartState();
|
m_RawScreenShot.SetActive(screenShotCut != null);
|
if (screenShotCut != null)
|
{
|
m_RawScreenShot.texture = screenShotCut;
|
}
|
|
model.treasureStageUpShow = true;
|
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = MapConfig.Get(mapId);
|
if (mapConfig == null || mapConfig.MapFBType == 0)
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
MapTransferUtility.Instance.Clear();
|
PlayerDatas.Instance.hero.StopPathFind();
|
}
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
StartCoroutine(Co_DelayShow());
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
IEnumerator Co_DelayShow()
|
{
|
yield return null;
|
DoPrepare();
|
}
|
|
protected override void OnPreClose()
|
{
|
model.treasureStageUpShow = false;
|
if (screenShotCut != null)
|
{
|
CameraUtility.StopShotCut(screenShotCut);
|
screenShotCut = null;
|
}
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
if (flying)
|
{
|
timer += Time.deltaTime;
|
if (timer > 5f)
|
{
|
CloseImmediately();
|
}
|
}
|
}
|
#endregion
|
|
void DoPrepare()
|
{
|
model.TryGetTreasure(model.selectedTreasure, out m_Treasure);
|
|
var instance = UIUtility.CreateWidget("TreasureUnlockFlyObject_1", "TreasureUnlockFlyObject_1");
|
instance.transform.SetParentEx(m_FurnacesFlyContainer, Vector3.zero, Quaternion.identity, Vector3.one);
|
flyObject = instance.GetComponent<FunctionUnlockFlyObject>();
|
flyObject.SetContent(FunctionUnlockType.TreasureFunc, 301);
|
flyObject.transform.localScale = Vector3.one * m_FurnacesScale;
|
flyObject.SetScale(m_FurnacesScale);
|
|
if (screenShotCut != null)
|
{
|
m_AlphaTween.Play(OnAlphaComplete);
|
}
|
else
|
{
|
m_AlphaTween.SetEndState();
|
flyObject.Begin(OnReach);
|
}
|
}
|
|
private void OnAlphaComplete()
|
{
|
flying = true;
|
flyObject.Begin(OnReach);
|
}
|
|
private void OnReach()
|
{
|
CloseImmediately();
|
}
|
}
|
}
|
|
|
|
|