504 lines
15 KiB
C#
504 lines
15 KiB
C#
|
using System.Collections;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using Games.LogicObj;
|
|||
|
using Games.Mission;
|
|||
|
using Games.Scene;
|
|||
|
using GCGame;
|
|||
|
using GCGame.Table;
|
|||
|
using Module.Log;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.SceneManagement;
|
|||
|
|
|||
|
/* 初始展示副本步骤
|
|||
|
*
|
|||
|
local BeginnerFBPhase =
|
|||
|
{
|
|||
|
INVALIDE = -1,
|
|||
|
PHASE_0 = 0, -- 对完话后,刷出第一波小怪
|
|||
|
PHASE_1 = 1, -- 击杀小怪后,播放动画
|
|||
|
PHASE_2 = 2, -- 刷出跳跃点,刷出精英怪
|
|||
|
PHASE_3 = 3, -- 击杀精英怪之后刷出法杖
|
|||
|
PHASE_4 = 4, -- 采集法杖后,去除空气墙
|
|||
|
PHASE_5 = 5, -- 播放动画后刷出小BOSS
|
|||
|
PHASE_6 = 6, -- BOSS死亡后播放轻功动画+BOSS出场动画
|
|||
|
PHASE_7 = 7, -- 动画播完后刷出BOSS
|
|||
|
PHASE_8 = 8, -- BOSS死亡后播放动画
|
|||
|
|
|||
|
PHASE_MAX = 9 -- 动画播完后定格为图案,切换图案后切换场景
|
|||
|
}
|
|||
|
|
|||
|
*/
|
|||
|
|
|||
|
|
|||
|
public class FirstShowScene : MonoBehaviour
|
|||
|
{
|
|||
|
private const string bundleName = "";
|
|||
|
public static int FirstShowStep = -100;
|
|||
|
private static FirstShowScene m_instance;
|
|||
|
|
|||
|
//寻路位置点
|
|||
|
public GameObject[] TargetPoints;
|
|||
|
|
|||
|
//特效
|
|||
|
public GameObject EffectObjectStage;
|
|||
|
public GameObject EffectObject3;
|
|||
|
public GameObject EffectObject2;
|
|||
|
|
|||
|
public GameObject StaveShow;
|
|||
|
public UICameraTexture StaveModel;
|
|||
|
|
|||
|
public GameObject Stage;
|
|||
|
public Canvas m_Canvas;
|
|||
|
public GameObject SkipBtn;
|
|||
|
public GameObject OverShowBtn;
|
|||
|
public RawImageAlpha m_RawImage1;
|
|||
|
public RawImageAlpha m_RawImage2;
|
|||
|
public GameObject JumpPoint;
|
|||
|
public GameObject FbQiang;
|
|||
|
public GameObject[] _SceneMovies;
|
|||
|
|
|||
|
|
|||
|
private bool _InitJumpPoint;
|
|||
|
private bool Destroyend;
|
|||
|
|
|||
|
private int m_CurrentBeginFBStep = -100;
|
|||
|
private float m_lastUpdateTime;
|
|||
|
private int m_ReleaseStep = -1;
|
|||
|
private float m_UpdateSpace = 1;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (m_instance != null)
|
|||
|
{
|
|||
|
m_instance.gameObject.SetActive(false);
|
|||
|
Destroy(m_instance.gameObject);
|
|||
|
m_instance = null;
|
|||
|
}
|
|||
|
|
|||
|
m_instance = this;
|
|||
|
|
|||
|
if (Singleton<ObjManager>.Instance.MainPlayer != null)
|
|||
|
MainPlayerFirstFaceTo(Singleton<ObjManager>.Instance.MainPlayer);
|
|||
|
|
|||
|
DontDestroyOnLoad(gameObject);
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
FbQiang.SetActive(true);
|
|||
|
JumpPoint.SetActive(false);
|
|||
|
Destroyend = false;
|
|||
|
OverShowBtn.SetActive(false);
|
|||
|
SetCanvas(true);
|
|||
|
Utils.HideMainTopRightUI();
|
|||
|
|
|||
|
var mainplay = Singleton<ObjManager>.Instance.MainPlayer;
|
|||
|
if (mainplay != null)
|
|||
|
mainplay.EnterAutoCombat();
|
|||
|
|
|||
|
|
|||
|
if (FirstShowStep != -100) UpdateNewStep(FirstShowStep);
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (Destroyend)
|
|||
|
return;
|
|||
|
if (SceneMovieManager.Instance._PlayingMovie)
|
|||
|
return;
|
|||
|
|
|||
|
var mainplay = Singleton<ObjManager>.Instance.MainPlayer;
|
|||
|
if (mainplay == null)
|
|||
|
return;
|
|||
|
if (SceneLogic.CameraController == null)
|
|||
|
return;
|
|||
|
if (Time.unscaledTime - m_lastUpdateTime < m_UpdateSpace)
|
|||
|
return;
|
|||
|
m_UpdateSpace = 1;
|
|||
|
m_lastUpdateTime = Time.unscaledTime;
|
|||
|
if (_InitJumpPoint == false)
|
|||
|
{
|
|||
|
CreateJumpPoint();
|
|||
|
Stage.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
switch (m_CurrentBeginFBStep)
|
|||
|
{
|
|||
|
case 0:
|
|||
|
{
|
|||
|
if (TargetPoints.Length < 1 ||
|
|||
|
Vector3.Distance(mainplay.Position, TargetPoints[0].transform.position) < 2)
|
|||
|
{
|
|||
|
mainplay.EnterAutoCombat();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (TargetPoints[0].activeSelf == false)
|
|||
|
return;
|
|||
|
mainplay.MainPlayMoveToPos(TargetPoints[0].transform.position, 2, bIsAutoSearch: false);
|
|||
|
TargetPoints[0].SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
{
|
|||
|
mainplay.LeveAutoCombat();
|
|||
|
PlayMovie(0);
|
|||
|
SendStepToServer(2);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
{
|
|||
|
if (JumpPoint.activeSelf == false)
|
|||
|
{
|
|||
|
JumpPoint.SetActive(true);
|
|||
|
m_UpdateSpace = 0.5f;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (TargetPoints.Length < 2 ||
|
|||
|
Vector3.Distance(mainplay.Position, TargetPoints[1].transform.position) < 3)
|
|||
|
{
|
|||
|
mainplay.EnterAutoCombat();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (TargetPoints[1].activeSelf == false)
|
|||
|
return;
|
|||
|
mainplay.MainPlayMoveToPos(TargetPoints[1].transform.position, 3, bIsAutoSearch: false);
|
|||
|
TargetPoints[1].SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
{
|
|||
|
StartCoroutine(IEnumerator3(mainplay));
|
|||
|
return;
|
|||
|
}
|
|||
|
case 4:
|
|||
|
{
|
|||
|
if (FbQiang.activeSelf)
|
|||
|
{
|
|||
|
ShowStave(20190);
|
|||
|
EffectObjectStage.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
FbQiang.SetActive(false);
|
|||
|
// if(UIManager.Instance()!=null && UIManager.Instance().EventSystemObj!=null)
|
|||
|
// UIManager.Instance().EventSystemObj.gameObject.SetActive(false);
|
|||
|
if (Vector3.Distance(mainplay.Position, TargetPoints[2].transform.position) < 0.5f)
|
|||
|
{
|
|||
|
if (TargetPoints[2].activeSelf)
|
|||
|
{
|
|||
|
TargetPoints[2].SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
// if (UIManager.Instance() != null && UIManager.Instance().EventSystemObj != null)
|
|||
|
// UIManager.Instance().EventSystemObj.gameObject.SetActive(true);
|
|||
|
Stage.SetActive(false);
|
|||
|
PlayMovie(1);
|
|||
|
SendStepToServer(5);
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
if (Vector3.Distance(mainplay.Position, TargetPoints[2].transform.position) > 0.5f)
|
|||
|
mainplay.MainPlayMoveToPos(TargetPoints[2].transform.position);
|
|||
|
return;
|
|||
|
}
|
|||
|
case 5:
|
|||
|
{
|
|||
|
mainplay.StopEffect(4099);
|
|||
|
StartCoroutine(AutoCombat(0.5f));
|
|||
|
Stage.SetActive(true);
|
|||
|
Stage.transform.position = new Vector3(9, 0, 1);
|
|||
|
EffectObject3.SetActive(true);
|
|||
|
Utils.HideMainTopRightUI(false);
|
|||
|
// if (UIManager.Instance() != null && UIManager.Instance().EventSystemObj != null)
|
|||
|
// UIManager.Instance().EventSystemObj.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 6:
|
|||
|
{
|
|||
|
// if (UIManager.Instance() != null && UIManager.Instance().EventSystemObj != null)
|
|||
|
// UIManager.Instance().EventSystemObj.gameObject.SetActive(true);
|
|||
|
Stage.SetActive(true);
|
|||
|
Stage.transform.position = new Vector3(9, 0, 1);
|
|||
|
mainplay.LeveAutoCombat();
|
|||
|
m_UpdateSpace = 0.5f;
|
|||
|
var distance = Vector3.Distance(mainplay.Position, TargetPoints[3].transform.position);
|
|||
|
float minDis = 5;
|
|||
|
if (TargetPoints[3].activeSelf)
|
|||
|
if (distance > 2 && distance < minDis)
|
|||
|
minDis = 2;
|
|||
|
TargetPoints[3].SetActive(false);
|
|||
|
if (distance > minDis && distance < 30)
|
|||
|
{
|
|||
|
mainplay.MainPlayMoveToPos(TargetPoints[3].transform.position);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
mainplay.StopMove();
|
|||
|
SendStepToServer(7);
|
|||
|
PlayMovie(2);
|
|||
|
SetCameraPos();
|
|||
|
Utils.HideMainTopRightUI(false);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 7:
|
|||
|
{
|
|||
|
mainplay.StopMove();
|
|||
|
mainplay.StopEffect(4138);
|
|||
|
if (SceneLogic.CameraController == null)
|
|||
|
return;
|
|||
|
SetCameraPos();
|
|||
|
mainplay.EnterAutoCombat();
|
|||
|
}
|
|||
|
break;
|
|||
|
case 8:
|
|||
|
{
|
|||
|
PlayMovie(3);
|
|||
|
mainplay.LeveAutoCombat();
|
|||
|
}
|
|||
|
break;
|
|||
|
case 9:
|
|||
|
{
|
|||
|
SkipBtn.SetActive(false);
|
|||
|
GameManager.gameManager.SoundManager.StopAllSoundEffect();
|
|||
|
GameManager.gameManager.SoundManager.PlaySoundEffect(512);
|
|||
|
m_CurrentBeginFBStep = -100;
|
|||
|
m_UpdateSpace = 0;
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
m_CurrentBeginFBStep = -100;
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
FirstShowStep = -100;
|
|||
|
if (m_instance.gameObject.activeSelf == false)
|
|||
|
m_instance = null;
|
|||
|
}
|
|||
|
|
|||
|
public static FirstShowScene Instance()
|
|||
|
{
|
|||
|
return m_instance;
|
|||
|
}
|
|||
|
|
|||
|
public static bool CanFindMissionPath()
|
|||
|
{
|
|||
|
return GameManager.gameManager.RunningScene != (int) GameDefine_Globe.SCENE_DEFINE.SCENE_FIRSTSHOW;
|
|||
|
}
|
|||
|
|
|||
|
public static void SetCameraPos()
|
|||
|
{
|
|||
|
if (SceneLogic.CameraController == null)
|
|||
|
return;
|
|||
|
SceneLogic.CameraController.Pitch = 10.04f;
|
|||
|
SceneLogic.CameraController.Yaw = 258.04f;
|
|||
|
SceneLogic.CameraController.Distance = 15.15f;
|
|||
|
}
|
|||
|
|
|||
|
private void SetCanvas(bool UseUI)
|
|||
|
{
|
|||
|
if (UseUI)
|
|||
|
{
|
|||
|
if (UIManager.Instance() != null)
|
|||
|
{
|
|||
|
m_Canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
|||
|
m_Canvas.worldCamera = UIManager.Instance().UICamera;
|
|||
|
m_Canvas.sortingOrder = UIManager.Instance().Canvas.sortingOrder - 1;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_Canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
|||
|
m_Canvas.sortingOrder = 11000;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateNewStep(int step)
|
|||
|
{
|
|||
|
m_CurrentBeginFBStep = step;
|
|||
|
m_ReleaseStep = step;
|
|||
|
FbQiang.SetActive(m_CurrentBeginFBStep <= 4);
|
|||
|
m_lastUpdateTime = 0;
|
|||
|
|
|||
|
if (m_CurrentBeginFBStep == 7) SetCameraPos();
|
|||
|
}
|
|||
|
|
|||
|
private int MoviePlayOver()
|
|||
|
{
|
|||
|
SkipBtn.SetActive(true);
|
|||
|
StartCoroutine(SendStepToServer());
|
|||
|
m_lastUpdateTime = Time.unscaledTime;
|
|||
|
m_UpdateSpace = 1.5f;
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator SendStepToServer()
|
|||
|
{
|
|||
|
//第八个步骤特殊处理一下,动画完毕需要显示图片
|
|||
|
if (m_ReleaseStep == 8)
|
|||
|
{
|
|||
|
SetCanvas(false);
|
|||
|
SkipBtn.SetActive(false);
|
|||
|
m_RawImage1.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
if (m_ReleaseStep == 5)
|
|||
|
{
|
|||
|
Stage.SetActive(true);
|
|||
|
Stage.transform.position = new Vector3(9, 0, 1);
|
|||
|
}
|
|||
|
|
|||
|
yield return new WaitForSeconds(1);
|
|||
|
if (m_ReleaseStep == 8)
|
|||
|
{
|
|||
|
SendStepToServer(m_ReleaseStep + 1);
|
|||
|
m_CurrentBeginFBStep = 9;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void SendStepToServer(int step)
|
|||
|
{
|
|||
|
var req = new ReqChangeBeginnerFBPhase();
|
|||
|
req.phase = step;
|
|||
|
req.SendMsg();
|
|||
|
}
|
|||
|
|
|||
|
private void ShowStave(int charModelID)
|
|||
|
{
|
|||
|
var charModel = TableManager.GetCharModelByID(charModelID);
|
|||
|
if (charModel == null)
|
|||
|
return;
|
|||
|
StaveShow.SetActive(true);
|
|||
|
StaveModel.InitModelPath("", charModel, isBody: true);
|
|||
|
StartCoroutine(HideStave());
|
|||
|
}
|
|||
|
|
|||
|
private bool Click_Mission()
|
|||
|
{
|
|||
|
if (MissionDialogAndLeftTabsLogic.Instance() == null)
|
|||
|
return false;
|
|||
|
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().ShowDefaultToggle();
|
|||
|
foreach (var kvp in GameManager.gameManager.MissionManager.MissionList.m_aMission)
|
|||
|
{
|
|||
|
if (kvp.Key < 0)
|
|||
|
continue;
|
|||
|
var missionBase = TableManager.GetMissionBaseByID(kvp.Key);
|
|||
|
if (missionBase != null)
|
|||
|
if (missionBase.MissionType == (int) MISSIONTYPE.MISSION_MAIN &&
|
|||
|
MissionDialogAndLeftTabsLogic.Instance() != null)
|
|||
|
{
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().ClickOneMissionItem(kvp.Key);
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator HideStave()
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(2);
|
|||
|
StaveShow.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator IEnumerator3(Obj_MainPlayer mainplayer)
|
|||
|
{
|
|||
|
if (mainplayer != null)
|
|||
|
mainplayer.PlayEffect(4099);
|
|||
|
yield return new WaitForSeconds(0);
|
|||
|
if (Click_Mission()) m_CurrentBeginFBStep = -100;
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator IEnumerator6(float waitTime)
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(waitTime);
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator AutoCombat(float waitTime)
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(waitTime);
|
|||
|
var mainplay = Singleton<ObjManager>.Instance.MainPlayer;
|
|||
|
if (mainplay != null) mainplay.EnterAutoCombat();
|
|||
|
}
|
|||
|
|
|||
|
private void DestroySelf()
|
|||
|
{
|
|||
|
Destroyend = true;
|
|||
|
gameObject.SetActive(false);
|
|||
|
Destroy(gameObject);
|
|||
|
}
|
|||
|
|
|||
|
public void MainPlayerFirstFaceTo(Obj_Character obj)
|
|||
|
{
|
|||
|
if (GameManager.gameManager.RunningScene != (int) GameDefine_Globe.SCENE_DEFINE.SCENE_FIRSTSHOW)
|
|||
|
{
|
|||
|
DestroySelf();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (obj == null)
|
|||
|
return;
|
|||
|
var mainplay = Singleton<ObjManager>.Instance.MainPlayer;
|
|||
|
if (mainplay != null)
|
|||
|
mainplay.EnterAutoCombat();
|
|||
|
|
|||
|
if (Vector3.Distance(obj.Position, TargetPoints[4].transform.position) < 5)
|
|||
|
obj.FaceTo(TargetPoints[4].transform.position);
|
|||
|
}
|
|||
|
|
|||
|
//如果不在展示场景就删除控件
|
|||
|
public void CheckScene(int NextSceneID)
|
|||
|
{
|
|||
|
SkipBtn.SetActive(NextSceneID == (int) GameDefine_Globe.SCENE_DEFINE.SCENE_FIRSTSHOW);
|
|||
|
|
|||
|
if (NextSceneID == (int) GameDefine_Globe.SCENE_DEFINE.SCENE_LOGIN)
|
|||
|
{
|
|||
|
DestroySelf();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (NextSceneID != (int) GameDefine_Globe.SCENE_DEFINE.SCENE_FIRSTSHOW) DestroySelf();
|
|||
|
}
|
|||
|
|
|||
|
private void PlayMovie(int index)
|
|||
|
{
|
|||
|
if (_SceneMovies.Length > index && _SceneMovies[index] != null && _SceneMovies[index].gameObject != null)
|
|||
|
{
|
|||
|
SkipBtn.SetActive(false);
|
|||
|
_SceneMovies[index].gameObject.SetActive(true);
|
|||
|
SceneMovieManager.Instance.MovieOverEvent += MoviePlayOver;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void CreateJumpPoint()
|
|||
|
{
|
|||
|
_InitJumpPoint = true;
|
|||
|
var sceneLogic = FindObjectOfType<SceneLogic>();
|
|||
|
if (sceneLogic == null)
|
|||
|
LogModule.ErrorLog("No SceneLogic in scene FirstShow at Scene " + SceneManager.GetActiveScene().name);
|
|||
|
else
|
|||
|
sceneLogic.RefreshSceneItems((int) GameDefine_Globe.SCENE_DEFINE.SCENE_FIRSTSHOW, JumpPoint);
|
|||
|
}
|
|||
|
|
|||
|
public void CloseStave()
|
|||
|
{
|
|||
|
StaveShow.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void SkipShow()
|
|||
|
{
|
|||
|
SendStepToServer(9);
|
|||
|
m_UpdateSpace = 0;
|
|||
|
}
|
|||
|
}
|