mirror of
https://github.com/Project-Redacted/project-hampter.git
synced 2025-05-31 15:53:15 +00:00
Update :3
This commit is contained in:
parent
1f50b3f262
commit
6bbd56a5cf
759 changed files with 269694 additions and 37600 deletions
60
Assets/Key/KeyScripts/keyHolder.cs
Normal file
60
Assets/Key/KeyScripts/keyHolder.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class keyHolder : MonoBehaviour
|
||||
{
|
||||
|
||||
public event EventHandler OnKeysChanged;
|
||||
public bool AllKeys = false;
|
||||
private List<Key.KeyType> keyList;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
keyList = new List<Key.KeyType>();
|
||||
}
|
||||
|
||||
public List<Key.KeyType> GetKeyList()
|
||||
{
|
||||
return keyList;
|
||||
}
|
||||
|
||||
public void AddKey(Key.KeyType keyType)
|
||||
{
|
||||
keyList.Add(keyType);
|
||||
OnKeysChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void RemoveKey(Key.KeyType keyType)
|
||||
{
|
||||
keyList.Remove(keyType);
|
||||
OnKeysChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public bool ContainsKey(Key.KeyType keyType)
|
||||
{
|
||||
return keyList.Contains(keyType);
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider collider)
|
||||
{
|
||||
Key key = collider.GetComponent<Key>();
|
||||
if (key != null)
|
||||
{
|
||||
AddKey(key.GetKeyType());
|
||||
Destroy(key.gameObject);
|
||||
|
||||
}
|
||||
|
||||
KeyDoor keyDoor = collider.GetComponent<KeyDoor>();
|
||||
if (keyDoor != null)
|
||||
{
|
||||
if (ContainsKey(keyDoor.GetKeyType()))
|
||||
{
|
||||
RemoveKey(keyDoor.GetKeyType());
|
||||
keyDoor.OpenDoor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue