1
0
Fork 0
LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/DialogueRoleManager.cs

71 lines
2.1 KiB
C#
Raw Normal View History

2023-09-13 15:04:19 +08:00
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace UnityTest.ZXL
{
public class DialogueRoleManager : BaseAutoMono<DialogueRoleManager>
{
public Transform leftPoint;
public Transform rightPoint;
public Dictionary<DialogueType, GameObject> dictionary = new Dictionary<DialogueType, GameObject>();
private void Awake()
{
HideAllRole();
}
#if UNITY_EDITOR
[Button]
#endif
public List<Animator> ShowRole(DialogueType left, DialogueType right)
2023-09-13 15:04:19 +08:00
{
HideAllRole();
if (!dictionary.TryGetValue(left, out GameObject leftGo))
return null;
2023-09-13 15:04:19 +08:00
leftPoint.gameObject.SetActive(true);
leftGo.SetActive(true);
leftGo.transform.position = leftPoint.position;
leftGo.transform.rotation = leftPoint.rotation;
if (!dictionary.TryGetValue(right, out GameObject rightGo))
return null;
rightPoint.gameObject.SetActive(true);
rightGo.SetActive(true);
2023-09-19 09:50:35 +08:00
rightGo.transform.position = rightPoint.position;
rightGo.transform.rotation = rightPoint.rotation;
2023-09-19 09:50:35 +08:00
if (right == DialogueType.119)
rightGo.transform.position += new Vector3(0.030f, 0.342f, 0.2544f);
List<Animator> list = new List<Animator>();
var leftAni = leftGo.GetComponent<Animator>();
list.Add(leftAni);
var rightAni = rightGo.GetComponent<Animator>();
list.Add(rightAni);
return list;
2023-09-13 15:04:19 +08:00
}
public void HideAllRole()
{
foreach (var value in dictionary.Values)
{
value.SetActive(false);
value.GetComponent<Animator>().enabled = false;
2023-09-13 15:04:19 +08:00
}
leftPoint.gameObject.SetActive(true);
rightPoint.gameObject.SetActive(true);
2023-09-13 15:04:19 +08:00
}
public GameObject Get(DialogueType dialogueType)
{
dictionary.TryGetValue(dialogueType, out GameObject go);
return go;
}
}
}