Human interactor inside hall

This commit is contained in:
Sewmina
2022-05-01 23:03:28 +05:30
parent fef687b701
commit ab4be7e108
14 changed files with 1663 additions and 823 deletions

View File

@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class HumanInteractor : MonoBehaviour
{
public GameObject[] showingObjects;
public UnityEvent OnInteraction;
public UnityEvent OnClose;
private bool showing;
[SerializeField]
public bool Showing => showing;
void Start()
{
Selector.OnSelectedChanged.AddListener(OnSelectionChanged);
Refresh();
}
void OnSelectionChanged(){
Toggle(Selector.selectedHuman==this);
}
public void Toggle(){
showing = !showing;
Refresh();
}
public void Toggle(bool value){
showing = value;
Refresh();
}
public void Refresh(){
foreach(GameObject go in showingObjects){
go.SetActive(showing);
}
if(!showing){
OnClose.Invoke();
}else{
OnInteraction.Invoke();
}
}
}