small fixes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class PlayerInfo : MonoBehaviour
|
||||
{
|
||||
Instance = this;
|
||||
health = 5;
|
||||
essence_basic = 1000;
|
||||
essence_basic = 1;
|
||||
rightHandHeld = null;
|
||||
leftHandHeld = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user