small fixes

This commit is contained in:
joonasp
2022-05-16 17:47:54 +03:00
parent 9a104a8bd3
commit 86d16e0cf2
23 changed files with 11245 additions and 9795 deletions

View File

@@ -28,25 +28,26 @@ public class CuttableTree : MonoBehaviour
{
if (other.tag == "Cutter")
{
rotation = transform.rotation;
rotation *= Quaternion.AngleAxis(20, Vector3.up);
Instantiate(stumpPrefab, transform.position, rotation);
Instantiate(logPrefab, transform.position + new Vector3(0, 1, 0), rotation);
onCut.Invoke();
Destroy(gameObject);
Cut();
}
}
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Cutter")
{
rotation = transform.rotation;
rotation *= Quaternion.AngleAxis(20, Vector3.up);
Instantiate(stumpPrefab, transform.position, rotation);
Instantiate(logPrefab, transform.position + new Vector3(0, 1, 0), rotation);
onCut.Invoke();
Destroy(gameObject);
Cut();
}
}
public void Cut()
{
Debug.LogWarning("CUT");
rotation = transform.rotation;
rotation *= Quaternion.AngleAxis(20, Vector3.up);
Instantiate(stumpPrefab, transform.position, rotation);
Instantiate(logPrefab, transform.position + new Vector3(0, 1, 0), rotation);
onCut.Invoke();
Destroy(gameObject);
}
}

View File

@@ -29,7 +29,7 @@ public class SlimeAI : MonoBehaviour
{
animator = GetComponent<Animator>();
player = GameObject.FindWithTag("Player");
HP = 0;
HP = 5;
}
@@ -141,6 +141,7 @@ public class SlimeAI : MonoBehaviour
{
yield return new WaitForSeconds(0.2f);
Debug.Log("Attack");
PlayerInfo.Instance.AddHealth(-1);
//do attack e.g check for player in range/hit collider
}

View File

@@ -27,7 +27,6 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning(action);
Debug.LogWarning(player.GetComponent<PlayerInfo>().GetRightHand());
if (player.GetComponent<PlayerInfo>().GetRightHand() != null)
{
@@ -52,7 +51,13 @@ public class ActionGestureInteraction : MonoBehaviour
}
else
{
Debug.LogWarning("WOODCUTTING ACTION");
GameObject tree = FindTree();
if (tree != null)
{
float distance = Vector3.Distance(transform.position, tree.transform.position);
Debug.LogWarning("TREE FOUND: " + distance);
if (distance < 6f) tree.GetComponent<CuttableTree>().Cut();
}
}
break;
case "VerticalLine":
@@ -101,7 +106,7 @@ public class ActionGestureInteraction : MonoBehaviour
}
else
{
Debug.LogWarning("WOODCUTTING ACTION");
}
break;
}
@@ -172,6 +177,22 @@ public class ActionGestureInteraction : MonoBehaviour
return null;
}
GameObject FindTree()
{
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.name.StartsWith("Cuttable_Tree_"))
{
return hit.transform.gameObject;
}
}
return null;
}
void ShootProjectile()
{
Ray ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

View File

@@ -26,7 +26,7 @@ public class EssenceNodeController : MonoBehaviour
{
nodeMaterial = GetComponent<Renderer>().material;
playerInfo = PlayerInfo.Instance;
playerInventory = GameObject.Find("Inventory").GetComponent<Inventory>();
//playerInventory = GameObject.Find("Inventory").GetComponent<Inventory>();
}
public void Touched()
@@ -65,7 +65,7 @@ public class EssenceNodeController : MonoBehaviour
playerInfo.AddEssenceBasic(1);
yield return new WaitForSeconds(2f);
//TODO: Update value in player inventory
playerInventory.AddItem(GetComponent<ItemData>());
//playerInventory.AddItem(GetComponent<ItemData>());
Destroy(gameObject);
}

View File

@@ -18,7 +18,7 @@ public class PlayerInfo : MonoBehaviour
{
Instance = this;
health = 5;
essence_basic = 1000;
essence_basic = 1;
rightHandHeld = null;
leftHandHeld = null;
}