essence add to playerinfo
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ using UnityEngine;
|
||||
|
||||
public class PlayerInfo : MonoBehaviour
|
||||
{
|
||||
public static PlayerInfo Instance;
|
||||
|
||||
private int health;
|
||||
|
||||
private int essence_basic;
|
||||
@@ -13,6 +15,7 @@ public class PlayerInfo : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
health = 5;
|
||||
essence_basic = 0;
|
||||
rightHandHeld = null;
|
||||
|
||||
Reference in New Issue
Block a user