forked from zxl/LaboratoryProtection
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
|
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 void ShowRole(DialogueType left, DialogueType right)
|
|||
|
{
|
|||
|
HideAllRole();
|
|||
|
if (dictionary.TryGetValue(left, out GameObject leftGo))
|
|||
|
{
|
|||
|
leftGo.SetActive(true);
|
|||
|
leftGo.transform.position = leftPoint.position;
|
|||
|
leftGo.transform.rotation = leftPoint.rotation;
|
|||
|
}
|
|||
|
|
|||
|
if (dictionary.TryGetValue(right, out GameObject rightGo))
|
|||
|
{
|
|||
|
rightGo.SetActive(true);
|
|||
|
rightGo.transform.position = rightPoint.position;
|
|||
|
rightGo.transform.rotation = rightPoint.rotation;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void HideAllRole()
|
|||
|
{
|
|||
|
foreach (var value in dictionary.Values)
|
|||
|
{
|
|||
|
value.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public GameObject Get(DialogueType dialogueType)
|
|||
|
{
|
|||
|
dictionary.TryGetValue(dialogueType, out GameObject go);
|
|||
|
return go;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|