Player can hold shopping basket
This commit is contained in:
@@ -7,7 +7,7 @@ using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class BlockingAnimation : Attribute{}
|
||||
public class BlockingAnimation : Attribute { }
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
@@ -32,7 +32,7 @@ public class Player : MonoBehaviour
|
||||
|
||||
private const string WALK_VELOCITY = "WalkVelocity";
|
||||
|
||||
private FoodObject _foodObject;
|
||||
private ContainerItem _containerItem;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -116,7 +116,10 @@ public class Player : MonoBehaviour
|
||||
|
||||
private bool IsPathComplete(Vector3 destination)
|
||||
{
|
||||
if (Vector3.Distance(destination, _navAgent.transform.position) <= _navAgent.radius)
|
||||
var dest = new Vector3(destination.x, 0, destination.z);
|
||||
var pos = new Vector3(_navAgent.transform.position.x, 0, _navAgent.transform.position.z);
|
||||
|
||||
if (Vector3.Distance(dest, pos) <= _navAgent.radius)
|
||||
{
|
||||
transform.position = destination;
|
||||
if (!_navAgent.hasPath || _navAgent.velocity.sqrMagnitude < 0.2f)
|
||||
@@ -227,26 +230,26 @@ public class Player : MonoBehaviour
|
||||
return attr != null;
|
||||
}
|
||||
|
||||
public void SetFoodObject(FoodObject foodObject)
|
||||
public void SetContainerItem(ContainerItem containerItem)
|
||||
{
|
||||
foodObject.transform.parent = _holdPoint;
|
||||
foodObject.transform.localPosition = Vector3.zero;
|
||||
_foodObject = foodObject;
|
||||
Debug.Log($"player hold {foodObject.GetFoodObjectSO().name}");
|
||||
containerItem.transform.parent = _holdPoint;
|
||||
containerItem.transform.localPosition = Vector3.zero;
|
||||
_containerItem = containerItem;
|
||||
|
||||
|
||||
}
|
||||
public FoodObject GetFoodObject()
|
||||
public ContainerItem GetContainerItem()
|
||||
{
|
||||
return _foodObject;
|
||||
return _containerItem;
|
||||
}
|
||||
public void ClearFoodObject()
|
||||
public void ClearContainerItem()
|
||||
{
|
||||
Destroy(_foodObject.gameObject);
|
||||
_foodObject = null;
|
||||
Destroy(_containerItem.gameObject);
|
||||
_containerItem = null;
|
||||
}
|
||||
|
||||
public bool HasFoodObject()
|
||||
public bool IsHoldContainerItem()
|
||||
{
|
||||
return _foodObject != null;
|
||||
return _containerItem != null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user