Merge remote-tracking branch 'origin/gesture_joonasp'

# Conflicts:
#	Assets/_TerrainData/TerrainData_521113671563848736.asset
#	Assets/_TerrainData/TerrainData_699485723238748736.asset
#	Assets/_TerrainData/TerrainData_869121471408748736.asset
#	Assets/_TerrainData/TerrainMaterial_521113671563848736.mat
#	Assets/_TerrainData/TerrainMaterial_699485723238748736.mat
#	Assets/_TerrainData/TerrainMaterial_869121471408748736.mat
#	ProjectSettings/EditorBuildSettings.asset
This commit is contained in:
HelarJ
2022-04-25 16:17:38 +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);
}
}