added new models
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, }
|
||||
public enum Tasks { Move, Interact, Rotate };
|
||||
public enum TaskStatus { Waiting, InProgress, Complete };
|
||||
public enum AnimationStates
|
||||
{
|
||||
[EnumMember(Value = "Idle")]
|
||||
Idle,
|
||||
[EnumMember(Value = "Move")]
|
||||
Walking,
|
||||
[EnumMember(Value = "Sleeping")]
|
||||
Sleeping,
|
||||
[EnumMember(Value = "StandToSit")]
|
||||
[BlockingAnimation]
|
||||
Sitting,
|
||||
[EnumMember(Value = "SitToStand")]
|
||||
[BlockingAnimation]
|
||||
Standing
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f29a36e328b7dd48988057b39cb810e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,15 +4,15 @@ using UnityEngine;
|
||||
public class ColaFreezer : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private FoodObjectSO _foodObjectSO;
|
||||
private SellableItemSO _sellableItemSO;
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
if (!player.HasFoodObject())
|
||||
{
|
||||
player.BuyObject(_foodObjectSO);
|
||||
//player.BuyObject(_sellableItemSO);
|
||||
// Spawn new object and set to player
|
||||
var transform = Instantiate(_foodObjectSO.prefab, _playerArrivePoint);
|
||||
var transform = Instantiate(_sellableItemSO.prefab, _playerArrivePoint);
|
||||
var foodObject = transform.GetComponent<FoodObject>();
|
||||
player.SetFoodObject(foodObject);
|
||||
}
|
||||
|
||||
@@ -7,27 +7,7 @@ using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class BlockingAnimation : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
public enum Tasks { Move, Interact, Rotate };
|
||||
public enum TaskStatus { Waiting, InProgress, Complete };
|
||||
public enum AnimationStates
|
||||
{
|
||||
[EnumMember(Value = "Idle")]
|
||||
Idle,
|
||||
[EnumMember(Value = "Move")]
|
||||
Walking,
|
||||
[EnumMember(Value = "Sleeping")]
|
||||
Sleeping,
|
||||
[EnumMember(Value = "StandToSit")]
|
||||
[BlockingAnimation]
|
||||
Sitting,
|
||||
[EnumMember(Value = "SitToStand")]
|
||||
[BlockingAnimation]
|
||||
Standing
|
||||
};
|
||||
public class BlockingAnimation : Attribute{}
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
@@ -106,7 +86,7 @@ public class Player : MonoBehaviour
|
||||
_currentTask.UpdateStatus(MoveToPoint());
|
||||
break;
|
||||
case Tasks.Interact:
|
||||
if (pathComplete(_currentTask.TagretObject._playerArrivePoint.position))
|
||||
if (IsPathComplete(_currentTask.TagretObject._playerArrivePoint.position))
|
||||
_currentTask.UpdateStatus(InteractWithObject(_currentTask.TagretObject));
|
||||
else
|
||||
{
|
||||
@@ -131,10 +111,10 @@ public class Player : MonoBehaviour
|
||||
Vector2 velocity = (Time.deltaTime > 1e-5f) ? _groundDeltaPosition / Time.deltaTime : Vector2.zero;
|
||||
_animator.SetFloat(WALK_VELOCITY, velocity.y);
|
||||
|
||||
return pathComplete(_navAgent.destination) ? TaskStatus.Complete : TaskStatus.InProgress;
|
||||
return IsPathComplete(_navAgent.destination) ? TaskStatus.Complete : TaskStatus.InProgress;
|
||||
}
|
||||
|
||||
private bool pathComplete(Vector3 destination)
|
||||
private bool IsPathComplete(Vector3 destination)
|
||||
{
|
||||
if (Vector3.Distance(destination, _navAgent.transform.position) <= _navAgent.radius)
|
||||
{
|
||||
@@ -216,10 +196,9 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void BuyObject(FoodObjectSO objectToBuy)
|
||||
public void Pay(float amount)
|
||||
{
|
||||
Stats[StatsId.Money].deduct(objectToBuy.objectPrice);
|
||||
//action.ApplyAction(this);
|
||||
Stats[StatsId.Money].deduct(amount);
|
||||
}
|
||||
|
||||
public float Eat()
|
||||
@@ -238,6 +217,7 @@ public class Player : MonoBehaviour
|
||||
?.GetCustomAttribute<EnumMemberAttribute>(false)
|
||||
?.Value;
|
||||
}
|
||||
|
||||
private static bool IsBlockingAnimation<T>(T value)
|
||||
where T : struct, IConvertible
|
||||
{
|
||||
@@ -247,7 +227,6 @@ public class Player : MonoBehaviour
|
||||
return attr != null;
|
||||
}
|
||||
|
||||
|
||||
public void SetFoodObject(FoodObject foodObject)
|
||||
{
|
||||
foodObject.transform.parent = _holdPoint;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, }
|
||||
|
||||
public class PlayerStats
|
||||
{
|
||||
public static Dictionary<StatsId, Stat> CreateInitialStats()
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu()]
|
||||
public class FoodObjectSO : ScriptableObject
|
||||
public class SellableItemSO : ScriptableObject
|
||||
{
|
||||
public Transform prefab;
|
||||
public string objectName;
|
||||
Reference in New Issue
Block a user