Cash Money

Player credits now tracked by game manager
Buying items subtracts credits
Right clicking on trade menu items allows player to buy multiple
Inventory panel dropdown now allows instantiating saved loadouts
This commit is contained in:
Reinier Vens 2021-01-19 01:22:56 +00:00
commit 48abee4847
9 changed files with 239 additions and 51 deletions

View file

@ -11,9 +11,9 @@ using UniRx;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.UI;
using Unity.Mathematics;
using UnityEngine.EventSystems;
using UnityEngine.Experimental.Rendering;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using int2 = Unity.Mathematics.int2;
@ -125,12 +125,27 @@ public class InventoryPanel : MonoBehaviour
if(GameManager.DockingBay!=null && _displayedCargo!=GameManager.DockingBay)
ContextMenu.AddOption(GameManager.DockingBay.Name, () => Display(GameManager.DockingBay));
ContextMenu.AddOption("Create Preset",
ContextMenu.AddOption("Save Loadout",
() =>
{
GameManager.SavePreset(EntityPack.Pack(_displayedEntity));
GameManager.SaveLoadout(EntityPack.Pack(_displayedEntity));
});
if (GameManager.Loadouts.Any())
{
ContextMenu.AddDropdown("Restore Loadout",
GameManager.Loadouts.Select<EntityPack, (string text, Action action, bool enabled)>(pack =>
(
$"{pack.Name} - {pack.Price(GameManager.ItemManager):n0}", () =>
{
var ship = EntityPack.Unpack(GameManager.ItemManager, GameManager.CurrentShip.Zone, pack, true);
ship.SetParent(GameManager.CurrentShip.Parent);
GameManager.PlayerShips.Add(ship);
GameManager.Credits -= pack.Price(GameManager.ItemManager);
}, pack.Price(GameManager.ItemManager) < GameManager.Credits
)));
}
ContextMenu.Show();
});
}