using System.Collections; using System.Collections.Generic; using UnityEngine; using Snxxz.UI; public class SelectRoleBehaviour { GameObject behaviour; Camera ceateRoleCamera; CreateRoleHeroPlatform platform; ActorShadowCaster shadow; UI3DShowHero playerModel = new UI3DShowHero(); public void Show() { LoadAssets(CreateRoleScriptableObject.GetJobParams(PlayerDatas.Instance.loginInfo.Job)); playerModel.Dispose(); var fashionClothes = 0; var fashionWeapon = 0; var fashionSecondary = 0; 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]; var itemConfig = ItemConfig.Get((int)equipInfo.ItemID); switch ((RoleEquipType)itemConfig.EquipPlace) { case RoleEquipType.FashionClothes: fashionClothes = (int)equipInfo.ItemID; break; case RoleEquipType.FashionWeapon: fashionWeapon = (int)equipInfo.ItemID; break; case RoleEquipType.FashionWeapon2: fashionSecondary = (int)equipInfo.ItemID; break; case RoleEquipType.Weapon: weaponItemId = (int)equipInfo.ItemID; break; case RoleEquipType.Clothes: clothesItemId = (int)equipInfo.ItemID; break; case RoleEquipType.Wing: wingsItemId = (int)equipInfo.ItemID; break; case RoleEquipType.Weapon2: secondaryItemId = (int)equipInfo.ItemID; break; } } var data = new UI3DPlayerExhibitionData() { job = PlayerDatas.Instance.loginInfo.Job, fashionClothesId = fashionClothes, clothesId = clothesItemId, suitLevel = suitLevel, fashionWeaponId = fashionWeapon, weaponId = weaponItemId, wingsId = wingsItemId, fashionSecondaryId = fashionSecondary, secondaryId = secondaryItemId, }; ceateRoleCamera.gameObject.SetActive(true); var model = playerModel.Show(data, platform.transform); playerModel.StandUp(); shadow.gameObject.SetActive(true); shadow.Cast(model.transform); } public void Hide() { if (ceateRoleCamera != null) { ceateRoleCamera.gameObject.SetActive(false); } if (shadow != null) { shadow.gameObject.SetActive(false); } } public void Dispose() { behaviour = null; ceateRoleCamera = null; platform = null; shadow = null; playerModel = null; } private void LoadAssets(CreateRoleScriptableObject.RoleShowParams showParams) { if (behaviour == null) { var prefab = SceneLoader.LoadCreateRole(showParams.platformPrefabName); behaviour = GameObject.Instantiate(prefab, showParams.platformPosition, Quaternion.identity); behaviour.name = showParams.platformPrefabName; shadow = behaviour.GetComponentInChildren(); platform = behaviour.GetComponentInChildren(); ceateRoleCamera = behaviour.GetComponentInChildren(); } } }