player interact with cola freezer, improvement in movements
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FoodObject : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private FoodObjectSO _foodObjectSO;
|
||||
|
||||
public FoodObjectSO GetFoodObjectSO()
|
||||
{
|
||||
return _foodObjectSO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef8197297f5651a4082c2562c95e5cd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class ColaFreezer : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private FoodObjectSO _foodObjectSO;
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
var transform = Instantiate(_foodObjectSO.prefab, _playerArrivePoint);
|
||||
var foodObject = transform.GetComponent<FoodObject>();
|
||||
player.SetFoodObject(foodObject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 476179b02ece27040b9373a7668b7a28
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -38,7 +38,9 @@ public class Player : MonoBehaviour
|
||||
[SerializeField]
|
||||
public Animator _animator;
|
||||
|
||||
private bool _isAllowMovement;
|
||||
[SerializeField]
|
||||
private Transform _holdPoint;
|
||||
|
||||
private AnimationStates _currentAnimation;
|
||||
private Vector3 _groundDeltaPosition;
|
||||
|
||||
@@ -50,6 +52,8 @@ public class Player : MonoBehaviour
|
||||
|
||||
private const string WALK_VELOCITY = "WalkVelocity";
|
||||
|
||||
private FoodObject _foodObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null)
|
||||
@@ -62,7 +66,6 @@ public class Player : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
TimeManager.OnMinuteChanged += UpdateStatsByClock;
|
||||
_isAllowMovement = true;
|
||||
_navAgent.updatePosition = false;
|
||||
Stats = PlayerStats.CreateInitialStats();
|
||||
}
|
||||
@@ -117,6 +120,23 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFoodObject(FoodObject foodObject)
|
||||
{
|
||||
foodObject.transform.parent = _holdPoint;
|
||||
foodObject.transform.localPosition = Vector3.zero;
|
||||
_foodObject = foodObject;
|
||||
Debug.Log($"player hold {foodObject.GetFoodObjectSO().name}");
|
||||
|
||||
}
|
||||
public FoodObject GetFoodObject()
|
||||
{
|
||||
return _foodObject;
|
||||
}
|
||||
public void ClearFoodObject()
|
||||
{
|
||||
_foodObject = null;
|
||||
}
|
||||
|
||||
private TaskStatus MoveToPoint()
|
||||
{
|
||||
SetPlayerAnimation(AnimationStates.Walking);
|
||||
@@ -151,13 +171,18 @@ public class Player : MonoBehaviour
|
||||
Quaternion rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target), 10 * Time.deltaTime);
|
||||
rotation.x = 0;
|
||||
transform.rotation = rotation;
|
||||
if (targetRot == transform.rotation)
|
||||
if (IsApproximate(targetRot, transform.rotation, 0.000004f))
|
||||
{
|
||||
return TaskStatus.Complete;
|
||||
}
|
||||
return TaskStatus.InProgress;
|
||||
}
|
||||
|
||||
public static bool IsApproximate(Quaternion q1, Quaternion q2, float precision)
|
||||
{
|
||||
return Mathf.Abs(Quaternion.Dot(q1, q2)) >= 1 - precision;
|
||||
}
|
||||
|
||||
private TaskStatus InteractWithObject(BaseInteractableObject interactableObject)
|
||||
{
|
||||
interactableObject.Interact(this);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c652740f6fc755242a12d600538e087a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: aec77d0318a147746a02df3c98dc1b76, type: 3}
|
||||
m_Name: Cola
|
||||
m_EditorClassIdentifier:
|
||||
prefab: {fileID: 2680879424619819010, guid: 48940f42625c11541b2ebe92e86b6314, type: 3}
|
||||
objectName: Cola
|
||||
objectPrice: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4db4c329bb512349bf5373c80e7b84a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu()]
|
||||
public class FoodObjectSO : ScriptableObject
|
||||
{
|
||||
public Transform prefab;
|
||||
public string objectName;
|
||||
public float objectPrice;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aec77d0318a147746a02df3c98dc1b76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user