add areaname
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
public enum JobPositions { Unemployed, Cashier, Clerk, ManagerAssistaint, Manager };
|
||||
public enum EducationSkill { NotEducated, School, HightSchool, University };
|
||||
public enum PlayerStates { Awake, Sleeping, Eating, Working }
|
||||
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, }
|
||||
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job,LocationName }
|
||||
public enum Tasks { Move, Interact, Rotate };
|
||||
public enum TaskStatus { Waiting, InProgress, Complete };
|
||||
public enum InteractionStatus { None,Complete, WaitForChoose, InProgress, FarFromPlayer };
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using UnityEngine;
|
||||
|
||||
public class AreaName : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string _areaName;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if(other.gameObject.tag.ToLower()=="player")
|
||||
{
|
||||
(Player.Instance.Stats[StatsId.LocationName] as IStringStat).SetValue(_areaName);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f0e472918ce7a41898514f037c380d
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
using Assets.Scripts.Interfaces;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -49,7 +50,7 @@ public class Fridge : BaseInteractableObject
|
||||
Debug.Log($"Fridge is full");
|
||||
break;
|
||||
case RadialMenuActions.Eat:
|
||||
var hunger = _player.Stats[StatsId.Food].MaxValue - _player.Stats[StatsId.Food].Value;
|
||||
var hunger = (_player.Stats[StatsId.Food] as INumericStat).MaxValue - (_player.Stats[StatsId.Food] as INumericStat).Value;
|
||||
var eatingItems = _foodObjects.Count < (hunger / 10) ? _foodObjects.Count : (hunger / 10);
|
||||
StartCoroutine(EatRoutine(eatingItems));
|
||||
_foodObjects.RemoveRange(0, (int)eatingItems);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a9e1a72e46f47a4b886261f13a9b9e6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Interfaces
|
||||
{
|
||||
public interface IStat
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
public interface IStringStat
|
||||
{
|
||||
string Value { get; }
|
||||
|
||||
void SetValue(string value);
|
||||
}
|
||||
|
||||
public interface INumericStat
|
||||
{
|
||||
float MaxValue { get; }
|
||||
float Price { get; }
|
||||
float Quantity { get; }
|
||||
float Value { get; }
|
||||
|
||||
bool deduct(float amount);
|
||||
void forceDeduct(float amount);
|
||||
void increase(float byAmount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63f19538482d7a94598f9c79a711e13e
|
||||
@@ -28,7 +28,12 @@ public class MouseInputManager : MonoBehaviour
|
||||
void Update()
|
||||
{
|
||||
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
if (!EventSystem.current.IsPointerOverGameObject() && Physics.Raycast(ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
|
||||
if(EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
return;
|
||||
}
|
||||
//hide rounded menu
|
||||
if (Physics.Raycast(ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
|
||||
{
|
||||
mouseRaycastHit.transform.TryGetComponent(out BaseInteractableObject baseObject);
|
||||
if (baseObject != null)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
public class Stat
|
||||
using Assets.Scripts.Interfaces;
|
||||
|
||||
public class NumericStat : INumericStat
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public float Value { get; private set; }
|
||||
@@ -6,14 +8,14 @@ public class Stat
|
||||
public float Quantity { get; private set; }
|
||||
public float MaxValue { get; private set; }
|
||||
|
||||
public Stat(string name, float startValue, float maxValue)
|
||||
public NumericStat(string name, float startValue, float maxValue)
|
||||
{
|
||||
Name = name;
|
||||
Value = startValue;
|
||||
MaxValue = maxValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
public Stat(string name, float price, float quantity, float maxValue)
|
||||
public NumericStat(string name, float price, float quantity, float maxValue)
|
||||
{
|
||||
Name = name;
|
||||
Price = price;
|
||||
@@ -1,6 +1,6 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Player : MonoBehaviour
|
||||
private PlayerStates _currentActing;
|
||||
private AnimationStates _currentAnimation;
|
||||
|
||||
public Dictionary<StatsId, Stat> Stats;
|
||||
public Dictionary<StatsId, object> Stats;
|
||||
public JobPositions JobPosition { get; set; }
|
||||
|
||||
public EducationSkill Education { get; set; }
|
||||
@@ -33,6 +33,7 @@ public class Player : MonoBehaviour
|
||||
|
||||
private ContainerItem _containerItem;
|
||||
private Action _OnAnimationFinish;
|
||||
private string _locationName;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -213,27 +214,27 @@ public class Player : MonoBehaviour
|
||||
switch (_currentActing)
|
||||
{
|
||||
case PlayerStates.Eating:
|
||||
Stats[StatsId.Food].increase(10f);
|
||||
(Stats[StatsId.Food] as INumericStat).increase(10f);
|
||||
break;
|
||||
case PlayerStates.Sleeping:
|
||||
Stats[StatsId.Energy].increase(0.2f);
|
||||
Stats[StatsId.Food].deduct(0.03f);
|
||||
(Stats[StatsId.Energy] as INumericStat).increase(0.2f);
|
||||
(Stats[StatsId.Food] as INumericStat).deduct(0.03f);
|
||||
break;
|
||||
default:
|
||||
Stats[StatsId.Food].deduct(0.05f); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
Stats[StatsId.Energy].deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
(Stats[StatsId.Food] as INumericStat).deduct(0.05f); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
(Stats[StatsId.Energy] as INumericStat).deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Pay(float amount)
|
||||
{
|
||||
Stats[StatsId.Money].deduct(amount);
|
||||
(Stats[StatsId.Money] as INumericStat).deduct(amount);
|
||||
}
|
||||
|
||||
public void AddMoney(float amount)
|
||||
{
|
||||
Stats[StatsId.Money].increase(amount);
|
||||
(Stats[StatsId.Money] as INumericStat).increase(amount);
|
||||
}
|
||||
|
||||
public void SetContainerItem(ContainerItem containerItem)
|
||||
@@ -255,4 +256,13 @@ public class Player : MonoBehaviour
|
||||
{
|
||||
return _containerItem != null;
|
||||
}
|
||||
|
||||
public void SetLocationName(string locationName)
|
||||
{
|
||||
_locationName = locationName;
|
||||
}
|
||||
public string GetLocationName()
|
||||
{
|
||||
return _locationName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,20 @@ using System.Collections.Generic;
|
||||
|
||||
public class PlayerStats
|
||||
{
|
||||
public static Dictionary<StatsId, Stat> CreateInitialStats()
|
||||
public static Dictionary<StatsId, object> CreateInitialStats()
|
||||
{
|
||||
return new Dictionary<StatsId, Stat>()
|
||||
return new Dictionary<StatsId, object>()
|
||||
{
|
||||
{StatsId.Money, new Stat("Money", 100.0f,10000000f)},
|
||||
{StatsId.RentAccount, new Stat("Rent Account", 0,10f)},
|
||||
{StatsId.Food, new Stat("Food Energy", 50f,100f) },
|
||||
{StatsId.Energy,new Stat("Energy", 50f,100f) },
|
||||
{StatsId.Money, new NumericStat("Money", 100.0f,10000000f)},
|
||||
{StatsId.RentAccount, new NumericStat("Rent Account", 0,10f)},
|
||||
{StatsId.Food, new NumericStat("Food Energy", 50f,100f) },
|
||||
{StatsId.Energy,new NumericStat("Energy", 50f,100f) },
|
||||
{StatsId.LocationName,new StringStat("Location","Nowhere") },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//// Knowledge for University Jobs
|
||||
//public Stat literatureKnowledge = new Stat("LiteratureKnowledge", 0);
|
||||
//public Stat mathematicsKnowledge = new Stat("MathematicsKnowledge", 0);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
|
||||
public class StringStat : IStringStat
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string Value { get; private set; }
|
||||
|
||||
public StringStat(string name, string startValue)
|
||||
{
|
||||
Name = name;
|
||||
Value = startValue;
|
||||
}
|
||||
|
||||
public void SetValue(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c57f2033235f86b4585b18775c652653
|
||||
@@ -1,3 +1,4 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -9,6 +10,9 @@ public class TopBarUI : MonoBehaviour
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _moneyText;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _locationText;
|
||||
|
||||
[SerializeField]
|
||||
public Slider _energy;
|
||||
@@ -31,8 +35,8 @@ public class TopBarUI : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
_moneyText.text = $"${Player.Instance.Stats[StatsId.Money].Value}";
|
||||
|
||||
_moneyText.text = $"${(Player.Instance.Stats[StatsId.Money] as INumericStat).Value}";
|
||||
_locationText.text= $"{(Player.Instance.Stats[StatsId.LocationName] as IStringStat).Value}";
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +47,7 @@ public class TopBarUI : MonoBehaviour
|
||||
_timeText.text = $"{TimeManager.CurrentTime.GetDayName()} {TimeManager.CurrentTime.ToString(@"hh\:mm")} day ({TimeManager.CurrentTime.Days})";
|
||||
}
|
||||
|
||||
_energy.value = (float)Player.Instance.Stats[StatsId.Energy].Value;
|
||||
_food.value = (float)Player.Instance.Stats[StatsId.Food].Value;
|
||||
_energy.value = (Player.Instance.Stats[StatsId.Energy] as INumericStat).Value;
|
||||
_food.value = (Player.Instance.Stats[StatsId.Food] as INumericStat).Value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user