using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using Snxxz.UI;
|
|
public class CreateRoleHeroShow : MonoBehaviour
|
{
|
[SerializeField] Camera m_CreateRoleCamera;
|
[SerializeField] CreateRoleHeroPlatform m_HeroPlatform;
|
[SerializeField] ActorShadowCaster m_Shadow;
|
[SerializeField] Animation m_CameraAnimation;
|
|
int m_CurrentShowJob = 0;
|
SFXController m_CreateRoleEffect;
|
|
UI3DShowHero playerModel = new UI3DShowHero();
|
|
public void CreateRoleShow(int _job)
|
{
|
UI3DModelFactory.ReleaseCreateRole(_job);
|
m_CurrentShowJob = _job;
|
UI3DModelFactory.LoadCreateRole(_job, OnLoadCreateRoleCallBack);
|
}
|
|
private void OnLoadCreateRoleCallBack(bool _ok, Object _object)
|
{
|
if (!_ok)
|
{
|
return;
|
}
|
|
var instance = _object as GameObject;
|
if (instance == null)
|
{
|
return;
|
}
|
|
var parent = instance.transform.GetChildTransformDeeply(GAStaticDefine.WeaponBindBoneName);
|
|
m_HeroPlatform.transform.localEulerAngles = new Vector3(0, 180, 0);
|
|
instance.transform.SetParentEx(m_HeroPlatform.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
instance.SetActive(true);
|
|
m_Shadow.Cast(instance.transform);
|
|
var animator = instance.GetComponent<Animator>();
|
if (animator != null)
|
{
|
animator.Play("Appear", 0, 0f);
|
m_HeroPlatform.ForbidSeconds(4);
|
}
|
|
if (m_CreateRoleEffect != null)
|
{
|
SFXPlayUtility.Instance.Release(m_CreateRoleEffect);
|
m_CreateRoleEffect = null;
|
}
|
|
switch (m_CurrentShowJob)
|
{
|
case 1:
|
m_CreateRoleEffect = SFXPlayUtility.Instance.Play(10006, instance.transform);
|
SoundPlayer.Instance.PlayUIAudio(95);
|
SoundPlayer.Instance.PlayNpcAudio(689);
|
break;
|
case 2:
|
m_CreateRoleEffect = SFXPlayUtility.Instance.Play(10005, instance.transform);
|
SoundPlayer.Instance.PlayUIAudio(96);
|
SoundPlayer.Instance.PlayNpcAudio(690);
|
break;
|
case 3:
|
break;
|
}
|
}
|
|
public void SelectRoleShow()
|
{
|
Dispose();
|
|
var clothesItemId = 0;
|
var weaponItemId = 0;
|
var wingsItemId = 0;
|
var secondaryItemId = 0;
|
var _suitLevel = 0;
|
var equipInfos = PlayerDatas.Instance.loginInfo.EquipInfo;
|
for (int i = 0; i < equipInfos.Length; i++)
|
{
|
var equipInfo = equipInfos[i];
|
switch ((RoleEquipType)equipInfo.ItemPlace)
|
{
|
case RoleEquipType.retWeapon:
|
weaponItemId = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.retClothes:
|
clothesItemId = (int)equipInfo.ItemID;
|
|
if (equipInfo.IsSuite == 1)
|
{
|
Dictionary<int, List<int>> _userDataDict = ConfigParse.Analysis(equipInfo.UserData);
|
if (_userDataDict.ContainsKey(30))
|
{
|
_suitLevel = _userDataDict[30][0];
|
}
|
}
|
break;
|
case RoleEquipType.retWing:
|
wingsItemId = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.retWeapon2:
|
secondaryItemId = (int)equipInfo.ItemID;
|
break;
|
}
|
}
|
|
var model = playerModel.Show(PlayerDatas.Instance.loginInfo.Job, clothesItemId, _suitLevel, weaponItemId, wingsItemId, secondaryItemId, m_HeroPlatform.transform);
|
m_Shadow.Cast(model.transform);
|
}
|
|
public void Dispose()
|
{
|
playerModel.Dispose();
|
UI3DModelFactory.ReleaseCreateRole(m_CurrentShowJob);
|
if (m_CreateRoleEffect != null)
|
{
|
SFXPlayUtility.Instance.Release(m_CreateRoleEffect);
|
m_CreateRoleEffect = null;
|
}
|
|
}
|
|
private void OnEnable()
|
{
|
var aspect = Screen.width / (float)Screen.height;
|
if (aspect < 1.6)
|
{
|
m_CreateRoleCamera.fieldOfView = 43;
|
}
|
else
|
{
|
m_CreateRoleCamera.fieldOfView = 35;
|
}
|
}
|
|
private void OnDestroy()
|
{
|
StopAllCoroutines();
|
UI3DModelFactory.ClearCreateRole();
|
}
|
|
[System.Serializable]
|
public struct CreateRoleAnimation
|
{
|
public int job;
|
public float delay;
|
public string animation;
|
}
|
|
}
|