Assemblies Made and Refactored Code Folders
Created assemblies for the new design code. Relocated legacy scripts into a legacy folder and made a "new_design" folder for new design.
This commit is contained in:
8
Assets/Scripts/Legacy/AssemblyReferences.meta
Normal file
8
Assets/Scripts/Legacy/AssemblyReferences.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffb312c0cba800244824866e8c414e45
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
Assets/Scripts/Legacy/CharacterControllerForce.cs
Normal file
30
Assets/Scripts/Legacy/CharacterControllerForce.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CharacterControllerForce : MonoBehaviour
|
||||
{
|
||||
private CharacterController character;
|
||||
private Vector3 impact = Vector3.zero;
|
||||
private readonly float mass = 3f; // defines the character mass
|
||||
|
||||
private void Start()
|
||||
{
|
||||
character = gameObject.GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// apply the impact force:
|
||||
if (impact.magnitude > 0.2)
|
||||
character.Move(impact * Time.deltaTime);
|
||||
// consumes the impact energy each cycle:
|
||||
impact = Vector3.Lerp(impact, Vector3.zero, 5 * Time.deltaTime);
|
||||
}
|
||||
|
||||
// call this function to add an impact force:
|
||||
public void AddImpact(Vector3 dir, float force)
|
||||
{
|
||||
dir.Normalize();
|
||||
if (dir.y < 0) dir.y = -dir.y; // reflect down force on the ground
|
||||
impact += dir.normalized * force / mass;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/CharacterControllerForce.cs.meta
Normal file
11
Assets/Scripts/Legacy/CharacterControllerForce.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fb5120753ff7544bb106f2fcaaad636
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Scripts/Legacy/DGemItem.cs
Normal file
26
Assets/Scripts/Legacy/DGemItem.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DGemItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float decSpeed = 5f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Player"))
|
||||
{
|
||||
collision.gameObject.GetComponent<Player.PlayerMovementController>().SetSpeed(decSpeed);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/DGemItem.cs.meta
Normal file
11
Assets/Scripts/Legacy/DGemItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b81301b367248407f8c53744b655b039
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Darkness.meta
Normal file
8
Assets/Scripts/Legacy/Darkness.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a790bc1f421c79948b8379e14ea3907d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/Legacy/Darkness/VectorFieldHandler.cs
Normal file
33
Assets/Scripts/Legacy/Darkness/VectorFieldHandler.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.VFX;
|
||||
|
||||
public class VectorFieldHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float avoidanceDist;
|
||||
|
||||
[SerializeField] private List<Vector3> avoidances;
|
||||
|
||||
[SerializeField] private Vector3 size;
|
||||
|
||||
[SerializeField] private VisualEffect effect;
|
||||
|
||||
private Texture3D vField;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
vField = new Texture3D((int)size.x, (int)size.y, (int)size.z, TextureFormat.RFloat, 0);
|
||||
for (var x = 0; x < size.x; x++)
|
||||
for (var y = 0; y < size.y; y++)
|
||||
for (var z = 0; z < size.z; z++)
|
||||
vField.SetPixel(x, y, z, new Color(1, 0, 0, 0));
|
||||
//vField.SetPixel(0, 0, 0, new Color(1, 0, 0, 0));
|
||||
effect.SetTexture("VectorField", vField);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Darkness/VectorFieldHandler.cs.meta
Normal file
11
Assets/Scripts/Legacy/Darkness/VectorFieldHandler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72a473445b963b24abc84791b0ffacaa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/Scripts/Legacy/DynamicLine.cs
Normal file
27
Assets/Scripts/Legacy/DynamicLine.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteAlways]
|
||||
[RequireComponent(typeof(LineRenderer))]
|
||||
public class DynamicLine : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float length = 5f;
|
||||
|
||||
[SerializeField] private int count = 2;
|
||||
|
||||
private LineRenderer lineRenderer;
|
||||
private int pCount;
|
||||
|
||||
private float pLength;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
lineRenderer = GetComponent<LineRenderer>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (pLength != length || pCount != count) lineRenderer.positionCount = count;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/DynamicLine.cs.meta
Normal file
11
Assets/Scripts/Legacy/DynamicLine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c4f6ccca2e0e4c40b0fe4a0c7ab98f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Enemies.meta
Normal file
8
Assets/Scripts/Legacy/Enemies.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c45f05892f2ff27429f6adc9e95855b9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Enemies/AI.meta
Normal file
8
Assets/Scripts/Legacy/Enemies/AI.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cad50f842393434fa2dc09cc614fd93
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Assets/Scripts/Legacy/Enemies/AI/AIStateMachine.cs
Normal file
39
Assets/Scripts/Legacy/Enemies/AI/AIStateMachine.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
/*
|
||||
# Enemy System
|
||||
## States
|
||||
1. **Passive**
|
||||
- Enemy is unaware of danger and performing idle actions. Not actively searching for anything.
|
||||
- Perception range is at its minimum.
|
||||
- If agressive target is "visible" enter `Agressive` state.
|
||||
- If nonagressive target is "visible" enter `Aware` state.
|
||||
2. **Guard**
|
||||
- Enemy is looking out for danger. Can be moving along a path or standing
|
||||
- Perception range is at regular level.
|
||||
- If aggressive target is "visible" enter `Agressive` state.
|
||||
- If nonagressive target is "visible" enter `Aware` state.
|
||||
3. **Aware**
|
||||
- Enemy has noticed something and is moving towards location of interest.
|
||||
- Peception range is at regular level.
|
||||
- If player is "visible" enter `Agressive` state.
|
||||
- If nonagresive target is "visible" of equal or greater importance change target.
|
||||
- If at location and no new item of note is added to "visible", then enter either `Passive` or `Guard` mode based on original mode.
|
||||
4. **Aggressive**
|
||||
- Enemy has noticed player:
|
||||
- Apply these actions in sequence:
|
||||
a. If player has not been "visible" for more than 5 seconds enter `Guard` mode.
|
||||
b. If player has not been "visible" for < 5 seconds move to last location it was visible.
|
||||
c. If player is in attack range and is visible, stop moving, and attack if able.
|
||||
d. If player is not in attack range and is visible, run in direction of player.
|
||||
|
||||
|
||||
*/
|
||||
class AIStateMachine : MonoBehaviour{
|
||||
[SerializeField]
|
||||
private EnemyAI.EnemyState state;
|
||||
|
||||
|
||||
|
||||
}
|
11
Assets/Scripts/Legacy/Enemies/AI/AIStateMachine.cs.meta
Normal file
11
Assets/Scripts/Legacy/Enemies/AI/AIStateMachine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecb02583e05945c42b91880d7bb76fec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Assets/Scripts/Legacy/Enemies/AI/EnemyState.cs
Normal file
12
Assets/Scripts/Legacy/Enemies/AI/EnemyState.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace EnemyAI{
|
||||
///The state the enemy is currently in.
|
||||
///Passive: Enemy is not searching for anyone and is at minimum perception distance.
|
||||
///Guard: Enemy is on the lookout for enemies. May be following a patrol path.
|
||||
///Aware: Enemy has noticed something and is investigating it.
|
||||
///Aggressive: Enemy has seen something it wants to attack and is performing its attack.
|
||||
public enum EnemyState{PASSIVE, GUARD, AWARE, AGGRESSIVE};
|
||||
|
||||
|
||||
}
|
11
Assets/Scripts/Legacy/Enemies/AI/EnemyState.cs.meta
Normal file
11
Assets/Scripts/Legacy/Enemies/AI/EnemyState.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb7c23d6f892d824ebcd580774822eff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
134
Assets/Scripts/Legacy/Enemies/AI/SkinlessMonsterAnimator.cs
Normal file
134
Assets/Scripts/Legacy/Enemies/AI/SkinlessMonsterAnimator.cs
Normal file
@ -0,0 +1,134 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Enemy {
|
||||
public class SkinlessMonsterAnimator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("This is the object with the skin dissolve material")]
|
||||
private GameObject modelObject;
|
||||
|
||||
[SerializeField] private List<GameObject> objectsThatFallOnDeath = new();
|
||||
|
||||
[SerializeField] private float deathSpeed = 5f;
|
||||
|
||||
[SerializeField] private float fastDeathduration = 1f;
|
||||
|
||||
[SerializeField] private float deathDuration = 5f;
|
||||
|
||||
private float curDeathSpeed = 5f;
|
||||
|
||||
private Material dissolveMaterial;
|
||||
private bool isAlive = true;
|
||||
|
||||
private float speed;
|
||||
public bool IsRunning { get; private set; }
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
dissolveMaterial = modelObject.GetComponent<SkinnedMeshRenderer>().materials[0];
|
||||
curDeathSpeed = deathSpeed;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (isAlive)
|
||||
{
|
||||
animator.SetFloat("Speed", speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
var quantity = dissolveMaterial.GetFloat("_DissolveQuantity");
|
||||
quantity = Mathf.Lerp(quantity, -2, Time.deltaTime * curDeathSpeed);
|
||||
dissolveMaterial.SetFloat("_DissolveQuantity", quantity);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartMoving()
|
||||
{
|
||||
if (isAlive)
|
||||
{
|
||||
IsRunning = true;
|
||||
speed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopMoving()
|
||||
{
|
||||
if (isAlive)
|
||||
{
|
||||
speed = 0;
|
||||
IsRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attack()
|
||||
{
|
||||
if (isAlive) animator.SetTrigger("Attack");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 0,1,2,3
|
||||
/// </summary>
|
||||
/// <param name="attackType"></param>
|
||||
public void SetAttackType(int attackType)
|
||||
{
|
||||
animator.SetInteger("AttackIndex", attackType);
|
||||
}
|
||||
|
||||
public void InLight()
|
||||
{
|
||||
if (isAlive)
|
||||
animator.SetBool("InLight", true);
|
||||
}
|
||||
|
||||
public void NotInLight()
|
||||
{
|
||||
if (isAlive)
|
||||
animator.SetBool("InLight", false);
|
||||
}
|
||||
|
||||
public void AttackScream()
|
||||
{
|
||||
if (isAlive)
|
||||
animator.SetTrigger("AttackScream");
|
||||
}
|
||||
|
||||
public void Kill(bool fast = false)
|
||||
{
|
||||
//animator.speed = 0;
|
||||
InLight();
|
||||
|
||||
|
||||
isAlive = false;
|
||||
foreach (var obj in objectsThatFallOnDeath)
|
||||
{
|
||||
obj.AddComponent<Rigidbody>();
|
||||
if (obj.GetComponent<Collider>() != null) obj.GetComponent<Collider>().enabled = false;
|
||||
}
|
||||
|
||||
var dur = deathDuration;
|
||||
if (fast)
|
||||
{
|
||||
dur = fastDeathduration;
|
||||
curDeathSpeed = deathSpeed * (deathDuration / fastDeathduration);
|
||||
}
|
||||
|
||||
StartCoroutine(destroyAfterSeconds(dur));
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator destroyAfterSeconds(float duration)
|
||||
{
|
||||
yield return new WaitForSeconds(duration);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25b1ea1a67bb5ac46ab647a1cd794807
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
397
Assets/Scripts/Legacy/Enemies/AI/SkinlessMonsterComponent.cs
Normal file
397
Assets/Scripts/Legacy/Enemies/AI/SkinlessMonsterComponent.cs
Normal file
@ -0,0 +1,397 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class SkinlessMonsterComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private NavMeshAgent agent;
|
||||
|
||||
[SerializeField] private Enemy.SkinlessMonsterAnimator animator;
|
||||
|
||||
[SerializeField] private float atTargetDistance = 2;
|
||||
|
||||
[SerializeField] private float health = 2f;
|
||||
|
||||
[SerializeField] [Tooltip("This is the angle of visibility the enemy has")]
|
||||
private float visibilityConeLimit = 90f;
|
||||
|
||||
[SerializeField] private float bulletSoundRange = 15f;
|
||||
|
||||
[SerializeField] private float newTargetCooldown = 5f;
|
||||
//private bool prePauseStoppedState = false;
|
||||
|
||||
[SerializeField] private BoxCollider leftHandDamage;
|
||||
|
||||
[SerializeField] private BoxCollider rightHandDamage;
|
||||
|
||||
private bool atTarget;
|
||||
private float distanceToPlayer;
|
||||
|
||||
private Item.FlareRegister flareRegister;
|
||||
private bool inDamageMargin;
|
||||
private bool inDamageRange;
|
||||
|
||||
|
||||
private bool isAlive = true;
|
||||
|
||||
|
||||
|
||||
|
||||
private Vector3 oppositeVector;
|
||||
|
||||
private Player.PlayerComponent player;
|
||||
private TargetInformation target;
|
||||
|
||||
private GameObject targetObject;
|
||||
private float timeSinceTarget;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//Find active player rn.
|
||||
var players = FindObjectsOfType<Player.PlayerComponent>();
|
||||
foreach (var p in players)
|
||||
if (p.isActiveAndEnabled)
|
||||
player = p;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
flareRegister = FindObjectOfType<Item.FlareRegister>();
|
||||
if (targetObject == null)
|
||||
targetObject = new GameObject();
|
||||
targetObject.name = "Enemy Target";
|
||||
|
||||
if (player == null) player = FindObjectOfType<Player.PlayerComponent>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!player.IsAlive) Stop();
|
||||
|
||||
if (target != null) HandleTargetOperations();
|
||||
CheckForAOERanges();
|
||||
if (isAlive && player.IsAlive)
|
||||
SetLiveTargeting();
|
||||
timeSinceTarget += Time.deltaTime;
|
||||
if (isAlive)
|
||||
{
|
||||
leftHandDamage.enabled = true;
|
||||
rightHandDamage.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
leftHandDamage.enabled = false;
|
||||
rightHandDamage.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
AI Behavior:
|
||||
A. If not targeting player
|
||||
1. Get distance to player
|
||||
- if distance < player.NoiseDistance then target player.
|
||||
2. Raycast to player to test line of sight
|
||||
- if in line of sight and angle between LOS vector and forward vector is < LOF margin, then
|
||||
target player.
|
||||
B. If targeting player
|
||||
1. If out of sound range and no line of sight then lose target.
|
||||
- stop()
|
||||
2. If beacon placed down and in range
|
||||
- remove agent
|
||||
- kill()
|
||||
3. If beacon placed down and in margin:
|
||||
- stop() and wait for player to leave AOE (enforced by navigation).
|
||||
*/
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.GetComponent<Item.BulletComponent>() != null)
|
||||
health -= other.gameObject.GetComponent<Item.BulletComponent>().DamageMagnitude;
|
||||
}
|
||||
|
||||
private void HandleTargetOperations()
|
||||
{
|
||||
//Update booleans for movement
|
||||
var distToTarget = Vector3.Distance(target.target.transform.position, agent.transform.position);
|
||||
atTarget = atTargetDistance >= distToTarget;
|
||||
if (target.hasDamageRange)
|
||||
{
|
||||
inDamageRange = target.damageRange <= distToTarget;
|
||||
inDamageMargin = target.damageMargin + target.damageRange <= distToTarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
inDamageRange = false;
|
||||
inDamageMargin = false;
|
||||
}
|
||||
|
||||
//Perform actions.
|
||||
if (target.runTowards)
|
||||
{
|
||||
if (inDamageRange)
|
||||
{
|
||||
//Damage is being dealt
|
||||
animator.InLight();
|
||||
//Deal Damage
|
||||
health -= Time.deltaTime;
|
||||
if (health < 0 && isAlive) Kill();
|
||||
}
|
||||
else if (inDamageMargin)
|
||||
{
|
||||
//Effective stop
|
||||
agent.SetDestination(transform.position);
|
||||
animator.StopMoving();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (atTarget)
|
||||
{
|
||||
//Effective stop
|
||||
agent.SetDestination(transform.position);
|
||||
animator.StopMoving();
|
||||
if (target.isHostile)
|
||||
{
|
||||
animator.Attack();
|
||||
animator.SetAttackType(Random.Range(0, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
agent.SetDestination(target.target.transform.position);
|
||||
animator.StartMoving();
|
||||
animator.NotInLight();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Run away logic
|
||||
if (atTarget || distToTarget < 3)
|
||||
{
|
||||
animator.StopMoving();
|
||||
}
|
||||
else
|
||||
{
|
||||
var r = new Ray();
|
||||
r.origin = transform.position;
|
||||
r.direction = oppositeVector;
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(r, out hit))
|
||||
{
|
||||
animator.StartMoving();
|
||||
agent.SetDestination(hit.point);
|
||||
}
|
||||
else
|
||||
{
|
||||
agent.SetDestination(transform.position + oppositeVector * 100);
|
||||
agent.isStopped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (atTarget && target.isHostile) SlowLookAt(target.target.transform.position - transform.position);
|
||||
}
|
||||
|
||||
private void SlowLookAt(Vector3 targetVector, float animatedRotationSpeed = 1f)
|
||||
{
|
||||
var relativePos = targetVector;
|
||||
var toRotation = Quaternion.LookRotation(relativePos);
|
||||
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, toRotation, animatedRotationSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
private void CheckForAOERanges()
|
||||
{
|
||||
foreach (var bullet in flareRegister.bullets)
|
||||
{
|
||||
var dist = Vector3.Distance(bullet.transform.position, transform.position);
|
||||
if (dist <= bullet.DamageRange)
|
||||
{
|
||||
health = 0;
|
||||
Kill(true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var beacon in flareRegister.beacons)
|
||||
{
|
||||
var dist = Vector3.Distance(beacon.transform.position, transform.position);
|
||||
if (dist <= beacon.Range) health = 0f;
|
||||
}
|
||||
|
||||
if (health <= 0) Kill();
|
||||
}
|
||||
|
||||
public bool isPlayerVisible(bool withAngle)
|
||||
{
|
||||
var r = new Ray();
|
||||
r.origin = transform.position;
|
||||
r.direction = player.transform.position - transform.position;
|
||||
var toPosition = (player.transform.position - transform.position).normalized;
|
||||
var angleToPosition = Vector3.Angle(transform.forward, toPosition);
|
||||
|
||||
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(r, out hit))
|
||||
{
|
||||
var hitObject = hit.transform.gameObject;
|
||||
|
||||
if (hitObject.GetComponent<Player.PlayerComponent>() != null)
|
||||
//hit player
|
||||
return angleToPosition <= visibilityConeLimit || !withAngle;
|
||||
if (hitObject.GetComponentInParent<Player.PlayerComponent>() != null)
|
||||
//also hit player
|
||||
return angleToPosition <= visibilityConeLimit || !withAngle;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetLiveTargeting()
|
||||
{
|
||||
if (!isAlive)
|
||||
//this.targetObject.transform.position = transform.position;
|
||||
Stop();
|
||||
|
||||
distanceToPlayer = Vector3.Distance(transform.position, player.transform.position);
|
||||
//print("Dist Comparison "+distanceToPlayer.ToString()+" Noise:"+player.NoiseManager.NoiseDistance);
|
||||
var isPlayerVisible = this.isPlayerVisible(true);
|
||||
//check if player is heard or player line of sight
|
||||
if (distanceToPlayer <= player.NoiseManager.NoiseDistance || isPlayerVisible)
|
||||
{
|
||||
//check that nothing in between
|
||||
if (this.isPlayerVisible(false)) Target(player.gameObject, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (timeSinceTarget < newTargetCooldown)
|
||||
//no further targeting
|
||||
//Stop();
|
||||
return;
|
||||
|
||||
Item.BulletComponent closestBullet = null;
|
||||
var closestDistance = Mathf.Infinity;
|
||||
foreach (var bullet in flareRegister.bullets)
|
||||
{
|
||||
var bDist = Vector3.Distance(bullet.transform.position, transform.position);
|
||||
if (closestBullet == null || (bDist < bulletSoundRange && bDist < closestDistance))
|
||||
{
|
||||
closestBullet = bullet;
|
||||
closestDistance = bDist;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestBullet != null && closestBullet.DamageRange == 0)
|
||||
{
|
||||
targetObject.transform.position = closestBullet.transform.position;
|
||||
Target(targetObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObject.transform.position = transform.position;
|
||||
Target(targetObject);
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
STANDARD BEHAVIOR:
|
||||
- OnSeeing/Hearing Player:
|
||||
- Run towards Player
|
||||
- OnHearing Bolt:
|
||||
- Run towards bolt
|
||||
- OnSeeing Flare:
|
||||
- Run towards flare if not within (flareRange + flareMargin).
|
||||
- This acts like if you are far enough away that you don't feel the pain of the flare
|
||||
- OnSeeing FlareBeacon:
|
||||
- Run away if within (flareBeaconRange + flareBeaconMargin).
|
||||
|
||||
*/
|
||||
|
||||
//Runs towards target. If its meant to be hostile, it will melee attack once in range.
|
||||
public void Target(GameObject obj, bool hostile = false)
|
||||
{
|
||||
if (target == null || target.target != obj)
|
||||
{
|
||||
//target = new TargetInformation(obj,hostile,false,runTowards:true);
|
||||
target = new TargetInformation();
|
||||
target.target = obj;
|
||||
target.isHostile = hostile;
|
||||
target.hasDamageRange = false;
|
||||
target.runTowards = true;
|
||||
timeSinceTarget = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Runs towards flare such that it stops randomly within margin before range.
|
||||
public void TargetFlare(GameObject obj, float range, float margin)
|
||||
{
|
||||
if (target == null || target.target != obj)
|
||||
{
|
||||
//target = new TargetInformation(obj, false, true, range, margin,runTowards:true);
|
||||
target = new TargetInformation();
|
||||
target.target = obj;
|
||||
target.isHostile = false;
|
||||
target.hasDamageRange = true;
|
||||
target.damageRange = range;
|
||||
target.damageMargin = margin;
|
||||
target.runTowards = true;
|
||||
timeSinceTarget = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs away from object. A minimum range is specified where it no longer takes damage, and a minimum margin is
|
||||
/// speicifed where it can stop running.
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="minRange"></param>
|
||||
/// <param name="minMargin"></param>
|
||||
public void RunAwayFrom(GameObject obj, float minRange, float minMargin)
|
||||
{
|
||||
if (target == null || target.target != obj)
|
||||
{
|
||||
//target = new TargetInformation(obj, false, true, minRange, minMargin, false);
|
||||
target = new TargetInformation();
|
||||
target.target = obj;
|
||||
target.isHostile = false;
|
||||
target.hasDamageRange = true;
|
||||
target.damageRange = minRange;
|
||||
target.damageMargin = minMargin;
|
||||
target.runTowards = false;
|
||||
oppositeVector = -(target.target.transform.position - transform.position).normalized;
|
||||
timeSinceTarget = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
target = new TargetInformation();
|
||||
target.target = gameObject;
|
||||
target.isHostile = false;
|
||||
target.hasDamageRange = false;
|
||||
target.runTowards = true;
|
||||
}
|
||||
|
||||
public void Kill(bool fast = false)
|
||||
{
|
||||
if (isAlive)
|
||||
{
|
||||
animator.Kill(fast);
|
||||
isAlive = false;
|
||||
agent.isStopped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class TargetInformation
|
||||
{
|
||||
public float damageMargin;
|
||||
public float damageRange;
|
||||
public bool hasDamageRange;
|
||||
public bool isHostile;
|
||||
public bool runTowards;
|
||||
|
||||
public GameObject target;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ef96d673cf373444b2ae89ea9588ee1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Enemies/AI/Tester.meta
Normal file
8
Assets/Scripts/Legacy/Enemies/AI/Tester.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb4695679f3562e48be282f6f41c7c98
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TestSkinnlessMonster : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private SkinlessMonsterComponent monster;
|
||||
|
||||
[SerializeField] private Camera cam;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1)) monster.Target(cam.gameObject, true);
|
||||
if (Input.GetKeyDown(KeyCode.Alpha2)) monster.TargetFlare(cam.gameObject, 1, 1);
|
||||
if (Input.GetKeyDown(KeyCode.Alpha3)) monster.RunAwayFrom(cam.gameObject, 1, 1);
|
||||
if (Input.GetKeyDown(KeyCode.Alpha0)) monster.Stop();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7669ff0185daae442aef0aafc331fdbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Scripts/Legacy/Enemies/DummyComponent.cs
Normal file
25
Assets/Scripts/Legacy/Enemies/DummyComponent.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Enemy
|
||||
{
|
||||
public class DummyComponent : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponentInParent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if (collision.gameObject.GetComponent<Item.BulletComponent>() != null) anim.Play("DummyFall");
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Enemies/DummyComponent.cs.meta
Normal file
11
Assets/Scripts/Legacy/Enemies/DummyComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7704c7887a840104bbb7774436810b7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Scripts/Legacy/Enemies/MonsterComponent.cs
Normal file
24
Assets/Scripts/Legacy/Enemies/MonsterComponent.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Enemy {
|
||||
public class MonsterComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float attackDamage = 1f;
|
||||
|
||||
[SerializeField] private bool shakeCameraOnHit = true;
|
||||
|
||||
public float AttackDamage => attackDamage;
|
||||
|
||||
public bool ShakeCameraOnHit => shakeCameraOnHit;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Enemies/MonsterComponent.cs.meta
Normal file
11
Assets/Scripts/Legacy/Enemies/MonsterComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14a29478dda21134ab3eef7c2c3f6d93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Enemies/Robot.meta
Normal file
8
Assets/Scripts/Legacy/Enemies/Robot.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b7da1e97ac501d47b23b10c3f65703d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
88
Assets/Scripts/Legacy/Enemies/Robot/IKControl_Robot.cs
Normal file
88
Assets/Scripts/Legacy/Enemies/Robot/IKControl_Robot.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class IKControl_Robot : MonoBehaviour
|
||||
{
|
||||
public bool ikActive;
|
||||
public Transform rightHandObj;
|
||||
public Transform leftHandObj;
|
||||
public Transform lookObj;
|
||||
public Transform stepOnObj;
|
||||
public Transform stepOffObj;
|
||||
|
||||
protected Animator animator;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
transform.Rotate(0, 90, 0);
|
||||
}
|
||||
|
||||
//a callback for calculating IK
|
||||
private void OnAnimatorIK()
|
||||
{
|
||||
if (animator)
|
||||
{
|
||||
//if the IK is active, set the position and rotation directly to the goal.
|
||||
if (ikActive)
|
||||
{
|
||||
// Set the look target position, if one has been assigned
|
||||
if (lookObj != null)
|
||||
{
|
||||
animator.SetLookAtWeight(1);
|
||||
animator.SetLookAtPosition(lookObj.position);
|
||||
}
|
||||
|
||||
// Set the right hand target position and rotation, if one has been assigned
|
||||
if (rightHandObj != null)
|
||||
{
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
|
||||
animator.SetIKPosition(AvatarIKGoal.RightHand, rightHandObj.position);
|
||||
animator.SetIKRotation(AvatarIKGoal.RightHand, rightHandObj.rotation);
|
||||
}
|
||||
|
||||
if (leftHandObj != null)
|
||||
{
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
|
||||
animator.SetIKPosition(AvatarIKGoal.LeftHand, leftHandObj.position);
|
||||
animator.SetIKRotation(AvatarIKGoal.LeftHand, leftHandObj.rotation);
|
||||
}
|
||||
|
||||
if (stepOnObj != null)
|
||||
{
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, 1);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, 1);
|
||||
animator.SetIKPosition(AvatarIKGoal.LeftFoot, stepOnObj.position);
|
||||
animator.SetIKRotation(AvatarIKGoal.LeftFoot, stepOnObj.rotation);
|
||||
}
|
||||
|
||||
if (stepOffObj != null)
|
||||
{
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, 1);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.RightFoot, 1);
|
||||
animator.SetIKPosition(AvatarIKGoal.RightFoot, stepOffObj.position);
|
||||
animator.SetIKRotation(AvatarIKGoal.RightFoot, stepOffObj.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
//if the IK is not active, set the position and rotation of the hand and head back to the original position
|
||||
else
|
||||
{
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 0);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 0);
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 0);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 0);
|
||||
|
||||
animator.SetLookAtWeight(0);
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, 0);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, 0);
|
||||
|
||||
animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, 0);
|
||||
animator.SetIKRotationWeight(AvatarIKGoal.RightFoot, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Enemies/Robot/IKControl_Robot.cs.meta
Normal file
11
Assets/Scripts/Legacy/Enemies/Robot/IKControl_Robot.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 892157fc59d54bc44baf3845b74c1ec6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/Legacy/Enemies/Robot/RobotMouthAnimator.cs
Normal file
44
Assets/Scripts/Legacy/Enemies/Robot/RobotMouthAnimator.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.VFX;
|
||||
|
||||
public class RobotMouthAnimator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private VisualEffect fireEffect;
|
||||
|
||||
[SerializeField] private Light fireLight;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
fireLight.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
anim.SetBool("FlapsOpen", !anim.GetBool("FlapsOpen"));
|
||||
if (anim.GetBool("FlapsOpen"))
|
||||
{
|
||||
StartCoroutine(WaitToFire());
|
||||
}
|
||||
else
|
||||
{
|
||||
fireEffect.Stop();
|
||||
fireLight.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitToFire()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
fireEffect.Play();
|
||||
fireLight.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e74663ab7e2dae46ae5884c256b157f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
65
Assets/Scripts/Legacy/Enemies/SwarmAnimator.cs
Normal file
65
Assets/Scripts/Legacy/Enemies/SwarmAnimator.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.VFX;
|
||||
|
||||
namespace Enemy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class SwarmAnimator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private VisualEffect vfx;
|
||||
|
||||
[SerializeField] private Rigidbody rb;
|
||||
//[SerializeField]
|
||||
//private string parameterName = "DeltaVector";
|
||||
|
||||
[SerializeField] private Vector3 avoidancePosDefault;
|
||||
|
||||
[SerializeField] private float explodeDuration = 1.0f;
|
||||
|
||||
private Vector3 currentPosition;
|
||||
private float dur;
|
||||
private bool isExploding;
|
||||
private Vector3 previousPosition;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
previousPosition = currentPosition;
|
||||
currentPosition = transform.position;
|
||||
var velocity = currentPosition - previousPosition;
|
||||
vfx.SetVector3("DeltaVector", velocity);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space)) Explode();
|
||||
if (isExploding)
|
||||
{
|
||||
if (dur > explodeDuration) StopExplode();
|
||||
dur += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
private void Explode()
|
||||
{
|
||||
vfx.SetVector3("Avoid", transform.position);
|
||||
isExploding = true;
|
||||
dur = 0;
|
||||
|
||||
//Wait a sec then stop.
|
||||
}
|
||||
|
||||
private void StopExplode()
|
||||
{
|
||||
vfx.SetVector3("Avoid", avoidancePosDefault);
|
||||
isExploding = false;
|
||||
vfx.Stop();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Enemies/SwarmAnimator.cs.meta
Normal file
11
Assets/Scripts/Legacy/Enemies/SwarmAnimator.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 735497967e6cfdf4090b8092757c54a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Enviornment.meta
Normal file
8
Assets/Scripts/Legacy/Enviornment.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0ef4ce8a6c29c1488c4d1cfc6b0bb17
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Assets/Scripts/Legacy/Enviornment/EmissiveLightMatching.cs
Normal file
36
Assets/Scripts/Legacy/Enviornment/EmissiveLightMatching.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EmissiveLightMatching : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<int> indexes;
|
||||
|
||||
[SerializeField] private Light reference;
|
||||
|
||||
private readonly List<Color> colors = new();
|
||||
private float initIntensity;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
initIntensity = reference.intensity;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
foreach (var index in indexes)
|
||||
colors.Add(gameObject.GetComponent<MeshRenderer>().materials[index].GetColor("_EmissiveColor"));
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
var x = 0;
|
||||
foreach (var i in indexes)
|
||||
{
|
||||
gameObject.GetComponent<MeshRenderer>().materials[i].SetColor("_EmissiveColor",
|
||||
colors[x] * (10 * reference.intensity / initIntensity));
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5121ccf5a359b594aa31296fd9902dfb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Experimental.meta
Normal file
8
Assets/Scripts/Legacy/Experimental.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7708026c94d9bda419e2135a5d117af1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TestAnimationParameters : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float speed;
|
||||
|
||||
[SerializeField] private int attackIndex;
|
||||
|
||||
[SerializeField] private int attack;
|
||||
|
||||
[SerializeField] private bool inlight;
|
||||
|
||||
[SerializeField] private int attackScream;
|
||||
|
||||
private Animator animator;
|
||||
private int pattack = -1;
|
||||
private int pAttackScream = -1;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
animator.SetFloat("Speed", speed);
|
||||
animator.SetInteger("AttackIndex", attackIndex);
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
animator.SetTrigger("Attack");
|
||||
pattack = attack;
|
||||
}
|
||||
|
||||
;
|
||||
animator.SetBool("InLight", inlight);
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
animator.SetTrigger("AttackScream");
|
||||
pAttackScream = attackScream;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ee204cb45a53774fb5bd811472f7be8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Game.meta
Normal file
8
Assets/Scripts/Legacy/Game.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32bb8ee4a70c926438bc8c849ca246c3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Scripts/Legacy/Game/Game_Assembly.asmdef
Normal file
25
Assets/Scripts/Legacy/Game/Game_Assembly.asmdef
Normal 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
|
||||
}
|
7
Assets/Scripts/Legacy/Game/Game_Assembly.asmdef.meta
Normal file
7
Assets/Scripts/Legacy/Game/Game_Assembly.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed2e13dc5752a434aadb5bd0b74dd42a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
139
Assets/Scripts/Legacy/Game/InGameManager.cs
Normal file
139
Assets/Scripts/Legacy/Game/InGameManager.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public class InGameManager : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private Volume gameVolume;
|
||||
|
||||
|
||||
[SerializeField] private Volume pausedVolume;
|
||||
|
||||
[SerializeField] private bool isPaused;
|
||||
|
||||
// [SerializeField]
|
||||
//private float pauseTransitionDuration = 1f;
|
||||
|
||||
[SerializeField] private Canvas gameCanvas;
|
||||
|
||||
[SerializeField] private Canvas pausedCanvas;
|
||||
|
||||
[SerializeField] private List<AudioSource> sounds = new();
|
||||
|
||||
private readonly List<float> initSoundVolumes = new();
|
||||
private bool isTransitioning;
|
||||
|
||||
public bool IsPaused => isPaused;
|
||||
[SerializeField] private Scriptable.GameState state;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
isPaused = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = isPaused;
|
||||
gameVolume.weight = 1;
|
||||
pausedVolume.weight = 0;
|
||||
gameCanvas.gameObject.SetActive(true);
|
||||
pausedCanvas.gameObject.SetActive(false);
|
||||
|
||||
foreach (var source in sounds) initSoundVolumes.Add(source.volume);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
state.IsPaused = isPaused;
|
||||
if (Input.GetButtonDown("Pause")) TogglePause();
|
||||
|
||||
if (isTransitioning || true)
|
||||
{
|
||||
if (isPaused)
|
||||
{
|
||||
//transition into pause
|
||||
|
||||
//gameVolume.weight = Mathf.Lerp(gameVolume.weight, 0, Time.deltaTime);
|
||||
//pausedVolume.weight = Mathf.Lerp(pausedVolume.weight, 1, Time.deltaTime);
|
||||
|
||||
//gameVolume.weight = gameVolume.weight < 0.1 ? 0 : gameVolume.weight;
|
||||
//pausedVolume.weight = pausedVolume.weight > 0.9 ? 1 : pausedVolume.weight;
|
||||
gameVolume.weight = 0;
|
||||
pausedVolume.weight = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//transition out of pause
|
||||
|
||||
gameVolume.weight = 1;
|
||||
pausedVolume.weight = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TogglePause()
|
||||
{
|
||||
if (!isTransitioning)
|
||||
{
|
||||
isPaused = !isPaused;
|
||||
Cursor.visible = isPaused;
|
||||
if (!isPaused)
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
else
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
StartCoroutine(pauseTransition());
|
||||
}
|
||||
}
|
||||
|
||||
public void UnPause()
|
||||
{
|
||||
if (!isTransitioning)
|
||||
{
|
||||
isPaused = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = isPaused;
|
||||
StartCoroutine(pauseTransition());
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!isTransitioning)
|
||||
{
|
||||
isPaused = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = isPaused;
|
||||
StartCoroutine(pauseTransition());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator pauseTransition()
|
||||
{
|
||||
if (pausedCanvas.gameObject.activeInHierarchy && !isPaused) pausedCanvas.gameObject.SetActive(false);
|
||||
if (gameCanvas.gameObject.activeInHierarchy && isPaused) gameCanvas.gameObject.SetActive(false);
|
||||
|
||||
isTransitioning = true;
|
||||
yield return new WaitForSeconds(0);
|
||||
isTransitioning = false;
|
||||
print("Unpause canvas?" + isPaused + "," + pausedCanvas.gameObject.activeInHierarchy);
|
||||
if (!pausedCanvas.gameObject.activeInHierarchy && isPaused) pausedCanvas.gameObject.SetActive(true);
|
||||
if (!gameCanvas.gameObject.activeInHierarchy && !isPaused) gameCanvas.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
public void SetVolume(float volume)
|
||||
{
|
||||
for (var i = 0; i < sounds.Count; i++) sounds[i].volume = initSoundVolumes[i] * volume;
|
||||
}
|
||||
|
||||
public void ExitToMenu()
|
||||
{
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Game/InGameManager.cs.meta
Normal file
11
Assets/Scripts/Legacy/Game/InGameManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d805c17d8132601478d1da4480f05fb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
56
Assets/Scripts/Legacy/Game/InGameMenuManager.cs
Normal file
56
Assets/Scripts/Legacy/Game/InGameMenuManager.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public class InGameMenuManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button settingsButton;
|
||||
|
||||
[SerializeField] private Button returnToMenuButton;
|
||||
|
||||
[SerializeField] private Scrollbar sensitivitySlider;
|
||||
|
||||
[SerializeField] private Scrollbar volumeSlider;
|
||||
|
||||
private InGameManager gameManager;
|
||||
private Animator menuAnimator;
|
||||
[SerializeField] private Scriptable.GameSettings settings;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
menuAnimator = GetComponent<Animator>();
|
||||
settingsButton.onClick.AddListener(SettingsClicked);
|
||||
returnToMenuButton.onClick.AddListener(SettingsUnClicked);
|
||||
|
||||
gameManager = FindObjectOfType<InGameManager>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
private void SettingsClicked()
|
||||
{
|
||||
menuAnimator.SetBool("SettingsOpen", true);
|
||||
}
|
||||
|
||||
private void SettingsUnClicked()
|
||||
{
|
||||
menuAnimator.SetBool("SettingsOpen", false);
|
||||
}
|
||||
|
||||
public void UpdateSensitivity()
|
||||
{
|
||||
//player.SetSensitivity(sensitivitySlider.value * 4f);
|
||||
settings.Sensitivity = sensitivitySlider.value * 4f;
|
||||
}
|
||||
|
||||
public void UpdateVolume()
|
||||
{
|
||||
gameManager.SetVolume(volumeSlider.value * 2);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Game/InGameMenuManager.cs.meta
Normal file
11
Assets/Scripts/Legacy/Game/InGameMenuManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557d1d026294ceb4eb459580401a637c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Assets/Scripts/Legacy/Game/Optimizer.cs
Normal file
41
Assets/Scripts/Legacy/Game/Optimizer.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game {
|
||||
/// <summary>
|
||||
/// Attach this behavior to a master room collider. Enables everything in this room OnTriggerEnter of [tag]
|
||||
/// disables everything in this room OnTriggerExit of [tag]
|
||||
/// </summary>
|
||||
public class Optimizer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public string Tag;
|
||||
|
||||
[SerializeField] private GameObject[] references;
|
||||
|
||||
[SerializeField] private bool beginDisabled = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (beginDisabled) Disable();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag(Tag)) Enable();
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag(Tag)) Disable();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
foreach (var go in references) go.SetActive(true);
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
foreach (var go in references) go.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Game/Optimizer.cs.meta
Normal file
11
Assets/Scripts/Legacy/Game/Optimizer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce10ec9aaa603bb4da9dfadd6e590584
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Scripts/Legacy/GemItem.cs
Normal file
26
Assets/Scripts/Legacy/GemItem.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GemItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float instantSpeed = 98f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Player"))
|
||||
{
|
||||
collision.gameObject.GetComponent<Player.PlayerMovementController>().SetSpeed(instantSpeed);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/GemItem.cs.meta
Normal file
11
Assets/Scripts/Legacy/GemItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1330f6d70036c9847aec81a067a760d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Holograms.meta
Normal file
8
Assets/Scripts/Legacy/Holograms.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1645cf9585f37f4bbf00d3b7e69c4f2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/Scripts/Legacy/Holograms/RotatingHologram.cs
Normal file
20
Assets/Scripts/Legacy/Holograms/RotatingHologram.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class RotatingHologram : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Vector3 globalRotation = Vector3.zero;
|
||||
|
||||
[SerializeField] private Vector3 localRotation = Vector3.zero;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
transform.eulerAngles += globalRotation * Time.deltaTime;
|
||||
transform.Rotate(localRotation * Time.deltaTime);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Holograms/RotatingHologram.cs.meta
Normal file
11
Assets/Scripts/Legacy/Holograms/RotatingHologram.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ef93bdb1481e341ab083f8146e3624
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Interactable.meta
Normal file
8
Assets/Scripts/Legacy/Interactable.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fcd41ca09dce3743acbd03713e9db60
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Assets/Scripts/Legacy/Interactable/Insertable.cs
Normal file
15
Assets/Scripts/Legacy/Interactable/Insertable.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
namespace Item {
|
||||
public class Insertable : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Interactable/Insertable.cs.meta
Normal file
11
Assets/Scripts/Legacy/Interactable/Insertable.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7406a2a2283cc074dba144678253dfee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/Legacy/Interactable/Interactable.cs
Normal file
18
Assets/Scripts/Legacy/Interactable/Interactable.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
namespace Item
|
||||
{
|
||||
|
||||
|
||||
public class Interactable : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Interactable/Interactable.cs.meta
Normal file
11
Assets/Scripts/Legacy/Interactable/Interactable.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b461df434f407d4e9a24104595ac3c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
46
Assets/Scripts/Legacy/Interactable/ItemSelector.cs
Normal file
46
Assets/Scripts/Legacy/Interactable/ItemSelector.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
namespace Item
|
||||
{
|
||||
public class ItemSelector : MonoBehaviour
|
||||
{
|
||||
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()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Interactable/ItemSelector.cs.meta
Normal file
11
Assets/Scripts/Legacy/Interactable/ItemSelector.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eb8c70704eba0741a0b281bc6ff3d8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Inventory.meta
Normal file
8
Assets/Scripts/Legacy/Inventory.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e4e90b371fb0994083a4dc7b32c70ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
70
Assets/Scripts/Legacy/Inventory/Inventory.cs
Normal file
70
Assets/Scripts/Legacy/Inventory/Inventory.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
/// <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
|
||||
{
|
||||
[SerializeField] private string inventoryName;
|
||||
|
||||
[SerializeField] private int inventorySize;
|
||||
|
||||
[SerializeField] private List<string> inventoryItems;
|
||||
|
||||
private int inventoryReserved;
|
||||
|
||||
/// <summary>
|
||||
/// Adds item to inventory. Does not disable.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddItem(Item.CarryableItem item)
|
||||
{
|
||||
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>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Inventory/Inventory.cs.meta
Normal file
11
Assets/Scripts/Legacy/Inventory/Inventory.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2003234a0aa11e4797fe8fe9376402f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
57
Assets/Scripts/Legacy/Inventory/TempInventory.cs
Normal file
57
Assets/Scripts/Legacy/Inventory/TempInventory.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
[Serializable]
|
||||
public class TempInventoryBuilderItem
|
||||
{
|
||||
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()
|
||||
{
|
||||
foreach (var item in initialInvent) inventory[item.name] = item.quantity;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Inventory/TempInventory.cs.meta
Normal file
11
Assets/Scripts/Legacy/Inventory/TempInventory.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0409b6b23ffc72640a6491311e0f6a26
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Item.meta
Normal file
8
Assets/Scripts/Legacy/Item.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95bdc0199a7bdb04a9f84c79893bff49
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/Legacy/Item/CarryableItem.cs
Normal file
18
Assets/Scripts/Legacy/Item/CarryableItem.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using FishNet.Connection;
|
||||
using FishNet.Object;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public abstract class CarryableItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string itemName;
|
||||
|
||||
[SerializeField] private int itemSize = 1;
|
||||
|
||||
public string ItemName => itemName;
|
||||
public int ItemSize => itemSize;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/CarryableItem.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/CarryableItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7beeb2b1c959a8a4a89869ecf33d0f16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
98
Assets/Scripts/Legacy/Item/DoorInteractable.cs
Normal file
98
Assets/Scripts/Legacy/Item/DoorInteractable.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using UnityEngine;
|
||||
namespace Item
|
||||
{
|
||||
public class DoorInteractable : HeavyItemReceiver
|
||||
{
|
||||
[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()
|
||||
{
|
||||
}
|
||||
|
||||
// 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 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;
|
||||
}
|
||||
|
||||
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
|
||||
{
|
||||
//print("INTERACTED 2");
|
||||
// print(heavyInvent);
|
||||
|
||||
if (heavyInvent != null && heavyInvent.ItemName.Contains(nameSearched))
|
||||
{
|
||||
//print("DOOR OPEN!");
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = true;
|
||||
|
||||
heavyInvent.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
|
||||
priorLocalPos = heavyInvent.transform.localPosition;
|
||||
priorLocalRot = heavyInvent.transform.localEulerAngles;
|
||||
priorScale = heavyInvent.transform.localScale;
|
||||
|
||||
heavyInvent.transform.parent = powerCoreCenter;
|
||||
|
||||
heavyInvent.gameObject.transform.localPosition = Vector3.zero;
|
||||
heavyInvent.gameObject.transform.localEulerAngles = Vector3.zero;
|
||||
heavyInvent.transform.parent = null;
|
||||
heavyInvent.gameObject.transform.localScale = priorScale;
|
||||
|
||||
insertedCore = heavyInvent;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (insertedCore != null && heavyInvent == null)
|
||||
{
|
||||
heavyInvent = insertedCore;
|
||||
|
||||
insertedCore = null;
|
||||
//get ref of player perhaps
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/DoorInteractable.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/DoorInteractable.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f575b137603a4b4282a6551120c979a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Item/FlareBeacon.meta
Normal file
8
Assets/Scripts/Legacy/Item/FlareBeacon.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8f50dd997a71e548881cf0a65dff80f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
72
Assets/Scripts/Legacy/Item/FlareBeacon/FlareBeacon.cs
Normal file
72
Assets/Scripts/Legacy/Item/FlareBeacon/FlareBeacon.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class FlareBeacon : MonoBehaviour
|
||||
{
|
||||
[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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
inRange.Add(other.gameObject);
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
inRange.Remove(other.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/FlareBeacon/FlareBeacon.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/FlareBeacon/FlareBeacon.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 210701b0acc3ff542b0d114370d98777
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Scripts/Legacy/Item/GenericInteractable.cs
Normal file
24
Assets/Scripts/Legacy/Item/GenericInteractable.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace Item
|
||||
{
|
||||
public class GenericInteractable : InteractableItem
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
BaseAwake();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Interact()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent)
|
||||
{
|
||||
return Interact();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/GenericInteractable.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/GenericInteractable.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebc98b4f9e53f6841830816aa1064d6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/Scripts/Legacy/Item/HeavyInteractableItem.cs
Normal file
49
Assets/Scripts/Legacy/Item/HeavyInteractableItem.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class HeavyInteractableItem : InteractableItem
|
||||
{
|
||||
private Vector3 init_rot;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
init_rot = transform.eulerAngles;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
BaseFixedUpdate();
|
||||
//print("Alpha Target:"+ base.target_alpha);
|
||||
}
|
||||
|
||||
public void DisableAll()
|
||||
{
|
||||
GetComponent<Collider>().enabled = 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);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/HeavyInteractableItem.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/HeavyInteractableItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 051ddd707f17e1040b0fbe15645f75b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Assets/Scripts/Legacy/Item/HeavyItemReceiver.cs
Normal file
13
Assets/Scripts/Legacy/Item/HeavyItemReceiver.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public abstract class HeavyItemReceiver : InteractableItem
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Specify the keyword search in the name of the item!")]
|
||||
protected string searchString;
|
||||
|
||||
protected HeavyInteractableItem item;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/HeavyItemReceiver.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/HeavyItemReceiver.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aef7fff75652a9a499e312b65c8f91b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
74
Assets/Scripts/Legacy/Item/InteractableItem.cs
Normal file
74
Assets/Scripts/Legacy/Item/InteractableItem.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using FishNet.Object;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public abstract class InteractableItem : CarryableItem
|
||||
{
|
||||
[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()
|
||||
{
|
||||
BaseAwake();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
BaseFixedUpdate();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/InteractableItem.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/InteractableItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1b92dbad437a8241a0eef54af2becd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
31
Assets/Scripts/Legacy/Item/KeyItem.cs
Normal file
31
Assets/Scripts/Legacy/Item/KeyItem.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
namespace Item
|
||||
{
|
||||
public class KeyItem : InteractableItem
|
||||
{
|
||||
[SerializeField] private string keyName;
|
||||
|
||||
public string KeyName => keyName;
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/KeyItem.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/KeyItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb21435ed07266d488d3c4116207dfd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Item/Pistol.meta
Normal file
8
Assets/Scripts/Legacy/Item/Pistol.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cd9f53a6ff4b6443b3d5b95e50767e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/Scripts/Legacy/Item/Pistol/BulletComponent.cs
Normal file
49
Assets/Scripts/Legacy/Item/Pistol/BulletComponent.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using FishNet.Object;
|
||||
using FishNet;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class BulletComponent : NetworkBehaviour
|
||||
{
|
||||
[SerializeField] private float duration = 5f;
|
||||
|
||||
[SerializeField] private string type = "flare";
|
||||
|
||||
[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 = Item.FlareRegister.instance;
|
||||
register.bullets.Add(this);
|
||||
this.transform.parent = null;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (existed >= duration)
|
||||
{
|
||||
register.bullets.Remove(this);
|
||||
InstanceFinder.ServerManager.Despawn(gameObject);
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
|
||||
existed += Time.fixedDeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/Pistol/BulletComponent.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/Pistol/BulletComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ea1ee4df8019a143b013f8837aa48d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class PistolAnimationAimAssist : MonoBehaviour
|
||||
{
|
||||
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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4463cddde602cde4b8fab345649839c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
207
Assets/Scripts/Legacy/Item/Pistol/PistolComponent.cs
Normal file
207
Assets/Scripts/Legacy/Item/Pistol/PistolComponent.cs
Normal file
@ -0,0 +1,207 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.VFX;
|
||||
using FishNet.Object;
|
||||
using FishNet;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class PistolComponent : NetworkBehaviour
|
||||
{
|
||||
public enum AimMode
|
||||
{
|
||||
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)
|
||||
{
|
||||
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.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);
|
||||
}
|
||||
|
||||
|
||||
[ServerRpc]
|
||||
public void Fire(bool offsetWithTargetBall)
|
||||
{
|
||||
|
||||
shootLightDuration = 0;
|
||||
shootLight.gameObject.SetActive(true);
|
||||
|
||||
// var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
|
||||
var projectile = Instantiate(projectilePrefab);
|
||||
projectile.transform.position = bulletSpawnPoint.transform.position;
|
||||
projectile.transform.rotation = bulletSpawnPoint.transform.rotation;
|
||||
//Comment this line if you want to remove the mega scale.
|
||||
projectile.transform.localScale =bulletSpawnPoint.transform.localScale;
|
||||
InstanceFinder.ServerManager.Spawn(projectile); //var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
|
||||
|
||||
//InstanceFinder.ServerManager.Spawn(projectile);
|
||||
|
||||
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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
IsEnabled = true;
|
||||
if (targetObject == null) targetObject = Instantiate(targetObjectPrefab);
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
IsEnabled = false;
|
||||
if (targetObject != null) Destroy(targetObject);
|
||||
}
|
||||
|
||||
|
||||
public void LightToggle()
|
||||
{
|
||||
targetingLight.gameObject.SetActive(!targetingLight.gameObject.activeSelf);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/Pistol/PistolComponent.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/Pistol/PistolComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0bc8aa373bfbe44e91f0625324088be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Item/Registers.meta
Normal file
8
Assets/Scripts/Legacy/Item/Registers.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90f48ba02e4248644b7c711ebd9b212f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Scripts/Legacy/Item/Registers/FlareRegister.cs
Normal file
24
Assets/Scripts/Legacy/Item/Registers/FlareRegister.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class FlareRegister : MonoBehaviour
|
||||
{
|
||||
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()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/Registers/FlareRegister.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/Registers/FlareRegister.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 788a4240e87c8654fa8813057977c848
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
116
Assets/Scripts/Legacy/Item/SpecialItemCycler.cs
Normal file
116
Assets/Scripts/Legacy/Item/SpecialItemCycler.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
[Serializable]
|
||||
public class ItemImageRef
|
||||
{
|
||||
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 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()
|
||||
{
|
||||
sqtInitColor = selectedQuantityText.color;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Legacy/Item/SpecialItemCycler.cs.meta
Normal file
11
Assets/Scripts/Legacy/Item/SpecialItemCycler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57edf3fe88ab13c42b4f2b0cab83a3b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Levels.meta
Normal file
8
Assets/Scripts/Legacy/Levels.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06fbfed4d1ea81a41bbcde89f691be0d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Legacy/Levels/Level0Scripts.meta
Normal file
8
Assets/Scripts/Legacy/Levels/Level0Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f02ae7c1e256284fb81278af2697803
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BasicLevelProgressionSystem : MonoBehaviour
|
||||
{
|
||||
//Fire1 is click or A
|
||||
//Place is F or "Y" button
|
||||
//Cycle is Tab or RB
|
||||
//Siwtch is Shift or "X"
|
||||
public enum InputType
|
||||
{
|
||||
FIRE1,
|
||||
PLACE,
|
||||
CYCLE,
|
||||
SWITCH,
|
||||
COLLISION,
|
||||
LOCATION,
|
||||
AIM,
|
||||
EXTERNAL
|
||||
}
|
||||
|
||||
[SerializeField] private UI.ObjectiveText objectiveGui;
|
||||
|
||||
[SerializeField] private UI.WaypointMarker marker;
|
||||
|
||||
[SerializeField] private Player.PlayerComponent player;
|
||||
//[SerializeField]
|
||||
//private float minDist = 3;
|
||||
|
||||
[SerializeField] private List<ProgressionSection> sections;
|
||||
|
||||
private int progress;
|
||||
private bool transitioning;
|
||||
public List<ProgressionSection> Sections => sections;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
var cur = getCurrent().getActive();
|
||||
if (cur != null)
|
||||
{
|
||||
if (!getCurrent().objectiveOneMet)
|
||||
{
|
||||
marker.target = cur;
|
||||
objectiveGui.visualObjects[0].text.text = getCurrent().instruction1;
|
||||
objectiveGui.visualObjects[1].text.text = getCurrent().istruction2;
|
||||
}
|
||||
else if (!getCurrent().objectiveTwoMet)
|
||||
{
|
||||
marker.target = cur;
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("Fire1") || (Input.GetAxis("Fire1") > 0.5f && !transitioning))
|
||||
ProgressCurrentIfInput(InputType.FIRE1);
|
||||
if (Input.GetButtonDown("TempPlace")) ProgressCurrentIfInput(InputType.PLACE);
|
||||
if (Input.GetButtonDown("CycleItems")) ProgressCurrentIfInput(InputType.CYCLE);
|
||||
if (Input.GetButtonDown("Fire3")) ProgressCurrentIfInput(InputType.SWITCH);
|
||||
if (Input.GetAxis("Aim") > .5f || Input.GetButtonDown("Aim"))
|
||||
if (!transitioning)
|
||||
ProgressCurrentIfInput(InputType.AIM);
|
||||
|
||||
if (Vector3.Distance(player.transform.position, getCurrent().getActive().position) < 3)
|
||||
{
|
||||
var canIterate = getCurrent().Iterate();
|
||||
if (!canIterate)
|
||||
{
|
||||
if (!getCurrent().objectiveOneMet && getCurrent().conditionalOne == InputType.LOCATION)
|
||||
OnePassed();
|
||||
else if (getCurrent().objectiveOneMet && getCurrent().conditionalTwo == InputType.LOCATION &&
|
||||
!getCurrent().objectiveTwoMet) TwoPassed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.GetComponentInParent<Player.PlayerComponent>() != null) ProgressCurrentIfCollide();
|
||||
}
|
||||
|
||||
private void ProgressCurrentIfCollide()
|
||||
{
|
||||
}
|
||||
|
||||
private void OnePassed()
|
||||
{
|
||||
getCurrent().objectiveOneMet = true;
|
||||
getCurrent().Progress();
|
||||
|
||||
objectiveGui.visualObjects[0].isComplete = true;
|
||||
}
|
||||
|
||||
public void TwoPassed()
|
||||
{
|
||||
if (transitioning) return;
|
||||
getCurrent().objectiveTwoMet = true;
|
||||
objectiveGui.visualObjects[1].isComplete = true;
|
||||
objectiveGui.FadeOut();
|
||||
transitioning = true;
|
||||
StartCoroutine(waitForFadeIn());
|
||||
}
|
||||
|
||||
public void ProgressCurrentIfInput(InputType type)
|
||||
{
|
||||
if (getCurrent().AtEnd() && getCurrent().conditionalOne == type && !getCurrent().objectiveOneMet)
|
||||
OnePassed();
|
||||
else if (getCurrent().AtEnd() && getCurrent().conditionalTwo == type) TwoPassed();
|
||||
}
|
||||
|
||||
public ProgressionSection getCurrent()
|
||||
{
|
||||
return sections[progress];
|
||||
}
|
||||
|
||||
private IEnumerator waitForFadeIn()
|
||||
{
|
||||
yield return new WaitForSeconds(3);
|
||||
if (sections.Count > progress + 1)
|
||||
{
|
||||
progress++;
|
||||
objectiveGui.FadeIn();
|
||||
objectiveGui.visualObjects[0].isComplete = false;
|
||||
objectiveGui.visualObjects[1].isComplete = false;
|
||||
}
|
||||
|
||||
transitioning = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class ProgressionSection
|
||||
{
|
||||
[SerializeField] public string instruction1;
|
||||
|
||||
[SerializeField] public string istruction2;
|
||||
|
||||
[SerializeField] public bool objectiveOneMet;
|
||||
|
||||
[SerializeField] public BasicLevelProgressionSystem.InputType conditionalOne;
|
||||
|
||||
[SerializeField] public bool objectiveTwoMet;
|
||||
|
||||
[SerializeField] public BasicLevelProgressionSystem.InputType conditionalTwo;
|
||||
|
||||
[SerializeField] public List<Transform> positionsOne = new();
|
||||
|
||||
[SerializeField] public List<Transform> positionsTwo = new();
|
||||
|
||||
[HideInInspector] public int activePosition;
|
||||
|
||||
public Transform getActive()
|
||||
{
|
||||
if (!objectiveOneMet)
|
||||
return positionsOne[activePosition];
|
||||
return positionsTwo[activePosition];
|
||||
}
|
||||
|
||||
public bool Iterate()
|
||||
{
|
||||
if (!objectiveOneMet && activePosition + 1 < positionsOne.Count)
|
||||
{
|
||||
activePosition += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (objectiveOneMet && !objectiveTwoMet && activePosition + 1 < positionsTwo.Count)
|
||||
{
|
||||
activePosition += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AtEnd()
|
||||
{
|
||||
if (!objectiveOneMet && activePosition + 1 < positionsOne.Count)
|
||||
return false;
|
||||
if (objectiveOneMet && !objectiveTwoMet && activePosition + 1 < positionsTwo.Count) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Progress()
|
||||
{
|
||||
activePosition = 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b320804c8114b8e4b954e2f51b5b8083
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user