added tooltips
This commit is contained in:
@@ -1,46 +1,13 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using static GameManager;
|
||||
|
||||
public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
private enum States { Idle, Walking, Sleeping };
|
||||
public Stat money = new Stat("Money", 100.0f);
|
||||
public Stat rentAccount = new Stat("Rent Account", 0);
|
||||
public Stat food = new Stat("Food Energy", 100);
|
||||
public Stat energy = new Stat("Energy", 100);
|
||||
|
||||
// bank
|
||||
public Stat bankAccount = new Stat("Bank Account", 0);
|
||||
|
||||
// jobs
|
||||
public Stat job = new Stat("Unemployed", 0);
|
||||
|
||||
// Knowledge for University Jobs
|
||||
public Stat literatureKnowledge = new Stat("LiteratureKnowledge", 0);
|
||||
public Stat mathematicsKnowledge = new Stat("MathematicsKnowledge", 0);
|
||||
public Stat computerScienceKnowledge = new Stat("ComputerScienceKnowledge", 0);
|
||||
|
||||
// Knowledge for Factory Jobs
|
||||
public Stat electronicsKnowledge = new Stat("ElectronicsKnowledge", 0);
|
||||
public Stat roboticsKnowledge = new Stat("RoboticsKnowledge", 0);
|
||||
public Stat industrialDesignKnowledge = new Stat("IndustrialDesignKnowledge", 0);
|
||||
|
||||
public Stat careerPoints = new Stat("careerPoints", 0);
|
||||
|
||||
// Achievements - to WIN the game
|
||||
public Stat whealthAchievement = new Stat("whealthAchievement", 999999);
|
||||
public Stat educationAchievement = new Stat("educationAchievement", 999999);
|
||||
public Stat careerAchievement = new Stat("careerAchievement", 999999);
|
||||
public Stat happinessAchievement = new Stat("happinessAchievement", 999999);
|
||||
|
||||
// Inventory items
|
||||
public Stat freezerItem = new Stat("Freezer Item", 400, 1);
|
||||
public Stat clothesItem = new Stat("Clothes Item", 200, 3);
|
||||
public Stat booksItem = new Stat("Books Item", 150, 2);
|
||||
public Stat tvItem = new Stat("Tv Item", 1500, 1);
|
||||
public Stat laptopItem = new Stat("Laptop Item", 3000, 1);
|
||||
|
||||
[SerializeField]
|
||||
public NavMeshAgent _navAgent;
|
||||
@@ -55,6 +22,9 @@ public class PlayerManager : MonoBehaviour
|
||||
private States _state;
|
||||
private Vector3 _groundDeltaPosition;
|
||||
|
||||
public Dictionary<StatsId, Stat> PlayerStats;
|
||||
public IWorkPlace WorkPlace { get; set; }
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TimeManager.OnMinuteChanged += DecreaseEnergy;
|
||||
@@ -70,6 +40,7 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
allowMovement = true;
|
||||
_navAgent.updatePosition = false;
|
||||
PlayerStats = GameManager.Instance.PlayerStats;
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
@@ -81,7 +52,6 @@ public class PlayerManager : MonoBehaviour
|
||||
_targetDest.Stop();
|
||||
if (Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 100))
|
||||
{
|
||||
|
||||
var pos = hit.point;
|
||||
pos.y += 0.2f;
|
||||
_targetDest.transform.position = pos;
|
||||
@@ -90,10 +60,10 @@ public class PlayerManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var worldDeltaPosition=_navAgent.nextPosition- transform.position;
|
||||
_groundDeltaPosition.x=Vector3.Dot(transform.right, worldDeltaPosition);
|
||||
|
||||
var worldDeltaPosition = _navAgent.nextPosition - transform.position;
|
||||
_groundDeltaPosition.x = Vector3.Dot(transform.right, worldDeltaPosition);
|
||||
_groundDeltaPosition.y = Vector3.Dot(transform.forward, worldDeltaPosition);
|
||||
|
||||
Vector2 velocity = (Time.deltaTime > 1e-5f) ? _groundDeltaPosition / Time.deltaTime : Vector2.zero;
|
||||
@@ -111,24 +81,24 @@ public class PlayerManager : MonoBehaviour
|
||||
|
||||
public void DecreaseEnergy()
|
||||
{
|
||||
food.deduct(0.034f); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
PlayerStats[StatsId.Food].deduct(0.034m); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
switch (_state)
|
||||
{
|
||||
case States.Idle:
|
||||
case States.Walking:
|
||||
energy.deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
PlayerStats[StatsId.Energy].deduct(0.1m); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
break;
|
||||
case States.Sleeping:
|
||||
energy.increase(1f);
|
||||
PlayerStats[StatsId.Energy].increase(1m);
|
||||
break;
|
||||
}
|
||||
if (energy.Value <= 10 && _state != States.Sleeping)
|
||||
if (PlayerStats[StatsId.Energy].Value <= 10 && _state != States.Sleeping)
|
||||
{
|
||||
_state = States.Sleeping;
|
||||
allowMovement = false;
|
||||
_animator.SetBool("IsSleeping", true);
|
||||
}
|
||||
if (energy.Value >= 100 && _state == States.Sleeping)
|
||||
if (PlayerStats[StatsId.Energy].Value >= 100 && _state == States.Sleeping)
|
||||
{
|
||||
_state = States.Idle;
|
||||
allowMovement = false;
|
||||
@@ -136,15 +106,10 @@ public class PlayerManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryBuyAction(BaseAction action)
|
||||
public void BuyAction(IPlayerAction action)
|
||||
{
|
||||
if (action is ISellableItem)
|
||||
{
|
||||
if (!money.deduct(((ISellableItem)action).Price))
|
||||
return false;
|
||||
}
|
||||
PlayerStats[StatsId.Money].deduct(((ISellable)action).Price);
|
||||
action.ApplyAction(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user