@@ -5,37 +5,17 @@ using UnityEngine;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine.UI;
|
||||
#endif // UNITY_EDITOR
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class BuildingManager : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private BuildingRegistry Registry;
|
||||
[SerializeField] private GameObject HeatGrid;
|
||||
|
||||
[Header("Colors")]
|
||||
[SerializeField] private Color FreezingColor;
|
||||
[SerializeField] private Color ColdColor;
|
||||
[SerializeField] private Color RoomColor;
|
||||
[SerializeField] private Color WarmColor;
|
||||
[SerializeField] private Color BoilingColor;
|
||||
|
||||
private enum HeatingLevel
|
||||
{
|
||||
Freezing,
|
||||
Cold,
|
||||
Room,
|
||||
Warm,
|
||||
Boiling
|
||||
}
|
||||
|
||||
|
||||
private class BuildingInfo
|
||||
{
|
||||
public BuildingInfo(Building b, RectTransform rt)
|
||||
@@ -75,55 +55,13 @@ namespace Fruitomation.Game
|
||||
|
||||
private static string Filepath => Path.Combine(Application.persistentDataPath, "buildings.json");
|
||||
|
||||
private (HeatingLevel, Image)[,] HeatingLevels { get; } = new (HeatingLevel, Image)[96, 49];
|
||||
private bool[,] InhabitedCells { get; } = new bool[96, 49];
|
||||
|
||||
private List<Building> Buildings { get; } = new();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
private static BuildingManager Instance;
|
||||
|
||||
public void ToggleGrid() => HeatGrid.SetActive(!HeatGrid.activeSelf);
|
||||
|
||||
private Color LevelToColor(HeatingLevel level)
|
||||
{
|
||||
return level switch
|
||||
{
|
||||
HeatingLevel.Room => RoomColor,
|
||||
HeatingLevel.Boiling => BoilingColor,
|
||||
HeatingLevel.Cold => ColdColor,
|
||||
HeatingLevel.Freezing => FreezingColor,
|
||||
HeatingLevel.Warm => WarmColor,
|
||||
var _ => new Color()
|
||||
};
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
HeatGrid.SetActive(false);
|
||||
Instance = this;
|
||||
|
||||
for (int x = 0; x < HeatingLevels.GetLength(0); x++)
|
||||
{
|
||||
for (int y = 0; y < HeatingLevels.GetLength(1); y++)
|
||||
{
|
||||
GameObject go = new($"Grid_{x}_{y}");
|
||||
go.transform.SetParent(HeatGrid.transform);
|
||||
|
||||
RectTransform rt = go.AddComponent<RectTransform>();
|
||||
Image img = go.AddComponent<Image>();
|
||||
|
||||
HeatingLevels[x, y].Item1 = (HeatingLevel)Random.Range(0, 5);
|
||||
HeatingLevels[x, y].Item2 = img;
|
||||
|
||||
img.color = LevelToColor(HeatingLevels[x, y].Item1);
|
||||
|
||||
rt.localScale = Vector3.one;
|
||||
img.raycastTarget = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Awake() => Instance = this;
|
||||
|
||||
[MenuItem("Fruitomation/Clear Buildings")]
|
||||
public static void ClearBuildings()
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using Fruitomation.Global;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class HeatExchanger : Building
|
||||
{
|
||||
[Header("Heat Exchanger Specific Items")]
|
||||
[SerializeField] private Animator Animator;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (GameStateController.Is(GameState.Simulation))
|
||||
{
|
||||
if (Animator.speed == 0)
|
||||
{
|
||||
Animator.Play(0, 0, 0f); // Play from beginning
|
||||
Animator.speed = 0.2f; // Playing
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (Animator.speed != 0)
|
||||
{
|
||||
Animator.Play(0, 0, 0f); // Jump back to default frame
|
||||
Animator.speed = 0; // Paused
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a40d30ecee1430c9a21ab42f4290132
|
||||
timeCreated: 1776951500
|
||||
Reference in New Issue
Block a user