先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
177 lines
5.9 KiB
C#
177 lines
5.9 KiB
C#
using cfg;
|
|
using asap.core;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.AddressableAssets;
|
|
using DG.Tweening;
|
|
using GameCore;
|
|
using game;
|
|
|
|
public class FishingAppearancePanel : MonoBehaviour
|
|
{
|
|
Tables _tables;
|
|
public float RodApperXOffset = -0.5f;
|
|
public float RodAppearTime = 0.2f;
|
|
IconRodRoot icon_rod;
|
|
RawImage rawImageRod;
|
|
|
|
GameObject loading;
|
|
private Dictionary<string, GameObject> rodAvatar = new Dictionary<string, GameObject>();
|
|
private List<GameObject> rodPrefab = new List<GameObject>();
|
|
RodData config;
|
|
RodSkinData skin;
|
|
|
|
GameObject currentRod;
|
|
Rod RodBehaviour;
|
|
ReviewNewRod reviewNewRod;
|
|
|
|
private void Awake()
|
|
{
|
|
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("FishingAppearancePanel");
|
|
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
loading = transform.Find("root/loading").gameObject;
|
|
rawImageRod = transform.Find("root/RawImageRod").GetComponent<RawImage>();
|
|
icon_rod = transform.Find("root/icon_rod").GetComponent<IconRodRoot>();
|
|
icon_rod.gameObject.SetActive(true);
|
|
icon_rod.SetRawImage(rawImageRod);
|
|
|
|
reviewNewRod = transform.Find("root/new_rod").GetComponent<ReviewNewRod>();
|
|
}
|
|
|
|
List<int> rodIds;
|
|
public void ShowNewRod(List<ItemData> itemDatas)
|
|
{
|
|
this.rodIds = new List<int>();
|
|
foreach (var item in itemDatas)
|
|
{
|
|
rodIds.Add(item.id);
|
|
}
|
|
rodIds.Sort();
|
|
int id = rodIds[0];
|
|
rodIds.RemoveAt(0);
|
|
config = _tables.TbRodData.GetOrDefault(id);
|
|
skin = _tables.TbRodSkinData.GetOrDefault(config.ID);
|
|
reviewNewRod.SetCurData(config, NextNewRod);
|
|
LoadRodAsync(skin.Fbx);
|
|
}
|
|
|
|
public void NextNewRod()
|
|
{
|
|
if (rodIds.Count == 0)
|
|
{
|
|
UIManager.Instance.DestroyUI(UITypes.FishingAppearancePanel);
|
|
GContext.Publish(new ShowData(RewardType.Destroy));
|
|
return;
|
|
}
|
|
int id = rodIds[0];
|
|
rodIds.RemoveAt(0);
|
|
config = _tables.TbRodData.GetOrDefault(id);
|
|
skin = _tables.TbRodSkinData.GetOrDefault(config.ID);
|
|
reviewNewRod.gameObject.SetActive(true);
|
|
reviewNewRod.SetCurData(config);
|
|
LoadRodAsync(skin.Fbx);
|
|
}
|
|
|
|
async void LoadRodAsync(string fbx)
|
|
{
|
|
GameObject _currentRod = null;
|
|
if (rodAvatar.ContainsKey(fbx))
|
|
{
|
|
_currentRod = rodAvatar[fbx];
|
|
}
|
|
else
|
|
{
|
|
var prefab = await Addressables.LoadAssetAsync<GameObject>(fbx).Task;
|
|
if (this == null)
|
|
{
|
|
Addressables.Release(prefab);
|
|
return;
|
|
}
|
|
if (rodAvatar.ContainsKey(fbx))
|
|
{
|
|
Addressables.Release(prefab);
|
|
_currentRod = rodAvatar[fbx];
|
|
}
|
|
else if (prefab != null)
|
|
{
|
|
rodPrefab.Add(prefab);
|
|
var go = Instantiate(prefab, icon_rod.avatar);
|
|
rodAvatar.Add(fbx, go);
|
|
go.SetActive(false);
|
|
Rod rod = go.GetComponent<Rod>();
|
|
rod.cCDIK.enabled = false;
|
|
_currentRod = go;
|
|
}
|
|
}
|
|
if (fbx == skin.Fbx && _currentRod != null)
|
|
{
|
|
InitRod(_currentRod, fbx);
|
|
}
|
|
}
|
|
|
|
void InitRod(GameObject _currentRod, string fbx)
|
|
{
|
|
icon_rod.avatar.gameObject.SetActive(false);
|
|
loading.SetActive(true);
|
|
if (fbx == skin.Fbx && _currentRod != null)
|
|
{
|
|
if (currentRod != null)
|
|
{
|
|
currentRod.SetActive(false);
|
|
}
|
|
//加载模型完成
|
|
loading.SetActive(false);
|
|
icon_rod.avatar.gameObject.SetActive(true);
|
|
currentRod = _currentRod;
|
|
currentRod.transform.localPosition = new Vector3(skin.DisplayPosition[0], skin.DisplayPosition[1], skin.DisplayPosition[2]);
|
|
currentRod.transform.localRotation = Quaternion.Euler(skin.DisplayRotation[0], skin.DisplayRotation[1], skin.DisplayRotation[2]);
|
|
currentRod.transform.localScale = Vector3.one * skin.DisplayScale;
|
|
currentRod.SetActive(true);
|
|
RodBehaviour = currentRod.GetComponent<Rod>();
|
|
RodBehaviour.rod.GetComponent<Animator>().Play("Show01");
|
|
for (int i = 0; i < icon_rod.fx_fishingrods.Length; i++)
|
|
{
|
|
icon_rod.fx_fishingrods[i].SetActive(config.Quality - 2 == i);
|
|
}
|
|
StartDoRotate();
|
|
icon_rod.avatar.DOKill();
|
|
icon_rod.avatar.localPosition = new Vector3(RodApperXOffset, 0, 0);
|
|
icon_rod.avatar.DOLocalMove(Vector3.zero, RodAppearTime);
|
|
}
|
|
}
|
|
|
|
private Transform _rotateTarget;
|
|
void StartDoRotate()
|
|
{
|
|
if (currentRod is null)
|
|
{
|
|
Debug.Log($"<color=#9858ad>Empty rod. No rod to rotate.</color>");
|
|
return;
|
|
}
|
|
// Debug.Log($"<color=#9858ad>{currentRod.transform.GetChild(0).name}</color>");
|
|
if (_rotateTarget != null)
|
|
{
|
|
_rotateTarget.DOKill();
|
|
}
|
|
_rotateTarget = currentRod.transform.GetChild(0);
|
|
var endRotation = _rotateTarget.localRotation.eulerAngles + new Vector3(0, 360, 0);
|
|
_rotateTarget.DOKill();
|
|
_rotateTarget.DOLocalRotate(endRotation, 10f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
|
|
/*
|
|
Debug.Log($"<color=#9858ad>Empty rod.</color>");
|
|
Debug.Log($"<color=#9858ad>Empty rod.</color>");
|
|
avatar.DOKill();
|
|
avatar.DOLocalRotate(Vector3.up * (avatar.localEulerAngles.y + 360), 10f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
|
|
*/
|
|
}
|
|
protected void OnDestroy()
|
|
{
|
|
for (int i = 0; i < rodPrefab.Count; i++)
|
|
{
|
|
Addressables.Release(rodPrefab[i]);
|
|
}
|
|
}
|
|
}
|