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
|
2023-09-19 01:12:41 +08:00
|
|
|
|
public List<Animator> ShowRole(DialogueType left, DialogueType right)
|
2023-09-13 15:04:19 +08:00
|
|
|
|
{
|
|
|
|
|
HideAllRole();
|
2023-09-19 01:12:41 +08:00
|
|
|
|
if (!dictionary.TryGetValue(left, out GameObject leftGo))
|
|
|
|
|
return null;
|
2023-09-13 15:04:19 +08:00
|
|
|
|
|
2023-09-19 01:12:41 +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);
|
|
|
|
|
rightGo.transform.position = rightPoint.position;
|
|
|
|
|
rightGo.transform.rotation = rightPoint.rotation;
|
|
|
|
|
|
|
|
|
|
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);
|
2023-09-19 01:12:41 +08:00
|
|
|
|
value.GetComponent<Animator>().enabled = false;
|
2023-09-13 15:04:19 +08:00
|
|
|
|
}
|
2023-09-19 01:12:41 +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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|