using System; using System.Linq; using Base; using Entity; using Managers; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace UI { public class SettlementUI:FullScreenUI,IPointerClickHandler { public Image title; public SettlementUIInventoryDisplay weaponDisplay; public SettlementUIInventoryDisplay itemDisplay; public SettlementUIText threatDisplay; public SettlementUIText materialsDisplay; public Sprite success, agentDead, baseDestroyed; public float animationTime = 1; public bool toBase; private float timer; private float endTime = 30; public SettlementUI() { needPause = false; } public override void Show() { base.Show(); weaponDisplay.StartShow(animationTime, (Program.Instance.FocusedEntity as Character)?.WeaponInventory.GetSlots().ToArray()); itemDisplay.StartShow(animationTime, (Program.Instance.FocusedEntity as Character)?.ItemInventory.GetSlots().ToArray()); var totalThreat=KeyValueArchiveManager.Instance.Get("LastGameTotalThreat"); var gameEnding= KeyValueArchiveManager.Instance.Get("LastGameEnding"); SetTitle(gameEnding); threatDisplay.StartShow(animationTime,totalThreat); materialsDisplay.StartShow(animationTime, (totalThreat + 99) / 100); Program.Instance.CoinCount += (totalThreat + 99) / 100; } public override void TickUI() { timer += Time.deltaTime; if (timer >= endTime) { Program.Instance.ReturnBase(); } } public void SetTitle(GameEnding gameEnding) { title.sprite = gameEnding switch { GameEnding.AreaSecured => success, GameEnding.AgentMissing => agentDead, GameEnding.BaseDestroyed => baseDestroyed, _ => throw new ArgumentOutOfRangeException(nameof(gameEnding), gameEnding, null) }; } public void OnPointerClick(PointerEventData eventData) { if(eventData.button != PointerEventData.InputButton.Left) return; if(toBase) Program.Instance.ReturnBase(); else { toBase = true; weaponDisplay.ShowAllImmediately(); itemDisplay.ShowAllImmediately(); } } } }