Assemblied created

This commit is contained in:
2023-06-02 00:30:58 -04:00
parent 3e1b55b036
commit 63039dbde2
99 changed files with 8302 additions and 1065 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ffb312c0cba800244824866e8c414e45
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -25,14 +25,15 @@ public class SkinlessMonsterComponent : MonoBehaviour
private bool atTarget;
private float distanceToPlayer;
private FlareRegister flareRegister;
private Item.FlareRegister flareRegister;
private bool inDamageMargin;
private bool inDamageRange;
private bool isAlive = true;
private Game.InGameManager manager;
private Vector3 oppositeVector;
@ -51,12 +52,12 @@ public class SkinlessMonsterComponent : MonoBehaviour
if (p.isActiveAndEnabled)
player = p;
manager = FindObjectOfType<Game.InGameManager>();
}
private void Start()
{
flareRegister = FindObjectOfType<FlareRegister>();
flareRegister = FindObjectOfType<Item.FlareRegister>();
if (targetObject == null)
targetObject = new GameObject();
targetObject.name = "Enemy Target";
@ -106,8 +107,8 @@ public class SkinlessMonsterComponent : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.GetComponent<BulletComponent>() != null)
health -= other.gameObject.GetComponent<BulletComponent>().DamageMagnitude;
if (other.gameObject.GetComponent<Item.BulletComponent>() != null)
health -= other.gameObject.GetComponent<Item.BulletComponent>().DamageMagnitude;
}
private void HandleTargetOperations()
@ -269,7 +270,7 @@ public class SkinlessMonsterComponent : MonoBehaviour
//Stop();
return;
BulletComponent closestBullet = null;
Item.BulletComponent closestBullet = null;
var closestDistance = Mathf.Infinity;
foreach (var bullet in flareRegister.bullets)
{

View File

@ -19,7 +19,7 @@ namespace Enemy
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.GetComponent<BulletComponent>() != null) anim.Play("DummyFall");
if (collision.gameObject.GetComponent<Item.BulletComponent>() != null) anim.Play("DummyFall");
}
}
}

View File

@ -0,0 +1,25 @@
{
"name": "Game_Assembly",
"rootNamespace": "Game",
"references": [
"GUID:457756d89b35d2941b3e7b37b4ece6f1",
"GUID:a075b55b404a34748ac14ea9b6039911",
"GUID:78bd2ddd6e276394a9615c203e574844",
"GUID:344e024b5bc996043a11da352e2c9150",
"GUID:304b399c7a7ca8f45afdcd73cf5552b3",
"GUID:5b5e144fbbfa9e24188cdc68fa9a4b3c",
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
"GUID:6e5480588ffa37d4f82fe96c45e8ce9c",
"GUID:bf043f86dbf1bda4398ec83eebe40b8c",
"GUID:f0bbd04fc036a3046993adc87bbfb698"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ed2e13dc5752a434aadb5bd0b74dd42a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,11 +4,14 @@ using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
namespace Game
{
public class InGameManager : MonoBehaviour
{
[SerializeField] private Volume gameVolume;
[SerializeField] private Volume pausedVolume;
@ -27,6 +30,7 @@ public class InGameManager : MonoBehaviour
private bool isTransitioning;
public bool IsPaused => isPaused;
[SerializeField] private Scriptable.GameState state;
// Start is called before the first frame update
private void Start()
@ -45,6 +49,7 @@ public class InGameManager : MonoBehaviour
// Update is called once per frame
private void Update()
{
state.IsPaused = isPaused;
if (Input.GetButtonDown("Pause")) TogglePause();
if (isTransitioning || true)

View File

@ -15,7 +15,7 @@ namespace Game
private InGameManager gameManager;
private Animator menuAnimator;
private Player.PlayerComponent player;
[SerializeField] private Scriptable.GameSettings settings;
// Start is called before the first frame update
private void Start()
@ -23,7 +23,7 @@ namespace Game
menuAnimator = GetComponent<Animator>();
settingsButton.onClick.AddListener(SettingsClicked);
returnToMenuButton.onClick.AddListener(SettingsUnClicked);
player = FindObjectOfType(typeof(Player.PlayerComponent)) as Player.PlayerComponent;
gameManager = FindObjectOfType<InGameManager>();
}
@ -44,7 +44,8 @@ namespace Game
public void UpdateSensitivity()
{
player.SetSensitivity(sensitivitySlider.value * 4f);
//player.SetSensitivity(sensitivitySlider.value * 4f);
settings.Sensitivity = sensitivitySlider.value * 4f;
}
public void UpdateVolume()

View File

@ -1,5 +1,5 @@
using UnityEngine;
namespace Item {
public class Insertable : MonoBehaviour
{
// Start is called before the first frame update
@ -11,4 +11,5 @@ public class Insertable : MonoBehaviour
private void Update()
{
}
}
}

View File

@ -1,4 +1,7 @@
using UnityEngine;
namespace Item
{
public class Interactable : MonoBehaviour
{
@ -11,4 +14,5 @@ public class Interactable : MonoBehaviour
private void Update()
{
}
}
}

View File

@ -1,44 +1,46 @@
using UnityEngine;
public class ItemSelector : MonoBehaviour
namespace Item
{
public static ItemSelector instance;
[SerializeField] private Camera cam;
[SerializeField] private LayerMask mask;
[SerializeField] private float range = 1;
public InteractableItem Selected { get; private set; }
// Start is called before the first frame update
private void Start()
public class ItemSelector : MonoBehaviour
{
instance = this;
}
public static ItemSelector instance;
// Update is called once per frame
private void Update()
{
}
[SerializeField] private Camera cam;
private void FixedUpdate()
{
var ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
[SerializeField] private LayerMask mask;
if (Physics.Raycast(ray, out hit, range, mask))
[SerializeField] private float range = 1;
public InteractableItem Selected { get; private set; }
// Start is called before the first frame update
private void Start()
{
if (Selected != null || hit.transform.gameObject == null) Selected.Disable();
Selected = hit.transform.gameObject.GetComponent<InteractableItem>();
Selected.Enable();
print(Selected);
instance = this;
}
else
// Update is called once per frame
private void Update()
{
if (Selected != null) Selected.Disable();
}
private void FixedUpdate()
{
var ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, range, mask))
{
if (Selected != null || hit.transform.gameObject == null) Selected.Disable();
Selected = hit.transform.gameObject.GetComponent<InteractableItem>();
Selected.Enable();
print(Selected);
}
else
{
if (Selected != null) Selected.Disable();
}
}
}
}

View File

@ -1,67 +1,70 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Inventory:
/// <list type="bullet">Inventory Name: The name of the inventory.</list>
/// <list type="bullet">Inventory Size: The amount of size the inventory has.</list>
/// <list type="bullet">
/// Invetory Items: List of all items in the inventory. No items in the world are "destroyed"
/// instead all items in inventory are disabled, but can be looked up by their item name.
/// </list>
/// </summary>
public class Inventory : MonoBehaviour
namespace Item
{
[SerializeField] private string inventoryName;
[SerializeField] private int inventorySize;
[SerializeField] private List<string> inventoryItems;
private int inventoryReserved;
/// <summary>
/// Adds item to inventory. Does not disable.
/// Inventory:
/// <list type="bullet">Inventory Name: The name of the inventory.</list>
/// <list type="bullet">Inventory Size: The amount of size the inventory has.</list>
/// <list type="bullet">
/// Invetory Items: List of all items in the inventory. No items in the world are "destroyed"
/// instead all items in inventory are disabled, but can be looked up by their item name.
/// </list>
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool AddItem(CarryableItem item)
public class Inventory : MonoBehaviour
{
if (item.ItemSize + inventoryReserved > inventorySize) return false;
inventoryItems.Add(item.ItemName);
inventoryReserved += item.ItemSize;
//item.gameObject.SetActive(false);
return true;
}
[SerializeField] private string inventoryName;
private bool FindItemOfName(string name, out CarryableItem item)
{
//NOTE: May not work. May need to move instead of disable objects.
var items = Resources.FindObjectsOfTypeAll<CarryableItem>();
[SerializeField] private int inventorySize;
foreach (var item2 in items)
if (item2.ItemName == name)
{
item = item2;
return true;
}
[SerializeField] private List<string> inventoryItems;
item = null;
return false;
}
private int inventoryReserved;
public bool RemoveItem(string name)
{
CarryableItem itemFound;
if (FindItemOfName(name, out itemFound))
/// <summary>
/// Adds item to inventory. Does not disable.
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool AddItem(Item.CarryableItem item)
{
itemFound.gameObject.SetActive(true);
inventoryItems.Remove(itemFound.ItemName);
inventoryReserved -= itemFound.ItemSize;
if (item.ItemSize + inventoryReserved > inventorySize) return false;
inventoryItems.Add(item.ItemName);
inventoryReserved += item.ItemSize;
//item.gameObject.SetActive(false);
return true;
}
private bool FindItemOfName(string name, out Item.CarryableItem item)
{
//NOTE: May not work. May need to move instead of disable objects.
var items = Resources.FindObjectsOfTypeAll<Item.CarryableItem>();
return false;
foreach (var item2 in items)
if (item2.ItemName == name)
{
item = item2;
return true;
}
item = null;
return false;
}
public bool RemoveItem(string name)
{
Item.CarryableItem itemFound;
if (FindItemOfName(name, out itemFound))
{
itemFound.gameObject.SetActive(true);
inventoryItems.Remove(itemFound.ItemName);
inventoryReserved -= itemFound.ItemSize;
return true;
}
return false;
}
}
}

View File

@ -2,53 +2,56 @@ using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class TempInventoryBuilderItem
namespace Item
{
public string name;
public int quantity;
}
public class TempInventory : MonoBehaviour
{
[SerializeField] private List<TempInventoryBuilderItem> initialInvent = new();
private readonly Dictionary<string, int> inventory = new();
// Start is called before the first frame update
private void Start()
[Serializable]
public class TempInventoryBuilderItem
{
foreach (var item in initialInvent) inventory[item.name] = item.quantity;
public string name;
public int quantity;
}
// Update is called once per frame
private void Update()
public class TempInventory : MonoBehaviour
{
}
[SerializeField] private List<TempInventoryBuilderItem> initialInvent = new();
public int GetQuantityOf(string name)
{
if (inventory.ContainsKey(name)) return inventory[name];
return 0;
}
private readonly Dictionary<string, int> inventory = new();
public bool Add(string name, int quantity = 1)
{
if (inventory.ContainsKey(name))
inventory[name] += quantity;
else
inventory.Add(name, quantity);
return true;
}
public bool Remove(string name, int quantity = 1)
{
if (inventory.ContainsKey(name))
// Start is called before the first frame update
private void Start()
{
inventory[name] = Mathf.Max(inventory[name] - quantity, 0);
return false;
foreach (var item in initialInvent) inventory[item.name] = item.quantity;
}
return false;
// Update is called once per frame
private void Update()
{
}
public int GetQuantityOf(string name)
{
if (inventory.ContainsKey(name)) return inventory[name];
return 0;
}
public bool Add(string name, int quantity = 1)
{
if (inventory.ContainsKey(name))
inventory[name] += quantity;
else
inventory.Add(name, quantity);
return true;
}
public bool Remove(string name, int quantity = 1)
{
if (inventory.ContainsKey(name))
{
inventory[name] = Mathf.Max(inventory[name] - quantity, 0);
return false;
}
return false;
}
}
}

View File

@ -1,13 +1,16 @@
using UnityEngine;
[RequireComponent(typeof(Collider))]
[RequireComponent(typeof(Rigidbody))]
public abstract class CarryableItem : MonoBehaviour
namespace Item
{
[SerializeField] private string itemName;
[RequireComponent(typeof(Collider))]
[RequireComponent(typeof(Rigidbody))]
public abstract class CarryableItem : MonoBehaviour
{
[SerializeField] private string itemName;
[SerializeField] private int itemSize = 1;
[SerializeField] private int itemSize = 1;
public string ItemName => itemName;
public int ItemSize => itemSize;
}
public string ItemName => itemName;
public int ItemSize => itemSize;
}
}

View File

@ -1,96 +1,98 @@
using UnityEngine;
public class DoorInteractable : HeavyItemReceiver
namespace Item
{
[SerializeField] private Transform powerCoreCenter;
[SerializeField] private float minAttractDist = 5;
[SerializeField] private string nameSearched = "Power Core";
[SerializeField] private Animator[] anims;
private HeavyInteractableItem insertedCore;
private Vector3 priorLocalPos;
private Vector3 priorLocalRot;
private Vector3 priorScale;
public bool Powered => insertedCore != null;
// Start is called before the first frame update
private void Start()
public class DoorInteractable : HeavyItemReceiver
{
}
[SerializeField] private Transform powerCoreCenter;
// Update is called once per frame
private void Update()
{
foreach (var anim in anims) anim.SetBool("IsPowered", Powered);
}
[SerializeField] private float minAttractDist = 5;
public override bool Interact()
{
//print("INTERACTED!");
if (insertedCore == null)
[SerializeField] private string nameSearched = "Power Core";
[SerializeField] private Animator[] anims;
private HeavyInteractableItem insertedCore;
private Vector3 priorLocalPos;
private Vector3 priorLocalRot;
private Vector3 priorScale;
public bool Powered => insertedCore != null;
// Start is called before the first frame update
private void Start()
{
var worldHeavyItems = FindObjectsOfType<HeavyInteractableItem>();
//print("Found:" + worldHeavyItems.Length);
for (var i = 0; i < worldHeavyItems.Length; i++)
{
var item = worldHeavyItems[i];
}
if (!item.ItemName.Contains(nameSearched)) continue;
var dist = Vector3.Distance(item.transform.position, powerCoreCenter.transform.position);
//print("DIST:" + dist);
if (dist <= minAttractDist)
// Update is called once per frame
private void Update()
{
foreach (var anim in anims) anim.SetBool("IsPowered", Powered);
}
public override bool Interact()
{
//print("INTERACTED!");
if (insertedCore == null)
{
var worldHeavyItems = FindObjectsOfType<HeavyInteractableItem>();
//print("Found:" + worldHeavyItems.Length);
for (var i = 0; i < worldHeavyItems.Length; i++)
{
var _i = Player.PlayerInteractionHandler.instance.Inventory;
Interact(ref _i, ref item);
return true;
var item = worldHeavyItems[i];
if (!item.ItemName.Contains(nameSearched)) continue;
var dist = Vector3.Distance(item.transform.position, powerCoreCenter.transform.position);
//print("DIST:" + dist);
if (dist <= minAttractDist)
{
var _i = Player.PlayerInteractionHandler.instance.Inventory;
Interact(ref _i, ref item);
return true;
}
}
}
return false;
}
return false;
}
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
//print("INTERACTED 2");
// print(heavyInvent);
if (heavyInvent != null && heavyInvent.ItemName.Contains(nameSearched))
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
//print("DOOR OPEN!");
heavyInvent.GetComponent<Rigidbody>().isKinematic = true;
//print("INTERACTED 2");
// print(heavyInvent);
heavyInvent.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
priorLocalPos = heavyInvent.transform.localPosition;
priorLocalRot = heavyInvent.transform.localEulerAngles;
priorScale = heavyInvent.transform.localScale;
if (heavyInvent != null && heavyInvent.ItemName.Contains(nameSearched))
{
//print("DOOR OPEN!");
heavyInvent.GetComponent<Rigidbody>().isKinematic = true;
heavyInvent.transform.parent = powerCoreCenter;
heavyInvent.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
priorLocalPos = heavyInvent.transform.localPosition;
priorLocalRot = heavyInvent.transform.localEulerAngles;
priorScale = heavyInvent.transform.localScale;
heavyInvent.gameObject.transform.localPosition = Vector3.zero;
heavyInvent.gameObject.transform.localEulerAngles = Vector3.zero;
heavyInvent.transform.parent = null;
heavyInvent.gameObject.transform.localScale = priorScale;
heavyInvent.transform.parent = powerCoreCenter;
insertedCore = heavyInvent;
heavyInvent.gameObject.transform.localPosition = Vector3.zero;
heavyInvent.gameObject.transform.localEulerAngles = Vector3.zero;
heavyInvent.transform.parent = null;
heavyInvent.gameObject.transform.localScale = priorScale;
return true;
insertedCore = heavyInvent;
return true;
}
if (insertedCore != null && heavyInvent == null)
{
heavyInvent = insertedCore;
insertedCore = null;
//get ref of player perhaps
return true;
}
return false;
}
if (insertedCore != null && heavyInvent == null)
{
heavyInvent = insertedCore;
insertedCore = null;
//get ref of player perhaps
return true;
}
return false;
}
}

View File

@ -2,68 +2,71 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class FlareBeacon : MonoBehaviour
namespace Item
{
[SerializeField] private float range = 1;
[SerializeField] private float duration = 5f;
[SerializeField] private NavMeshObstacle obstacle;
private readonly List<GameObject> inRange = new();
private FlareRegister register;
public float Range => range;
// Start is called before the first frame update
private void Start()
public class FlareBeacon : MonoBehaviour
{
register = FlareRegister.instance;
register.beacons.Add(this);
transform.localEulerAngles = new Vector3(-89.98f, 0, 0);
var r = new Ray();
r.direction = -transform.forward;
r.origin = transform.position;
RaycastHit hit;
var rays = Physics.RaycastAll(r);
foreach (var _hit in rays)
[SerializeField] private float range = 1;
[SerializeField] private float duration = 5f;
[SerializeField] private NavMeshObstacle obstacle;
private readonly List<GameObject> inRange = new();
private Item.FlareRegister register;
public float Range => range;
// Start is called before the first frame update
private void Start()
{
if (_hit.transform.gameObject.GetComponent<FlareBeacon>() != null) continue;
transform.position = _hit.point;
break;
register = Item.FlareRegister.instance;
register.beacons.Add(this);
transform.localEulerAngles = new Vector3(-89.98f, 0, 0);
var r = new Ray();
r.direction = -transform.forward;
r.origin = transform.position;
RaycastHit hit;
var rays = Physics.RaycastAll(r);
foreach (var _hit in rays)
{
if (_hit.transform.gameObject.GetComponent<FlareBeacon>() != null) continue;
transform.position = _hit.point;
break;
}
if (Physics.Raycast(r, out hit))
{
// transform.position = hit.point;
}
if (obstacle != null)
obstacle.radius = range / 10;
}
if (Physics.Raycast(r, out hit))
// Update is called once per frame
private void Update()
{
// transform.position = hit.point;
}
if (obstacle != null)
obstacle.radius = range / 10;
}
private void OnDrawGizmosSelected()
{
// Draw a yellow sphere at the transform's position
Gizmos.color = Color.yellow;
// Update is called once per frame
private void Update()
{
}
private void OnDrawGizmosSelected()
{
// Draw a yellow sphere at the transform's position
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, range);
}
Gizmos.DrawWireSphere(transform.position, range);
}
private void OnTriggerEnter(Collider other)
{
inRange.Add(other.gameObject);
}
private void OnTriggerEnter(Collider other)
{
inRange.Add(other.gameObject);
}
private void OnTriggerExit(Collider other)
{
inRange.Remove(other.gameObject);
private void OnTriggerExit(Collider other)
{
inRange.Remove(other.gameObject);
}
}
}

View File

@ -1,21 +1,24 @@
public class GenericInteractable : InteractableItem
namespace Item
{
private void Awake()
public class GenericInteractable : InteractableItem
{
BaseAwake();
}
private void Awake()
{
BaseAwake();
}
private void Start()
{
}
private void Start()
{
}
public override bool Interact()
{
return false;
}
public override bool Interact()
{
return false;
}
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
return Interact();
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
return Interact();
}
}
}

View File

@ -1,46 +1,49 @@
using UnityEngine;
public class HeavyInteractableItem : InteractableItem
namespace Item
{
private Vector3 init_rot;
// Start is called before the first frame update
private void Start()
public class HeavyInteractableItem : InteractableItem
{
init_rot = transform.eulerAngles;
}
private Vector3 init_rot;
// Update is called once per frame
private void Update()
{
}
// Start is called before the first frame update
private void Start()
{
init_rot = transform.eulerAngles;
}
private void FixedUpdate()
{
BaseFixedUpdate();
//print("Alpha Target:"+ base.target_alpha);
}
// Update is called once per frame
private void Update()
{
}
public void DisableAll()
{
GetComponent<Collider>().enabled = false;
}
private void FixedUpdate()
{
BaseFixedUpdate();
//print("Alpha Target:"+ base.target_alpha);
}
public override bool Interact()
{
//Todo
return false;
}
public void DisableAll()
{
GetComponent<Collider>().enabled = false;
}
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
return false;
}
public override bool Interact()
{
//Todo
return false;
}
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
return false;
}
public void EnableAll()
{
GetComponent<Collider>().enabled = true;
transform.eulerAngles = new Vector3(init_rot.x, transform.eulerAngles.y, init_rot.z);
public void EnableAll()
{
GetComponent<Collider>().enabled = true;
transform.eulerAngles = new Vector3(init_rot.x, transform.eulerAngles.y, init_rot.z);
}
}
}

View File

@ -1,9 +1,13 @@
using UnityEngine;
public abstract class HeavyItemReceiver : InteractableItem
namespace Item
{
[SerializeField] [Tooltip("Specify the keyword search in the name of the item!")]
protected string searchString;
public abstract class HeavyItemReceiver : InteractableItem
{
[SerializeField]
[Tooltip("Specify the keyword search in the name of the item!")]
protected string searchString;
protected HeavyInteractableItem item;
protected HeavyInteractableItem item;
}
}

View File

@ -2,67 +2,70 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Collider))]
[RequireComponent(typeof(Rigidbody))]
public abstract class InteractableItem : CarryableItem
namespace Item
{
[SerializeField] private Canvas interactionCanvas;
[SerializeField] protected bool canPickup;
private Image[] interaction_images;
private TMP_Text[] interaction_texts;
protected bool isEnabled;
protected float target_alpha;
public bool CanPickup => canPickup;
public bool IsEnabled => isEnabled;
private void Awake()
[RequireComponent(typeof(Collider))]
[RequireComponent(typeof(Rigidbody))]
public abstract class InteractableItem : CarryableItem
{
BaseAwake();
}
[SerializeField] private Canvas interactionCanvas;
private void FixedUpdate()
{
BaseFixedUpdate();
}
[SerializeField] protected bool canPickup;
public void Enable()
{
//print("Enabled!");
interactionCanvas.transform.LookAt(GameObject.FindGameObjectWithTag("MainCamera").transform.position);
interactionCanvas.transform.Rotate(0, 180, 0);
target_alpha = 1;
isEnabled = true;
}
private Image[] interaction_images;
private TMP_Text[] interaction_texts;
protected bool isEnabled;
protected float target_alpha;
public void Disable()
{
//print("Disabled!");
target_alpha = 0;
isEnabled = true;
}
public bool CanPickup => canPickup;
public bool IsEnabled => isEnabled;
public abstract bool Interact();
public abstract bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent);
private void Awake()
{
BaseAwake();
}
protected void BaseAwake()
{
interaction_texts = interactionCanvas.GetComponentsInChildren<TMP_Text>();
interaction_images = interactionCanvas.GetComponentsInChildren<Image>();
foreach (var text in interaction_texts) text.color = new Color(text.color.r, text.color.g, text.color.b, 0);
foreach (var image in interaction_images)
image.color = new Color(image.color.r, image.color.g, image.color.b, 0);
}
private void FixedUpdate()
{
BaseFixedUpdate();
}
protected void BaseFixedUpdate()
{
foreach (var text in interaction_texts)
text.color = Color.Lerp(new Color(text.color.r, text.color.g, text.color.b, text.color.a),
new Color(text.color.r, text.color.g, text.color.b, target_alpha), 10 * Time.deltaTime);
foreach (var image in interaction_images)
image.color = Color.Lerp(new Color(image.color.r, image.color.g, image.color.b, image.color.a),
new Color(image.color.r, image.color.g, image.color.b, target_alpha), 10 * Time.deltaTime);
public void Enable()
{
//print("Enabled!");
interactionCanvas.transform.LookAt(GameObject.FindGameObjectWithTag("MainCamera").transform.position);
interactionCanvas.transform.Rotate(0, 180, 0);
target_alpha = 1;
isEnabled = true;
}
public void Disable()
{
//print("Disabled!");
target_alpha = 0;
isEnabled = true;
}
public abstract bool Interact();
public abstract bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent);
protected void BaseAwake()
{
interaction_texts = interactionCanvas.GetComponentsInChildren<TMP_Text>();
interaction_images = interactionCanvas.GetComponentsInChildren<Image>();
foreach (var text in interaction_texts) text.color = new Color(text.color.r, text.color.g, text.color.b, 0);
foreach (var image in interaction_images)
image.color = new Color(image.color.r, image.color.g, image.color.b, 0);
}
protected void BaseFixedUpdate()
{
foreach (var text in interaction_texts)
text.color = Color.Lerp(new Color(text.color.r, text.color.g, text.color.b, text.color.a),
new Color(text.color.r, text.color.g, text.color.b, target_alpha), 10 * Time.deltaTime);
foreach (var image in interaction_images)
image.color = Color.Lerp(new Color(image.color.r, image.color.g, image.color.b, image.color.a),
new Color(image.color.r, image.color.g, image.color.b, target_alpha), 10 * Time.deltaTime);
}
}
}

View File

@ -1,29 +1,31 @@
using System;
using UnityEngine;
public class KeyItem : InteractableItem
namespace Item
{
[SerializeField] private string keyName;
public string KeyName => keyName;
private void Awake()
public class KeyItem : InteractableItem
{
BaseAwake();
}
[SerializeField] private string keyName;
private void Start()
{
}
public string KeyName => keyName;
public override bool Interact()
{
throw new NotImplementedException();
}
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
return Interact();
private void Awake()
{
BaseAwake();
}
private void Start()
{
}
public override bool Interact()
{
throw new NotImplementedException();
}
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
{
return Interact();
}
}
}

View File

@ -1,40 +1,43 @@
using UnityEngine;
public class BulletComponent : MonoBehaviour
namespace Item
{
[SerializeField] private float duration = 5f;
[SerializeField] private string type = "flare";
[SerializeField] private float damageRange = 20f;
[SerializeField] private float damageMagnitude = 1f;
private float existed;
private FlareRegister register;
public float DamageMagnitude => damageMagnitude;
public float DamageRange => damageRange;
// Start is called before the first frame update
private void Start()
public class BulletComponent : MonoBehaviour
{
register = FlareRegister.instance;
register.bullets.Add(this);
}
[SerializeField] private float duration = 5f;
// Update is called once per frame
private void Update()
{
}
[SerializeField] private string type = "flare";
private void FixedUpdate()
{
if (existed >= duration)
[SerializeField] private float damageRange = 20f;
[SerializeField] private float damageMagnitude = 1f;
private float existed;
private Item.FlareRegister register;
public float DamageMagnitude => damageMagnitude;
public float DamageRange => damageRange;
// Start is called before the first frame update
private void Start()
{
register.bullets.Remove(this);
Destroy(gameObject);
register = Item.FlareRegister.instance;
register.bullets.Add(this);
}
existed += Time.fixedDeltaTime;
// Update is called once per frame
private void Update()
{
}
private void FixedUpdate()
{
if (existed >= duration)
{
register.bullets.Remove(this);
Destroy(gameObject);
}
existed += Time.fixedDeltaTime;
}
}
}

View File

@ -1,45 +1,48 @@
using UnityEngine;
public class PistolAnimationAimAssist : MonoBehaviour
namespace Item
{
public Transform leftShoulder;
public Transform rightShoulder;
[SerializeField] private bool isEnabled;
private Animator anim;
private Vector3 lTarget;
private Vector3 rTarget;
// Start is called before the first frame update
private void Start()
public class PistolAnimationAimAssist : MonoBehaviour
{
lTarget = new Vector3(72.9f, 122.2f, -129.9f);
rTarget = new Vector3(82f, 11f, -88f);
anim = GetComponent<Animator>();
}
public Transform leftShoulder;
public Transform rightShoulder;
// Update is called once per frame
private void Update()
{
if (isEnabled)
[SerializeField] private bool isEnabled;
private Animator anim;
private Vector3 lTarget;
private Vector3 rTarget;
// Start is called before the first frame update
private void Start()
{
anim.StopPlayback();
leftShoulder.transform.eulerAngles = lTarget;
rightShoulder.transform.eulerAngles = rTarget;
print("Applying!");
anim.StartPlayback();
lTarget = new Vector3(72.9f, 122.2f, -129.9f);
rTarget = new Vector3(82f, 11f, -88f);
anim = GetComponent<Animator>();
}
// Update is called once per frame
private void Update()
{
if (isEnabled)
{
anim.StopPlayback();
leftShoulder.transform.eulerAngles = lTarget;
rightShoulder.transform.eulerAngles = rTarget;
print("Applying!");
anim.StartPlayback();
}
}
public void Enable()
{
isEnabled = true;
}
public void Disable()
{
isEnabled = false;
}
}
public void Enable()
{
isEnabled = true;
}
public void Disable()
{
isEnabled = false;
}
}

View File

@ -1,189 +1,192 @@
using UnityEngine;
using UnityEngine.VFX;
public class PistolComponent : MonoBehaviour
namespace Item
{
public enum AimMode
public class PistolComponent : MonoBehaviour
{
GUN,
MODIFIED,
CAMERA
}
public AimMode aimMode = AimMode.CAMERA;
[SerializeField] private Light targetingLight;
[SerializeField] private GameObject targetObjectPrefab;
[SerializeField] public GameObject projectilePrefab;
[SerializeField] public string projectileName;
[SerializeField] private Transform bulletSpawnPoint;
[SerializeField] private float firePower = 20f;
[SerializeField] private float maxProjectileDuration = 5f;
[SerializeField] private float maxTargetObjDistance = 15f;
[SerializeField] private VisualEffect shootEffect;
[SerializeField] private Light shootLight;
[SerializeField] private float shootLightDuration = 0.1f;
[SerializeField] private LayerMask ignoreLayers;
private bool hasCloseTarget;
private bool IsEnabled;
private GameObject targetObject;
private float timeSinceLightDuration;
public bool IsLightOn => targetingLight.gameObject.activeSelf;
//private Dictionary<int,float> projectiles = new Dictionary<int, float>();
// Start is called before the first frame update
private void Start()
{
}
// Update is called once per frame
private void Update()
{
timeSinceLightDuration += Time.deltaTime;
}
private void FixedUpdate()
{
if (shootLight.gameObject.activeSelf && timeSinceLightDuration > shootLightDuration)
shootLight.gameObject.SetActive(false);
if (aimMode == AimMode.CAMERA) targetObject.gameObject.transform.position = Player.PlayerAim.active.targetPosition;
if (IsEnabled && aimMode != AimMode.CAMERA)
public enum AimMode
{
var ray = new Ray(transform.position, transform.up);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 50, ignoreLayers))
{
var hitDist = Vector3.Distance(hit.point, transform.position);
if (hitDist < maxTargetObjDistance)
{
targetObject.gameObject.transform.position = hit.point;
GUN,
MODIFIED,
CAMERA
}
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0]
.SetColor("_EmissiveColor", new Color(255, 0, 0));
//Track if we have a close target
hasCloseTarget = true;
public AimMode aimMode = AimMode.CAMERA;
[SerializeField] private Light targetingLight;
[SerializeField] private GameObject targetObjectPrefab;
[SerializeField] public GameObject projectilePrefab;
[SerializeField] public string projectileName;
[SerializeField] private Transform bulletSpawnPoint;
[SerializeField] private float firePower = 20f;
[SerializeField] private float maxProjectileDuration = 5f;
[SerializeField] private float maxTargetObjDistance = 15f;
[SerializeField] private VisualEffect shootEffect;
[SerializeField] private Light shootLight;
[SerializeField] private float shootLightDuration = 0.1f;
[SerializeField] private LayerMask ignoreLayers;
private bool hasCloseTarget;
private bool IsEnabled;
private GameObject targetObject;
private float timeSinceLightDuration;
public bool IsLightOn => targetingLight.gameObject.activeSelf;
//private Dictionary<int,float> projectiles = new Dictionary<int, float>();
// Start is called before the first frame update
private void Start()
{
}
// Update is called once per frame
private void Update()
{
timeSinceLightDuration += Time.deltaTime;
}
private void FixedUpdate()
{
if (shootLight.gameObject.activeSelf && timeSinceLightDuration > shootLightDuration)
shootLight.gameObject.SetActive(false);
if (aimMode == AimMode.CAMERA) targetObject.gameObject.transform.position = Player.PlayerAim.active.targetPosition;
if (IsEnabled && aimMode != AimMode.CAMERA)
{
var ray = new Ray(transform.position, transform.up);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 50, ignoreLayers))
{
var hitDist = Vector3.Distance(hit.point, transform.position);
if (hitDist < maxTargetObjDistance)
{
targetObject.gameObject.transform.position = hit.point;
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0]
.SetColor("_EmissiveColor", new Color(255, 0, 0));
//Track if we have a close target
hasCloseTarget = true;
}
else
{
targetObject.gameObject.transform.position =
transform.position + ray.direction * maxTargetObjDistance;
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0]
.SetColor("_EmissiveColor", new Color(255, 255, 255));
//Track if we have a close target
hasCloseTarget = false;
}
//float drop = CalculateDrop(this.bulletSpawnPoint.position, hit.point, this.transform.up * this.firePower);
//print(drop);
}
else
{
targetObject.gameObject.transform.position =
transform.position + ray.direction * maxTargetObjDistance;
targetObject.gameObject.transform.position = transform.position + ray.direction * maxTargetObjDistance;
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0]
.SetColor("_EmissiveColor", new Color(255, 255, 255));
//Track if we have a close target
hasCloseTarget = false;
}
//float drop = CalculateDrop(this.bulletSpawnPoint.position, hit.point, this.transform.up * this.firePower);
//print(drop);
}
else
{
targetObject.gameObject.transform.position = transform.position + ray.direction * maxTargetObjDistance;
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0]
.SetColor("_EmissiveColor", new Color(255, 255, 255));
hasCloseTarget = false;
}
}
}
private float CalculateDrop(Vector3 origin, Vector3 destination, Vector3 force)
{
// Calculate the initial velocity required to reach the destination.
var displacement = destination - origin;
var time = Mathf.Sqrt(2f * displacement.magnitude / Physics.gravity.magnitude);
var velocity = (displacement - 0.5f * Physics.gravity * time * time) / time + force;
// Calculate the height the object will reach during its flight.
var maxHeight = origin.y + velocity.y * time - 0.5f * Physics.gravity.y * time * time;
// Calculate the distance the object will drop during its flight.
var dropDistance = maxHeight - destination.y;
return dropDistance;
}
public void Fire()
{
Fire(!hasCloseTarget);
}
public void Fire(bool offsetWithTargetBall)
{
shootLightDuration = 0;
shootLight.gameObject.SetActive(true);
var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
projectile.transform.localPosition = Vector3.zero;
projectile.transform.localEulerAngles = Vector3.zero;
projectile.transform.localScale = Vector3.one;
var pRigid = projectile.GetComponent<Rigidbody>();
/*Modified targeting system
1. Since aim direction is vector from camera to ball (where player thinks its gonna go), raycast forward there, till hit. If no hit,
then set target distance to ~50.
2. Modify launch vector apply modified force
*/
var launchVector = pRigid.transform.up * firePower;
if (offsetWithTargetBall || aimMode == AimMode.MODIFIED)
private float CalculateDrop(Vector3 origin, Vector3 destination, Vector3 force)
{
var ballCamVector = targetObject.transform.position -
GetComponentInParent<Player.PlayerMovementController>().cam.transform.position;
var r = new Ray();
r.origin = targetObject.transform.position;
r.direction = ballCamVector.normalized;
RaycastHit hit;
if (Physics.Raycast(r, out hit, ignoreLayers))
// Calculate the initial velocity required to reach the destination.
var displacement = destination - origin;
var time = Mathf.Sqrt(2f * displacement.magnitude / Physics.gravity.magnitude);
var velocity = (displacement - 0.5f * Physics.gravity * time * time) / time + force;
// Calculate the height the object will reach during its flight.
var maxHeight = origin.y + velocity.y * time - 0.5f * Physics.gravity.y * time * time;
// Calculate the distance the object will drop during its flight.
var dropDistance = maxHeight - destination.y;
return dropDistance;
}
public void Fire()
{
Fire(!hasCloseTarget);
}
public void Fire(bool offsetWithTargetBall)
{
shootLightDuration = 0;
shootLight.gameObject.SetActive(true);
var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
projectile.transform.localPosition = Vector3.zero;
projectile.transform.localEulerAngles = Vector3.zero;
projectile.transform.localScale = Vector3.one;
var pRigid = projectile.GetComponent<Rigidbody>();
/*Modified targeting system
1. Since aim direction is vector from camera to ball (where player thinks its gonna go), raycast forward there, till hit. If no hit,
then set target distance to ~50.
2. Modify launch vector apply modified force
*/
var launchVector = pRigid.transform.up * firePower;
if (offsetWithTargetBall || aimMode == AimMode.MODIFIED)
{
launchVector = (hit.point - pRigid.transform.position).normalized;
var ballCamVector = targetObject.transform.position -
GetComponentInParent<Player.PlayerMovementController>().cam.transform.position;
var r = new Ray();
r.origin = targetObject.transform.position;
r.direction = ballCamVector.normalized;
RaycastHit hit;
if (Physics.Raycast(r, out hit, ignoreLayers))
{
launchVector = (hit.point - pRigid.transform.position).normalized;
launchVector *= firePower;
}
}
else if (aimMode == AimMode.CAMERA)
{
var target = Player.PlayerAim.active.targetPosition;
var lv = target - pRigid.transform.position;
launchVector = lv.normalized;
launchVector *= firePower;
}
pRigid.AddForce(launchVector, ForceMode.Impulse);
projectile.transform.parent = null;
shootEffect.Play();
}
else if (aimMode == AimMode.CAMERA)
public void Enable()
{
var target = Player.PlayerAim.active.targetPosition;
var lv = target - pRigid.transform.position;
launchVector = lv.normalized;
launchVector *= firePower;
IsEnabled = true;
if (targetObject == null) targetObject = Instantiate(targetObjectPrefab);
}
pRigid.AddForce(launchVector, ForceMode.Impulse);
projectile.transform.parent = null;
shootEffect.Play();
}
public void Enable()
{
IsEnabled = true;
if (targetObject == null) targetObject = Instantiate(targetObjectPrefab);
}
public void Disable()
{
IsEnabled = false;
if (targetObject != null) Destroy(targetObject);
}
public void Disable()
{
IsEnabled = false;
if (targetObject != null) Destroy(targetObject);
}
public void LightToggle()
{
targetingLight.gameObject.SetActive(!targetingLight.gameObject.activeSelf);
public void LightToggle()
{
targetingLight.gameObject.SetActive(!targetingLight.gameObject.activeSelf);
}
}
}

View File

@ -1,21 +1,24 @@
using System.Collections.Generic;
using UnityEngine;
public class FlareRegister : MonoBehaviour
namespace Item
{
public static FlareRegister instance;
public List<BulletComponent> bullets = new();
public List<FlareBeacon> beacons = new();
// Start is called before the first frame update
private void Start()
public class FlareRegister : MonoBehaviour
{
instance = this;
}
public static FlareRegister instance;
public List<BulletComponent> bullets = new();
// Update is called once per frame
private void Update()
{
public List<FlareBeacon> beacons = new();
// Start is called before the first frame update
private void Start()
{
instance = this;
}
// Update is called once per frame
private void Update()
{
}
}
}

View File

@ -4,110 +4,113 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
[Serializable]
public class ItemImageRef
namespace Item
{
public string name;
public GameObject item;
public Sprite icon;
}
public class SpecialItemCycler : MonoBehaviour
{
[SerializeField] private List<ItemImageRef> spawnableItems = new();
[SerializeField] private List<ItemImageRef> shootableItems = new();
[SerializeField] private Player.PlayerInteractionHandler interactionHandler;
[SerializeField] private PistolComponent pistol;
[SerializeField]
//private Inventory invent;
private TempInventory invent;
[SerializeField] private Image selectedImage;
[SerializeField] private TMP_Text selectedQuantityText;
private int shootableIndex;
private int spawnableIndex;
private Color sqtInitColor;
// Start is called before the first frame update
private void Start()
[Serializable]
public class ItemImageRef
{
sqtInitColor = selectedQuantityText.color;
public string name;
public GameObject item;
public Sprite icon;
}
// Update is called once per frame
private void Update()
public class SpecialItemCycler : MonoBehaviour
{
if (interactionHandler.GunEnabled)
[SerializeField] private List<ItemImageRef> spawnableItems = new();
[SerializeField] private List<ItemImageRef> shootableItems = new();
[SerializeField] private Player.PlayerInteractionHandler interactionHandler;
[SerializeField] private Item.PistolComponent pistol;
[SerializeField]
//private Inventory invent;
private TempInventory invent;
[SerializeField] private Image selectedImage;
[SerializeField] private TMP_Text selectedQuantityText;
private int shootableIndex;
private int spawnableIndex;
private Color sqtInitColor;
// Start is called before the first frame update
private void Start()
{
pistol.projectilePrefab = shootableItems[shootableIndex % shootableItems.Count].item;
pistol.projectileName = shootableItems[shootableIndex % shootableItems.Count].name;
sqtInitColor = selectedQuantityText.color;
}
SetImage();
if (Input.GetButtonDown("CycleItems"))
// Update is called once per frame
private void Update()
{
if (interactionHandler.GunEnabled)
{
pistol.projectilePrefab = shootableItems[shootableIndex % shootableItems.Count].item;
pistol.projectileName = shootableItems[shootableIndex % shootableItems.Count].name;
}
SetImage();
if (Input.GetButtonDown("CycleItems"))
{
if (interactionHandler.GunEnabled)
{
shootableIndex = (shootableIndex + 1) % shootableItems.Count;
selectedImage.sprite = shootableItems[shootableIndex].icon;
}
else
{
spawnableIndex = (spawnableIndex + 1) % spawnableItems.Count;
selectedImage.sprite = spawnableItems[spawnableIndex].icon;
}
if (selectedImage.sprite == null)
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 0);
else
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 1);
}
if (Input.GetButtonDown("TempPlace"))
if (invent.GetQuantityOf(spawnableItems[spawnableIndex].name) > 0)
if (!interactionHandler.GunEnabled && spawnableItems[spawnableIndex].item != null)
{
var prefab = spawnableItems[spawnableIndex].item;
var instance = Instantiate(prefab, interactionHandler.CarryingPos);
instance.transform.localPosition = Vector3.zero;
instance.transform.parent = null;
invent.Remove(spawnableItems[spawnableIndex].name);
}
}
private void SetImage()
{
if (interactionHandler.GunEnabled)
{
shootableIndex = (shootableIndex + 1) % shootableItems.Count;
selectedImage.sprite = shootableItems[shootableIndex].icon;
selectedQuantityText.text = invent.GetQuantityOf(shootableItems[shootableIndex].name).ToString();
}
else
{
spawnableIndex = (spawnableIndex + 1) % spawnableItems.Count;
selectedImage.sprite = spawnableItems[spawnableIndex].icon;
selectedQuantityText.text = invent.GetQuantityOf(spawnableItems[spawnableIndex].name).ToString();
}
if (selectedImage.sprite == null)
{
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 0);
selectedQuantityText.gameObject.SetActive(false);
}
else
{
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 1);
}
if (Input.GetButtonDown("TempPlace"))
if (invent.GetQuantityOf(spawnableItems[spawnableIndex].name) > 0)
if (!interactionHandler.GunEnabled && spawnableItems[spawnableIndex].item != null)
{
var prefab = spawnableItems[spawnableIndex].item;
var instance = Instantiate(prefab, interactionHandler.CarryingPos);
instance.transform.localPosition = Vector3.zero;
instance.transform.parent = null;
invent.Remove(spawnableItems[spawnableIndex].name);
}
}
private void SetImage()
{
if (interactionHandler.GunEnabled)
{
selectedImage.sprite = shootableItems[shootableIndex].icon;
selectedQuantityText.text = invent.GetQuantityOf(shootableItems[shootableIndex].name).ToString();
}
else
{
selectedImage.sprite = spawnableItems[spawnableIndex].icon;
selectedQuantityText.text = invent.GetQuantityOf(spawnableItems[spawnableIndex].name).ToString();
}
if (selectedImage.sprite == null)
{
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 0);
selectedQuantityText.gameObject.SetActive(false);
}
else
{
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 1);
selectedQuantityText.gameObject.SetActive(true);
if (selectedQuantityText.text == "0")
selectedQuantityText.color = Color.red;
else
selectedQuantityText.color = sqtInitColor;
selectedQuantityText.gameObject.SetActive(true);
if (selectedQuantityText.text == "0")
selectedQuantityText.color = Color.red;
else
selectedQuantityText.color = sqtInitColor;
}
}
}
}

View File

@ -21,9 +21,9 @@ public class BasicLevelProgressionSystem : MonoBehaviour
EXTERNAL
}
[SerializeField] private ObjectiveText objectiveGui;
[SerializeField] private UI.ObjectiveText objectiveGui;
[SerializeField] private WaypointMarker marker;
[SerializeField] private UI.WaypointMarker marker;
[SerializeField] private Player.PlayerComponent player;
//[SerializeField]

View File

@ -7,17 +7,17 @@ public class LevelZeroSpecial : MonoBehaviour
{
//[SerializeField]
//private int initalPlaceIndex = 0;
[SerializeField] private DoorInteractable recepticleOne;
[SerializeField] private Item.DoorInteractable recepticleOne;
[SerializeField] private BasicLevelProgressionSystem progression;
[SerializeField] private int enabledOn = 4;
[SerializeField] private List<HeavyInteractableItem> powercores;
[SerializeField] private List<Item.HeavyInteractableItem> powercores;
[SerializeField] private List<DoorInteractable> recepticals;
[SerializeField] private List<Item.DoorInteractable> recepticals;
[SerializeField] private WaypointMarker marker;
[SerializeField] private UI.WaypointMarker marker;
[SerializeField] private Animator cover;
@ -27,16 +27,16 @@ public class LevelZeroSpecial : MonoBehaviour
[SerializeField] private Player.PlayerComponent player;
[SerializeField] private WaypointMarker marker2Ref;
[SerializeField] private UI.WaypointMarker marker2Ref;
[SerializeField] private WaypointMarker marker3Ref;
[SerializeField] private UI.WaypointMarker marker3Ref;
[SerializeField] private Game.Optimizer finalRoomOptimizer;
private int countPowered;
private bool isEnabled;
private readonly List<WaypointMarker> markers = new();
private readonly List<UI.WaypointMarker> markers = new();
private bool transitioningOut;

View File

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CryopodSpawnComponent : MonoBehaviour
{
public string playerName;
[SerializeField]
private TMPro.TMP_Text text;
[SerializeField]
private Transform spawn;
private bool isOccupied = false;
public bool IsOccupied { get { return isOccupied; } }
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
text.text = playerName;
}
}

View File

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

View File

@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UI
{
public class LobbyManager : MonoBehaviour
{
[SerializeField]
private Animator[] lights;
[SerializeField]
private int playersInSession = 0;
public bool AddPlayer()
{
if (playersInSession>= lights.Length)
{
return false;
}
lights[playersInSession].SetBool("IsPowered", true);
playersInSession++;
return true;
}
public bool RemovePlayer()
{
if (playersInSession <=0)
{
return false;
}
playersInSession--;
lights[playersInSession].SetBool("IsPowered", false);
return true;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyUp(KeyCode.LeftShift))
{
AddPlayer();
}else if(Input.GetKeyUp(KeyCode.RightShift))
{
RemovePlayer();
}
}
}
}

View File

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

View File

@ -1,3 +1,4 @@
using Mono.CompilerServices.SymbolWriter;
using System.Collections;
using System.Collections.Generic;
using TMPro;
@ -5,72 +6,75 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MainMenuManager : MonoBehaviour
namespace UI
{
[SerializeField] private TMP_Text title;
[SerializeField] private List<TMP_Text> textList = new();
[SerializeField] private float dilateSpeed = 0.1f;
[SerializeField] private Animator cover;
private readonly string component = "_FaceDilate";
private float dilate = -1;
private readonly List<float> dilates = new();
private float initDilate;
private readonly List<float> initDilates = new();
private bool transitioning;
// Start is called before the first frame update
private void Start()
public class MainMenuManager : MonoBehaviour
{
//initDilate = title.fontSharedMaterials[0].GetFloat(component);
initDilate = title.fontMaterials[0].GetFloat(component);
[SerializeField] private TMP_Text title;
[SerializeField] private List<TMP_Text> textList = new();
foreach (var text in textList)
[SerializeField] private float dilateSpeed = 0.1f;
[SerializeField] private Animator cover;
private readonly string component = "_FaceDilate";
private float dilate = -1;
private readonly List<float> dilates = new();
private float initDilate;
private readonly List<float> initDilates = new();
private bool transitioning;
// Start is called before the first frame update
private void Start()
{
initDilates.Add(text.fontMaterials[0].GetFloat(component));
dilates.Add(-1f);
//initDilate = title.fontSharedMaterials[0].GetFloat(component);
initDilate = title.fontMaterials[0].GetFloat(component);
foreach (var text in textList)
{
initDilates.Add(text.fontMaterials[0].GetFloat(component));
dilates.Add(-1f);
}
textList[0].GetComponent<Button>().onClick.AddListener(LoadFirstLevel);
textList[2].GetComponent<Button>().onClick.AddListener(ExitApp);
}
textList[0].GetComponent<Button>().onClick.AddListener(LoadFirstLevel);
textList[2].GetComponent<Button>().onClick.AddListener(ExitApp);
}
// Update is called once per frame
private void Update()
{
//dilate = Mathf.Min(initDilate, dilate += Time.deltaTime);
dilate = Mathf.Lerp(dilate, initDilate, Time.deltaTime * dilateSpeed);
title.fontMaterials[0].SetFloat(component, dilate);
for (var i = 0; i < textList.Count; i++)
// Update is called once per frame
private void Update()
{
dilates[i] = Mathf.Lerp(dilates[i], initDilates[i], Time.deltaTime * dilateSpeed);
textList[i].fontMaterials[0].SetFloat(component, dilates[i]);
//dilate = Mathf.Min(initDilate, dilate += Time.deltaTime);
dilate = Mathf.Lerp(dilate, initDilate, Time.deltaTime * dilateSpeed);
title.fontMaterials[0].SetFloat(component, dilate);
for (var i = 0; i < textList.Count; i++)
{
dilates[i] = Mathf.Lerp(dilates[i], initDilates[i], Time.deltaTime * dilateSpeed);
textList[i].fontMaterials[0].SetFloat(component, dilates[i]);
}
}
private void LoadFirstLevel()
{
if (!transitioning)
{
cover.Play("Cover_load_out");
transitioning = true;
StartCoroutine(_LoadFirstLevel());
}
}
private IEnumerator _LoadFirstLevel()
{
yield return new WaitForSeconds(4);
SceneManager.LoadScene(1);
}
private void ExitApp()
{
Application.Quit();
}
}
private void LoadFirstLevel()
{
if (!transitioning)
{
cover.Play("Cover_load_out");
transitioning = true;
StartCoroutine(_LoadFirstLevel());
}
}
private IEnumerator _LoadFirstLevel()
{
yield return new WaitForSeconds(4);
SceneManager.LoadScene(1);
}
private void ExitApp()
{
Application.Quit();
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9b6514adc0f89c7449476a228cc73b3f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Player
{
public class LobbyPlayerComponent : MonoBehaviour
{
[SerializeField]
private Animator anim;
// Start is called before the first frame update
void Start()
{
anim.SetBool("IsRunning", false);
anim.SetFloat("RunningSpeed", 0);
anim.Play("CryopodIdle");
}
// Update is called once per frame
void Update()
{
}
}
}

View File

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

View File

@ -18,7 +18,7 @@ namespace Player
[SerializeField] private PlayerAnimationController animationController;
[HideInInspector] public FlareRegister flareRegister;
[HideInInspector] public Item.FlareRegister flareRegister;
[SerializeField] private CinemachineFreeLook cameraFreeLook;
@ -33,18 +33,21 @@ namespace Player
public NoiseVisibilitySettingsManager NoiseManager => noiseManager;
public PlayerMovementController MovementController => movementController;
[SerializeField]
private Scriptable.GameSettings settings;
[HideInInspector] public bool IsAlive => health > 0;
private void Awake()
{
flareRegister = FindObjectOfType<FlareRegister>();
flareRegister = FindObjectOfType<Item.FlareRegister>();
}
// Start is called before the first frame update
private void Start()
{
perlin = cameraFreeLook.GetRig(1).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
settings.OnValueChange.AddListener(OnSettingChange);
}
// Update is called once per frame
@ -92,7 +95,13 @@ namespace Player
perlin.m_AmplitudeGain = intensity;
shakeTimer = time;
}
public void OnSettingChange(Scriptable.GameSettings.SettingModification mod, float value)
{
if(mod == Scriptable.GameSettings.SettingModification.Sensitivity)
{
SetSensitivity(value);
}
}
public void SetSensitivity(float magnitude)
{
movementController.SetSensitivity(magnitude);

View File

@ -4,7 +4,6 @@ using UnityEngine;
namespace Player
{
[RequireComponent(typeof(Collider))]
public class PlayerInteractionHandler : MonoBehaviour
{
@ -20,7 +19,7 @@ public class PlayerInteractionHandler : MonoBehaviour
[SerializeField] private bool useItemSelector = true;
[SerializeField] private PistolComponent pistol;
[SerializeField] private Item.PistolComponent pistol;
[SerializeField] private NoiseVisibilitySettingsManager noiseManager;
@ -32,18 +31,18 @@ public class PlayerInteractionHandler : MonoBehaviour
private readonly AxisIsDown fireDown = new("Fire1");
private bool flashlightEnabled = true;
private HeavyInteractableItem heavyInvent;
private readonly List<HeavyInteractableItem> heavyItemsInRange = new();
private Item.HeavyInteractableItem heavyInvent;
private readonly List<Item.HeavyInteractableItem> heavyItemsInRange = new();
private Color initColor;
private Inventory invent;
private Item.Inventory invent;
private ItemSelector itemSelector;
private readonly List<InteractableItem> itemsInRange = new();
private Game.InGameManager manager;
private Item.ItemSelector itemSelector;
private readonly List<Item.InteractableItem> itemsInRange = new();
[SerializeField]
private Scriptable.GameState manager;
private Material selMaterial;
private TempInventory tempInvent;
public Inventory Inventory => invent;
private Item.TempInventory tempInvent;
public Item.Inventory Inventory => invent;
public bool IsCarrying => heavyInvent != null;
public bool GunEnabled { get; private set; }
@ -53,16 +52,16 @@ public class PlayerInteractionHandler : MonoBehaviour
private void Start()
{
instance = this;
invent = transform.parent.GetComponent<Inventory>();
invent = transform.parent.GetComponent<Item.Inventory>();
//TEMP FIELD
tempInvent = transform.parent.GetComponent<TempInventory>();
tempInvent = transform.parent.GetComponent<Item.TempInventory>();
initColor = flashlight3D.GetComponent<MeshRenderer>().materials[materialIndex].GetColor("_BaseColor");
selMaterial = flashlight3D.GetComponent<MeshRenderer>().materials[materialIndex];
itemSelector = ItemSelector.instance;
itemSelector = Item.ItemSelector.instance;
pistol.gameObject.SetActive(GunEnabled);
flashlightEnabled = flashlight.gameObject.activeSelf;
manager = FindObjectOfType<Game.InGameManager>();
}
// Update is called once per frame
@ -126,7 +125,7 @@ public class PlayerInteractionHandler : MonoBehaviour
{
if (!item.Interact(ref invent, ref heavyInvent))
item.Interact();
else if (item is HeavyItemReceiver)
else if (item is Item.HeavyItemReceiver)
if (heavyInvent != null)
{
heavyInvent.transform.parent = carryingPos;
@ -146,7 +145,7 @@ public class PlayerInteractionHandler : MonoBehaviour
int refIndex;
if (itemsInRange.Count > 0 && receiverInRange(out refIndex))
{
((HeavyItemReceiver)itemsInRange[refIndex]).Interact(ref invent, ref heavyInvent);
((Item.HeavyItemReceiver)itemsInRange[refIndex]).Interact(ref invent, ref heavyInvent);
heavyInvent = null;
}
else
@ -191,9 +190,9 @@ public class PlayerInteractionHandler : MonoBehaviour
var aimAxis = Input.GetAxis("Aim");
if (aimAxis > 0.5f)
pistol.aimMode = PistolComponent.AimMode.CAMERA;
pistol.aimMode = Item.PistolComponent.AimMode.CAMERA;
else
pistol.aimMode = PistolComponent.AimMode.MODIFIED;
pistol.aimMode = Item.PistolComponent.AimMode.MODIFIED;
}
shift.SetCenter(!GunEnabled);
@ -202,37 +201,37 @@ public class PlayerInteractionHandler : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.GetComponent<InteractableItem>() != null)
if (other.gameObject.GetComponent<Item.InteractableItem>() != null)
{
var item = other.gameObject.GetComponent<InteractableItem>();
if (item is InteractableItem && item is not HeavyInteractableItem)
var item = other.gameObject.GetComponent<Item.InteractableItem>();
if (item is Item.InteractableItem && item is not Item.HeavyInteractableItem)
{
item.Enable();
itemsInRange.Add(item);
}
else if (item is HeavyInteractableItem)
else if (item is Item.HeavyInteractableItem)
{
((HeavyInteractableItem)item).Enable();
heavyItemsInRange.Add((HeavyInteractableItem)item);
((Item.HeavyInteractableItem)item).Enable();
heavyItemsInRange.Add((Item.HeavyInteractableItem)item);
}
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.GetComponent<InteractableItem>() != null)
if (other.gameObject.GetComponent<Item.InteractableItem>() != null)
{
var item = other.gameObject.GetComponent<InteractableItem>();
if (item is InteractableItem && item is not HeavyInteractableItem)
var item = other.gameObject.GetComponent<Item.InteractableItem>();
if (item is Item.InteractableItem && item is not Item.HeavyInteractableItem)
{
item.Disable();
itemsInRange.Remove(item);
}
else if (item is HeavyInteractableItem)
else if (item is Item.HeavyInteractableItem)
{
((HeavyInteractableItem)item).Disable();
((Item.HeavyInteractableItem)item).Disable();
//itemsInRange.Remove((HeavyInteractableItem)(item));
heavyItemsInRange.Remove((HeavyInteractableItem)item);
heavyItemsInRange.Remove((Item.HeavyInteractableItem)item);
}
}
}
@ -242,7 +241,7 @@ public class PlayerInteractionHandler : MonoBehaviour
var i = 0;
foreach (var item in itemsInRange)
{
if (item is HeavyItemReceiver)
if (item is Item.HeavyItemReceiver)
{
index = i;
return true;

View File

@ -44,8 +44,9 @@ namespace Player
private Vector3 lookingDirectionVector;
private Game.InGameManager manager;
[SerializeField]
private Scriptable.GameState manager;
private bool movementLocked;
@ -61,9 +62,10 @@ namespace Player
private void Start()
{
ccForceAddon = ccontroller.gameObject.GetComponent<CharacterControllerForce>();
manager = FindObjectOfType<Game.InGameManager>();
initXSensitivity = freelook.m_XAxis.m_MaxSpeed;
initYSensitivity = freelook.m_YAxis.m_MaxSpeed;
}
// Update is called once per frame
@ -103,6 +105,10 @@ namespace Player
IsRunning = Mathf.Abs(y) > 0.1f || Mathf.Abs(x) > 0.1f;
}
/// <summary>
/// Gets called by PlayerComponent to change sensitivity.
/// </summary>
/// <param name="sensitivity"></param>
public void SetSensitivity(float sensitivity)
{
freelook.m_XAxis.m_MaxSpeed = initXSensitivity * sensitivity;

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f48441fbbbc3fc40be68e97edc7e3f1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Scriptable
{
[CreateAssetMenu(fileName = "GameSettings", menuName = "ScriptableObjects/GameSetting", order = 1)]
public class GameSettings : ScriptableObject
{
private float sensitivity;
private float volume;
public float Sensitivity { get { return this.sensitivity; } set {
OnValueChange.Invoke(SettingModification.Sensitivity,sensitivity);
} }
public float Volume { get { return this.volume; } set
{
OnValueChange.Invoke(SettingModification.Volume,volume);
} }
public enum SettingModification { Sensitivity, Volume};
public UnityEvent<SettingModification,float> OnValueChange;
}
}

View File

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

View File

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Scriptable
{
[CreateAssetMenu(fileName = "GameState", menuName = "ScriptableObjects/GameStateManager", order = 1)]
public class GameState : ScriptableObject
{
[HideInInspector]
public bool IsPaused = false;
}
}

View File

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

View File

@ -0,0 +1,14 @@
{
"name": "Scriptable_Assembly",
"rootNamespace": "Scriptable",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f0bbd04fc036a3046993adc87bbfb698
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,50 +3,52 @@ using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[ExecuteAlways]
public class ObjectiveText : MonoBehaviour
namespace UI
{
[SerializeField] public List<VisualObjectiveItemGUI> visualObjects;
[SerializeField] private Color inCompleteColor = Color.white;
[SerializeField] private Color completeColor = Color.yellow;
[SerializeField] private float speed;
[SerializeField] private Animator animator;
// Start is called before the first frame update
private void Start()
[ExecuteAlways]
public class ObjectiveText : MonoBehaviour
{
[SerializeField] public List<VisualObjectiveItemGUI> visualObjects;
[SerializeField] private Color inCompleteColor = Color.white;
[SerializeField] private Color completeColor = Color.yellow;
[SerializeField] private float speed;
[SerializeField] private Animator animator;
// Start is called before the first frame update
private void Start()
{
}
// Update is called once per frame
private void Update()
{
foreach (var item in visualObjects)
if (item.isComplete)
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime * speed);
else
item.icon.color = Color.Lerp(item.icon.color, inCompleteColor, Time.deltaTime * speed);
}
public void FadeOut()
{
animator.Play("FadeOut");
}
public void FadeIn()
{
animator.Play("FadeIn");
}
}
// Update is called once per frame
private void Update()
[Serializable]
public class VisualObjectiveItemGUI
{
foreach (var item in visualObjects)
if (item.isComplete)
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime * speed);
else
item.icon.color = Color.Lerp(item.icon.color, inCompleteColor, Time.deltaTime * speed);
}
public void FadeOut()
{
animator.Play("FadeOut");
}
public void FadeIn()
{
animator.Play("FadeIn");
public TMP_Text text;
public Image icon;
public bool isComplete;
}
}
[Serializable]
public class VisualObjectiveItemGUI
{
public TMP_Text text;
public Image icon;
public bool isComplete;
}

View File

@ -0,0 +1,16 @@
{
"name": "UI_Definition",
"rootNamespace": "UI",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3d3648da7fb990349a7d848d55c40947
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,49 +1,51 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class WaypointMarker : MonoBehaviour
namespace UI
{
public Image pointer;
public Transform target;
public TMP_Text distanceMarker;
private Vector2 offset;
// Start is called before the first frame update
private void Start()
public class WaypointMarker : MonoBehaviour
{
offset = distanceMarker.transform.position - pointer.transform.position;
}
public Image pointer;
public Transform target;
public TMP_Text distanceMarker;
// Update is called once per frame
private void Update()
{
var minX = pointer.GetPixelAdjustedRect().width / 2;
var maxX = Screen.width - minX;
var minY = pointer.GetPixelAdjustedRect().height / 2;
var maxY = Screen.height - minY;
private Vector2 offset;
Vector2 pos = Camera.main.WorldToScreenPoint(target.position);
if (Vector3.Dot(target.position - Camera.main.transform.position, Camera.main.transform.forward) < 0)
// Start is called before the first frame update
private void Start()
{
//target is behind player
if (pos.x < Screen.width / 2)
pos.x = maxX;
else
pos.x = minX;
offset = distanceMarker.transform.position - pointer.transform.position;
}
pos.x = Mathf.Clamp(pos.x, minX, maxX);
pos.y = Mathf.Clamp(pos.y, minY, maxY);
// Update is called once per frame
private void Update()
{
var minX = pointer.GetPixelAdjustedRect().width / 2;
var maxX = Screen.width - minX;
var minY = pointer.GetPixelAdjustedRect().height / 2;
var maxY = Screen.height - minY;
pointer.transform.position = pos;
distanceMarker.text =
Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)) + " meters";
if (pos.x < Screen.width / 2)
distanceMarker.transform.position = pos + offset;
else
distanceMarker.transform.position = pos - offset;
Vector2 pos = Camera.main.WorldToScreenPoint(target.position);
if (Vector3.Dot(target.position - Camera.main.transform.position, Camera.main.transform.forward) < 0)
{
//target is behind player
if (pos.x < Screen.width / 2)
pos.x = maxX;
else
pos.x = minX;
}
pos.x = Mathf.Clamp(pos.x, minX, maxX);
pos.y = Mathf.Clamp(pos.y, minY, maxY);
pointer.transform.position = pos;
distanceMarker.text =
Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)) + " meters";
if (pos.x < Screen.width / 2)
distanceMarker.transform.position = pos + offset;
else
distanceMarker.transform.position = pos - offset;
}
}
}
}