Update :3

This commit is contained in:
Michał Gdula 2023-03-24 10:33:36 +00:00
parent 1f50b3f262
commit 6bbd56a5cf
759 changed files with 269694 additions and 37600 deletions

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class Key : MonoBehaviour
{
[SerializeField] private KeyType keyType;
public int KeyNumber;
public enum KeyType
{
Red,
Green,
Blue
}
public KeyType GetKeyType()
{
return keyType;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89d7c77cd3e87864aa9ebbad136269d7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class KeyDoor : MonoBehaviour
{
[SerializeField] private Key.KeyType keyType;
[SerializeField] int keyNeeded;
public Key.KeyType GetKeyType()
{
return keyType;
}
public void OpenDoor()
{
gameObject.SetActive(false);
}
private void OnTriggerEnter(Collider other)
{
Key key = other.GetComponent<Key>();
if (key != null)
{
if(key.KeyNumber == keyNeeded)
{
other.gameObject.SetActive(false);
alertEnemies();
Invoke("OpenDoor", 10);
}
}
}
public void alertEnemies()
{
GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
GameObject closest = null;
foreach(GameObject enemy in enemies)
{
if(closest == null)
{
closest = enemy;
}
if(Vector3.Distance(closest.transform.position, transform.position) > Vector3.Distance(enemy.transform.position, transform.position))
{
closest = enemy;
}
}
closest.GetComponent<AIMovement>().Alert(transform.position);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f75dc57d18e125d418a47276090cbe40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,37 @@
//using UnityEngine;
//public class Move : MonoBehaviour
//{
//public float rotationSpeed = 50f;
// Update is called once per frame
// void Update()
// {
// transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y + (rotationSpeed * Time.deltaTime), 0);
// }
//}
using UnityEngine;
public class Move : MonoBehaviour
{
public float rotationSpeed = 10f;
public float movementSpeed = 1f;
public float movementRange = 1f;
private Vector3 startPosition;
private void Start()
{
startPosition = transform.position;
}
private void Update()
{
// Rotate the object around the Y axis at the specified speed
transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime);
// Move the object up and down within a specified range
Vector3 newPosition = startPosition + new Vector3(0, Mathf.Sin(Time.time * movementSpeed) * movementRange, 0);
transform.position = newPosition;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 40d481756ef142640ba7b14025795d61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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();
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35065700f6f3b4348a904478a3860dab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: