merge door to staging

This commit is contained in:
HelarJ
2022-03-28 16:54:50 +03:00
1331 changed files with 410263 additions and 5190 deletions

View File

@@ -5,113 +5,106 @@ using UnityEngine;
public class ActionGestureInteraction : MonoBehaviour
{
public List<GameObject> objects;
public Camera playerCamera;
private Vector3 destination;
private Transform rightHandTransform;
public Transform rightHandTransform;
private GameObject player;
/**public int blinkUses;
public float blinkCooldown, blinkDistance, blinkSpeed, blinkDestinationMultiplier;
public LayerMask blinkLayerMask;**/
public float projectileSpeed = 30;
void Start()
{
player = GameObject.Find("XR Origin");
rightHandTransform = player.transform.Find("Camera Offset").Find("RightHand Controller").transform;
player = gameObject;
}
public void PerformAction(string action)
{
//Debug.Log(action);
//if (action == "Blink")
//{
//BlinkCast(); [DEPRECATED]
//}
//else
//{
Debug.Log(action);
if (action == "Portal")
{
// Raycast to find portal were looking at.
var nearestPortal = FindPortalInFront();
Debug.Log(nearestPortal);
EnableDisablePortal(nearestPortal);
}
else
{
foreach (var item in objects)
{
if (item.name == action)
if (item.name == action && action == "IceBolt")
{
Instantiate(item, rightHandTransform.position, Quaternion.identity);
ShootProjectile();
InstantiateIceBolt(item);
}
}
//}
}
/**
int maxUses;
float cooldownTimer;
bool blinking = false;
Vector3 destination;
**/
private void Update()
{
// Blink cooldown action;
}
/** [DEPRECATED]
void BlinkCast()
{
Transform cameraTransform = Camera.main.transform;
Transform playerTransform = player.transform;
ParticleSystem blinkTrail = player.transform.Find("BlinkTrail").GetComponent<ParticleSystem>();
maxUses = blinkUses;
cooldownTimer = blinkCooldown;
Blink();
if (blinkUses < maxUses)
{
if (cooldownTimer > 0)
{
cooldownTimer -= Time.deltaTime;
}
else
{
blinkUses += 1;
cooldownTimer = blinkCooldown;
}
if (blinking)
{
var dist = Vector3.Distance(playerTransform.position, destination);
if (dist > 0.5f)
if (item.name == action && action == "IceWall")
{
Debug.Log(Time.deltaTime * blinkSpeed);
playerTransform.position = Vector3.MoveTowards(playerTransform.position, destination, blinkDistance);
// Make ice wall appear from below to block incoming projectiles
}
}
}
}
void EnableDisablePortal(GameObject portal)
{
// Did the raycast catch a portal in front of us?
if (portal != null)
{
var distance = Vector3.Distance(portal.transform.position, this.transform.position);
Debug.Log(distance);
// Is the portal within a reasonable distance?
if (distance <= 10.0f)
{
var portalVFX = portal.transform.Find("PortalFX");
var portalTrigger = portal.transform.Find("Portal");
// if the nearest portal is already enabled, then disable, else enable.
if (portalVFX.gameObject.activeInHierarchy)
{
portalVFX.gameObject.SetActive(false);
portalTrigger.gameObject.GetComponent<PortalTeleporter>().enabled = false;
}
else
{
blinking = false;
portalVFX.gameObject.SetActive(true);
portalTrigger.gameObject.GetComponent<PortalTeleporter>().enabled =true;
}
}
}
void Blink()
{
if (blinkUses > 0)
{
blinkUses -= 1;
blinkTrail.Play();
//RaycastHit hit;
if (Physics.Raycast(playerTransform.position, playerTransform.forward, out hit, blinkDistance, blinkLayerMask))
{
Debug.Log(hit.transform.name);
destination = hit.point * blinkDestinationMultiplier;
}
else
{
destination = (cameraTransform.position + cameraTransform.forward.normalized * blinkDistance) * blinkDestinationMultiplier;
//}
}
destination.y += Camera.main.transform.position.y;
blinking = true;
GameObject FindPortalInFront()
{
Ray ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
LayerMask playerLayerMask = LayerMask.GetMask("Player");
if (Physics.Raycast(ray, out hit, playerLayerMask))
{
if (hit.transform.gameObject.transform.root.CompareTag("Portal"))
{
return hit.transform.gameObject.transform.root.gameObject;
}
}
}**/
return null;
}
void ShootProjectile()
{
Ray ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
destination = hit.point;
}
else
{
destination = ray.GetPoint(1000);
}
}
void InstantiateIceBolt(GameObject item)
{
var projectileObj = Instantiate(item, rightHandTransform.position, Quaternion.identity) as GameObject;
projectileObj.GetComponent<Rigidbody>().velocity = (destination - rightHandTransform.position).normalized * projectileSpeed;
}
}

View File

@@ -9,7 +9,7 @@ using UnityEngine.Events;
public class GestureRecognizer : MonoBehaviour
{
//public InputDevice rightHandController;
public XRNode rightHandSource;
public InputHelpers.Button rightInputButton;
public InputHelpers.Button rightControlButton;
@@ -60,11 +60,13 @@ public class GestureRecognizer : MonoBehaviour
if (!isMoving && startGesture)
{
StartMovement();
//StartCoroutine("Haptics");
}
// Ending the movement
else if (isMoving && !startGesture)
{
EndMovement();
//StopCoroutine("Haptics");
}
// Updating the movement
else if (isMoving && startGesture)
@@ -72,6 +74,14 @@ public class GestureRecognizer : MonoBehaviour
UpdateMovement();
}
}
// Still needs to be tested
//IEnumerator Haptics()
//{
// while (true)
// {
// rightHandController.SendHapticImpulse(0u, 0.7f, 0.2f);
// }
//}
void StartMovement()
{

View File

@@ -13,7 +13,12 @@ public class SpawnerGestureInteraction : MonoBehaviour
foreach (var item in objects)
{
if (item.name == objectName)
Debug.Log(item);
if (item.name == "IceBolt")
{
Instantiate(item, rightHandTransform.position, Quaternion.identity, rightHandTransform);
}
else
{
Instantiate(item, rightHandTransform.position, Quaternion.identity);
Debug.Log(objectName);

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
<<<<<<< HEAD:Assets/LowPolyDungeons/LowPolyDungeons_HDRP_2018.4.unitypackage.meta
guid: 756af0be88eb0024a9d659a6afb1bebc
=======
guid: 20b2cd43130816e429a419c3adf589b0
folderAsset: yes
>>>>>>> Shumpei:Assets/Project Files/Scripts/Shumpei.meta
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ArmSwingLocomotion : MonoBehaviour
{
public GameObject LeftHand;
public GameObject RightHand;
public GameObject CenterEyeCamera;
public GameObject ForwardDirection;
private Vector3 PositionPreviousFrameLeftHand;
private Vector3 PositionPreviousFrameRightHand;
private Vector3 PlayerPositionPreviousFrame;
private Vector3 PlayerPositionCurrentFrame;
private Vector3 PositionCurrentFrameLeftHand;
private Vector3 PositionCurrentFrameRightHand;
public float Speed;
private float HandSpeed;
// Start is called before the first frame update
void Start()
{
PlayerPositionPreviousFrame = transform.position;
PositionPreviousFrameLeftHand = LeftHand.transform.position;
PlayerPositionPreviousFrame = RightHand.transform.position;
}
// Update is called once per frame
void Update()
{
float Yrot = CenterEyeCamera.transform.eulerAngles.y;
ForwardDirection.transform.eulerAngles = new Vector3(0, Yrot, 0);
PositionCurrentFrameLeftHand = LeftHand.transform.position;
PositionCurrentFrameRightHand = RightHand.transform.position;
PlayerPositionCurrentFrame = transform.position;
//Debug.Log("Previous" + PositionPreviousFrameLeftHand);
//Debug.Log("Current" + PositionCurrentFrameLeftHand);
var playerDistanceMoved = Vector3.Distance(PlayerPositionCurrentFrame, PlayerPositionPreviousFrame);
var leftHandDistanceMoved = Vector3.Distance(PositionCurrentFrameLeftHand, PositionPreviousFrameLeftHand);
var rightHandDistanceMoved = Vector3.Distance(PositionCurrentFrameRightHand, PositionPreviousFrameRightHand);
HandSpeed = ((leftHandDistanceMoved - playerDistanceMoved) + (rightHandDistanceMoved - playerDistanceMoved));
if (Time.timeSinceLevelLoad > 1f)
{
transform.position += ForwardDirection.transform.forward * HandSpeed * Speed * Time.deltaTime;
}
PositionPreviousFrameLeftHand = PositionCurrentFrameLeftHand;
PositionPreviousFrameRightHand = PositionCurrentFrameRightHand;
PlayerPositionPreviousFrame = PlayerPositionCurrentFrame;
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoorController : MonoBehaviour
{
[SerializeField] private Animator myDoor = null;
// Start is called before the first frame update
public void DoorOpen()
{
myDoor.Play("DoorOpen", 0, 0.0f);
}
public void DoorClose()
{
myDoor.Play("DoorClose", 0, 0.0f);
}
}

View File

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

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class PhysicsButton : MonoBehaviour
{
[SerializeField] private float threshold = 0.1f;
[SerializeField] private float deadzone = 0.025f;
private bool _isPressed;
private Vector3 _startPos;
private ConfigurableJoint _joint;
public UnityEvent onPressed, onReleased;
// Start is called before the first frame update
void Start()
{
_startPos = transform.localPosition;
_joint = GetComponent<ConfigurableJoint>();
}
// Update is called once per frame
void Update()
{
if (!_isPressed && GetValue() + threshold >= 1)
Pressed();
if (_isPressed && GetValue() - threshold <= 0)
Released();
}
private float GetValue()
{
var value = Vector3.Distance(_startPos, transform.localPosition) / _joint.linearLimit.limit;
if (Mathf.Abs(value) < deadzone)
value = 0;
return Mathf.Clamp(value, -1f, 1f);
}
private void Pressed()
{
_isPressed = true;
onPressed.Invoke();
Debug.Log("Pressed");
}
private void Released()
{
_isPressed = false;
onReleased.Invoke();
Debug.Log("Released");
}
}

View File

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

View File

@@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerDoorController : MonoBehaviour
{
[SerializeField] private Animator myDoor = null;
[SerializeField] private bool openTrigger = false;
[SerializeField] private bool closeTrigger = false;
[SerializeField] private string doorOpen = "DoorOpen";
[SerializeField] private string doorClose = "DoorClose";
// Start is called before the first frame update
public void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Debug.Log("col");
if (openTrigger)
{
Debug.Log("open");
myDoor.Play(doorOpen, 0, 0.0f);
gameObject.SetActive(false);
}
else if (closeTrigger)
{
myDoor.Play(doorClose, 0, 0.0f);
gameObject.SetActive(false);
}
}
}
}

View File

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