Skip to content

Commit

Permalink
Fixed glass blocks ID saving and some GUI issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Droog71 committed Sep 16, 2020
1 parent 7801e9e commit df49f22
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 26 deletions.
6 changes: 6 additions & 0 deletions ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,12 @@ public void StartBuildMode()
playerController.inventoryOpen = false;
playerController.craftingGUIopen = false;
playerController.storageGUIopen = false;
if (playerController.paintGunActive == true)
{
playerController.paintGun.SetActive(false);
playerController.paintGunActive = false;
playerController.paintColorSelected = false;
}
if (playerController.scannerActive == true)
{
playerController.scanner.SetActive(false);
Expand Down
10 changes: 4 additions & 6 deletions CombinedMeshManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public void CombineBlocks()
{
ironCount++;
}
if (block.GetComponent<PhysicsHandler>().falling == false && block.GetComponent<PhysicsHandler>().fallingStack == false && block.GetComponent<PhysicsHandler>().needsSupportCheck == false)
if (block.GetComponent<PhysicsHandler>().IsSupported())
{
block.transform.parent = gameManager.ironBlocks[ironCount].transform;
if (gameManager.initIron == false)
Expand All @@ -340,7 +340,7 @@ public void CombineBlocks()
{
glassCount++;
}
if (block.GetComponent<PhysicsHandler>().falling == false && block.GetComponent<PhysicsHandler>().fallingStack == false && block.GetComponent<PhysicsHandler>().needsSupportCheck == false)
if (block.GetComponent<PhysicsHandler>().IsSupported())
{
block.transform.parent = gameManager.glass[glassCount].transform;
if (gameManager.initGlass == false)
Expand All @@ -366,7 +366,7 @@ public void CombineBlocks()
{
steelCount++;
}
if (block.GetComponent<PhysicsHandler>().falling == false && block.GetComponent<PhysicsHandler>().fallingStack == false && block.GetComponent<PhysicsHandler>().needsSupportCheck == false)
if (block.GetComponent<PhysicsHandler>().IsSupported())
{
block.transform.parent = gameManager.steel[steelCount].transform;
if (gameManager.initSteel == false)
Expand All @@ -392,7 +392,7 @@ public void CombineBlocks()
{
brickCount++;
}
if (block.GetComponent<PhysicsHandler>().falling == false && block.GetComponent<PhysicsHandler>().fallingStack == false && block.GetComponent<PhysicsHandler>().needsSupportCheck == false)
if (block.GetComponent<PhysicsHandler>().IsSupported())
{
block.transform.parent = gameManager.bricks[brickCount].transform;
if (gameManager.initBrick == false)
Expand Down Expand Up @@ -639,7 +639,6 @@ private IEnumerator CombineMeshCoroutine()
gameManager.clearGlassDummies = true;
FileBasedPrefs.SetBool(gameManager.GetComponent<StateManager>().WorldName + "initGlass", true);
}
//Debug.Log("Finished mesh combine for glass at: " + System.DateTime.Now);
}

if (gameManager.steelMeshRequired == true)
Expand Down Expand Up @@ -703,7 +702,6 @@ private IEnumerator CombineMeshCoroutine()
gameManager.clearSteelDummies = true;
FileBasedPrefs.SetBool(gameManager.GetComponent<StateManager>().WorldName + "initSteel", true);
}
//Debug.Log("Finished mesh combine for steel at: " + System.DateTime.Now);
}

if (gameManager.brickMeshRequired == true)
Expand Down
6 changes: 6 additions & 0 deletions GuiCoordinates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ public class GuiCoordinates
public Rect marketMessageLabelRect;
public Rect marketMessageButtonRect;

//PAINT COLOR
public Rect paintGunMenuBackgroundRect;

public GuiCoordinates()
{
//ASPECT RATIO
Expand Down Expand Up @@ -551,5 +554,8 @@ public GuiCoordinates()
marketMessageRect = new Rect(((ScreenWidth / 2) - 300), ((ScreenHeight / 2) - 200), 600, 400);
marketMessageLabelRect = new Rect(((ScreenWidth / 2) - 175), ((ScreenHeight / 2) - 100), 400, 100);
marketMessageButtonRect = new Rect(((ScreenWidth / 2) - (ScreenWidth * 0.07f)), ((ScreenHeight / 2) + 30), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));

//PAINT GUN COLOR SELECTION BACKGROUND
paintGunMenuBackgroundRect = new Rect((ScreenWidth * 0.4f), (ScreenHeight * 0.04f), (ScreenWidth * 0.2f), (ScreenHeight * 0.56f));
}
}
60 changes: 41 additions & 19 deletions InfoHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Iron Block");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
else if (obj.GetComponent<Steel>() != null)
{
Expand All @@ -178,9 +181,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Steel Block");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
else if (obj.GetComponent<Glass>() != null)
{
Expand All @@ -192,10 +198,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Glass Block");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.Label(resourceInfoRect, "Glass Block");
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
else if (obj.GetComponent<Brick>() != null)
{
Expand All @@ -207,10 +215,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Brick Block");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.Label(resourceInfoRect, "Brick Block");
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
else if (obj.GetComponent<ElectricLight>() != null)
{
Expand Down Expand Up @@ -698,7 +708,7 @@ public void OnGUI()
}
}
}
else if (playerController.lookingAtCombinedMesh == true && playerController.paintGunActive == false)
else if (playerController.lookingAtCombinedMesh == true)
{
if (obj.name.Equals("ironHolder(Clone)"))
{
Expand All @@ -710,9 +720,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Iron Structure");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
if (obj.name.Equals("glassHolder(Clone)"))
{
Expand All @@ -724,9 +737,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Glass Structure");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
if (obj.name.Equals("steelHolder(Clone)"))
{
Expand All @@ -738,9 +754,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Steel Structure");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
if (obj.name.Equals("brickHolder(Clone)"))
{
Expand All @@ -752,9 +771,12 @@ public void OnGUI()
Vector2 size = style.CalcSize(content);
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height - 70) - (size.y / 2), size.x, size.y);
GUI.Label(resourceInfoRect, "Brick Structure");
if (playerController.paintGunActive == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress Q to stop building.");
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions PhysicsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ private void CheckForSupport()
needsSupportCheck = false;
}

// Returns true if the block is not at risk of falling
public bool IsSupported()
{
return falling == false && fallingStack == false && needsSupportCheck == false;
}

// Called by unity engine once per physics update for every collider that is touching the trigger
public void OnTriggerStay(Collider other)
{
Expand Down
5 changes: 4 additions & 1 deletion PlayerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ public void OnGUI()
if (playerController.building == true && playerController.tabletOpen == false)
{
GUI.DrawTexture(guiCoordinates.buildInfoRectBG, textureDictionary.dictionary["Interface Background"]);
int f = GUI.skin.label.fontSize;
GUI.skin.label.fontSize = 16;
GUI.Label(guiCoordinates.buildInfoRect, "Right click to place block.\nPress F to collect.\nPress R to rotate.\nPress Q to stop building.");
GUI.skin.label.fontSize = f;
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
int buildItemCount = 0;
foreach (InventorySlot slot in playerInventory.inventory)
Expand All @@ -631,7 +634,7 @@ public void OnGUI()
{
if (playerController.paintColorSelected == false)
{
GUI.DrawTexture(guiCoordinates.optionsMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
GUI.DrawTexture(guiCoordinates.paintGunMenuBackgroundRect, textureDictionary.dictionary["Menu Background"]);
GUI.Label(guiCoordinates.optionsButton1Rect, " Paint Gun");
GUI.Label(guiCoordinates.optionsButton2Rect, " Select Color");
GUI.Label(guiCoordinates.sliderLabel1Rect, "Red");
Expand Down
1 change: 1 addition & 0 deletions SaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ public IEnumerator SaveDataCoroutine()
}
if (T.gameObject.GetComponent<Glass>() != null)
{
objectName = stateManager.WorldName + "Glass";
worldID = T.gameObject.GetComponent<Glass>().ID;
objectID = int.Parse(worldID.Substring(objectName.Length));
idList.Add(objectID);
Expand Down

0 comments on commit df49f22

Please sign in to comment.