Fixed bad math for aspect ratios, refactored scripts attached to player object.
This commit is contained in:
parent
12fef072bf
commit
a2abccd563
@ -32,9 +32,9 @@ public class AutoCrafter : MonoBehaviour
|
||||
public void Start()
|
||||
{
|
||||
craftingManager = GetComponent<CraftingManager>();
|
||||
craftingDictionary = gameObject.AddComponent<CraftingDictionary>();
|
||||
powerReceiver = gameObject.AddComponent<PowerReceiver>();
|
||||
connectionLine = gameObject.AddComponent<LineRenderer>();
|
||||
craftingDictionary = new CraftingDictionary();
|
||||
connectionLine.startWidth = 0.2f;
|
||||
connectionLine.endWidth = 0.2f;
|
||||
connectionLine.material = lineMat;
|
||||
|
@ -1,15 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BlockInteraction : MonoBehaviour
|
||||
public class BlockInteraction
|
||||
{
|
||||
private PlayerController playerController;
|
||||
private InteractionController interactionController;
|
||||
|
||||
// Called by unity engine on start up to initialize variables
|
||||
public void Start()
|
||||
public BlockInteraction(PlayerController playerController, InteractionController interactionController)
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
interactionController = GetComponent<InteractionController>();
|
||||
this.playerController = playerController;
|
||||
this.interactionController = interactionController;
|
||||
}
|
||||
|
||||
// Called once per frame when the player is looking at an iron block.
|
||||
@ -78,7 +77,7 @@ public class BlockInteraction : MonoBehaviour
|
||||
GameManager manager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
if (manager.working == false)
|
||||
{
|
||||
manager.meshManager.SeparateBlocks(transform.position, "all", true);
|
||||
manager.meshManager.SeparateBlocks(playerController.transform.position, "all", true);
|
||||
playerController.separatedBlocks = true;
|
||||
}
|
||||
else
|
||||
@ -88,7 +87,7 @@ public class BlockInteraction : MonoBehaviour
|
||||
if (playerController.building == false)
|
||||
{
|
||||
playerController.destroying = true;
|
||||
playerController.destroyStartPosition = transform.position;
|
||||
playerController.destroyStartPosition = playerController.transform.position;
|
||||
}
|
||||
}
|
||||
if (playerController.paintGunActive == true && playerController.paintColorSelected == true)
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
// This class provides the crafting recipe dictionary used by the crafting manager
|
||||
public class CraftingDictionary : MonoBehaviour
|
||||
public class CraftingDictionary
|
||||
{
|
||||
public Dictionary<string, CraftingRecipe> dictionary;
|
||||
|
||||
@ -66,7 +66,7 @@ public class CraftingDictionary : MonoBehaviour
|
||||
private readonly int[] darkMatterCollectorAmounts = { 50, 50, 50, 50, 50, 100, 100, 100 };
|
||||
private readonly int[] darkMatterConduitAmounts = { 25, 25, 25, 25, 25, 50, 50, 50 };
|
||||
|
||||
void Start()
|
||||
public CraftingDictionary()
|
||||
{
|
||||
dictionary = new Dictionary<string, CraftingRecipe>
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GuiCoordinates : MonoBehaviour
|
||||
public class GuiCoordinates
|
||||
{
|
||||
//MESSAGES
|
||||
public Rect messageRect;
|
||||
@ -225,12 +225,13 @@ public class GuiCoordinates : MonoBehaviour
|
||||
public Rect marketMessageLabelRect;
|
||||
public Rect marketMessageButtonRect;
|
||||
|
||||
void Start()
|
||||
public GuiCoordinates()
|
||||
{
|
||||
//ASPECT RATIO
|
||||
int ScreenHeight = Screen.height;
|
||||
int ScreenWidth = Screen.width;
|
||||
if (ScreenWidth / ScreenHeight < 1.7f)
|
||||
float ratio = ScreenWidth / ScreenHeight;
|
||||
if (ratio < 1.5f)
|
||||
{
|
||||
ScreenHeight = (int)(ScreenHeight * 0.75f);
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public class InfoHUD : MonoBehaviour
|
||||
public void Start()
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
guiCoordinates = GetComponent<GuiCoordinates>();
|
||||
textureDictionary = GetComponent<TextureDictionary>();
|
||||
guiCoordinates = new GuiCoordinates();
|
||||
}
|
||||
|
||||
// Returns true if the info hud should be drawn
|
||||
|
@ -14,16 +14,17 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
blockDictionary = new BlockDictionary(playerController);
|
||||
machineInteraction = gameObject.AddComponent<MachineInteraction>();
|
||||
storageInteraction = gameObject.AddComponent<StorageInteraction>();
|
||||
blockInteraction = gameObject.AddComponent<BlockInteraction>();
|
||||
machineInteraction = new MachineInteraction(playerController, this);
|
||||
storageInteraction = new StorageInteraction(playerController, this);
|
||||
blockInteraction = new BlockInteraction(playerController, this);
|
||||
}
|
||||
|
||||
// Called once per frame by unity engine
|
||||
public void Update()
|
||||
{
|
||||
//RAYCAST AND ASSOCIATED DATA FOR INTERACTING WITH MACHINES AND OTHER OBJECTS
|
||||
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out playerController.playerLookHit, 40))
|
||||
// Raycast and associated data for interacting with machines and other objects.
|
||||
Transform camPos = Camera.main.gameObject.transform;
|
||||
if (Physics.Raycast(camPos.position, camPos.forward, out playerController.playerLookHit, 40))
|
||||
{
|
||||
if (playerController.inventoryOpen == false && playerController.escapeMenuOpen == false && playerController.tabletOpen == false)
|
||||
{
|
||||
|
@ -18,9 +18,9 @@ public class InventoryGUI : MonoBehaviour
|
||||
playerController = GetComponent<PlayerController>();
|
||||
playerInventory = GetComponent<InventoryManager>();
|
||||
craftingManager = GetComponent<CraftingManager>();
|
||||
craftingDictionary = gameObject.AddComponent<CraftingDictionary>();
|
||||
guiCoordinates = GetComponent<GuiCoordinates>();
|
||||
textureDictionary = GetComponent<TextureDictionary>();
|
||||
craftingDictionary = new CraftingDictionary();
|
||||
guiCoordinates = new GuiCoordinates();
|
||||
}
|
||||
|
||||
// Called by unity engine for rendering and handling GUI events
|
||||
|
@ -11,8 +11,8 @@ public class MachineGUI : MonoBehaviour
|
||||
public void Start()
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
guiCoordinates = GetComponent<GuiCoordinates>();
|
||||
textureDictionary = GetComponent<TextureDictionary>();
|
||||
guiCoordinates = new GuiCoordinates();
|
||||
}
|
||||
|
||||
// Called by unity engine for rendering and handling GUI events
|
||||
|
@ -1,15 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class MachineInteraction : MonoBehaviour
|
||||
public class MachineInteraction
|
||||
{
|
||||
private PlayerController playerController;
|
||||
private InteractionController interactionController;
|
||||
|
||||
// Called by unity engine on start up to initialize variables
|
||||
public void Start()
|
||||
public MachineInteraction(PlayerController playerController, InteractionController interactionController)
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
interactionController = GetComponent<InteractionController>();
|
||||
this.playerController = playerController;
|
||||
this.interactionController = interactionController;
|
||||
}
|
||||
|
||||
public void InteractWithElectricLight()
|
||||
@ -29,10 +28,10 @@ public class MachineInteraction : MonoBehaviour
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
AirLock[] airLocks = FindObjectsOfType<AirLock>();
|
||||
AirLock[] airLocks = Object.FindObjectsOfType<AirLock>();
|
||||
foreach (AirLock a in airLocks)
|
||||
{
|
||||
if (Vector3.Distance(transform.position, a.transform.position) < 40)
|
||||
if (Vector3.Distance(playerController.transform.position, a.transform.position) < 40)
|
||||
{
|
||||
a.ToggleOpen();
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public class MarketGUI : MonoBehaviour
|
||||
public void Start()
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
guiCoordinates = GetComponent<GuiCoordinates>();
|
||||
textureDictionary = GetComponent<TextureDictionary>();
|
||||
guiCoordinates = new GuiCoordinates();
|
||||
priceDictionary = new Dictionary<string, int>
|
||||
{
|
||||
{ "Iron Block", 10 },
|
||||
|
@ -735,15 +735,10 @@ public class PlayerController : MonoBehaviour
|
||||
string destinationPath = Path.Combine(Application.persistentDataPath, "SaveData/" + fileName + ".bak");
|
||||
File.Copy(FileBasedPrefs.GetSaveFilePath(), destinationPath, true);
|
||||
|
||||
if (!Application.isEditor && GameObject.Find("Player").GetComponent<PlayerController>().exiting == true)
|
||||
if (GameObject.Find("Player").GetComponent<PlayerController>().exiting == true)
|
||||
{
|
||||
Debug.Log("Shutting down...");
|
||||
System.Diagnostics.Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Shutting down...");
|
||||
break;
|
||||
Debug.Log("Loading main menu...");
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ public class PlayerGUI : MonoBehaviour
|
||||
playerInventory = GetComponent<InventoryManager>();
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
stateManager = GameObject.Find("GameManager").GetComponent<StateManager>();
|
||||
guiCoordinates = GetComponent<GuiCoordinates>();
|
||||
textureDictionary = GetComponent<TextureDictionary>();
|
||||
guiCoordinates = new GuiCoordinates();
|
||||
}
|
||||
|
||||
// Returns true if the escape menu should be displayed.
|
||||
@ -39,7 +39,6 @@ public class PlayerGUI : MonoBehaviour
|
||||
&& playerController.requestedSave == false
|
||||
&& gameManager.dataSaveRequested == false
|
||||
&& stateManager.saving == false;
|
||||
|
||||
}
|
||||
|
||||
private bool IsStandardBlock(string type)
|
||||
|
@ -1,16 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class StorageInteraction : MonoBehaviour
|
||||
public class StorageInteraction
|
||||
{
|
||||
private PlayerController playerController;
|
||||
private InteractionController interactionController;
|
||||
private GameManager gameManager;
|
||||
|
||||
public void Start()
|
||||
public StorageInteraction(PlayerController playerController, InteractionController interactionController)
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
interactionController = GetComponent<InteractionController>();
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
this.playerController = playerController;
|
||||
this.interactionController = interactionController;
|
||||
}
|
||||
|
||||
public void InteractWithStorageContainer()
|
||||
@ -24,7 +22,7 @@ public class StorageInteraction : MonoBehaviour
|
||||
if (GameObject.Find("GameManager").GetComponent<GameManager>().working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
playerController.gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
@ -85,7 +83,7 @@ public class StorageInteraction : MonoBehaviour
|
||||
{
|
||||
playerController.playerInventory.AddItem("Storage Container", 1);
|
||||
}
|
||||
Destroy(playerController.objectInSight);
|
||||
Object.Destroy(playerController.objectInSight);
|
||||
playerController.PlayCraftingSound();
|
||||
}
|
||||
else
|
||||
@ -110,7 +108,7 @@ public class StorageInteraction : MonoBehaviour
|
||||
if (GameObject.Find("GameManager").GetComponent<GameManager>().working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
playerController.gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user