This commit is contained in:
2022-04-25 16:35:30 +03:00
32 changed files with 11075 additions and 44160 deletions

View File

@@ -13,6 +13,10 @@ public class ActionGestureInteraction : MonoBehaviour
public float projectileSpeed = 30;
private bool holdingWand;
private float wandPower;
private string wandElement;
public AudioSource noEssenceAudio;
void Start()
{
@@ -23,16 +27,19 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning(action);
/* todo: playerinfo doesnt have these methods?
Debug.LogWarning(player.GetComponent<PlayerInfo>().GetRightHand());
if (player.GetComponent<PlayerInfo>().GetRightHand() != null)
{
Debug.LogWarning(player.GetComponent<PlayerInfo>().GetRightHand().name);
if (player.GetComponent<PlayerInfo>().GetRightHand().name.Equals("wand")) holdingWand = true;
if (player.GetComponent<PlayerInfo>().GetRightHand().name.Contains("wand"))
{
holdingWand = true;
wandPower = player.GetComponent<PlayerInfo>().GetRightHand().GetComponent<WandData>().power;
}
}
else holdingWand = false;
*/
switch (action)
{
@@ -47,17 +54,29 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning("WOODCUTTING ACTION");
}
return;
break;
case "VerticalLine":
if (holdingWand)
{
Debug.LogWarning("WAND VERTICAL");
if (PlayerInfo.Instance.AddEssenceBasic(-1))
{
Vector3 spawnPoint = transform.position + playerCamera.transform.forward;
spawnPoint = new Vector3(spawnPoint.x, spawnPoint.y + 1, spawnPoint.z);
GameObject shield = Instantiate(objects[1], spawnPoint, Quaternion.Euler(-90, playerCamera.transform.eulerAngles.y - 180, 180));
shield.GetComponent<ShieldController>().health = 3 * wandPower;
}
else
{
noEssenceAudio.Play();
}
}
else
{
Debug.LogWarning("VERTICAL");
}
return;
break;
case "Circle":
if (holdingWand)
{
@@ -66,9 +85,15 @@ public class ActionGestureInteraction : MonoBehaviour
}
else
{
Debug.LogWarning("CIRCLE");
GameObject minigame = FindMinigame();
if (minigame != null)
{
float distance = Vector3.Distance(transform.position, minigame.transform.position);
if(distance < 4f) minigame.GetComponent<WellController>().StartMinigame();
}
}
return;
break;
case "Triangle":
if (holdingWand)
{
@@ -78,7 +103,7 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning("WOODCUTTING ACTION");
}
return;
break;
}
/*if (action == "Portal")
@@ -167,6 +192,7 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning("INSTANTIATE BOLT");
var projectileObj = Instantiate(item, rightHandTransform.position, playerCamera.transform.rotation) as GameObject;
projectileObj.GetComponent<Rigidbody>().velocity = (destination - rightHandTransform.position).normalized * projectileSpeed;
projectileObj.GetComponent<Projectile>().damage = 1 * wandPower;
projectileObj.GetComponent<Rigidbody>().velocity = (playerCamera.transform.forward).normalized * projectileSpeed;
}
}

View File

@@ -14,6 +14,8 @@ public class GestureRecognizer : MonoBehaviour
public InputHelpers.Button rightInputButton;
public InputHelpers.Button rightControlButton;
public Camera mainCamera;
public float inputThreshold = 0.1f;
public Transform movementSource;
@@ -31,10 +33,15 @@ public class GestureRecognizer : MonoBehaviour
private List<Gesture> trainingSet = new List<Gesture>();
private bool isMoving = false;
private List<Vector3> positionsList = new List<Vector3>();
private Vector3 relativePosition;
private List<GameObject> debugCubes;
private List<Vector3> relativePositions;
// Start is called before the first frame update
void Start()
{
debugCubes = new List<GameObject>();
relativePositions = new List<Vector3>();
// Path = ..\AppData\LocalLow\DefaultCompany\Heroes of Hiis SCM
Debug.Log(Application.persistentDataPath);
string[] gestureFiles = Directory.GetFiles(Application.persistentDataPath, "*.xml");
@@ -85,13 +92,18 @@ public class GestureRecognizer : MonoBehaviour
void StartMovement()
{
debugCubes.Clear();
relativePositions.Clear();
Debug.Log("Movement started");
isMoving = true;
positionsList.Clear();
positionsList.Add(movementSource.position);
relativePosition = movementSource.position - mainCamera.transform.position;
positionsList.Add(relativePosition);
if (debugCubePrefab)
{
Destroy(Instantiate(debugCubePrefab, movementSource.position, Quaternion.identity), 3);
GameObject cube = Instantiate(debugCubePrefab, relativePosition, Quaternion.identity);
debugCubes.Add(cube);
relativePositions.Add(relativePosition);
}
}
void EndMovement()
@@ -129,17 +141,31 @@ public class GestureRecognizer : MonoBehaviour
}
}
foreach(GameObject obj in debugCubes)
{
Destroy(obj);
}
}
void UpdateMovement()
{
Vector3 lastPosition = positionsList[positionsList.Count - 1];
if (Vector3.Distance(movementSource.position, lastPosition) > newPositionThresholdDistance)
relativePosition = movementSource.position - mainCamera.transform.position;
for(int i = 0; i < debugCubes.Count; i++)
{
positionsList.Add(movementSource.position);
debugCubes[i].transform.position = mainCamera.transform.position + relativePositions[i];
}
Vector3 lastPosition = positionsList[positionsList.Count - 1];
if (Vector3.Distance(relativePosition, lastPosition) > newPositionThresholdDistance)
{
positionsList.Add(relativePosition);
if (debugCubePrefab)
{
Destroy(Instantiate(debugCubePrefab, movementSource.position, Quaternion.identity), 3);
GameObject cube = Instantiate(debugCubePrefab, relativePosition, Quaternion.identity);
debugCubes.Add(cube);
relativePositions.Add(relativePosition);
}
}
}

View File

@@ -7,34 +7,46 @@ public class Projectile : MonoBehaviour
private bool collided;
Vector3 oldEulerAngles;
public float damage;
private void Start()
{
// Will always be destroyed after 10 seconds.
Destroy(gameObject, 10);
oldEulerAngles = transform.rotation.eulerAngles;
//oldEulerAngles = transform.rotation.eulerAngles;
}
private void Update()
{
if (oldEulerAngles != transform.rotation.eulerAngles)
/*if (oldEulerAngles != transform.rotation.eulerAngles)
{
Destroy(gameObject);
}
*/
}
private void onCollisionEnter(Collider other)
private void OnCollisionEnter(Collision collision)
{
Debug.LogWarning(collision.gameObject.name);
if (collision.gameObject.tag != "IceBolt" && collision.gameObject.tag != "Player" && !collided)
{
collided = true;
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK AND DAMAGE CHECKING
Destroy(gameObject);
}
}
private void OnTriggerEnter(Collider other)
{
Debug.LogWarning(other.gameObject.name);
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
}
private void onTriggerEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
else if (other.gameObject.name == "Dummy")
{
collided = true;
Destroy(other.gameObject);
Destroy(gameObject);
}
}

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class CraftingTable : MonoBehaviour
{
public Transform item1;
public Transform item2;
public Transform socket1;
public Transform socket2;
public Transform output;
public GameObject startWand;
void Start()
{
item1 = null;
item2 = null;
}
public void Set1()
{
StartCoroutine(DelayCast(socket1,1));
}
public void Exit1()
{
item1 = null;
}
public void Set2()
{
StartCoroutine(DelayCast(socket2, 2));
}
public void Exit2()
{
item2 = null;
}
public void Craft()
{
//Currently simple if statement check crafting. Could be done better but will see if this system will be expanded
if (item1 == null || item2 == null) Debug.LogError("Missing item!");
else
{
if((item1.name.StartsWith("wand") && item2.name.StartsWith("Log")) || (item2.name.StartsWith("wand") && item1.name.StartsWith("Log")))
{
if (item1.name.StartsWith("wand"))
{
WandData data = item1.GetComponent<WandData>();
data.SetPower(data.power + 0.5f);
item1.transform.position = output.position;
Destroy(item2.gameObject);
item2 = null;
}
else
{
WandData data = item2.GetComponent<WandData>();
data.SetPower(data.power + 0.5f);
item2.transform.position = output.position;
Destroy(item1.gameObject);
item1 = null;
}
}
}
Debug.LogError("Invalid Recipe!");
}
IEnumerator DelayCast(Transform from, int i)
{
yield return new WaitForSeconds(0.5f);
RaycastHit hit;
if (Physics.Raycast(from.position + from.up, -from.up, out hit, Mathf.Infinity))
{
if (i == 1) item1 = hit.transform;
else item2 = hit.transform;
}
}
}

View File

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

View File

@@ -25,7 +25,7 @@ public class EssenceNodeController : MonoBehaviour
private void Awake()
{
nodeMaterial = GetComponent<Renderer>().material;
//playerInfo = PlayerInfo.Instance;
playerInfo = PlayerInfo.Instance;
playerInventory = GameObject.Find("Inventory").GetComponent<Inventory>();
}

View File

@@ -4,32 +4,70 @@ using UnityEngine;
public class PlayerInfo : MonoBehaviour
{
public static PlayerInfo Instance;
private int health;
private int essence_basic;
//Add elemental essences?
private GameObject rightHandHeld;
private GameObject leftHandHeld;
private void Awake()
{
Instance = this;
health = 5;
essence_basic = 0;
rightHandHeld = null;
leftHandHeld = null;
}
public void AddHealth(int value)
public bool AddHealth(int value)
{
health += value;
if (health <= 0)
{
Debug.Log("NO HEALTH REMAINING");
return false;
}
return true;
}
public void AddEssenceBasic(int value)
public bool AddEssenceBasic(int value)
{
if (essence_basic + value < 0)
{
Debug.LogError("NOT ENOUGH ESSENCE");
Debug.Log("NOT ENOUGH ESSENCE");
return false;
}
else
{
essence_basic += value;
return true;
}
else essence_basic += value;
}
public void AddLeftHand(GameObject obj)
{
leftHandHeld = obj;
}
public void AddRightHand(GameObject obj)
{
rightHandHeld = obj;
}
public void RemoveLeftHand()
{
leftHandHeld = null;
}
public void RemoveRightHand()
{
rightHandHeld = null;
}
public GameObject GetRightHand() { return rightHandHeld; }
public GameObject GetLeftHand() { return leftHandHeld; }
}

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShieldController : MonoBehaviour
{
public float health = 5;
public Color startColor;
public Color endColor;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
health -= Time.deltaTime;
GetComponent<Renderer>().material.SetColor("_Color0", Color.Lerp(endColor, startColor, health / 5));
if (health <= 0) Destroy(gameObject);
}
}

View File

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

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WandData : MonoBehaviour
{
public float power = 1f;
//public string element = "water";
private void Awake()
{
}
public void SetPower(float pow)
{
power = pow;
}
}

View File

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

View File

@@ -32,7 +32,7 @@ public class XRGUI : MonoBehaviour
ExitButton.onClick.AddListener(() =>
{
Debug.Log("Clicked");
UnityEditor.EditorApplication.isPlaying = false;
//UnityEditor.EditorApplication.isPlaying = false;
});
}