Merge remote-tracking branch 'origin/joonasp_Milestone3' into staging2
# Conflicts: # Assets/SkyProfile-457889269655148736.asset # 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
This commit is contained in:
@@ -12,6 +12,8 @@ public class ActionGestureInteraction : MonoBehaviour
|
||||
private GameObject player;
|
||||
public float projectileSpeed = 30;
|
||||
|
||||
private bool holdingWand;
|
||||
|
||||
void Start()
|
||||
{
|
||||
player = gameObject;
|
||||
@@ -19,8 +21,63 @@ public class ActionGestureInteraction : MonoBehaviour
|
||||
|
||||
public void PerformAction(string action)
|
||||
{
|
||||
Debug.Log(action);
|
||||
if (action == "Portal")
|
||||
Debug.LogWarning(action);
|
||||
|
||||
if (player.GetComponent<PlayerInfo>().GetRightHand() != null)
|
||||
{
|
||||
Debug.LogWarning(player.GetComponent<PlayerInfo>().GetRightHand().name);
|
||||
if (player.GetComponent<PlayerInfo>().GetRightHand().name.Equals("wand")) holdingWand = true;
|
||||
}
|
||||
else holdingWand = false;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "HorizontalLine":
|
||||
if (holdingWand)
|
||||
{
|
||||
Debug.LogWarning("CAST BOLT");
|
||||
ShootProjectile();
|
||||
InstantiateIceBolt(objects[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("WOODCUTTING ACTION");
|
||||
}
|
||||
return;
|
||||
case "VerticalLine":
|
||||
if (holdingWand)
|
||||
{
|
||||
Debug.LogWarning("WAND VERTICAL");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("VERTICAL");
|
||||
}
|
||||
return;
|
||||
case "Circle":
|
||||
if (holdingWand)
|
||||
{
|
||||
Debug.LogWarning("Arcing fireball");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("CIRCLE");
|
||||
}
|
||||
return;
|
||||
case "Triangle":
|
||||
if (holdingWand)
|
||||
{
|
||||
Debug.LogWarning("WAND TRIANGLE");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("WOODCUTTING ACTION");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (action == "Portal")
|
||||
{
|
||||
// Raycast to find portal were looking at.
|
||||
var nearestPortal = FindPortalInFront();
|
||||
@@ -41,9 +98,9 @@ public class ActionGestureInteraction : MonoBehaviour
|
||||
// Make ice wall appear from below to block incoming projectiles
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
void EnableDisablePortal(GameObject portal)
|
||||
void MinigameEnable(GameObject portal)
|
||||
{
|
||||
// Did the raycast catch a portal in front of us?
|
||||
if (portal != null)
|
||||
@@ -70,7 +127,7 @@ public class ActionGestureInteraction : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
GameObject FindPortalInFront()
|
||||
GameObject FindMinigame()
|
||||
{
|
||||
Ray ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
|
||||
RaycastHit hit;
|
||||
@@ -104,6 +161,7 @@ public class ActionGestureInteraction : MonoBehaviour
|
||||
|
||||
void InstantiateIceBolt(GameObject item)
|
||||
{
|
||||
Debug.LogWarning("INSTANTIATE BOLT");
|
||||
var projectileObj = Instantiate(item, rightHandTransform.position, playerCamera.transform.rotation) as GameObject;
|
||||
projectileObj.GetComponent<Rigidbody>().velocity = (destination - rightHandTransform.position).normalized * projectileSpeed;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ public class EssenceNodeController : MonoBehaviour
|
||||
|
||||
public bool isTouched;
|
||||
private bool followPlayer = false;
|
||||
private Transform player;
|
||||
private Transform playerCamera;
|
||||
|
||||
[SerializeField]
|
||||
private PlayerInfo playerInfo;
|
||||
|
||||
private float timer;
|
||||
private Material nodeMaterial;
|
||||
@@ -21,6 +24,7 @@ public class EssenceNodeController : MonoBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
nodeMaterial = GetComponent<Renderer>().material;
|
||||
playerInfo = PlayerInfo.Instance;
|
||||
}
|
||||
|
||||
public void Touched()
|
||||
@@ -37,7 +41,7 @@ public class EssenceNodeController : MonoBehaviour
|
||||
public void FollowPlayer()
|
||||
{
|
||||
followPlayer = true;
|
||||
player = GameObject.FindGameObjectWithTag("MainCamera").transform;
|
||||
playerCamera = GameObject.FindGameObjectWithTag("MainCamera").transform;
|
||||
StartCoroutine(Collect());
|
||||
|
||||
}
|
||||
@@ -56,8 +60,8 @@ public class EssenceNodeController : MonoBehaviour
|
||||
|
||||
IEnumerator Collect()
|
||||
{
|
||||
playerInfo.AddEssenceBasic(1);
|
||||
yield return new WaitForSeconds(2f);
|
||||
//TODO: Update value in player inventory
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
@@ -76,7 +80,7 @@ public class EssenceNodeController : MonoBehaviour
|
||||
|
||||
if (followPlayer)
|
||||
{
|
||||
transform.position = Vector3.Lerp(transform.position, new Vector3(player.position.x,player.position.y - 0.5f, player.position.z), Time.deltaTime);
|
||||
transform.position = Vector3.Lerp(transform.position, new Vector3(playerCamera.position.x, playerCamera.position.y - 0.5f, playerCamera.position.z), Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
73
Assets/Project Files/Scripts/JoonasP/PlayerInfo.cs
Normal file
73
Assets/Project Files/Scripts/JoonasP/PlayerInfo.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerInfo : MonoBehaviour
|
||||
{
|
||||
public static PlayerInfo Instance;
|
||||
|
||||
private int health;
|
||||
|
||||
private int essence_basic;
|
||||
|
||||
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)
|
||||
{
|
||||
health += value;
|
||||
if (health <= 0)
|
||||
{
|
||||
Debug.Log("NO HEALTH REAMINING");
|
||||
}
|
||||
}
|
||||
|
||||
public void AddEssenceBasic(int value)
|
||||
{
|
||||
if (essence_basic + value < 0)
|
||||
{
|
||||
Debug.Log("NOT ENOUGH ESSENCE");
|
||||
}
|
||||
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 GetLeftHand()
|
||||
{
|
||||
return leftHandHeld;
|
||||
}
|
||||
|
||||
public GameObject GetRightHand()
|
||||
{
|
||||
return rightHandHeld;
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JoonasP/PlayerInfo.cs.meta
Normal file
11
Assets/Project Files/Scripts/JoonasP/PlayerInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51150922d2ca8cc44b6fc27d9365a8d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user