added tooltips
This commit is contained in:
+883
-74
File diff suppressed because it is too large
Load Diff
@@ -2,20 +2,26 @@
|
||||
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public class Eat : BaseAction, ISellableItem
|
||||
public class Eat : IPlayerAction, Interfaces.ISellable
|
||||
{
|
||||
public float Price { get; private set; }
|
||||
public decimal Price { get; private set; }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string Description => $"{Name} - {Price}$";
|
||||
private int _energy;
|
||||
public Eat(int duration, int energy, float price) : base(duration)
|
||||
|
||||
public Eat(string name, int energy, decimal price)
|
||||
{
|
||||
Name = name;
|
||||
Price = price;
|
||||
_energy = energy;
|
||||
}
|
||||
|
||||
|
||||
public override void ApplyAction(PlayerManager playerController)
|
||||
public void ApplyAction(PlayerManager playerController)
|
||||
{
|
||||
playerController.food.increase(_energy);
|
||||
playerController.PlayerStats[GameManager.StatsId.Food].increase(_energy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
namespace Assets.Scripts.Actions.Interfaces
|
||||
{
|
||||
internal interface ISellableItem
|
||||
{
|
||||
public float Price { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Assets.Scripts.Actions.Interfaces
|
||||
{
|
||||
public enum JobId { Unemployed, HotDogs };
|
||||
public interface IPlayerAction
|
||||
{
|
||||
public string Description { get; }
|
||||
public void ApplyAction(PlayerManager player);
|
||||
}
|
||||
|
||||
public interface ISellable
|
||||
{
|
||||
public decimal Price { get; }
|
||||
}
|
||||
|
||||
public interface IWorkPlace
|
||||
{
|
||||
public JobId JobID { get; }
|
||||
public decimal Sallary { get; }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11ca03325bf76704b91eb2f9b2fafec9
|
||||
guid: 5b7ba6deb189bc44ca6f628a799c8667
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,24 @@
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public class JobPosition : IPlayerAction, IWorkPlace
|
||||
{
|
||||
public string Description => $"{_position} - {Sallary}$ per hour";
|
||||
public decimal Sallary { get; private set; }
|
||||
public JobId JobID { get; private set; }
|
||||
|
||||
|
||||
private string _position;
|
||||
|
||||
public JobPosition(string position, decimal sallary, JobId jobId)
|
||||
{
|
||||
_position = position;
|
||||
Sallary = sallary;
|
||||
}
|
||||
public void ApplyAction(PlayerManager playerController)
|
||||
{
|
||||
playerController.WorkPlace = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a40c2851bc6f1454789ac4d529a148c9
|
||||
guid: 80cfc634ca94f1e4fa1726ca19eab626
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46382eb4a7b5812458ddf7287b5a65ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,15 +1,20 @@
|
||||
namespace Assets.Scripts.Actions
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public class Relax : BaseAction
|
||||
public class Relax : IPlayerAction
|
||||
{
|
||||
private int _energyPerTick;
|
||||
public Relax(int duration, int energyPerTick) : base(duration)
|
||||
public Relax(int duration, int energyPerTick)
|
||||
{
|
||||
_energyPerTick = energyPerTick;
|
||||
}
|
||||
public override void ApplyAction(PlayerManager playerController)
|
||||
|
||||
public string Description => throw new System.NotImplementedException();
|
||||
|
||||
public void ApplyAction(PlayerManager playerController)
|
||||
{
|
||||
playerController.energy.increase(_energyPerTick);
|
||||
playerController.PlayerStats[GameManager.StatsId.Energy].increase(_energyPerTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public class Work : BaseAction
|
||||
{
|
||||
private PlayerManager playerController;
|
||||
private int energyPerTick;
|
||||
public Work(PlayerManager player, int duration, int energyPerTick) : base(duration)
|
||||
{
|
||||
this.playerController = player;
|
||||
this.energyPerTick = energyPerTick;
|
||||
}
|
||||
public override void ApplyAction(PlayerManager playerController)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace Assets.Scripts.Buildings
|
||||
public abstract class BaseCell : MonoBehaviour
|
||||
{
|
||||
protected string _name;
|
||||
protected Dictionary<string, BaseAction> _optionsList;
|
||||
protected List<IPlayerAction> _optionsList;
|
||||
[SerializeField]
|
||||
private ConversationController _conversationController;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_optionsList = new Dictionary<string, BaseAction>();
|
||||
_optionsList = new List<IPlayerAction>();
|
||||
Initialize();
|
||||
BuildOptionsList();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Assets.Scripts.Actions;
|
||||
|
||||
namespace Assets.Scripts.Buildings
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public class Burger : BaseCell
|
||||
{
|
||||
@@ -11,12 +9,12 @@ namespace Assets.Scripts.Buildings
|
||||
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
_optionsList.Add("Hamburgers - 83$", new Eat(6, 10, 83));
|
||||
_optionsList.Add("Cheesburger - 94$", new Eat(6, 1, 94));
|
||||
_optionsList.Add("Astro chicken - 131$", new Eat(6, 1, 131));
|
||||
_optionsList.Add("Fries - 68$", new Eat(6, 1, 68));
|
||||
_optionsList.Add("Shakes - 108$", new Eat(6, 1, 108));
|
||||
_optionsList.Add("Colas - 73$", new Eat(6, 1, 73));
|
||||
//_optionsList.Add("Hamburgers - 83$", new Eat(6, 10, 83));
|
||||
//_optionsList.Add("Cheesburger - 94$", new Eat(6, 1, 94));
|
||||
//_optionsList.Add("Astro chicken - 131$", new Eat(6, 1, 131));
|
||||
//_optionsList.Add("Fries - 68$", new Eat(6, 1, 68));
|
||||
//_optionsList.Add("Shakes - 108$", new Eat(6, 1, 108));
|
||||
//_optionsList.Add("Colas - 73$", new Eat(6, 1, 73));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Assets.Scripts.Buildings
|
||||
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
_optionsList.Add("Hot Dog - 20$", new Eat(6, 15, 83));
|
||||
_optionsList.Add("Colas - 10$", new Eat(6, 10, 73));
|
||||
_optionsList.Add(new Eat("Hot Dog", 15, 20));
|
||||
_optionsList.Add(new Eat("Cola", 10, 10));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Assets.Scripts.Actions;
|
||||
|
||||
namespace Assets.Scripts.Buildings
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public class House : BaseCell
|
||||
{
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
_optionsList.Add("Rest", new Relax(6, 1));
|
||||
//_optionsList.Add(new Relax("Rest", 6, 1));
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public class JobAgency : BaseCell
|
||||
{
|
||||
protected override void Initialize()
|
||||
{
|
||||
_name = "Job Agency";
|
||||
}
|
||||
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
_optionsList.Add(new JobPosition("Hot Dogs sailer ", 20, JobId.HotDogs));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16925e4f4154a004dadcfa7300af1bbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +1,18 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class ConversationChangeEvent : UnityEvent<BaseAction> { }
|
||||
public class ConversationChangeEvent : UnityEvent<IPlayerAction> { }
|
||||
|
||||
public class ChoiceController : MonoBehaviour
|
||||
{
|
||||
public KeyValuePair<string, BaseAction> _option;
|
||||
public IPlayerAction _option;
|
||||
public ConversationChangeEvent conversationChangeEvent;
|
||||
// Update is called once per frame
|
||||
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, KeyValuePair<string, BaseAction> option, int index)
|
||||
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, IPlayerAction option, int index)
|
||||
{
|
||||
int buttonSpacing = -50;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class ChoiceController : MonoBehaviour
|
||||
button.transform.SetParent(choiceButtonTemplate.transform.parent);
|
||||
button.transform.localScale = Vector3.one;
|
||||
button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
|
||||
button.name = option.Key;
|
||||
button.name = option.Description;
|
||||
button.gameObject.SetActive(true);
|
||||
ChoiceController choiceController = button.GetComponent<ChoiceController>();
|
||||
choiceController._option = option;
|
||||
@@ -36,11 +35,11 @@ public class ChoiceController : MonoBehaviour
|
||||
var btn = GetComponent<Button>();
|
||||
|
||||
var txt = btn.GetComponentInChildren<TextMeshProUGUI>();
|
||||
txt.text = _option.Key;
|
||||
txt.text = _option.Description;
|
||||
}
|
||||
|
||||
public void MakeChoice()
|
||||
{
|
||||
conversationChangeEvent.Invoke(_option.Value);
|
||||
conversationChangeEvent.Invoke(_option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
@@ -7,29 +7,34 @@ using UnityEngine.UI;
|
||||
|
||||
public class ConversationController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public TextMeshProUGUI _title;
|
||||
[SerializeField]
|
||||
public Button _choiceButton;
|
||||
[SerializeField]
|
||||
private Button _closeBtn;
|
||||
|
||||
[SerializeField]
|
||||
PlayerManager _playerManager;
|
||||
[SerializeField] public TextMeshProUGUI _title;
|
||||
[SerializeField] public Button _choiceButton;
|
||||
[SerializeField] private Button _btnApply;
|
||||
[SerializeField] private Button _btnClose;
|
||||
[SerializeField] PlayerManager _playerManager;
|
||||
|
||||
public ConversationChangeEvent conversationChangeEvent;
|
||||
private List<ChoiceController> choiceControllers = new();
|
||||
|
||||
private IPlayerAction _selectedAction = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void Change(string title, Dictionary<string, BaseAction> options)
|
||||
public void Change(string title, List<IPlayerAction> options)
|
||||
{
|
||||
_closeBtn.onClick.AddListener(() =>
|
||||
_btnApply.interactable = false;
|
||||
|
||||
_btnClose.onClick.AddListener(() =>
|
||||
{
|
||||
Hide();
|
||||
});
|
||||
|
||||
_btnApply.onClick.AddListener(() =>
|
||||
{
|
||||
Hide();
|
||||
ApplyActionOnPlayer(_selectedAction);
|
||||
});
|
||||
|
||||
_playerManager.allowMovement = false;
|
||||
@@ -40,31 +45,30 @@ public class ConversationController : MonoBehaviour
|
||||
for (var count = 0; count < options.Count; count++)
|
||||
{
|
||||
ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
|
||||
c.conversationChangeEvent.AddListener(ApplyActionOnPlayer);
|
||||
c.conversationChangeEvent.AddListener(SelectAction);
|
||||
choiceControllers.Add(c);
|
||||
}
|
||||
|
||||
StopAllCoroutines();
|
||||
|
||||
|
||||
Time.timeScale = 0;
|
||||
_choiceButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void ApplyActionOnPlayer(BaseAction action)
|
||||
private void SelectAction(IPlayerAction action)
|
||||
{
|
||||
if (!_playerManager.TryBuyAction(action))
|
||||
_selectedAction = action;
|
||||
if (action is ISellable)
|
||||
{
|
||||
YesNoDialogUI.Instance.ShowQuestion("not enouth money",
|
||||
() =>
|
||||
{
|
||||
},
|
||||
() =>
|
||||
{
|
||||
//do nothing
|
||||
});
|
||||
_btnApply.interactable = _playerManager.PlayerStats[GameManager.StatsId.Money].Value >= (action as ISellable).Price;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyActionOnPlayer(IPlayerAction action)
|
||||
{
|
||||
if (action is ISellable)
|
||||
_playerManager.BuyAction(action);
|
||||
}
|
||||
private void RemoveChoices()
|
||||
{
|
||||
foreach (ChoiceController c in choiceControllers)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GameController : MonoBehaviour
|
||||
{
|
||||
public Map GameMap;
|
||||
public PlayerManager Player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, }
|
||||
|
||||
public static GameManager Instance { get; private set; }
|
||||
|
||||
public Map GameMap;
|
||||
public PlayerManager Player;
|
||||
public Dictionary<StatsId, Stat> PlayerStats;
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
InitPlayerStats();
|
||||
}
|
||||
|
||||
private void InitPlayerStats()
|
||||
{
|
||||
PlayerStats = new Dictionary<StatsId, Stat>()
|
||||
{
|
||||
{StatsId.Money, new Stat("Money", 100.0m)},
|
||||
{StatsId.RentAccount, new Stat("Rent Account", 0)},
|
||||
{StatsId.Food, new Stat("Food Energy", 100) },
|
||||
{StatsId.Energy,new Stat("Energy", 100) },
|
||||
{StatsId.BankAccount,new Stat("Bank Account", 0) },
|
||||
{StatsId.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);
|
||||
// Update is called once per frame
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static GameManager;
|
||||
|
||||
public class GameUIManager : MonoBehaviour
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class GameUIManager : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
_moneyText.text = $"${_playerController.money.Value}";
|
||||
_moneyText.text = $"${_playerController.PlayerStats[StatsId.Money].Value}";
|
||||
|
||||
|
||||
}
|
||||
@@ -45,7 +46,7 @@ public class GameUIManager : MonoBehaviour
|
||||
_timeText.text = TimeManager.CurrentTime.ToString(@"hh\:mm");
|
||||
}
|
||||
|
||||
_energy.value = _playerController.energy.Value;
|
||||
_food.value = _playerController.food.Value;
|
||||
_energy.value = (float)_playerController.PlayerStats[StatsId.Energy].Value;
|
||||
_food.value = (float)_playerController.PlayerStats[StatsId.Food].Value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
public class Stat
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public float Value { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double Quantity { get; set; }
|
||||
public decimal Value { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
public Stat(string name, float startValue)
|
||||
public Stat(string name, decimal startValue)
|
||||
{
|
||||
Name = name;
|
||||
Value = startValue;
|
||||
}
|
||||
|
||||
public Stat(string name, float price, float quantity)
|
||||
public Stat(string name, decimal price, decimal quantity)
|
||||
{
|
||||
Name = name;
|
||||
Price = price;
|
||||
Quantity = quantity;
|
||||
}
|
||||
|
||||
public void increase(float byAmount)
|
||||
public void increase(decimal byAmount)
|
||||
{
|
||||
Value += byAmount;
|
||||
}
|
||||
|
||||
public bool deduct(float amount)
|
||||
public bool deduct(decimal amount)
|
||||
{
|
||||
if (Value >= amount)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ public class Stat
|
||||
return false;
|
||||
}
|
||||
|
||||
public void forceDeduct(float amount)
|
||||
public void forceDeduct(decimal amount)
|
||||
{
|
||||
Value -= amount;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[ExecuteInEditMode()]
|
||||
public class ToolTip : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI headerField;
|
||||
public TextMeshProUGUI contentField;
|
||||
public LayoutElement layoutElement;
|
||||
public int characterWrapLimit;
|
||||
|
||||
public RectTransform rectTransform;
|
||||
private void Awake()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
public void SetText(string content, string header = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(header))
|
||||
{
|
||||
headerField.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
headerField.gameObject.SetActive(true);
|
||||
headerField.text = header;
|
||||
}
|
||||
contentField.text = content;
|
||||
|
||||
int headerLength = headerField.text.Length;
|
||||
int contentLength = contentField.text.Length;
|
||||
|
||||
layoutElement.enabled = (headerLength > characterWrapLimit || contentLength > characterWrapLimit);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
int headerLength = headerField.text.Length;
|
||||
int contentLength = contentField.text.Length;
|
||||
|
||||
layoutElement.enabled = (headerLength > characterWrapLimit || contentLength > characterWrapLimit);
|
||||
}
|
||||
Vector2 position = Input.mousePosition;
|
||||
|
||||
float pivotX = position.x / Screen.width;
|
||||
float pivotY = position.y / Screen.height;
|
||||
|
||||
rectTransform.pivot = new Vector2(pivotX, pivotY);
|
||||
transform.position = position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: feff04ad815f5974cb387c4ae348a844
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ToolTipSystem : MonoBehaviour
|
||||
{
|
||||
private static ToolTipSystem _current;
|
||||
[SerializeField] private ToolTip _toolTip;
|
||||
public void Awake()
|
||||
{
|
||||
_current = this;
|
||||
_current._toolTip.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public static void Show(string content, string header = "")
|
||||
{
|
||||
_current._toolTip.SetText(content, header);
|
||||
_current._toolTip.gameObject.SetActive(true);
|
||||
}
|
||||
public static void Hide()
|
||||
{
|
||||
_current._toolTip.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49f5114aac344be42a48ac8ceb3b93fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class ToolTipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
private static LTDescr delay;
|
||||
[SerializeField] private string _content;
|
||||
[SerializeField] private string _header;
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
delay = LeanTween.delayedCakk(0.5f, () =>
|
||||
{
|
||||
ToolTipSystem.Show(_content, _header);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
LeanTween.cancek(delay.uniqueId);
|
||||
ToolTipSystem.Hide();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b31294925f6cbdb40969c856428d8894
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,7 +3,7 @@
|
||||
"com.unity.2d.sprite": "1.0.0",
|
||||
"com.unity.collab-proxy": "1.17.6",
|
||||
"com.unity.feature.development": "1.0.1",
|
||||
"com.unity.ide.rider": "3.0.15",
|
||||
"com.unity.ide.rider": "3.0.16",
|
||||
"com.unity.ide.visualstudio": "2.0.16",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.probuilder": "5.0.6",
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.ide.visualstudio": "2.0.16",
|
||||
"com.unity.ide.rider": "3.0.15",
|
||||
"com.unity.ide.rider": "3.0.16",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.editorcoroutines": "1.0.0",
|
||||
"com.unity.performance.profile-analyzer": "1.1.1",
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "3.0.15",
|
||||
"version": "3.0.16",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -94,7 +94,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.services.core": {
|
||||
"version": "1.5.2",
|
||||
"version": "1.6.0",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2021.3.13f1
|
||||
m_EditorVersionWithRevision: 2021.3.13f1 (9e7d58001ecf)
|
||||
m_EditorVersion: 2021.3.14f1
|
||||
m_EditorVersionWithRevision: 2021.3.14f1 (eee1884e7226)
|
||||
|
||||
Reference in New Issue
Block a user