//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, September 09, 2017
|
//--------------------------------------------------------
|
using Snxxz.UI;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
using UnityStandardAssets.ImageEffects;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class UI3DModelExhibition : MonoBehaviour
|
{
|
[SerializeField] Transform m_PlayerShowPoint;
|
[SerializeField] Transform m_HorseShowPoint;
|
[SerializeField] Transform m_WingShowPoint;
|
[SerializeField] Transform m_NPCShowPoint;
|
[SerializeField] Transform m_DialogPoint;
|
[SerializeField] Transform m_EquipmentPoint;
|
[SerializeField] Transform m_GodWeaponEffectPoint;
|
[SerializeField] Camera m_ShowCamera;
|
[SerializeField] bool m_Interactable = false;
|
[SerializeField] UI3DModelInteractProcessor m_InteractProcessor;
|
[SerializeField] ColorCorrectionCurves m_CameraColor;
|
|
public bool interactable {
|
get { return m_Interactable; }
|
set { m_Interactable = value; }
|
}
|
|
UI3DShowHero playerModel = new UI3DShowHero();
|
|
int m_HorseModelId = 0;
|
GameObject horseModel = null;
|
public GameObject NpcModelHorse {
|
get { return horseModel; }
|
set { horseModel = value; }
|
}
|
|
int m_NPCId = 0;
|
GameObject npcModel = null;
|
SFXController m_NpcEffect;
|
readonly List<SFXController> m_BindEffectList = new List<SFXController>();
|
public GameObject NpcModelPet {
|
get { return npcModel; }
|
set { npcModel = value; }
|
}
|
|
int m_WingModelId = 0;
|
GameObject wingModel = null;
|
|
int m_EquipmentModelId = 0;
|
GameObject equipmentModel = null;
|
|
SFXController godWeaponEffect = null;
|
|
bool isShowingPlayer = false;
|
bool isShowingHorse = false;
|
bool isShowingNPC = false;
|
bool isShowWing = false;
|
bool isShowinEquipment = false;
|
|
Vector2 prePosition = Vector2.zero;
|
|
PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
public static UI3DModelExhibition Instance { get; private set; }
|
|
static UI3DModelExhibition m_InstanceClone1 = null;
|
public static UI3DModelExhibition InstanceClone1 {
|
get {
|
if (m_InstanceClone1 == null)
|
{
|
CreateCloneStage();
|
}
|
return m_InstanceClone1;
|
}
|
}
|
|
public static void CreateStage()
|
{
|
var prefab = BuiltInLoader.LoadPrefab("UI3DModelExhibitionStage");
|
var gameObject = GameObject.Instantiate(prefab);
|
Instance = gameObject.GetComponent<UI3DModelExhibition>();
|
Instance.transform.position = new Vector3(1000, 2000, 3000);
|
Instance.name = "UI3DModelExhibitionStage";
|
Instance.gameObject.SetActive(true);
|
Instance.m_ShowCamera.enabled = false;
|
DontDestroyOnLoad(gameObject);
|
}
|
|
static void CreateCloneStage()
|
{
|
var prefab = BuiltInLoader.LoadPrefab("UI3DModelExhibitionStage");
|
var gameObject = GameObject.Instantiate(prefab);
|
m_InstanceClone1 = gameObject.GetComponent<UI3DModelExhibition>();
|
m_InstanceClone1.transform.position = new Vector3(2000, 4000, 5000);
|
m_InstanceClone1.name = "UI3DModelExhibitionStage(clone1)";
|
m_InstanceClone1.gameObject.SetActive(true);
|
m_InstanceClone1.m_ShowCamera.enabled = false;
|
DontDestroyOnLoad(gameObject);
|
}
|
|
public string GetName()
|
{
|
return this.name;
|
}
|
|
public void ShowLoginPlayer(RawImage _rawImage, int _job)
|
{
|
var flashClothes = 0;
|
var flashWeapon = 0;
|
var flashSecondary = 0;
|
var clothesItemId = 0;
|
var weaponItemId = 0;
|
var wingsItemId = 0;
|
var secondaryItemId = 0;
|
var suitLevel = 0;
|
var equipInfos = PlayerDatas.Instance.loginInfo.EquipInfo;
|
Dictionary<int, int> dict = null;
|
EquipShowSwitch.IsGodWeaponEffectOn(PlayerDatas.Instance.loginInfo.EquipShowSwitch, out dict);
|
|
for (int i = 0; i < equipInfos.Length; i++)
|
{
|
var equipInfo = equipInfos[i];
|
switch ((RoleEquipType)equipInfo.ItemPlace)
|
{
|
case RoleEquipType.FashionClothes:
|
flashClothes = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.FashionWeapon:
|
flashWeapon = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.FashionWeapon2:
|
flashSecondary = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.Weapon:
|
weaponItemId = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.Clothes:
|
clothesItemId = (int)equipInfo.ItemID;
|
|
if (equipInfo.IsSuite == 1)
|
{
|
var userDataDict = ConfigParse.Analysis(equipInfo.UserData);
|
if (userDataDict.ContainsKey(30))
|
{
|
suitLevel = userDataDict[30][0];
|
}
|
}
|
break;
|
case RoleEquipType.Wing:
|
wingsItemId = (int)equipInfo.ItemID;
|
break;
|
case RoleEquipType.Weapon2:
|
secondaryItemId = (int)equipInfo.ItemID;
|
break;
|
}
|
}
|
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = _job,
|
fashionClothesId = flashClothes,
|
fashionWeaponId = flashWeapon,
|
fashionSecondaryId = flashSecondary,
|
clothesId = clothesItemId,
|
suitLevel = suitLevel,
|
weaponId = weaponItemId,
|
wingsId = wingsItemId,
|
secondaryId = secondaryItemId,
|
isDialogue = false,
|
godWeapons = dict
|
};
|
|
ShowPlayer(_rawImage, data);
|
}
|
|
public void ShowPlayer(RawImage _rawImage, int _job, bool _isDialogue = false)
|
{
|
var clothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Clothes);
|
var flashClothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionClothes);
|
var clothesId = clothes == null ? 0 : (int)clothes.itemId;
|
var flashClothesId = flashClothes == null ? 0 : flashClothes.itemId;
|
|
var weapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon);
|
var flashWeapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon);
|
var weaponId = weapon == null ? 0 : (int)weapon.itemId;
|
var flashWeaponId = flashWeapon == null ? 0 : flashWeapon.itemId;
|
|
var wings = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Wing);
|
var wingsId = wings == null ? 0 : (int)wings.itemId;
|
|
var flahsSecondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon2);
|
var secondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon2);
|
var secondaryId = secondary == null ? 0 : (int)secondary.itemId;
|
var flashSecondaryId = flahsSecondary == null ? 0 : flahsSecondary.itemId;
|
|
int suitLevel = 0;
|
if (clothes != null)
|
{
|
if (clothes.isSuite == 1)
|
{
|
if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
|
{
|
suitLevel = clothes.GetUseDataModel(30)[0];
|
}
|
}
|
}
|
|
Dictionary<int, int> dict = null;
|
EquipShowSwitch.IsGodWeaponEffectOn(PlayerDatas.Instance.baseData.equipShowSwitch, out dict);
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = _job,
|
fashionClothesId = flashClothesId,
|
fashionWeaponId = flashWeaponId,
|
fashionSecondaryId = flashSecondaryId,
|
clothesId = clothesId,
|
suitLevel = suitLevel,
|
weaponId = weaponId,
|
wingsId = wingsId,
|
secondaryId = secondaryId,
|
isDialogue = _isDialogue,
|
godWeapons = dict
|
};
|
|
ShowPlayer(_rawImage, data);
|
}
|
|
public void ShowPlayer(RawImage rawImage, int job, RoleEquipType exceptEquip)
|
{
|
var clothesId = 0;
|
var weaponId = 0;
|
var wingsId = 0;
|
var secondaryId = 0;
|
var flashClothesId = 0;
|
var flashWeaponId = 0;
|
var flashSecondaryId = 0;
|
|
ItemModel clothes = null;
|
|
if (exceptEquip != RoleEquipType.Clothes)
|
{
|
clothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Clothes);
|
var flashClothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionClothes);
|
clothesId = clothes == null ? 0 : (int)clothes.itemId;
|
flashClothesId = flashClothes == null ? 0 : flashClothes.itemId;
|
}
|
|
if (exceptEquip != RoleEquipType.Weapon)
|
{
|
var flashWeapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon);
|
var weapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon);
|
weaponId = weapon == null ? 0 : (int)weapon.itemId;
|
flashWeaponId = flashWeapon == null ? 0 : flashWeapon.itemId;
|
}
|
|
if (exceptEquip != RoleEquipType.Wing)
|
{
|
var wings = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Wing);
|
wingsId = wings == null ? 0 : (int)wings.itemId;
|
}
|
|
if (exceptEquip != RoleEquipType.Weapon2)
|
{
|
var flashSecondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon2);
|
var secondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon2);
|
secondaryId = secondary == null ? 0 : (int)secondary.itemId;
|
flashSecondaryId = flashSecondary == null ? 0 : flashSecondary.itemId;
|
}
|
|
var suitLevel = 0;
|
if (clothes != null)
|
{
|
if (clothes.isSuite == 1)
|
{
|
if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
|
{
|
suitLevel = clothes.GetUseDataModel(30)[0];
|
}
|
}
|
}
|
|
Dictionary<int, int> dict = null;
|
EquipShowSwitch.IsGodWeaponEffectOn(PlayerDatas.Instance.baseData.equipShowSwitch, out dict);
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = job,
|
clothesId = clothesId,
|
suitLevel = suitLevel,
|
weaponId = weaponId,
|
wingsId = wingsId,
|
secondaryId = secondaryId,
|
fashionClothesId = flashClothesId,
|
fashionWeaponId = flashWeaponId,
|
fashionSecondaryId = flashSecondaryId,
|
isDialogue = false,
|
godWeapons = dict
|
};
|
|
ShowPlayer(rawImage, data);
|
}
|
|
void ShowPlayer(RawImage _rawImage, UI3DPlayerExhibitionData data)
|
{
|
StopShow();
|
|
var isDialogue = data.isDialogue;
|
var instance = playerModel.Show(data, isDialogue ? m_DialogPoint : m_PlayerShowPoint);
|
interactable = !isDialogue;
|
m_PlayerShowPoint.localEulerAngles = Vector3.zero;
|
|
if (isDialogue)
|
{
|
instance.transform.localPosition = GeneralDefine.heroDialogueOffset;
|
instance.transform.localEulerAngles = GeneralDefine.heroDialogueRotation;
|
instance.transform.localScale = GeneralDefine.heroDialogueScale * Vector3.one;
|
}
|
|
m_ShowCamera.enabled = true;
|
isShowingPlayer = true;
|
ResetCameraColor();
|
|
if (playerModel != null)
|
{
|
playerModel.StandUp();
|
}
|
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
}
|
|
public void ShowOtherPlayer(RawImage _rawImage, UI3DPlayerExhibitionData data)
|
{
|
StopShow();
|
|
playerModel.Show(data, m_PlayerShowPoint);
|
|
interactable = true;
|
m_PlayerShowPoint.localEulerAngles = Vector3.zero;
|
m_ShowCamera.enabled = true;
|
isShowingPlayer = true;
|
ResetCameraColor();
|
|
if (playerModel != null)
|
{
|
playerModel.StandUp();
|
}
|
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
}
|
|
public void ShowSitDownPlayer(RawImage _rawImage, int _job)
|
{
|
var clothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Clothes);
|
var flashClothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionClothes);
|
var clothesId = clothes == null ? 0 : (int)clothes.itemId;
|
var flashClothesId = flashClothes == null ? 0 : flashClothes.itemId;
|
|
var weapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon);
|
var flashWeapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon);
|
var weaponId = weapon == null ? 0 : (int)weapon.itemId;
|
var flashWeaponId = flashWeapon == null ? 0 : flashWeapon.itemId;
|
|
var wings = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Wing);
|
var wingsId = wings == null ? 0 : (int)wings.itemId;
|
|
var flahsSecondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon2);
|
var secondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon2);
|
var secondaryId = secondary == null ? 0 : (int)secondary.itemId;
|
var flashSecondaryId = flahsSecondary == null ? 0 : flahsSecondary.itemId;
|
|
int suitLevel = 0;
|
if (clothes != null)
|
{
|
if (clothes.isSuite == 1)
|
{
|
if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
|
{
|
suitLevel = clothes.GetUseDataModel(30)[0];
|
}
|
}
|
}
|
|
Dictionary<int, int> dict = null;
|
EquipShowSwitch.IsGodWeaponEffectOn(PlayerDatas.Instance.baseData.equipShowSwitch, out dict);
|
if (dict != null && dict.ContainsKey(2))
|
{
|
dict.Remove(2);
|
}
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = _job,
|
fashionClothesId = flashClothesId,
|
fashionWeaponId = flashWeaponId,
|
fashionSecondaryId = flashSecondaryId,
|
clothesId = clothesId,
|
suitLevel = suitLevel,
|
weaponId = weaponId,
|
wingsId = wingsId,
|
secondaryId = secondaryId,
|
isDialogue = false,
|
godWeapons = dict
|
};
|
ShowOtherPlayer(_rawImage, data);
|
if (playerModel != null)
|
{
|
playerModel.SitDown();
|
}
|
}
|
|
public void ShowHourse(int _modelId, RawImage _rawImage)
|
{
|
StopShow();
|
m_ShowCamera.enabled = true;
|
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
|
var instance = UI3DModelFactory.LoadUIHorse(_modelId);
|
if (instance == null)
|
{
|
return;
|
}
|
|
isShowingHorse = true;
|
interactable = true;
|
|
m_HorseModelId = _modelId;
|
horseModel = instance;
|
|
m_HorseShowPoint.rotation = Quaternion.identity;
|
|
var modelConfig = ModelResConfig.Get(_modelId);
|
var position = modelConfig.UIOffset;
|
var rotation = modelConfig.UIRotation;
|
instance.transform.SetParentEx(m_HorseShowPoint, position, rotation, modelConfig.UIScale);
|
instance.SetActive(true);
|
ResetCameraColor();
|
|
ShowNpcEffect(instance.transform, modelConfig.ResourcesName);
|
}
|
|
private GameObject ObjEquipment;
|
public void ShowEquipment(int _modelId, Vector3 _localEulerAngles, RawImage _rawImage)
|
{
|
var instance = UI3DModelFactory.LoadUIWing(_modelId);
|
ObjEquipment = instance;
|
if (instance == null)
|
{
|
return;
|
}
|
|
StopShow();
|
|
isShowinEquipment = true;
|
interactable = true;
|
m_ShowCamera.enabled = true;
|
m_EquipmentModelId = _modelId;
|
equipmentModel = instance;
|
instance.transform.SetParentEx(m_EquipmentPoint, Vector3.zero, _localEulerAngles, Vector3.one);
|
instance.SetActive(true);
|
ResetCameraColor();
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
}
|
|
public void ShowWing(int _modelId, Vector3 _localEulerAngles, RawImage _rawImage)
|
{
|
StopShow();
|
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
|
var instance = UI3DModelFactory.LoadUIWing(_modelId);
|
if (instance == null)
|
{
|
return;
|
}
|
|
m_ShowCamera.enabled = true;
|
isShowWing = true;
|
interactable = true;
|
|
m_WingModelId = _modelId;
|
wingModel = instance;
|
|
m_WingShowPoint.rotation = Quaternion.identity;
|
var modelConfig = ModelResConfig.Get(_modelId);
|
var position = modelConfig.UIOffset;
|
var rotation = modelConfig.UIRotation;
|
instance.transform.SetParentEx(m_WingShowPoint, position, rotation, modelConfig.UIScale);
|
|
instance.SetActive(true);
|
ResetCameraColor();
|
var animator = instance.GetComponent<Animator>();
|
if (animator != null)
|
{
|
animator.Play("UI_Idle_Single");
|
}
|
}
|
|
public void ShowNPC(RawImage rawImage, UI3DNPCExhibitionData data)
|
{
|
StopShow();
|
ResetCameraColor();
|
var config = NPCConfig.Get(data.npcId);
|
m_NPCId = data.npcId;
|
var job = 0;
|
if (config.MODE.Contains("A_Zs"))
|
{
|
job = 1;
|
}
|
else if (config.MODE.Contains("A_Fs"))
|
{
|
job = 2;
|
}
|
|
var offset = config.UIModeLOffset;
|
var eulerAngles = config.UIModelRotation;
|
var scale = Vector3.one * config.UIModeLProportion;
|
|
var isPlayer = job != 0;
|
if (isPlayer)
|
{
|
var instance = UI3DModelFactory.LoadUINPC(data.npcId);
|
if (instance == null)
|
{
|
DebugEx.LogFormat("无法获得npc模型资源,id :{0}", data.npcId);
|
return;
|
}
|
|
instance.transform.SetParentEx(data.isDialogue ? m_DialogPoint : m_NPCShowPoint, offset, eulerAngles, scale);
|
npcModel = instance;
|
isShowingNPC = true;
|
|
var _configName = string.Empty;
|
|
if (job == 1)
|
{
|
_configName = config.MODE.Substring(config.MODE.LastIndexOf("A_"));
|
}
|
else if (job == 2)
|
{
|
_configName = config.MODE.Substring(config.MODE.LastIndexOf("A_"));
|
}
|
|
if (!string.IsNullOrEmpty(_configName))
|
{
|
var _renderer = instance.GetComponentInChildren<SkinnedMeshRenderer>();
|
if (_renderer)
|
{
|
MaterialLoader.Release(_renderer.material);
|
|
var _modelResConfig = ModelResConfig.GetClothesConfig(_configName);
|
if (_modelResConfig != null)
|
{
|
_renderer.material = MaterialLoader.LoadClothesMaterial(_modelResConfig.ID, false, false);
|
}
|
}
|
}
|
|
var ids = config.Equips.Split('|');
|
var weaponId = int.Parse(ids[0]);
|
var secondaryId = ids.Length > 1 ? int.Parse(ids[1]) : 0;
|
var wingId = ids.Length > 3 ? int.Parse(ids[3]) : 0;
|
|
playerModel.Show(instance, job, weaponId, wingId, secondaryId, m_PlayerShowPoint);
|
playerModel.TakeOffGodWeaponEffect();
|
playerModel.StandUp();
|
|
m_PlayerShowPoint.localEulerAngles = Vector3.zero;
|
isShowingPlayer = true;
|
|
interactable = true;
|
m_ShowCamera.enabled = true;
|
if (rawImage != null)
|
{
|
var x = rawImage.rectTransform.rect.height * 4f / 3;
|
var y = rawImage.rectTransform.rect.height;
|
rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
rawImage.texture = m_ShowCamera.targetTexture;
|
rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = rawImage.rectTransform;
|
}
|
}
|
else
|
{
|
ShowNPC(data.npcId, offset, eulerAngles, rawImage, data.gray, data.isDialogue);
|
}
|
}
|
|
public void ShowNPC(int _npcId, Vector3 _localEulerAngles, RawImage _rawImage, bool _gray = false, bool _isDialogue = false)
|
{
|
ShowNPC(_npcId, Vector3.zero, _localEulerAngles, _rawImage, _gray, _isDialogue);
|
}
|
|
public void ShowNPC(int _npcId, Vector3 _offset, Vector3 _localEulerAngles, RawImage _rawImage, bool _gray = false, bool _isDialogue = false)
|
{
|
StopShow();
|
m_ShowCamera.enabled = true;
|
m_NPCId = _npcId;
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
|
var instance = UI3DModelFactory.LoadUINPC(_npcId);
|
if (instance == null)
|
{
|
return;
|
}
|
|
interactable = !_isDialogue;
|
isShowingNPC = true;
|
|
if (!_isDialogue)
|
{
|
m_NPCShowPoint.localEulerAngles = _localEulerAngles;
|
}
|
|
npcModel = instance;
|
var config = NPCConfig.Get(_npcId);
|
instance.transform.SetParentEx(_isDialogue ? m_DialogPoint : m_NPCShowPoint, _offset, Quaternion.identity, Vector3.one * config.UIModeLProportion);
|
if (config.NPCEffect != 0)
|
{
|
var effectConfig = EffectConfig.Get(config.NPCEffect);
|
var parent = instance.transform;
|
if (!string.IsNullOrEmpty(effectConfig.nodeName))
|
{
|
parent = instance.transform.GetChildTransformDeeply(effectConfig.nodeName);
|
}
|
m_NpcEffect = SFXPlayUtility.Instance.PlayBattleEffect(config.NPCEffect, parent);
|
}
|
|
if (_isDialogue)
|
{
|
instance.transform.localEulerAngles = _localEulerAngles;
|
}
|
|
instance.SetActive(true);
|
|
if (npcModel)
|
{
|
ShowNpcEffect(npcModel.transform, config.MODE);
|
}
|
|
ResetCameraColor(_gray);
|
m_CameraColor.saturation = _gray ? 0.08f : 1f;
|
|
}
|
|
public void ShowGodWeaponEffect(int type, int level, RawImage _rawImage)
|
{
|
StopShow();
|
|
m_ShowCamera.enabled = true;
|
|
var job = PlayerDatas.Instance.baseData.Job;
|
var config = GodWeaponEffectConfig.Get(type, level);
|
var effectJson = LitJson.JsonMapper.ToObject(config.effect);
|
var effectId = int.Parse(effectJson[job.ToString()].ToString());
|
godWeaponEffect = SFXPlayUtility.Instance.PlayBattleEffect(effectId, m_GodWeaponEffectPoint);
|
|
if (godWeaponEffect != null)
|
{
|
var index = Mathf.Max(0, job - 1);
|
godWeaponEffect.transform.localPosition = index < config.effectPosition.Length ?
|
config.effectPosition[index] : Vector3.zero;
|
godWeaponEffect.transform.localEulerAngles = index < config.effectAngles.Length ?
|
config.effectAngles[index] : Vector3.zero;
|
godWeaponEffect.transform.localScale = index < config.effectScale.Length ?
|
config.effectScale[index] : Vector3.one;
|
}
|
|
if (_rawImage != null)
|
{
|
var x = _rawImage.rectTransform.rect.height * 4f / 3;
|
var y = _rawImage.rectTransform.rect.height;
|
_rawImage.rectTransform.sizeDelta = new Vector2(x, y);
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
m_InteractProcessor.rectTransform = _rawImage.rectTransform;
|
}
|
}
|
|
public void StopShow()
|
{
|
m_ShowCamera.enabled = false;
|
|
playerModel.Dispose();
|
isShowingPlayer = false;
|
|
if (m_NPCId != 0)
|
{
|
var config = NPCConfig.Get(m_NPCId);
|
if (config != null)
|
{
|
var job = 0;
|
if (config.MODE.Contains("A_Zs"))
|
{
|
job = 1;
|
}
|
else if (config.MODE.Contains("A_Fs"))
|
{
|
job = 2;
|
}
|
if (job != 0)
|
{
|
var _renderer = npcModel.GetComponentInChildren<SkinnedMeshRenderer>();
|
if (_renderer)
|
{
|
MaterialLoader.Release(_renderer.material);
|
_renderer.material = _renderer.sharedMaterial = null;
|
_renderer.materials = _renderer.sharedMaterials = new Material[0];
|
}
|
}
|
}
|
}
|
|
if (npcModel != null)
|
{
|
npcModel.transform.localScale = Vector3.one;
|
if (m_NpcEffect != null)
|
{
|
SFXPlayUtility.Instance.Release(m_NpcEffect);
|
m_NpcEffect = null;
|
}
|
|
UI3DModelFactory.ReleaseUINPC(m_NPCId, npcModel);
|
npcModel = null;
|
}
|
|
m_NPCId = 0;
|
isShowingNPC = false;
|
|
if (horseModel != null)
|
{
|
horseModel.transform.localScale = Vector3.one;
|
UI3DModelFactory.ReleaseUIHourse(m_HorseModelId, horseModel);
|
horseModel = null;
|
}
|
m_HorseModelId = 0;
|
isShowingHorse = false;
|
|
if (wingModel != null)
|
{
|
wingModel.transform.localScale = Vector3.one;
|
UI3DModelFactory.ReleaseUIWing(m_WingModelId, wingModel);
|
wingModel = null;
|
}
|
m_WingModelId = 0;
|
isShowWing = false;
|
|
if (equipmentModel != null)
|
{
|
UI3DModelFactory.ReleaseUIWing(m_EquipmentModelId, equipmentModel);
|
equipmentModel = null;
|
}
|
m_EquipmentModelId = 0;
|
isShowinEquipment = false;
|
|
if (godWeaponEffect != null)
|
{
|
SFXPlayUtility.Instance.Release(godWeaponEffect);
|
godWeaponEffect = null;
|
}
|
|
interactable = false;
|
}
|
|
public void ResetCameraColor(bool _enable = false)
|
{
|
m_CameraColor.enabled = _enable;
|
}
|
|
private void Awake()
|
{
|
m_InteractProcessor.clickEvent += OnClick3DModel;
|
m_InteractProcessor.beginDragEvent += OnBeginDrag3DModel;
|
m_InteractProcessor.endDragEvent += OnEndDrag3DModel;
|
m_InteractProcessor.dragingEvent += OnDrag3DModel;
|
}
|
|
private void OnDestroy()
|
{
|
m_InteractProcessor.clickEvent -= OnClick3DModel;
|
m_InteractProcessor.beginDragEvent -= OnBeginDrag3DModel;
|
m_InteractProcessor.endDragEvent -= OnEndDrag3DModel;
|
m_InteractProcessor.dragingEvent -= OnDrag3DModel;
|
}
|
|
private void LateUpdate()
|
{
|
if (isShowinEquipment && ObjEquipment != null)
|
{
|
if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
|
{
|
ObjEquipment.transform.Rotate(WindowCenter.Instance.Get<FirstTimeRechargeWin>().RotateVector * 1f, Space.Self);
|
}
|
if (WindowCenter.Instance.IsOpen("FirstChargeTrialWin"))
|
{
|
ObjEquipment.transform.Rotate(WindowCenter.Instance.Get<FirstChargeTrialWin>().RotateVector * 1f, Space.Self);
|
}
|
}
|
}
|
|
private void OnBeginDrag3DModel(Vector2 _position)
|
{
|
if (!m_Interactable)
|
{
|
return;
|
}
|
|
prePosition = _position;
|
}
|
|
private void OnDrag3DModel(Vector2 _position)
|
{
|
if (!m_Interactable)
|
{
|
return;
|
}
|
|
var delta = _position - prePosition;
|
if (isShowingPlayer)
|
{
|
m_PlayerShowPoint.localEulerAngles += new Vector3(0, -delta.x, 0);
|
}
|
|
if (isShowingHorse)
|
{
|
m_HorseShowPoint.localEulerAngles += new Vector3(0, -delta.x, 0);
|
}
|
|
if (isShowingNPC)
|
{
|
m_NPCShowPoint.localEulerAngles += new Vector3(0, -delta.x, 0);
|
}
|
|
prePosition = _position;
|
}
|
|
private void OnEndDrag3DModel(Vector2 _position)
|
{
|
if (!m_Interactable)
|
{
|
return;
|
}
|
}
|
|
private void OnClick3DModel()
|
{
|
if (!m_Interactable)
|
{
|
return;
|
}
|
}
|
|
private void ShowNpcEffect(Transform parent, string modelName)
|
{
|
HideNpcEffect();
|
|
var _boneList = ModelResConfig.GetBoneList(modelName);
|
var _effectlist = ModelResConfig.GetEffectList(modelName);
|
|
if (_boneList != null && _effectlist != null)
|
{
|
for (int i = 0; i < _boneList.Count; ++i)
|
{
|
if (_boneList[i].Equals("null"))
|
{
|
var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], parent);
|
m_BindEffectList.Add(_ctrl);
|
}
|
else
|
{
|
|
var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], parent.GetChildTransformDeeply(_boneList[i]));
|
m_BindEffectList.Add(_ctrl);
|
}
|
}
|
}
|
}
|
|
private void HideNpcEffect()
|
{
|
foreach (var _ctrl in m_BindEffectList)
|
{
|
SFXPlayUtility.Instance.Release(_ctrl);
|
}
|
m_BindEffectList.Clear();
|
}
|
}
|
|
public struct UI3DPlayerExhibitionData
|
{
|
public int job;
|
public int clothesId;
|
public int suitLevel;
|
public int weaponId;
|
public int wingsId;
|
public int secondaryId;
|
public int fashionClothesId;
|
public int fashionWeaponId;
|
public int fashionSecondaryId;
|
public bool isDialogue;
|
public Dictionary<int, int> godWeapons;
|
}
|
|
public struct UI3DNPCExhibitionData
|
{
|
public int npcId;
|
public bool gray;
|
public bool isDialogue;
|
}
|
}
|
|
|
|