//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, February 19, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
using System;
|
|
namespace vnxbqy.UI
|
{
|
|
public class MainPositionTween : MonoBehaviour
|
{
|
[Header("切换按钮旋转")]
|
public Vector3 Vec3 = new Vector3(0f, 0f, 225f);//切换旋转的角度
|
[SerializeField] Transform m_ImageRotation;//切换滚动
|
[SerializeField] RedpointBehaviour m_RightSwitchPoint;
|
|
[Header("主界面顶部上下切换模块")]
|
public float rightTopSwitchTime = 1f;
|
[SerializeField] Transform m_RightTopFunction;
|
[SerializeField] Transform m_ContainerBossList;
|
[SerializeField] Transform m_RightTopPosition1;
|
[SerializeField] Transform m_RightTopPosition2;
|
|
[Header("主界面顶部左右切换模块")]
|
[SerializeField] Transform m_TRightFunction;
|
[SerializeField] Transform m_RightTopPosition3;
|
[SerializeField] Transform m_RightTopPosition4;
|
|
[Header("主界面技能面板切换模块")]
|
public float rightBottomSwitchTime = 1.2f;
|
[SerializeField] Transform m_ContainerSkill;//技能面板
|
[SerializeField] Transform m_SkillPosition1;
|
[SerializeField] Transform m_SkillPosition2;
|
[SerializeField] RightBottomFadeInOut m_FunctionFadeInOut;//右下角按钮组
|
|
[Header("主界面任务模块")]
|
public float leftMiddleSwitchTime = 0.5f;//任务面板移动的速度
|
[SerializeField] Transform m_ContainerLeftMiddle;
|
[SerializeField] Transform m_LeftMiddlePosition1;
|
[SerializeField] Transform m_LeftMiddlePosition2;
|
[SerializeField] GameObject m_LeftImage;
|
[SerializeField] GameObject m_RightImg;
|
|
[SerializeField] ClickScreenOtherSpace m_RayMask;//便捷切换按钮
|
|
TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
|
public void Init()
|
{
|
this.enabled = true;
|
}
|
|
public void UnInit()
|
{
|
this.enabled = false;
|
}
|
|
void Start()
|
{
|
m_RayMask.AddListener(MarkRayButton);
|
DTC0102_tagCDBPlayer.switchAccountEvent += OnSwitchAccount;
|
}
|
|
void LateUpdate()
|
{
|
var alwayShow = NewBieCenter.Instance.IsAreaNeedUnflod(2) || FunctionalGuideCenter.Instance.IsAreaNeedUnflod(2);
|
if (!alwayShow)
|
{
|
if (resetToDefaultTimer > 0f)
|
{
|
resetToDefaultTimer -= Time.deltaTime;
|
if (resetToDefaultTimer <= 0f)
|
{
|
SwitchFunctions(new SwitchParam() { showDefault = true, immediately = false });
|
}
|
}
|
}
|
}
|
|
public void ShowTaskImmedidately(bool show, bool force)
|
{
|
if (!force)
|
{
|
if (taskUserPrefer == TaskUserPrefer.Show && !show)
|
{
|
return;
|
}
|
|
if (taskUserPrefer == TaskUserPrefer.Hide && show)
|
{
|
return;
|
}
|
}
|
|
taskShow = show;
|
m_LeftImage.SetActive(show);
|
m_RightImg.SetActive(!show);
|
m_ContainerLeftMiddle.DOKill();
|
m_ContainerLeftMiddle.localPosition = show ? m_LeftMiddlePosition1.localPosition : m_LeftMiddlePosition2.localPosition;
|
}
|
|
public void ShowTask(bool show, bool force, bool byUser)
|
{
|
if (!force && !byUser)
|
{
|
if (taskUserPrefer == TaskUserPrefer.Show && !show)
|
{
|
return;
|
}
|
|
if (taskUserPrefer == TaskUserPrefer.Hide && show)
|
{
|
return;
|
}
|
}
|
|
if (byUser)
|
{
|
taskUserPrefer = show ? TaskUserPrefer.Show : TaskUserPrefer.Hide;
|
}
|
|
taskShow = show;
|
m_LeftImage.SetActive(show);
|
m_RightImg.SetActive(!show);
|
|
var endX = show ? m_LeftMiddlePosition1.localPosition.x : m_LeftMiddlePosition2.localPosition.x;
|
m_ContainerLeftMiddle.DOLocalMoveX(endX, leftMiddleSwitchTime);
|
}
|
|
static TaskUserPrefer taskUserPrefer = TaskUserPrefer.None;
|
public static bool taskShow { get; private set; }
|
public static RightTopState rightTopState { get; private set; }
|
public static RightBottomState rightBottomState { get; private set; }
|
public static bool isDefaultState { get; private set; }
|
public static event Action<bool> switchFunctionStateEvent;
|
|
public static float resetToDefaultTimer = 0;
|
public static void SetRecoverToSkillTimer()
|
{
|
resetToDefaultTimer = 8f;
|
}
|
|
public void SwitchFunctions(SwitchParam switchParams)
|
{
|
if (switchParams.manual && switchParams.showDefault)
|
{
|
resetToDefaultTimer = 0f;
|
}
|
ProcessSwitch(switchParams);
|
|
m_RightSwitchPoint.SetActive(MainPositionTween.isDefaultState);
|
}
|
|
private void ProcessSwitch(SwitchParam switchParams)
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var isDungeon = MapUtility.IsDungeon(mapId);
|
var isNeutralMap = GeneralDefine.neutralBossMaps.Contains(mapId);
|
var isBossArea = PlayerDatas.Instance.hero != null && MapArea.IsInMapArea(PlayerDatas.Instance.hero.CurMapArea, MapArea.E_Type.Boss);
|
var isGuiding = NewBieCenter.Instance.inGuiding;
|
|
m_ContainerBossList.SetActive(isNeutralMap);
|
|
rightTopState = RightTopState.Function;
|
if ((isDungeon || isNeutralMap || isBossArea || AdventureStage.Instance.IsInAdventureStage)
|
&& !isGuiding && switchParams.showDefault)
|
{
|
if (resetToDefaultTimer >0)
|
{ rightTopState = RightTopState.Function; }
|
else
|
rightTopState = RightTopState.Boss;
|
}
|
else
|
{
|
rightTopState = RightTopState.Function;
|
}
|
|
switch (rightTopState)
|
{
|
case RightTopState.Function:
|
if (switchParams.immediately)
|
{
|
m_RightTopFunction.localPosition = m_RightTopPosition1.localPosition;
|
m_ContainerBossList.localPosition = m_RightTopPosition2.localPosition;
|
m_TRightFunction.localPosition = m_RightTopPosition3.localPosition;
|
}
|
else
|
{
|
m_RightTopFunction.DOLocalMoveY(m_RightTopPosition1.localPosition.y, rightTopSwitchTime);
|
m_ContainerBossList.DOLocalMoveY(m_RightTopPosition2.localPosition.y, rightTopSwitchTime);
|
m_TRightFunction.DOLocalMoveX(m_RightTopPosition3.localPosition.x, rightTopSwitchTime);
|
}
|
break;
|
case RightTopState.Boss:
|
if (switchParams.immediately)
|
{
|
m_ContainerBossList.localPosition = m_RightTopPosition1.localPosition;
|
m_RightTopFunction.localPosition = m_RightTopPosition2.localPosition;
|
m_TRightFunction.localPosition = m_RightTopPosition4.localPosition;
|
}
|
else
|
{
|
m_ContainerBossList.DOLocalMoveY(m_RightTopPosition1.localPosition.y, rightTopSwitchTime);
|
m_RightTopFunction.DOLocalMoveY(m_RightTopPosition2.localPosition.y, rightTopSwitchTime);
|
m_TRightFunction.DOLocalMoveX(m_RightTopPosition4.localPosition.x, rightTopSwitchTime);
|
}
|
break;
|
}
|
|
var rightBottomState = RightBottomState.Skill;
|
switch (switchParams.bottomState)
|
{
|
case RightBottomState.None:
|
rightBottomState = resetToDefaultTimer <= 0f
|
&& switchParams.showDefault
|
&& !isGuiding
|
&& !(treasureModel.newGotShowing && WindowCenter.Instance.IsOpen<TreasureNewGotWin>())
|
? RightBottomState.Skill : RightBottomState.Function;
|
break;
|
default:
|
rightBottomState = switchParams.bottomState;
|
break;
|
}
|
|
switch (rightBottomState)
|
{
|
case RightBottomState.Function:
|
if (switchParams.immediately)
|
{
|
m_FunctionFadeInOut.SwitchImmedidately(true);
|
m_ContainerSkill.localPosition = m_SkillPosition2.localPosition;
|
}
|
else
|
{
|
m_FunctionFadeInOut.Switch(true);
|
m_ContainerSkill.DOLocalMoveX(m_SkillPosition2.localPosition.x, rightBottomSwitchTime);
|
}
|
break;
|
case RightBottomState.Skill:
|
if (switchParams.immediately)
|
{
|
m_FunctionFadeInOut.SwitchImmedidately(false);
|
m_ContainerSkill.localPosition = m_SkillPosition1.localPosition;
|
}
|
else
|
{
|
m_FunctionFadeInOut.Switch(false);
|
m_ContainerSkill.DOLocalMoveX(m_SkillPosition1.localPosition.x, rightBottomSwitchTime);
|
}
|
break;
|
}
|
|
isDefaultState = rightBottomState == RightBottomState.Skill;
|
resetToDefaultTimer = !isDefaultState ? 8f : 0f;
|
m_RayMask.SetActive(!isDefaultState);
|
|
if (switchParams.immediately)
|
{
|
m_ImageRotation.localEulerAngles = isDefaultState ? Vector3.zero : new Vector3(0, 0, 225);
|
}
|
else
|
{
|
m_ImageRotation.DOLocalRotate(isDefaultState ? Vector3.zero : new Vector3(0, 0, 225), rightBottomSwitchTime);
|
}
|
|
if (switchFunctionStateEvent != null)
|
{
|
switchFunctionStateEvent(switchParams.immediately);
|
}
|
}
|
|
private void MarkRayButton()
|
{
|
if (NewBieCenter.Instance.inGuiding)
|
{
|
return;
|
}
|
|
if (treasureModel.treasureStageUpShow || treasureModel.newGotShowing)
|
{
|
return;
|
}
|
|
resetToDefaultTimer = 0.0001f;
|
}
|
|
private void OnSwitchAccount()
|
{
|
taskUserPrefer = TaskUserPrefer.None;
|
}
|
|
public enum RightTopState
|
{
|
Function,
|
Boss,
|
}
|
|
public enum RightBottomState
|
{
|
None,
|
Function,
|
Skill,
|
}
|
|
public enum TaskUserPrefer
|
{
|
None,
|
Show,
|
Hide,
|
}
|
|
public struct SwitchParam
|
{
|
public bool showDefault;
|
public bool immediately;
|
public bool manual;
|
public RightBottomState bottomState;
|
}
|
|
}
|
|
}
|
|
|
|