using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using vnxbqy.UI;
|
|
public class CreateRoleProcessor
|
{
|
CreateRoleTimeLine m_WarriorTimeLine = new CreateRoleTimeLine();
|
CreateRoleTimeLine m_MagicTimeLine = new CreateRoleTimeLine();
|
|
CreateRoleBehaviour m_WarriorBehaviour = new CreateRoleBehaviour();
|
CreateRoleBehaviour m_MagicBehaviour = new CreateRoleBehaviour();
|
|
Animator cameraAnimator;
|
Camera createRoleCamera;
|
|
GameObject m_WarriorPlatform = null;
|
GameObject warriorPlatform {
|
get {
|
if (m_WarriorPlatform == null)
|
{
|
m_WarriorPlatform = GameObject.Find("Cj_1");
|
}
|
return m_WarriorPlatform;
|
}
|
}
|
|
GameObject m_MagicPlatform = null;
|
GameObject magicPlatform {
|
get {
|
if (m_MagicPlatform == null)
|
{
|
m_MagicPlatform = GameObject.Find("Cj_2");
|
}
|
return m_MagicPlatform;
|
}
|
}
|
|
public void LoadNecessaryResources()
|
{
|
if (cameraAnimator == null || createRoleCamera == null)
|
{
|
var cameraParams = CreateRoleScriptableObject.GetCameraParams();
|
var prefab = SceneLoader.LoadCreateRole(cameraParams.prefabName);
|
var instance = GameObject.Instantiate(prefab);
|
cameraAnimator = instance.GetComponent<Animator>();
|
createRoleCamera = instance.GetComponentInChildren<Camera>(true);
|
createRoleCamera.enabled = false;
|
}
|
}
|
|
public void SwitchToWarrior(bool immediately)
|
{
|
if (warriorPlatform != null)
|
{
|
warriorPlatform.SetActive(true);
|
}
|
|
m_WarriorTimeLine.ClearNode();
|
var cameraParams = CreateRoleScriptableObject.GetCameraParams();
|
|
m_MagicBehaviour.SetActive(false);
|
m_WarriorBehaviour.SetActive(false);
|
|
m_WarriorTimeLine.AddNone(0f, () =>
|
{
|
WindowCenter.Instance.Close<CreateRoleWin>();
|
createRoleCamera.enabled = true;
|
cameraAnimator.Play(cameraParams.magicToWarrior, 0, immediately ? 1f : 0f);
|
|
m_MagicBehaviour.ReleaseEffects();
|
m_WarriorBehaviour.ReleaseEffects();
|
});
|
|
m_WarriorTimeLine.AddNone(immediately ? 0f : cameraParams.magicToWarriorTime, () =>
|
{
|
if (magicPlatform != null)
|
{
|
magicPlatform.SetActive(false);
|
}
|
m_WarriorBehaviour.SetActive(true);
|
m_WarriorBehaviour.Show(CreateRoleScriptableObject.GetJobParams(1));
|
});
|
|
}
|
|
public void SwitchToMagic(bool immediately)
|
{
|
if (magicPlatform != null)
|
{
|
magicPlatform.SetActive(true);
|
}
|
|
m_MagicTimeLine.ClearNode();
|
var cameraParams = CreateRoleScriptableObject.GetCameraParams();
|
|
m_MagicBehaviour.SetActive(false);
|
m_WarriorBehaviour.SetActive(false);
|
|
m_MagicTimeLine.AddNone(0f, () =>
|
{
|
WindowCenter.Instance.Close<CreateRoleWin>();
|
createRoleCamera.enabled = true;
|
cameraAnimator.Play(cameraParams.warriorToMagic, 0, immediately ? 1f : 0f);
|
|
m_MagicBehaviour.ReleaseEffects();
|
m_WarriorBehaviour.ReleaseEffects();
|
});
|
|
m_MagicTimeLine.AddNone(immediately ? 0f : cameraParams.warriorToMagicTime, () =>
|
{
|
if (warriorPlatform != null)
|
{
|
warriorPlatform.SetActive(false);
|
}
|
m_MagicBehaviour.SetActive(true);
|
m_MagicBehaviour.Show(CreateRoleScriptableObject.GetJobParams(2));
|
});
|
}
|
|
public void Dispose()
|
{
|
m_WarriorBehaviour.Dispose();
|
m_MagicBehaviour.Dispose();
|
m_WarriorBehaviour = null;
|
m_MagicBehaviour = null;
|
|
m_WarriorPlatform = null;
|
m_MagicPlatform = null;
|
|
m_WarriorTimeLine.Dispose();
|
m_MagicTimeLine.Dispose();
|
|
cameraAnimator = null;
|
createRoleCamera = null;
|
}
|
|
|
}
|