New development branch as of 05/16/21
This commit is contained in:
parent
b20da13ee9
commit
4b4cf79f88
ActionManager.csAddressManager.csAlloySmelter.csAuger.csAutoCrafter.csBasicMachine.csBlockDictionary.csBlockInteraction.csBlockSelector.csBrick.csBuildController.csChatGUI.csCombinedMeshManager.csConduitItem.csCraftingDictionary.csCraftingGUI.csCraftingManager.csDarkMatterCollector.csDarkMatterConduit.csDescriptions.csDoor.csElectricLight.csGameManager.csGlass.csGuiCoordinates.csHazardManager.csHeatExchanger.csInfoHUD.csInputManager.csInteractionController.csInventoryGUI.csInventoryHandler.csInventoryManager.csIronBlock.csItem.csLaserController.csMachineGUI.csMachineInteraction.csMainMenu.csMarketGUI.csMeshPainter.csMeteor.csMissileTurret.csModBlock.csModMachine.csNetworkController.csNetworkPlayer.csNetworkReceive.csNetworkSend.csNuclearReactor.csObjImporter.csPhysicsHandler.csPirate.csPlayerController.csPlayerGUI.csPowerConduit.csPowerSource.csRailCart.csRailCartHub.csRetriever.csRocket.csSaveManager.csStateManager.csSteel.csStorageComputer.csStorageInteraction.csTextureDictionary.csTurret.csUniversalConduit.csUniversalExtractor.cscInputInit.cs
211
ActionManager.cs
211
ActionManager.cs
@ -53,8 +53,6 @@ public class ActionManager
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
@ -90,8 +88,6 @@ public class ActionManager
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
@ -120,6 +116,21 @@ public class ActionManager
|
||||
//! Toggles the paint gun.
|
||||
public void TogglePaintGun()
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
if (playerController.paintGunActive == false)
|
||||
{
|
||||
playerController.paintGunActive = true;
|
||||
@ -135,23 +146,6 @@ public class ActionManager
|
||||
playerController.paintGunActive = false;
|
||||
playerController.paintColorSelected = false;
|
||||
}
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Toggles the inventory GUI.
|
||||
@ -159,23 +153,6 @@ public class ActionManager
|
||||
{
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.machineGUIopen = false;
|
||||
@ -198,23 +175,6 @@ public class ActionManager
|
||||
{
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.machineGUIopen = false;
|
||||
@ -238,23 +198,6 @@ public class ActionManager
|
||||
{
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.machineGUIopen = false;
|
||||
@ -280,23 +223,6 @@ public class ActionManager
|
||||
{
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.tabletOpen = true;
|
||||
@ -562,8 +488,6 @@ public class ActionManager
|
||||
if (playerController.buildIncrementTimer >= 0.1f)
|
||||
{
|
||||
playerController.buildMultiplier += 1;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.buildIncrementTimer = 0;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
@ -576,51 +500,48 @@ public class ActionManager
|
||||
if (playerController.buildIncrementTimer >= 0.1f)
|
||||
{
|
||||
playerController.buildMultiplier -= 1;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.buildIncrementTimer = 0;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
|
||||
//! Toggles building mode.
|
||||
public void ToggleBuilding()
|
||||
{
|
||||
if (playerController.building == true)
|
||||
{
|
||||
StopBuilding();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartBuildMode();
|
||||
}
|
||||
}
|
||||
|
||||
//! Starts build mode, for placing blocks.
|
||||
public void StartBuildMode()
|
||||
{
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
bool foundItems = false;
|
||||
foreach (InventorySlot slot in playerController.playerInventory.inventory)
|
||||
if (playerController.paintGunActive == true)
|
||||
{
|
||||
if (foundItems == false && slot.amountInSlot > 0)
|
||||
{
|
||||
foundItems |= slot.typeInSlot.Equals(playerController.buildType);
|
||||
}
|
||||
playerController.paintGun.SetActive(false);
|
||||
playerController.paintGunActive = false;
|
||||
playerController.paintColorSelected = false;
|
||||
}
|
||||
if (foundItems == true)
|
||||
if (playerController.scannerActive == true)
|
||||
{
|
||||
playerController.building = true;
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
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);
|
||||
playerController.scannerActive = false;
|
||||
}
|
||||
if (playerController.laserCannonActive == true)
|
||||
{
|
||||
playerController.laserCannon.SetActive(false);
|
||||
playerController.laserCannonActive = false;
|
||||
}
|
||||
playerController.scanner.SetActive(false);
|
||||
playerController.scannerActive = false;
|
||||
}
|
||||
if (playerController.laserCannonActive == true)
|
||||
{
|
||||
playerController.laserCannon.SetActive(false);
|
||||
playerController.laserCannonActive = false;
|
||||
}
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
playerController.building = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -634,8 +555,6 @@ public class ActionManager
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
@ -644,32 +563,17 @@ public class ActionManager
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
if (playerController.paintGunActive == true)
|
||||
{
|
||||
TogglePaintGun();
|
||||
}
|
||||
}
|
||||
|
||||
//! Removes duplicate blocks.
|
||||
public void Undo()
|
||||
{
|
||||
playerController.gameManager.UndoBuiltObjects();
|
||||
}
|
||||
|
||||
//! Closes machine GUI.
|
||||
public void CloseMachineGUI()
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.gameObject.GetComponent<MSCameraController>().enabled = false;
|
||||
@ -679,23 +583,6 @@ public class ActionManager
|
||||
//! Closes tablet GUI.
|
||||
public void CloseTablet()
|
||||
{
|
||||
if (playerController.building == true || playerController.destroying == true)
|
||||
{
|
||||
if (playerController.gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.gameObject.GetComponent<MSCameraController>().enabled = false;
|
||||
|
@ -24,83 +24,83 @@ public class AddressManager
|
||||
{
|
||||
if (go != null)
|
||||
{
|
||||
if (go.transform.parent != stateManager.BuiltObjects.transform)
|
||||
if (go.transform.parent != stateManager.builtObjects.transform)
|
||||
{
|
||||
if (go.GetComponent<Auger>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Auger";
|
||||
objectName = stateManager.worldName + "Auger";
|
||||
go.GetComponent<Auger>().ID = objectName + idCount;
|
||||
go.GetComponent<Auger>().address = idCount;
|
||||
}
|
||||
if (go.GetComponent<ElectricLight>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "ElectricLight";
|
||||
objectName = stateManager.worldName + "ElectricLight";
|
||||
go.GetComponent<ElectricLight>().ID = objectName + idCount;
|
||||
go.GetComponent<ElectricLight>().address = idCount;
|
||||
}
|
||||
if (go.GetComponent<DarkMatterCollector>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "DarkMatterCollector";
|
||||
objectName = stateManager.worldName + "DarkMatterCollector";
|
||||
go.GetComponent<DarkMatterCollector>().ID = objectName + idCount;
|
||||
go.GetComponent<DarkMatterCollector>().address = idCount;
|
||||
}
|
||||
if (go.GetComponent<DarkMatterConduit>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "DarkMatterConduit";
|
||||
objectName = stateManager.worldName + "DarkMatterConduit";
|
||||
go.GetComponent<DarkMatterConduit>().address = idCount;
|
||||
go.GetComponent<DarkMatterConduit>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<RailCart>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "RailCart";
|
||||
objectName = stateManager.worldName + "RailCart";
|
||||
go.GetComponent<RailCart>().address = idCount;
|
||||
go.GetComponent<RailCart>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<RailCartHub>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "RailCartHub";
|
||||
objectName = stateManager.worldName + "RailCartHub";
|
||||
go.GetComponent<RailCartHub>().address = idCount;
|
||||
go.GetComponent<RailCartHub>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<UniversalConduit>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "UniversalConduit";
|
||||
objectName = stateManager.worldName + "UniversalConduit";
|
||||
go.GetComponent<UniversalConduit>().address = idCount;
|
||||
go.GetComponent<UniversalConduit>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<HeatExchanger>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "HeatExchanger";
|
||||
objectName = stateManager.worldName + "HeatExchanger";
|
||||
go.GetComponent<HeatExchanger>().address = idCount;
|
||||
go.GetComponent<HeatExchanger>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<Retriever>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Retriever";
|
||||
objectName = stateManager.worldName + "Retriever";
|
||||
go.GetComponent<Retriever>().address = idCount;
|
||||
go.GetComponent<Retriever>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<AutoCrafter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "AutoCrafter";
|
||||
objectName = stateManager.worldName + "AutoCrafter";
|
||||
go.GetComponent<AutoCrafter>().address = idCount;
|
||||
go.GetComponent<AutoCrafter>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<Smelter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Smelter";
|
||||
objectName = stateManager.worldName + "Smelter";
|
||||
go.GetComponent<Smelter>().address = idCount;
|
||||
go.GetComponent<Smelter>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<Turret>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Turret";
|
||||
objectName = stateManager.worldName + "Turret";
|
||||
go.GetComponent<Turret>().address = idCount;
|
||||
go.GetComponent<Turret>().ID = (objectName + idCount);
|
||||
}
|
||||
if (go.GetComponent<MissileTurret>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "MissileTurret";
|
||||
objectName = stateManager.worldName + "MissileTurret";
|
||||
go.GetComponent<MissileTurret>().address = idCount;
|
||||
go.GetComponent<MissileTurret>().ID = (objectName + idCount);
|
||||
}
|
||||
@ -108,84 +108,91 @@ public class AddressManager
|
||||
{
|
||||
if (go.GetComponent<PowerSource>().type == "Solar Panel")
|
||||
{
|
||||
objectName = stateManager.WorldName + "SolarPanel";
|
||||
objectName = stateManager.worldName + "SolarPanel";
|
||||
}
|
||||
else if (go.GetComponent<PowerSource>().type == "Generator")
|
||||
{
|
||||
objectName = stateManager.WorldName + "Generator";
|
||||
objectName = stateManager.worldName + "Generator";
|
||||
}
|
||||
else if (go.GetComponent<PowerSource>().type == "Reactor Turbine")
|
||||
{
|
||||
objectName = stateManager.WorldName + "ReactorTurbine";
|
||||
objectName = stateManager.worldName + "ReactorTurbine";
|
||||
}
|
||||
go.GetComponent<PowerSource>().address = idCount;
|
||||
go.GetComponent<PowerSource>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<NuclearReactor>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "NuclearReactor";
|
||||
objectName = stateManager.worldName + "NuclearReactor";
|
||||
go.GetComponent<NuclearReactor>().address = idCount;
|
||||
go.GetComponent<NuclearReactor>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<PowerConduit>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "PowerConduit";
|
||||
objectName = stateManager.worldName + "PowerConduit";
|
||||
go.GetComponent<PowerConduit>().address = idCount;
|
||||
go.GetComponent<PowerConduit>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<AlloySmelter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "AlloySmelter";
|
||||
objectName = stateManager.worldName + "AlloySmelter";
|
||||
go.GetComponent<AlloySmelter>().address = idCount;
|
||||
go.GetComponent<AlloySmelter>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<Press>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Press";
|
||||
objectName = stateManager.worldName + "Press";
|
||||
go.GetComponent<Press>().address = idCount;
|
||||
go.GetComponent<Press>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<Extruder>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Extruder";
|
||||
objectName = stateManager.worldName + "Extruder";
|
||||
go.GetComponent<Extruder>().address = idCount;
|
||||
go.GetComponent<Extruder>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<GearCutter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "GearCutter";
|
||||
objectName = stateManager.worldName + "GearCutter";
|
||||
go.GetComponent<GearCutter>().address = idCount;
|
||||
go.GetComponent<GearCutter>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<UniversalExtractor>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "UniversalExtractor";
|
||||
objectName = stateManager.worldName + "UniversalExtractor";
|
||||
go.GetComponent<UniversalExtractor>().address = idCount;
|
||||
go.GetComponent<UniversalExtractor>().ID = objectName + idCount;
|
||||
}
|
||||
if (stateManager.IsStorageContainer(go))
|
||||
{
|
||||
objectName = stateManager.WorldName + "StorageContainer";
|
||||
objectName = stateManager.worldName + "StorageContainer";
|
||||
go.GetComponent<InventoryManager>().ID = objectName + idCount;
|
||||
go.GetComponent<InventoryManager>().address = idCount;
|
||||
go.GetComponent<InventoryManager>().SaveData();
|
||||
}
|
||||
if (go.GetComponent<StorageComputer>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "StorageComputer";
|
||||
objectName = stateManager.worldName + "StorageComputer";
|
||||
go.GetComponent<StorageComputer>().address = idCount;
|
||||
go.GetComponent<StorageComputer>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<AirLock>() != null)
|
||||
if (go.GetComponent<Door>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "AirLock";
|
||||
go.GetComponent<AirLock>().address = idCount;
|
||||
go.GetComponent<AirLock>().ID = objectName + idCount;
|
||||
if (go.GetComponent<Door>().type == "Door")
|
||||
{
|
||||
objectName = stateManager.worldName + "Door";
|
||||
}
|
||||
else if (go.GetComponent<Door>().type == "Quantum Hatchway")
|
||||
{
|
||||
objectName = stateManager.worldName + "QuantumHatchway";
|
||||
}
|
||||
go.GetComponent<Door>().address = idCount;
|
||||
go.GetComponent<Door>().ID = objectName + idCount;
|
||||
}
|
||||
if (go.GetComponent<ModMachine>() != null)
|
||||
{
|
||||
ModMachine machine = go.GetComponent<ModMachine>();
|
||||
objectName = stateManager.WorldName + "ModMachine";
|
||||
objectName = stateManager.worldName + "ModMachine";
|
||||
go.GetComponent<ModMachine>().ID = objectName + idCount;
|
||||
go.GetComponent<ModMachine>().address = idCount;
|
||||
}
|
||||
@ -202,7 +209,7 @@ public class AddressManager
|
||||
}
|
||||
}
|
||||
|
||||
Transform[] blocks = stateManager.BuiltObjects.GetComponentsInChildren<Transform>(true);
|
||||
Transform[] blocks = stateManager.builtObjects.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform T in blocks)
|
||||
{
|
||||
if (T != null)
|
||||
@ -211,11 +218,11 @@ public class AddressManager
|
||||
{
|
||||
if (T.gameObject.name.Equals("IronRamp(Clone)"))
|
||||
{
|
||||
objectName = stateManager.WorldName + "IronRamp";
|
||||
objectName = stateManager.worldName + "IronRamp";
|
||||
}
|
||||
else
|
||||
{
|
||||
objectName = stateManager.WorldName + "IronBlock";
|
||||
objectName = stateManager.worldName + "IronBlock";
|
||||
}
|
||||
T.gameObject.GetComponent<IronBlock>().ID = objectName + idCount;
|
||||
T.gameObject.GetComponent<IronBlock>().address = idCount;
|
||||
@ -225,11 +232,11 @@ public class AddressManager
|
||||
{
|
||||
if (T.gameObject.name.Equals("SteelRamp(Clone)"))
|
||||
{
|
||||
objectName = stateManager.WorldName + "SteelRamp";
|
||||
objectName = stateManager.worldName + "SteelRamp";
|
||||
}
|
||||
else
|
||||
{
|
||||
objectName = stateManager.WorldName + "Steel";
|
||||
objectName = stateManager.worldName + "Steel";
|
||||
}
|
||||
T.gameObject.GetComponent<Steel>().ID = objectName + idCount;
|
||||
T.gameObject.GetComponent<Steel>().address = idCount;
|
||||
@ -237,18 +244,25 @@ public class AddressManager
|
||||
}
|
||||
if (T.gameObject.GetComponent<Brick>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Brick";
|
||||
objectName = stateManager.worldName + "Brick";
|
||||
T.gameObject.GetComponent<Brick>().ID = objectName + idCount;
|
||||
T.gameObject.GetComponent<Brick>().address = idCount;
|
||||
idCount++;
|
||||
}
|
||||
if (T.gameObject.GetComponent<Glass>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Glass";
|
||||
objectName = stateManager.worldName + "Glass";
|
||||
T.gameObject.GetComponent<Glass>().ID = objectName + idCount;
|
||||
T.gameObject.GetComponent<Glass>().address = idCount;
|
||||
idCount++;
|
||||
}
|
||||
if (T.gameObject.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
objectName = stateManager.worldName + "ModBlock";
|
||||
T.gameObject.GetComponent<ModBlock>().ID = objectName + idCount;
|
||||
T.gameObject.GetComponent<ModBlock>().address = idCount;
|
||||
idCount++;
|
||||
}
|
||||
|
||||
addressingInterval++;
|
||||
if (addressingInterval >= 10)
|
||||
|
@ -48,13 +48,15 @@ public class AlloySmelter : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
conduitItem = GetComponentInChildren<ConduitItem>(true);
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
|
3
Auger.cs
3
Auger.cs
@ -40,6 +40,9 @@ public class Auger : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -43,13 +43,16 @@ public class AutoCrafter : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
conduitItem = GetComponentInChildren<ConduitItem>(true);
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ public class BasicMachine : MonoBehaviour
|
||||
private LineRenderer connectionLine;
|
||||
private GameObject builtObjects;
|
||||
public StateManager stateManager;
|
||||
public bool hasCustomSound;
|
||||
private int machineTimer;
|
||||
private int warmup;
|
||||
|
||||
@ -44,12 +45,15 @@ public class BasicMachine : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
@ -242,6 +246,10 @@ public class BasicMachine : MonoBehaviour
|
||||
outputObject.GetComponent<UniversalConduit>().amount += speed - heat;
|
||||
amount -= speed - heat;
|
||||
machineTimer = 0;
|
||||
if (hasCustomSound == true)
|
||||
{
|
||||
GetComponent<AudioSource>().Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -10,6 +10,8 @@ public class BlockDictionary
|
||||
private PlayerController playerController;
|
||||
public Dictionary<string, GameObject> machineDictionary;
|
||||
public Dictionary<string, GameObject> blockDictionary;
|
||||
public Dictionary<string, Mesh> meshDictionary;
|
||||
public Dictionary<string, Type> typeDictionary;
|
||||
|
||||
public BlockDictionary(PlayerController playerController)
|
||||
{
|
||||
@ -114,9 +116,70 @@ public class BlockDictionary
|
||||
}
|
||||
}
|
||||
|
||||
//! Adds blocks from mods to the game.
|
||||
public void AddModBlocks(Dictionary<string, GameObject> dictionary)
|
||||
{
|
||||
string modPath = Path.Combine(Application.persistentDataPath, "Mods");
|
||||
Directory.CreateDirectory(modPath);
|
||||
string[] modDirs = Directory.GetDirectories(modPath);
|
||||
foreach (string path in modDirs)
|
||||
{
|
||||
string blockPath = path + "/Blocks/";
|
||||
Directory.CreateDirectory(blockPath);
|
||||
DirectoryInfo d = new DirectoryInfo(blockPath);
|
||||
foreach (FileInfo file in d.GetFiles("*.qe"))
|
||||
{
|
||||
string filePath = blockPath + file.Name;
|
||||
string fileContents = File.ReadAllText(filePath);
|
||||
string blockName = file.Name.Remove(file.Name.Length - 3);
|
||||
if (!dictionary.ContainsKey(blockName))
|
||||
{
|
||||
dictionary.Add(blockName, playerController.modBlock);
|
||||
List<string> objList = playerController.blockSelector.objectNames.ToList();
|
||||
objList.Add(blockName);
|
||||
playerController.blockSelector.objectNames = objList.ToArray();
|
||||
string modName = new DirectoryInfo(path).Name;
|
||||
playerController.gameManager.modBlockNames.Add(blockName);
|
||||
Debug.Log("Mod "+"["+modName+"]"+" created a new block: [" + blockName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
playerController.gameManager.InitModBlocks();
|
||||
}
|
||||
|
||||
//! Adds blocks from mods to the game.
|
||||
public void AddModMeshes(Dictionary<string, Mesh> dictionary)
|
||||
{
|
||||
string modPath = Path.Combine(Application.persistentDataPath, "Mods");
|
||||
Directory.CreateDirectory(modPath);
|
||||
string[] modDirs = Directory.GetDirectories(modPath);
|
||||
foreach (string path in modDirs)
|
||||
{
|
||||
string meshPath = path + "/Models/";
|
||||
Directory.CreateDirectory(meshPath);
|
||||
DirectoryInfo d = new DirectoryInfo(meshPath);
|
||||
foreach (FileInfo file in d.GetFiles("*.obj"))
|
||||
{
|
||||
string filePath = meshPath + file.Name;
|
||||
string meshName = file.Name.Remove(file.Name.Length - 4);
|
||||
if (!dictionary.ContainsKey(meshName))
|
||||
{
|
||||
ObjImporter importer = new ObjImporter();
|
||||
Mesh newMesh = importer.ImportFile(filePath);
|
||||
dictionary.Add(meshName, newMesh);
|
||||
string modName = new DirectoryInfo(path).Name;
|
||||
Debug.Log("Mod "+"["+modName+"]"+" created a new mesh: [" + meshName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
playerController.gameManager.InitModBlocks();
|
||||
}
|
||||
|
||||
//! Initializes variables.
|
||||
private void Init()
|
||||
{
|
||||
meshDictionary = new Dictionary<string, Mesh>();
|
||||
|
||||
blockDictionary = new Dictionary<string, GameObject>
|
||||
{
|
||||
{ "Brick", playerController.brick },
|
||||
@ -129,7 +192,8 @@ public class BlockDictionary
|
||||
|
||||
machineDictionary = new Dictionary<string, GameObject>
|
||||
{
|
||||
{ "Quantum Hatchway", playerController.airlock },
|
||||
{ "Quantum Hatchway", playerController.quantumHatchway },
|
||||
{ "Door", playerController.door },
|
||||
{ "Alloy Smelter", playerController.alloySmelter },
|
||||
{ "Auger", playerController.auger },
|
||||
{ "Auto Crafter", playerController.autoCrafter },
|
||||
@ -156,5 +220,41 @@ public class BlockDictionary
|
||||
{ "Universal Conduit", playerController.universalConduit },
|
||||
{ "Universal Extractor", playerController.universalExtractor }
|
||||
};
|
||||
|
||||
typeDictionary = new Dictionary<string, Type>
|
||||
{
|
||||
{ "Door", typeof (Door) },
|
||||
{ "Quantum Hatchway", typeof (Door) },
|
||||
{ "Alloy Smelter", typeof (AlloySmelter) },
|
||||
{ "Auger", typeof (Auger) },
|
||||
{ "Auto Crafter", typeof (AutoCrafter) },
|
||||
{ "Dark Matter Collector", typeof (DarkMatterCollector) },
|
||||
{ "Dark Matter Conduit", typeof (DarkMatterConduit) },
|
||||
{ "Electric Light", typeof (ElectricLight) },
|
||||
{ "Extruder", typeof (Extruder) },
|
||||
{ "Gear Cutter", typeof (GearCutter) },
|
||||
{ "Generator", typeof (PowerSource) },
|
||||
{ "Heat Exchanger", typeof (HeatExchanger) },
|
||||
{ "Nuclear Reactor", typeof (NuclearReactor) },
|
||||
{ "Power Conduit", typeof (PowerConduit) },
|
||||
{ "Press", typeof (Press) },
|
||||
{ "Rail Cart", typeof (RailCart) },
|
||||
{ "Rail Cart Hub", typeof (RailCartHub) },
|
||||
{ "Reactor Turbine", typeof (PowerSource) },
|
||||
{ "Retriever", typeof (Retriever) },
|
||||
{ "Smelter", typeof (Smelter) },
|
||||
{ "Solar Panel", typeof (PowerSource) },
|
||||
{ "Storage Computer", typeof (StorageComputer) },
|
||||
{ "Storage Container", typeof (InventoryManager) },
|
||||
{ "Turret", typeof (Turret) },
|
||||
{ "Universal Conduit", typeof (UniversalConduit) },
|
||||
{ "Universal Extractor", typeof (UniversalExtractor) },
|
||||
{ "Brick", typeof (Brick) },
|
||||
{ "Glass Block", typeof (Glass) },
|
||||
{ "Iron Block", typeof (IronBlock) },
|
||||
{ "Iron Ramp", typeof (IronBlock) },
|
||||
{ "Steel Block", typeof (Steel) },
|
||||
{ "Steel Ramp", typeof (Steel) }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,16 @@ public class BlockInteraction
|
||||
}
|
||||
}
|
||||
|
||||
//! Called once per frame when the player is looking at an iron block.
|
||||
public void InteractWithModBlock(string blockName)
|
||||
{
|
||||
playerController.machineGUIopen = false;
|
||||
if (cInput.GetKeyDown("Collect Object"))
|
||||
{
|
||||
interactionController.CollectObject(blockName);
|
||||
}
|
||||
}
|
||||
|
||||
//! Called once per frame when the player is looking at a combined mesh object.
|
||||
public void InteractWithCombinedMesh()
|
||||
{
|
||||
@ -104,19 +114,19 @@ public class BlockInteraction
|
||||
playerController.paintGun.GetComponent<AudioSource>().Play();
|
||||
if (playerController.objectInSight.name.Equals("glassHolder(Clone)"))
|
||||
{
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.glass, "glassHolder"));
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.glassHolders, "glassHolder"));
|
||||
}
|
||||
if (playerController.objectInSight.name.Equals("brickHolder(Clone)"))
|
||||
{
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.bricks, "brickHolder"));
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.brickHolders, "brickHolder"));
|
||||
}
|
||||
if (playerController.objectInSight.name.Equals("ironHolder(Clone)"))
|
||||
{
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.ironBlocks, "ironHolder"));
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.ironHolders, "ironHolder"));
|
||||
}
|
||||
if (playerController.objectInSight.name.Equals("steelHolder(Clone)"))
|
||||
{
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.steel, "steelHolder"));
|
||||
interactionController.paintingCoroutine = interactionController.StartCoroutine(PaintMesh(playerController.gameManager.steelHolders, "steelHolder"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +140,7 @@ public class BlockInteraction
|
||||
foreach (GameObject holder in holders)
|
||||
{
|
||||
holder.GetComponent<Renderer>().material.color = color;
|
||||
FileBasedPrefs.SetBool(playerController.stateManager.WorldName + name + holder.GetComponent<MeshPainter>().ID + "painted", true);
|
||||
FileBasedPrefs.SetBool(playerController.stateManager.worldName + name + holder.GetComponent<MeshPainter>().ID + "painted", true);
|
||||
yield return null;
|
||||
}
|
||||
int interval = 0;
|
||||
|
@ -16,6 +16,7 @@
|
||||
"Iron Ramp",
|
||||
"Steel Block",
|
||||
"Steel Ramp",
|
||||
"Door",
|
||||
"Quantum Hatchway",
|
||||
"Storage Container",
|
||||
"Storage Computer",
|
||||
@ -53,8 +54,6 @@
|
||||
playerController.nextBuildType = selection == objectNames.Length - 1 ? objectNames[0] : objectNames[selection + 1];
|
||||
playerController.displayingBuildItem = true;
|
||||
playerController.buildItemDisplayTimer = 0;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
|
||||
|
3
Brick.cs
3
Brick.cs
@ -18,6 +18,9 @@ public class Brick : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using System.Net;
|
||||
|
||||
public class BuildController : MonoBehaviour
|
||||
{
|
||||
@ -9,6 +10,8 @@ public class BuildController : MonoBehaviour
|
||||
private LineRenderer dirLine;
|
||||
public Material lineMat;
|
||||
public GameObject builtObjects;
|
||||
public AudioClip singleBuildClip;
|
||||
public AudioClip multiBuildClip;
|
||||
public bool autoAxis;
|
||||
private Coroutine buildBlockCoroutine;
|
||||
|
||||
@ -18,7 +21,7 @@ public class BuildController : MonoBehaviour
|
||||
playerController = GetComponent<PlayerController>();
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
blockDictionary = new BlockDictionary(playerController);
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine
|
||||
@ -28,25 +31,6 @@ public class BuildController : MonoBehaviour
|
||||
{
|
||||
if (playerController.building == true)
|
||||
{
|
||||
playerController.buildTimer += 1 * Time.deltaTime;
|
||||
if (playerController.buildTimer >= 30)
|
||||
{
|
||||
if (GameObject.Find("GameManager").GetComponent<GameManager>().working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerController.separatedBlocks == false)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
@ -63,7 +47,7 @@ public class BuildController : MonoBehaviour
|
||||
else
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, playerController.buildStartPosition);
|
||||
if (distance > gameManager.chunkSize - 40)
|
||||
if (distance > gameManager.chunkSize * 0.75f)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
{
|
||||
@ -88,7 +72,7 @@ public class BuildController : MonoBehaviour
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, playerController.buildObject.transform.position);
|
||||
Material buildObjectMaterial = playerController.buildObject.GetComponent<MeshRenderer>().material;
|
||||
buildObjectMaterial.color = distance > gameManager.chunkSize - 40 ? Color.red : Color.white;
|
||||
buildObjectMaterial.color = distance > gameManager.chunkSize * 0.75f ? Color.red : Color.white;
|
||||
if (hit.transform.gameObject.tag == "Built")
|
||||
{
|
||||
if (autoAxis == true)
|
||||
@ -106,7 +90,7 @@ public class BuildController : MonoBehaviour
|
||||
SetupFreePlacement(hit);
|
||||
}
|
||||
}
|
||||
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out RaycastHit buildHit, gameManager.chunkSize - 40))
|
||||
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out RaycastHit buildHit, gameManager.chunkSize * 0.75f))
|
||||
{
|
||||
if (buildHit.collider.gameObject.tag != "CombinedMesh")
|
||||
{
|
||||
@ -130,6 +114,10 @@ public class BuildController : MonoBehaviour
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(buildHit.point, "all", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedChunkLoad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,9 +192,6 @@ public class BuildController : MonoBehaviour
|
||||
if (znDif > xnDif && znDif > ynDif)
|
||||
playerController.cubeloc = "back";
|
||||
}
|
||||
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
}
|
||||
|
||||
//! Changes the axis along which blocks will be placed.
|
||||
@ -236,9 +221,6 @@ public class BuildController : MonoBehaviour
|
||||
{
|
||||
playerController.cubeloc = "up";
|
||||
}
|
||||
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
}
|
||||
|
||||
//! Implements the current build axis.
|
||||
@ -300,6 +282,7 @@ public class BuildController : MonoBehaviour
|
||||
private void BuildMachine(string type, RaycastHit hit)
|
||||
{
|
||||
bool foundItems = false;
|
||||
gameManager.undoBlocks.Clear();
|
||||
foreach (InventorySlot slot in playerController.playerInventory.inventory)
|
||||
{
|
||||
if (foundItems == false)
|
||||
@ -348,10 +331,14 @@ public class BuildController : MonoBehaviour
|
||||
{
|
||||
obj.GetComponent<ModMachine>().machineName = type;
|
||||
}
|
||||
gameManager.undoBlocks.Add(new GameManager.Block(type, obj));
|
||||
slot.amountInSlot -= 1;
|
||||
playerController.builderSound.clip = singleBuildClip;
|
||||
playerController.builderSound.Play();
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
UpdateNetwork(0,type,pos, obj.transform.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slot.amountInSlot == 0)
|
||||
@ -363,25 +350,25 @@ public class BuildController : MonoBehaviour
|
||||
}
|
||||
if (foundItems == false)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
playerController.PlayMissingItemsSound();
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends instantiated block info to the server in multiplayer games.
|
||||
private void UpdateNetwork(int destroy, string type, Vector3 pos, Quaternion rot)
|
||||
{
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(PlayerPrefs.GetString("serverURL") + "/blocks");
|
||||
string position = Mathf.Round(pos.x) + "," + Mathf.Round(pos.y) + "," + Mathf.Round(pos.z);
|
||||
string rotation = Mathf.Round(rot.x) + "," + Mathf.Round(rot.y) + "," + Mathf.Round(rot.z) + "," + Mathf.Round(rot.w);
|
||||
client.UploadStringAsync(uri, "POST", "@" + destroy + ":" + type + ":" + position + ":" + rotation);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildBlock(string type)
|
||||
{
|
||||
gameManager.undoBlocks.Clear();
|
||||
buildBlockCoroutine = StartCoroutine(BuildBlockCoroutine(type));
|
||||
}
|
||||
|
||||
@ -432,10 +419,18 @@ public class BuildController : MonoBehaviour
|
||||
}
|
||||
h += 5;
|
||||
GameObject obj = Instantiate(blockDictionary.blockDictionary[type], multiBuildPlacement, rotation);
|
||||
if (obj.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
obj.GetComponent<ModBlock>().blockName = type;
|
||||
}
|
||||
obj.transform.parent = builtObjects.transform;
|
||||
gameManager.undoBlocks.Add(new GameManager.Block(type, obj));
|
||||
playerController.builderSound.clip = playerController.buildMultiplier > 1 ? multiBuildClip : singleBuildClip;
|
||||
playerController.builderSound.Play();
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
UpdateNetwork(0, type, obj.transform.position, obj.transform.rotation);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
@ -448,20 +443,7 @@ public class BuildController : MonoBehaviour
|
||||
}
|
||||
if (foundItems == false)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
playerController.PlayMissingItemsSound();
|
||||
}
|
||||
}
|
||||
}
|
124
ChatGUI.cs
Normal file
124
ChatGUI.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ChatGUI : MonoBehaviour
|
||||
{
|
||||
public string messages;
|
||||
private string inputMsg = "";
|
||||
public GUISkin ChatGUIskin;
|
||||
private bool playersVisible = false;
|
||||
private PlayerController playerController;
|
||||
private NetworkController networkController;
|
||||
private Coroutine chatDataCoroutine;
|
||||
private string playersOnline;
|
||||
private int playerCount;
|
||||
private float chatNetTimer;
|
||||
Vector2 scrollPosition;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
playerController = GetComponent<PlayerController>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == false || playerController.stateManager.worldLoaded == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (networkController != null)
|
||||
{
|
||||
chatNetTimer += 1 * Time.deltaTime;
|
||||
if (chatNetTimer >= Random.Range(0.75f, 1.0f))
|
||||
{
|
||||
chatDataCoroutine = StartCoroutine(networkController.networkReceive.ReceiveChatData());
|
||||
chatNetTimer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
networkController = playerController.networkController;
|
||||
}
|
||||
}
|
||||
|
||||
//! Called by unity engine for rendering and handling GUI events.
|
||||
public void OnGUI()
|
||||
{
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == false || playerController.stateManager.worldLoaded == false || playerController.GuiOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GUI.skin = ChatGUIskin;
|
||||
|
||||
int ScreenHeight = Screen.height;
|
||||
int ScreenWidth = Screen.width;
|
||||
|
||||
Rect textFieldRect = new Rect(0, (ScreenHeight * 0.80f), (ScreenWidth * 0.15f), (ScreenHeight * 0.03f));
|
||||
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition,false,false, GUILayout.Width(ScreenWidth * 0.4f), GUILayout.Height(ScreenHeight * 0.65f));
|
||||
GUILayout.Label(messages);
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
GUI.SetNextControlName ("textfield");
|
||||
inputMsg = GUI.TextField (textFieldRect, inputMsg, 300);
|
||||
|
||||
if (GUI.GetNameOfFocusedControl() != "textfield")
|
||||
{
|
||||
GUI.color = new Color(0.2824f, 0.7882f, 0.9569f);
|
||||
GUI.Label(textFieldRect, " Press backspace to chat.");
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
Event ev = Event.current;
|
||||
if (ev.keyCode == KeyCode.Backspace)
|
||||
{
|
||||
GUI.FocusControl ("textfield");
|
||||
}
|
||||
|
||||
Event e = Event.current;
|
||||
if (e.keyCode == KeyCode.Return)
|
||||
{
|
||||
if (inputMsg != "")
|
||||
{
|
||||
if (inputMsg == "/list" || inputMsg == "/players")
|
||||
{
|
||||
NetworkPlayer[] allPlayers = FindObjectsOfType<NetworkPlayer>();
|
||||
playerCount = allPlayers.Length + 1;
|
||||
List<string> nameList = new List<string>();
|
||||
nameList.Add(PlayerPrefs.GetString("UserName"));
|
||||
foreach (NetworkPlayer player in allPlayers)
|
||||
{
|
||||
nameList.Add(player.gameObject.name);
|
||||
}
|
||||
playersOnline = string.Join("\n", nameList.ToArray());
|
||||
playersVisible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
networkController.networkSend.SendChatMessage(inputMsg);
|
||||
}
|
||||
inputMsg = "";
|
||||
}
|
||||
GUIUtility.keyboardControl = 0;
|
||||
}
|
||||
|
||||
if (playersVisible == true)
|
||||
{
|
||||
messages += "\n\n"+playerCount+" players online.";
|
||||
messages += "\n"+playersOnline+"\n\n";
|
||||
playersVisible = false;
|
||||
}
|
||||
|
||||
if (messages.Length >= 500)
|
||||
{
|
||||
messages = "";
|
||||
}
|
||||
|
||||
scrollPosition.y += 1000;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public class CombinedMeshManager
|
||||
private bool steelMeshRequired;
|
||||
private bool glassMeshRequired;
|
||||
private bool brickMeshRequired;
|
||||
private bool modMeshRequired;
|
||||
|
||||
//! The Combined Mesh Manager handles all combined meshes for building blocks.
|
||||
//! All standard building blocks are stored in combined meshes after being placed.
|
||||
@ -35,9 +36,9 @@ public class CombinedMeshManager
|
||||
}
|
||||
|
||||
//! Spawns a combined mesh identical to the one being rebuilt, so it is not invisible during the process.
|
||||
private void SpawnDummy(GameObject realObject, GameObject dummyObject, GameObject toSpawn, string name)
|
||||
private void SpawnDummy(GameObject realObject, GameObject toSpawn, string name)
|
||||
{
|
||||
dummyObject = Object.Instantiate(toSpawn, gameManager.transform.position, gameManager.transform.rotation);
|
||||
GameObject dummyObject = Object.Instantiate(toSpawn, gameManager.transform.position, gameManager.transform.rotation);
|
||||
dummyObject.transform.parent = gameManager.builtObjects.transform;
|
||||
dummyObject.AddComponent<HolderDummy>();
|
||||
dummyObject.name = name;
|
||||
@ -49,6 +50,8 @@ public class CombinedMeshManager
|
||||
{
|
||||
dummyObject.GetComponent<MeshFilter>().mesh = realObject.GetComponent<MeshFilter>().mesh;
|
||||
}
|
||||
dummyObject.GetComponent<Renderer>().material = realObject.GetComponent<Renderer>().material;
|
||||
dummyObject.GetComponent<Renderer>().material.mainTexture = realObject.GetComponent<Renderer>().material.mainTexture;
|
||||
dummyObject.GetComponent<Renderer>().material.color = realObject.GetComponent<Renderer>().material.color;
|
||||
Object.Destroy(realObject.GetComponent<MeshFilter>());
|
||||
}
|
||||
@ -65,17 +68,18 @@ public class CombinedMeshManager
|
||||
int totalBrick = 0;
|
||||
int totalGlass = 0;
|
||||
int totalSteel = 0;
|
||||
int totalModBlocks = 0;
|
||||
|
||||
int ironSeprationInterval = 0;
|
||||
for (int i = 0; i < gameManager.ironBlocks.Length; i++)
|
||||
for (int i = 0; i < gameManager.ironHolders.Length; i++)
|
||||
{
|
||||
Transform[] blocks = gameManager.ironBlocks[i].GetComponentsInChildren<Transform>(true);
|
||||
Transform[] blocks = gameManager.ironHolders[i].GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform ironBlock in blocks)
|
||||
{
|
||||
if (ironBlock != null)
|
||||
{
|
||||
float distance = Vector3.Distance(ironBlock.position, target);
|
||||
if (distance < gameManager.chunkSize - 20 && type.Equals("all"))
|
||||
if (distance < gameManager.chunkSize && type.Equals("all"))
|
||||
{
|
||||
ironBlock.gameObject.SetActive(true);
|
||||
ironBlock.parent = gameManager.builtObjects.transform;
|
||||
@ -103,15 +107,15 @@ public class CombinedMeshManager
|
||||
}
|
||||
|
||||
int glassSeprationInterval = 0;
|
||||
for (int i = 0; i < gameManager.glass.Length; i++)
|
||||
for (int i = 0; i < gameManager.glassHolders.Length; i++)
|
||||
{
|
||||
Transform[] glassBlocks = gameManager.glass[i].GetComponentsInChildren<Transform>(true);
|
||||
Transform[] glassBlocks = gameManager.glassHolders[i].GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform glassBlock in glassBlocks)
|
||||
{
|
||||
if (glassBlock != null)
|
||||
{
|
||||
float distance = Vector3.Distance(glassBlock.position, target);
|
||||
if (distance < gameManager.chunkSize - 20 && type.Equals("all"))
|
||||
if (distance < gameManager.chunkSize && type.Equals("all"))
|
||||
{
|
||||
glassBlock.gameObject.SetActive(true);
|
||||
glassBlock.parent = gameManager.builtObjects.transform;
|
||||
@ -139,15 +143,15 @@ public class CombinedMeshManager
|
||||
}
|
||||
|
||||
int steelSeprationInterval = 0;
|
||||
for (int i = 0; i < gameManager.steel.Length; i++)
|
||||
for (int i = 0; i < gameManager.steelHolders.Length; i++)
|
||||
{
|
||||
Transform[] steelBlocks = gameManager.steel[i].GetComponentsInChildren<Transform>(true);
|
||||
Transform[] steelBlocks = gameManager.steelHolders[i].GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform steelBlock in steelBlocks)
|
||||
{
|
||||
if (steelBlock != null)
|
||||
{
|
||||
float distance = Vector3.Distance(steelBlock.position, target);
|
||||
if (distance < gameManager.chunkSize - 20 && type.Equals("all"))
|
||||
if (distance < gameManager.chunkSize && type.Equals("all"))
|
||||
{
|
||||
steelBlock.gameObject.SetActive(true);
|
||||
steelBlock.parent = gameManager.builtObjects.transform;
|
||||
@ -175,15 +179,15 @@ public class CombinedMeshManager
|
||||
}
|
||||
|
||||
int brickSeprationInterval = 0;
|
||||
for (int i = 0; i < gameManager.bricks.Length; i++)
|
||||
for (int i = 0; i < gameManager.brickHolders.Length; i++)
|
||||
{
|
||||
Transform[] brickBlocks = gameManager.bricks[i].GetComponentsInChildren<Transform>(true);
|
||||
Transform[] brickBlocks = gameManager.brickHolders[i].GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform brickBlock in brickBlocks)
|
||||
{
|
||||
if (brickBlock != null)
|
||||
{
|
||||
float distance = Vector3.Distance(brickBlock.position, target);
|
||||
if (distance < gameManager.chunkSize - 20 && type.Equals("all"))
|
||||
if (distance < gameManager.chunkSize && type.Equals("all"))
|
||||
{
|
||||
brickBlock.gameObject.SetActive(true);
|
||||
brickBlock.parent = gameManager.builtObjects.transform;
|
||||
@ -210,14 +214,55 @@ public class CombinedMeshManager
|
||||
}
|
||||
}
|
||||
|
||||
int modBlockIndex = 0;
|
||||
foreach (string blockName in gameManager.modBlockNames)
|
||||
{
|
||||
int modBlockSeparationInterval = 0;
|
||||
GameObject[] currentBlockType = gameManager.modBlockHolders[modBlockIndex];
|
||||
for (int i = 0; i < currentBlockType.Length; i++)
|
||||
{
|
||||
Transform[] modBlocks = currentBlockType[i].GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform modBlock in modBlocks)
|
||||
{
|
||||
if (modBlock != null)
|
||||
{
|
||||
float distance = Vector3.Distance(modBlock.position, target);
|
||||
if (distance < gameManager.chunkSize && type.Equals("all"))
|
||||
{
|
||||
modBlock.gameObject.SetActive(true);
|
||||
modBlock.parent = gameManager.builtObjects.transform;
|
||||
totalModBlocks++;
|
||||
}
|
||||
if (distance < 20 && type.Equals(blockName))
|
||||
{
|
||||
modBlock.gameObject.SetActive(true);
|
||||
modBlock.parent = gameManager.builtObjects.transform;
|
||||
totalModBlocks++;
|
||||
}
|
||||
if (distance < 10 && type.Equals(blockName))
|
||||
{
|
||||
modBlock.gameObject.GetComponent<PhysicsHandler>().Explode();
|
||||
totalModBlocks++;
|
||||
}
|
||||
}
|
||||
modBlockSeparationInterval++;
|
||||
if (modBlockSeparationInterval >= 250)
|
||||
{
|
||||
yield return null;
|
||||
modBlockSeparationInterval = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
modBlockIndex++;
|
||||
}
|
||||
|
||||
if (totalIron > 0)
|
||||
{
|
||||
int ironDummyInterval = 0;
|
||||
for (int i = 0; i < gameManager.ironBlocks.Length; i++)
|
||||
for (int i = 0; i < gameManager.ironHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.ironBlocks[i];
|
||||
GameObject dummyObject = gameManager.ironBlocksDummy[i];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.ironHolder, "Iron Dummy");
|
||||
GameObject realObject = gameManager.ironHolders[i];
|
||||
SpawnDummy(realObject, gameManager.ironHolder, "Iron Dummy");
|
||||
ironDummyInterval++;
|
||||
if (ironDummyInterval >= 10)
|
||||
{
|
||||
@ -231,11 +276,10 @@ public class CombinedMeshManager
|
||||
if (totalGlass > 0)
|
||||
{
|
||||
int glassDummyInterval = 0;
|
||||
for (int i = 0; i < gameManager.glass.Length; i++)
|
||||
for (int i = 0; i < gameManager.glassHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.glass[i];
|
||||
GameObject dummyObject = gameManager.glassDummy[i];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.glassHolder, "Glass Dummy");
|
||||
GameObject realObject = gameManager.glassHolders[i];
|
||||
SpawnDummy(realObject, gameManager.glassHolder, "Glass Dummy");
|
||||
glassDummyInterval++;
|
||||
if (glassDummyInterval >= 10)
|
||||
{
|
||||
@ -249,11 +293,10 @@ public class CombinedMeshManager
|
||||
if (totalSteel > 0)
|
||||
{
|
||||
int steelDummyInterval = 0;
|
||||
for (int i = 0; i < gameManager.steel.Length; i++)
|
||||
for (int i = 0; i < gameManager.steelHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.steel[i];
|
||||
GameObject dummyObject = gameManager.steelDummy[i];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.steelHolder, "Steel Dummy");
|
||||
GameObject realObject = gameManager.steelHolders[i];
|
||||
SpawnDummy(realObject, gameManager.steelHolder, "Steel Dummy");
|
||||
steelDummyInterval++;
|
||||
if (steelDummyInterval >= 10)
|
||||
{
|
||||
@ -267,11 +310,10 @@ public class CombinedMeshManager
|
||||
if (totalBrick > 0)
|
||||
{
|
||||
int brickDummyInterval = 0;
|
||||
for (int i = 0; i < gameManager.bricks.Length; i++)
|
||||
for (int i = 0; i < gameManager.brickHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.bricks[i];
|
||||
GameObject dummyObject = gameManager.bricksDummy[i];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.brickHolder, "Brick Dummy");
|
||||
GameObject realObject = gameManager.brickHolders[i];
|
||||
SpawnDummy(realObject, gameManager.brickHolder, "Brick Dummy");
|
||||
brickDummyInterval++;
|
||||
if (brickDummyInterval >= 10)
|
||||
{
|
||||
@ -282,6 +324,29 @@ public class CombinedMeshManager
|
||||
brickMeshRequired = true;
|
||||
}
|
||||
|
||||
if (totalModBlocks > 0)
|
||||
{
|
||||
modBlockIndex = 0;
|
||||
foreach (string blockName in gameManager.modBlockNames)
|
||||
{
|
||||
int modBlockInterval = 0;
|
||||
GameObject[] currentBlockType = gameManager.modBlockHolders[modBlockIndex];
|
||||
for (int i = 0; i < currentBlockType.Length; i++)
|
||||
{
|
||||
GameObject realObject = currentBlockType[i];
|
||||
SpawnDummy(realObject, gameManager.modBlockHolder, blockName + " Dummy");
|
||||
modBlockInterval++;
|
||||
if (modBlockInterval >= 10)
|
||||
{
|
||||
yield return null;
|
||||
modBlockInterval = 0;
|
||||
}
|
||||
}
|
||||
modBlockIndex++;
|
||||
}
|
||||
modMeshRequired = true;
|
||||
}
|
||||
|
||||
if (CombinedMeshRequired() == true)
|
||||
{
|
||||
gameManager.replacingMeshFilters = true;
|
||||
@ -298,7 +363,7 @@ public class CombinedMeshManager
|
||||
//! Returns true if any combined mesh needs to be created or rebuilt.
|
||||
private bool CombinedMeshRequired()
|
||||
{
|
||||
return ironMeshRequired == true || glassMeshRequired == true || brickMeshRequired == true || steelMeshRequired == true;
|
||||
return ironMeshRequired == true || glassMeshRequired == true || brickMeshRequired == true || steelMeshRequired == true || modMeshRequired == true;
|
||||
}
|
||||
|
||||
//! Starts the coroutine to combine all blocks into combined meshes.
|
||||
@ -307,6 +372,31 @@ public class CombinedMeshManager
|
||||
gameManager.blockCombineCoroutine = gameManager.StartCoroutine(BlockCombineCoroutine());
|
||||
}
|
||||
|
||||
//! Sets up the material for mod block meshes.
|
||||
public void SetMaterial(GameObject obj, string blockType)
|
||||
{
|
||||
TextureDictionary textureDictionary = GameObject.Find("Player").GetComponent<TextureDictionary>();
|
||||
if (textureDictionary.dictionary.ContainsKey(blockType))
|
||||
{
|
||||
if (blockType.ToUpper().Contains("GLASS"))
|
||||
{
|
||||
obj.GetComponent<Renderer>().material = gameManager.glassMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
Material mat = new Material(Shader.Find("Standard"));
|
||||
mat.mainTexture = textureDictionary.dictionary[blockType];
|
||||
if (textureDictionary.dictionary.ContainsKey(blockType + "_Normal"))
|
||||
{
|
||||
mat.shaderKeywords = new string[] { "_NORMALMAP" };
|
||||
mat.SetTexture("_BumpMap", textureDictionary.dictionary[blockType + "_Normal"]);
|
||||
mat.SetFloat("_BumpScale", 2);
|
||||
}
|
||||
obj.GetComponent<Renderer>().material = mat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Creates combined meshes from placed building blocks.
|
||||
public IEnumerator BlockCombineCoroutine()
|
||||
{
|
||||
@ -317,44 +407,43 @@ public class CombinedMeshManager
|
||||
|
||||
gameManager.working = true;
|
||||
int combineInterval = 0;
|
||||
int ironCount = 0;
|
||||
int steelCount = 0;
|
||||
int glassCount = 0;
|
||||
int brickCount = 0;
|
||||
int ironHolderCount = 0;
|
||||
int steelHolderCount = 0;
|
||||
int glassHolderCount = 0;
|
||||
int brickHolderCount = 0;
|
||||
int modHolderCount = 0;
|
||||
int ironBlockCount = 0;
|
||||
int steelBlockCount = 0;
|
||||
int glassBlockCount = 0;
|
||||
int brickBlockCount = 0;
|
||||
int modBlockCount = 0;
|
||||
|
||||
IronBlock[] allIronBlocks = Object.FindObjectsOfType<IronBlock>();
|
||||
foreach (IronBlock block in allIronBlocks)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
Transform[] blocks = gameManager.ironBlocks[ironCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (ironCount == gameManager.ironBlocks.Length - 1)
|
||||
{
|
||||
List<GameObject> ironList = gameManager.ironBlocks.ToList();
|
||||
GameObject ironHolder = Object.Instantiate(gameManager.ironHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
ironHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
ironHolder.GetComponent<MeshPainter>().ID = ironCount + 1;
|
||||
ironHolder.SetActive(false);
|
||||
ironList.Add(ironHolder);
|
||||
gameManager.ironBlocks = ironList.ToArray();
|
||||
List<GameObject> ironDummyList = gameManager.ironBlocksDummy.ToList();
|
||||
GameObject newDummy = new GameObject();
|
||||
ironDummyList.Add(newDummy);
|
||||
gameManager.ironBlocksDummy = ironDummyList.ToArray();
|
||||
}
|
||||
ironCount++;
|
||||
}
|
||||
if (block.GetComponent<PhysicsHandler>().IsSupported())
|
||||
{
|
||||
block.transform.parent = gameManager.ironBlocks[ironCount].transform;
|
||||
block.transform.parent = gameManager.ironHolders[ironHolderCount].transform;
|
||||
ironBlockCount++;
|
||||
}
|
||||
|
||||
Transform[] blocks = gameManager.ironHolders[ironHolderCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (ironHolderCount == gameManager.ironHolders.Length - 1)
|
||||
{
|
||||
List<GameObject> ironList = gameManager.ironHolders.ToList();
|
||||
GameObject ironHolder = Object.Instantiate(gameManager.ironHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
ironHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
ironHolder.GetComponent<MeshPainter>().ID = ironHolderCount + 1;
|
||||
ironHolder.SetActive(false);
|
||||
ironList.Add(ironHolder);
|
||||
gameManager.ironHolders = ironList.ToArray();
|
||||
}
|
||||
ironHolderCount++;
|
||||
}
|
||||
}
|
||||
combineInterval++;
|
||||
if (combineInterval >= 250)
|
||||
@ -369,30 +458,27 @@ public class CombinedMeshManager
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
Transform[] blocks = gameManager.glass[glassCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (glassCount == gameManager.glass.Length - 1)
|
||||
{
|
||||
List<GameObject> glassList = gameManager.glass.ToList();
|
||||
GameObject glassHolder = Object.Instantiate(gameManager.glassHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
glassHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
glassHolder.GetComponent<MeshPainter>().ID = glassCount + 1;
|
||||
glassHolder.SetActive(false);
|
||||
glassList.Add(glassHolder);
|
||||
gameManager.glass = glassList.ToArray();
|
||||
List<GameObject> glassDummyList = gameManager.glassDummy.ToList();
|
||||
GameObject newDummy = new GameObject();
|
||||
glassDummyList.Add(newDummy);
|
||||
gameManager.glassDummy = glassDummyList.ToArray();
|
||||
}
|
||||
glassCount++;
|
||||
}
|
||||
if (block.GetComponent<PhysicsHandler>().IsSupported())
|
||||
{
|
||||
block.transform.parent = gameManager.glass[glassCount].transform;
|
||||
block.transform.parent = gameManager.glassHolders[glassHolderCount].transform;
|
||||
glassBlockCount++;
|
||||
}
|
||||
|
||||
Transform[] blocks = gameManager.glassHolders[glassHolderCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (glassHolderCount == gameManager.glassHolders.Length - 1)
|
||||
{
|
||||
List<GameObject> glassList = gameManager.glassHolders.ToList();
|
||||
GameObject glassHolder = Object.Instantiate(gameManager.glassHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
glassHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
glassHolder.GetComponent<MeshPainter>().ID = glassHolderCount + 1;
|
||||
glassHolder.SetActive(false);
|
||||
glassList.Add(glassHolder);
|
||||
gameManager.glassHolders = glassList.ToArray();
|
||||
}
|
||||
glassHolderCount++;
|
||||
}
|
||||
}
|
||||
combineInterval++;
|
||||
if (combineInterval >= 250)
|
||||
@ -407,30 +493,27 @@ public class CombinedMeshManager
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
Transform[] blocks = gameManager.steel[steelCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (steelCount == gameManager.steel.Length - 1)
|
||||
{
|
||||
List<GameObject> steelList = gameManager.steel.ToList();
|
||||
GameObject steelHolder = Object.Instantiate(gameManager.steelHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
steelHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
steelHolder.GetComponent<MeshPainter>().ID = steelCount + 1;
|
||||
steelHolder.SetActive(false);
|
||||
steelList.Add(steelHolder);
|
||||
gameManager.steel = steelList.ToArray();
|
||||
List<GameObject> steelDummyList = gameManager.steelDummy.ToList();
|
||||
GameObject newDummy = new GameObject();
|
||||
steelDummyList.Add(newDummy);
|
||||
gameManager.steelDummy = steelDummyList.ToArray();
|
||||
}
|
||||
steelCount++;
|
||||
}
|
||||
if (block.GetComponent<PhysicsHandler>().IsSupported())
|
||||
{
|
||||
block.transform.parent = gameManager.steel[steelCount].transform;
|
||||
block.transform.parent = gameManager.steelHolders[steelHolderCount].transform;
|
||||
steelBlockCount++;
|
||||
}
|
||||
|
||||
Transform[] blocks = gameManager.steelHolders[steelHolderCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (steelHolderCount == gameManager.steelHolders.Length - 1)
|
||||
{
|
||||
List<GameObject> steelList = gameManager.steelHolders.ToList();
|
||||
GameObject steelHolder = Object.Instantiate(gameManager.steelHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
steelHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
steelHolder.GetComponent<MeshPainter>().ID = steelHolderCount + 1;
|
||||
steelHolder.SetActive(false);
|
||||
steelList.Add(steelHolder);
|
||||
gameManager.steelHolders = steelList.ToArray();
|
||||
}
|
||||
steelHolderCount++;
|
||||
}
|
||||
}
|
||||
combineInterval++;
|
||||
if (combineInterval >= 250)
|
||||
@ -445,30 +528,27 @@ public class CombinedMeshManager
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
Transform[] blocks = gameManager.bricks[brickCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (brickCount == gameManager.bricks.Length - 1)
|
||||
{
|
||||
List<GameObject> brickList = gameManager.bricks.ToList();
|
||||
GameObject brickHolder = Object.Instantiate(gameManager.brickHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
brickHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
brickHolder.GetComponent<MeshPainter>().ID = brickCount + 1;
|
||||
brickHolder.SetActive(false);
|
||||
brickList.Add(brickHolder);
|
||||
gameManager.bricks = brickList.ToArray();
|
||||
List<GameObject> bricksDummyList = gameManager.bricksDummy.ToList();
|
||||
GameObject newDummy = new GameObject();
|
||||
bricksDummyList.Add(newDummy);
|
||||
gameManager.bricksDummy = bricksDummyList.ToArray();
|
||||
}
|
||||
brickCount++;
|
||||
}
|
||||
if (block.GetComponent<PhysicsHandler>().IsSupported())
|
||||
{
|
||||
block.transform.parent = gameManager.bricks[brickCount].transform;
|
||||
block.transform.parent = gameManager.brickHolders[brickHolderCount].transform;
|
||||
brickBlockCount++;
|
||||
}
|
||||
|
||||
Transform[] blocks = gameManager.brickHolders[brickHolderCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (brickHolderCount == gameManager.brickHolders.Length - 1)
|
||||
{
|
||||
List<GameObject> brickList = gameManager.brickHolders.ToList();
|
||||
GameObject brickHolder = Object.Instantiate(gameManager.brickHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
brickHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
brickHolder.GetComponent<MeshPainter>().ID = brickHolderCount + 1;
|
||||
brickHolder.SetActive(false);
|
||||
brickList.Add(brickHolder);
|
||||
gameManager.brickHolders = brickList.ToArray();
|
||||
}
|
||||
brickHolderCount++;
|
||||
}
|
||||
}
|
||||
combineInterval++;
|
||||
if (combineInterval >= 250)
|
||||
@ -478,15 +558,59 @@ public class CombinedMeshManager
|
||||
}
|
||||
}
|
||||
|
||||
int modBlockIndex = 0;
|
||||
foreach (string blockType in gameManager.modBlockNames)
|
||||
{
|
||||
ModBlock[] allModBlocks = Object.FindObjectsOfType<ModBlock>();
|
||||
foreach (ModBlock block in allModBlocks)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
if (block.blockName == blockType)
|
||||
{
|
||||
GameObject[] currentBlockType = gameManager.modBlockHolders[modBlockIndex];
|
||||
if (block.GetComponent<PhysicsHandler>().IsSupported())
|
||||
{
|
||||
block.transform.parent = currentBlockType[modHolderCount].transform;
|
||||
modBlockCount++;
|
||||
}
|
||||
|
||||
Transform[] blocks = currentBlockType[modHolderCount].GetComponentsInChildren<Transform>(true);
|
||||
if (blocks.Length >= 500)
|
||||
{
|
||||
if (modHolderCount == currentBlockType.Length - 1)
|
||||
{
|
||||
List<GameObject> modBlockList = currentBlockType.ToList();
|
||||
GameObject modBlockHolder = Object.Instantiate(gameManager.modBlockHolder, gameManager.transform.position, gameManager.transform.rotation);
|
||||
modBlockHolder.transform.parent = gameManager.builtObjects.transform;
|
||||
SetMaterial(modBlockHolder, blockType);
|
||||
modBlockHolder.SetActive(false);
|
||||
modBlockList.Add(modBlockHolder);
|
||||
gameManager.modBlockHolders[modBlockIndex] = modBlockList.ToArray();
|
||||
}
|
||||
modHolderCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
combineInterval++;
|
||||
if (combineInterval >= 250)
|
||||
{
|
||||
combineInterval = 0;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
modHolderCount = 0;
|
||||
modBlockIndex++;
|
||||
}
|
||||
|
||||
combineInterval = 0;
|
||||
|
||||
if (ironBlockCount > 0)
|
||||
{
|
||||
for (int i = 0; i < gameManager.ironBlocks.Length; i++)
|
||||
for (int i = 0; i < gameManager.ironHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.ironBlocks[ironCount];
|
||||
GameObject dummyObject = gameManager.ironBlocksDummy[ironCount];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.ironHolder, "Iron Dummy");
|
||||
GameObject realObject = gameManager.ironHolders[i];
|
||||
SpawnDummy(realObject, gameManager.ironHolder, "Iron Dummy");
|
||||
combineInterval++;
|
||||
if (combineInterval >= 10)
|
||||
{
|
||||
@ -500,11 +624,10 @@ public class CombinedMeshManager
|
||||
|
||||
if (steelBlockCount > 0)
|
||||
{
|
||||
for (int i = 0; i < gameManager.steel.Length; i++)
|
||||
for (int i = 0; i < gameManager.steelHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.steel[steelCount];
|
||||
GameObject dummyObject = gameManager.steelDummy[steelCount];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.steelHolder, "Steel Dummy");
|
||||
GameObject realObject = gameManager.steelHolders[i];
|
||||
SpawnDummy(realObject, gameManager.steelHolder, "Steel Dummy");
|
||||
combineInterval++;
|
||||
if (combineInterval >= 10)
|
||||
{
|
||||
@ -518,11 +641,10 @@ public class CombinedMeshManager
|
||||
|
||||
if (glassBlockCount > 0)
|
||||
{
|
||||
for (int i = 0; i < gameManager.glass.Length; i++)
|
||||
for (int i = 0; i < gameManager.glassHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.glass[glassCount];
|
||||
GameObject dummyObject = gameManager.glassDummy[glassCount];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.glassHolder, "Glass Dummy");
|
||||
GameObject realObject = gameManager.glassHolders[i];
|
||||
SpawnDummy(realObject, gameManager.glassHolder, "Glass Dummy");
|
||||
combineInterval++;
|
||||
if (combineInterval >= 10)
|
||||
{
|
||||
@ -536,11 +658,10 @@ public class CombinedMeshManager
|
||||
|
||||
if (brickBlockCount > 0)
|
||||
{
|
||||
for (int i = 0; i < gameManager.bricks.Length; i++)
|
||||
for (int i = 0; i < gameManager.brickHolders.Length; i++)
|
||||
{
|
||||
GameObject realObject = gameManager.bricks[brickCount];
|
||||
GameObject dummyObject = gameManager.bricksDummy[brickCount];
|
||||
SpawnDummy(realObject, dummyObject, gameManager.brickHolder, "Brick Dummy");
|
||||
GameObject realObject = gameManager.brickHolders[i];
|
||||
SpawnDummy(realObject, gameManager.brickHolder, "Brick Dummy");
|
||||
combineInterval++;
|
||||
if (combineInterval >= 10)
|
||||
{
|
||||
@ -552,6 +673,29 @@ public class CombinedMeshManager
|
||||
gameManager.replacingMeshFilters = true;
|
||||
}
|
||||
|
||||
if (modBlockCount > 0)
|
||||
{
|
||||
modBlockIndex = 0;
|
||||
foreach (string blockName in gameManager.modBlockNames)
|
||||
{
|
||||
GameObject[] currentBlockType = gameManager.modBlockHolders[modBlockIndex];
|
||||
for (int i = 0; i < currentBlockType.Length; i++)
|
||||
{
|
||||
GameObject realObject = currentBlockType[i];
|
||||
SpawnDummy(realObject, gameManager.modBlockHolder, blockName + " Dummy");
|
||||
combineInterval++;
|
||||
if (combineInterval >= 10)
|
||||
{
|
||||
combineInterval = 0;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
modMeshRequired = true;
|
||||
gameManager.replacingMeshFilters = true;
|
||||
modBlockIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
gameManager.blocksCombined = true;
|
||||
if (gameManager.replacingMeshFilters == false)
|
||||
{
|
||||
@ -614,7 +758,7 @@ public class CombinedMeshManager
|
||||
if (ironMeshRequired == true)
|
||||
{
|
||||
int ironCombineInterval = 0;
|
||||
foreach (GameObject holder in gameManager.ironBlocks)
|
||||
foreach (GameObject holder in gameManager.ironHolders)
|
||||
{
|
||||
CreateCombinedMesh(holder);
|
||||
ironCombineInterval++;
|
||||
@ -630,7 +774,7 @@ public class CombinedMeshManager
|
||||
if (glassMeshRequired == true)
|
||||
{
|
||||
int glassCombineInterval = 0;
|
||||
foreach (GameObject holder in gameManager.glass)
|
||||
foreach (GameObject holder in gameManager.glassHolders)
|
||||
{
|
||||
CreateCombinedMesh(holder);
|
||||
glassCombineInterval++;
|
||||
@ -646,7 +790,7 @@ public class CombinedMeshManager
|
||||
if (steelMeshRequired == true)
|
||||
{
|
||||
int steelCombineInterval = 0;
|
||||
foreach (GameObject holder in gameManager.steel)
|
||||
foreach (GameObject holder in gameManager.steelHolders)
|
||||
{
|
||||
CreateCombinedMesh(holder);
|
||||
steelCombineInterval++;
|
||||
@ -662,7 +806,7 @@ public class CombinedMeshManager
|
||||
if (brickMeshRequired == true)
|
||||
{
|
||||
int brickCombineInterval = 0;
|
||||
foreach (GameObject holder in gameManager.bricks)
|
||||
foreach (GameObject holder in gameManager.brickHolders)
|
||||
{
|
||||
CreateCombinedMesh(holder);
|
||||
brickCombineInterval++;
|
||||
@ -675,6 +819,27 @@ public class CombinedMeshManager
|
||||
brickMeshRequired = false;
|
||||
}
|
||||
|
||||
if (modMeshRequired == true)
|
||||
{
|
||||
int modBlockIndex = 0;
|
||||
foreach (string blockName in gameManager.modBlockNames)
|
||||
{
|
||||
int modCombineInterval = 0;
|
||||
foreach (GameObject holder in gameManager.modBlockHolders[modBlockIndex])
|
||||
{
|
||||
CreateCombinedMesh(holder);
|
||||
modCombineInterval++;
|
||||
if (modCombineInterval >= 10)
|
||||
{
|
||||
yield return null;
|
||||
modCombineInterval = 0;
|
||||
}
|
||||
}
|
||||
modBlockIndex++;
|
||||
}
|
||||
modMeshRequired = false;
|
||||
}
|
||||
|
||||
HolderDummy[] allHolders = Object.FindObjectsOfType<HolderDummy>();
|
||||
int dummyDestroyInterval = 0;
|
||||
foreach (HolderDummy h in allHolders)
|
||||
|
@ -33,7 +33,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<AlloySmelter>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<AlloySmelter>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<AlloySmelter>().outputType))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<AlloySmelter>().outputType + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AlloySmelter>().outputType + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<AlloySmelter>().outputType))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AlloySmelter>().outputType];
|
||||
}
|
||||
@ -54,7 +58,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<AutoCrafter>().inputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<AutoCrafter>().inputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<AutoCrafter>().type))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<AutoCrafter>().type + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AutoCrafter>().type + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<AutoCrafter>().type))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AutoCrafter>().type];
|
||||
}
|
||||
@ -84,7 +92,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<Extruder>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<Extruder>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<Extruder>().outputType))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<Extruder>().outputType + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Extruder>().outputType + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<Extruder>().outputType))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Extruder>().outputType];
|
||||
}
|
||||
@ -96,7 +108,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<GearCutter>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<GearCutter>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<GearCutter>().outputType))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<GearCutter>().outputType + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<GearCutter>().outputType + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<GearCutter>().outputType))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<GearCutter>().outputType];
|
||||
}
|
||||
@ -108,7 +124,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<Press>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<Press>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<Press>().outputType))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<Press>().outputType + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Press>().outputType + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<Press>().outputType))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Press>().outputType];
|
||||
}
|
||||
@ -120,7 +140,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<ModMachine>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<ModMachine>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<ModMachine>().outputType))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<ModMachine>().outputType + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<ModMachine>().outputType + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<ModMachine>().outputType))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<ModMachine>().outputType];
|
||||
}
|
||||
@ -132,7 +156,12 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<Retriever>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<Retriever>().outputObject;
|
||||
if (textureDictionary.ContainsKey(target.GetComponent<UniversalConduit>().type))
|
||||
if (textureDictionary.ContainsKey(target.GetComponent<UniversalConduit>().type + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[target.GetComponent<UniversalConduit>().type + "_Icon"];
|
||||
billboard2.GetComponent<Renderer>().material.mainTexture = textureDictionary[target.GetComponent<UniversalConduit>().type + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(target.GetComponent<UniversalConduit>().type))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[target.GetComponent<UniversalConduit>().type];
|
||||
billboard2.GetComponent<Renderer>().material.mainTexture = textureDictionary[target.GetComponent<UniversalConduit>().type];
|
||||
@ -145,7 +174,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<Smelter>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<Smelter>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<Smelter>().outputType))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<Smelter>().outputType + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Smelter>().outputType + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<Smelter>().outputType))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Smelter>().outputType];
|
||||
}
|
||||
@ -156,7 +189,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<UniversalConduit>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<UniversalConduit>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalConduit>().type))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalConduit>().type + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalConduit>().type + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<UniversalConduit>().type))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalConduit>().type];
|
||||
}
|
||||
@ -168,7 +205,11 @@ public class ConduitItem : MonoBehaviour
|
||||
if (machine.GetComponent<UniversalExtractor>().outputObject != null)
|
||||
{
|
||||
target = machine.GetComponent<UniversalExtractor>().outputObject;
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalExtractor>().type))
|
||||
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalExtractor>().type + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalExtractor>().type + "_Icon"];
|
||||
}
|
||||
else if (textureDictionary.ContainsKey(machine.GetComponent<UniversalExtractor>().type))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalExtractor>().type];
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ public class CraftingDictionary
|
||||
private readonly string[] quantumHatchwayIngredients =
|
||||
{ "Tin Plate", "Dark Matter" };
|
||||
|
||||
private readonly string[] doorIngredients =
|
||||
{ "Iron Plate", "Dark Matter" };
|
||||
|
||||
private readonly string[] electricLightIngredients =
|
||||
{ "Glass Block", "Tin Plate", "Copper Wire" };
|
||||
|
||||
@ -100,6 +103,7 @@ public class CraftingDictionary
|
||||
|
||||
private readonly int[] ironBlockAmounts = { 1 };
|
||||
private readonly int[] steelBlockAmounts = { 1 };
|
||||
private readonly int[] doorAmounts = { 1, 1 };
|
||||
private readonly int[] quantumHatchwayAmounts = { 1, 1 };
|
||||
private readonly int[] electricLightAmounts = { 1, 1, 2 };
|
||||
private readonly int[] augerAmounts = { 10, 10 };
|
||||
@ -138,6 +142,7 @@ public class CraftingDictionary
|
||||
{ "Iron Ramp", new CraftingRecipe(ironBlockIngredients, ironBlockAmounts, "Iron Ramp", 10) },
|
||||
{ "Steel Block", new CraftingRecipe(steelBlockIngredients, steelBlockAmounts, "Steel Block", 10) },
|
||||
{ "Steel Ramp", new CraftingRecipe(steelBlockIngredients, steelBlockAmounts, "Steel Ramp", 10) },
|
||||
{ "Door", new CraftingRecipe(doorIngredients, doorAmounts, "Door", 1) },
|
||||
{ "Quantum Hatchway", new CraftingRecipe(quantumHatchwayIngredients, quantumHatchwayAmounts, "Quantum Hatchway", 1) },
|
||||
{ "Electric Light", new CraftingRecipe(electricLightIngredients, electricLightAmounts, "Electric Light", 1) },
|
||||
{ "Auger", new CraftingRecipe(augerIngredients, augerAmounts, "Auger", 1) },
|
||||
|
104
CraftingGUI.cs
104
CraftingGUI.cs
@ -23,6 +23,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
descriptions = new Descriptions();
|
||||
}
|
||||
|
||||
//! Called by unity engine for rendering and handling GUI events.
|
||||
public void OnGUI()
|
||||
{
|
||||
// Style.
|
||||
@ -445,6 +446,18 @@ public class CraftingGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.steelRamp + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button5Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Door"];
|
||||
int length = recipe.ingredients.Length;
|
||||
string[] crafting = new string[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
crafting[i] = recipe.amounts[i] + "x " + recipe.ingredients[i];
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.door + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button6Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Quantum Hatchway"];
|
||||
@ -456,7 +469,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.quantumHatchway + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button6Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button7Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Electric Light"];
|
||||
@ -468,7 +481,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.electricLight + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button7Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button9Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Circuit Board"];
|
||||
@ -480,7 +493,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.circuitBoard + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button9Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button10Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Electric Motor"];
|
||||
@ -492,7 +505,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.electricMotor + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button10Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button11Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Storage Computer"];
|
||||
@ -504,7 +517,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.storageComputer + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button11Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button12Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Turret"];
|
||||
@ -516,7 +529,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.turret + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button12Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button13Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Missile Turret"];
|
||||
@ -528,7 +541,7 @@ public class CraftingGUI : MonoBehaviour
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.missileTurret + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
if (guiCoordinates.button13Rect.Contains(Event.current.mousePosition))
|
||||
if (guiCoordinates.button14Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
CraftingRecipe recipe = craftingDictionary.dictionary["Missile"];
|
||||
@ -558,41 +571,55 @@ public class CraftingGUI : MonoBehaviour
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Steel Ramp"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button5Rect, "Quantum Hatchway"))
|
||||
if (GUI.Button(guiCoordinates.button5Rect, "Door"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Door"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button6Rect, "Quantum Hatchway"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Quantum Hatchway"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button6Rect, "Electric Light"))
|
||||
if (GUI.Button(guiCoordinates.button7Rect, "Electric Light"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Electric Light"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button7Rect, "Circuit Board"))
|
||||
if (GUI.Button(guiCoordinates.button9Rect, "Circuit Board"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Circuit Board"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button9Rect, "Electric Motor"))
|
||||
if (GUI.Button(guiCoordinates.button10Rect, "Electric Motor"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Electric Motor"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button10Rect, "Storage Computer"))
|
||||
if (GUI.Button(guiCoordinates.button11Rect, "Storage Computer"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Storage Computer"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button11Rect, "Turret"))
|
||||
if (GUI.Button(guiCoordinates.button12Rect, "Turret"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Turret"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button12Rect, "Missile Turret"))
|
||||
if (GUI.Button(guiCoordinates.button13Rect, "Missile Turret"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Missile Turret"]);
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button13Rect, "Missile"))
|
||||
if (GUI.Button(guiCoordinates.button14Rect, "Missile"))
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.dictionary["Missile"]);
|
||||
}
|
||||
}
|
||||
if (craftingPage == 2)
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 24;
|
||||
GUI.color = new Color(0.44f, 0.72f, 0.82f, 1);
|
||||
GUI.Label(guiCoordinates.craftingTitleRect, "CRAFTING");
|
||||
GUI.skin.label.fontSize = f;
|
||||
GUI.color = Color.white;
|
||||
|
||||
int index = 0;
|
||||
KeyValuePair<string, CraftingRecipe>[] recipes = new KeyValuePair<string, CraftingRecipe>[craftingDictionary.modDictionary.Count];
|
||||
foreach (KeyValuePair<string,CraftingRecipe> kvp in craftingDictionary.modDictionary)
|
||||
@ -601,13 +628,30 @@ public class CraftingGUI : MonoBehaviour
|
||||
index++;
|
||||
}
|
||||
|
||||
GUI.DrawTexture(guiCoordinates.craftingBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 24;
|
||||
GUI.color = new Color(0.44f, 0.72f, 0.82f, 1);
|
||||
GUI.Label(guiCoordinates.craftingTitleRect, "CRAFTING");
|
||||
GUI.skin.label.fontSize = f;
|
||||
GUI.color = Color.white;
|
||||
string desc = recipes[modCraftingIndex].Value.output;
|
||||
string iconKey = desc + "_Icon";
|
||||
|
||||
if (textureDictionary.dictionary.ContainsKey(iconKey))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingItemRect, textureDictionary.dictionary[iconKey]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingItemRect, textureDictionary.dictionary[desc]);
|
||||
}
|
||||
|
||||
if (GetComponent<BuildController>().blockDictionary.machineDictionary.ContainsKey(recipes[modCraftingIndex].Value.output))
|
||||
{
|
||||
desc = GetComponent<BuildController>().blockDictionary.GetMachineDescription(recipes[modCraftingIndex].Value.output);
|
||||
}
|
||||
|
||||
string[] crafting = new string[recipes[modCraftingIndex].Value.ingredients.Length];
|
||||
for (int i = 0; i < recipes[modCraftingIndex].Value.ingredients.Length; i++)
|
||||
{
|
||||
crafting[i] = recipes[modCraftingIndex].Value.amounts[i] + "x " + recipes[modCraftingIndex].Value.ingredients[i];
|
||||
}
|
||||
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, desc + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
|
||||
if (GUI.Button(guiCoordinates.button3Rect, "<-"))
|
||||
{
|
||||
@ -631,22 +675,6 @@ public class CraftingGUI : MonoBehaviour
|
||||
{
|
||||
craftingManager.CraftItemAsPlayer(craftingDictionary.modDictionary[recipes[modCraftingIndex].Value.output]);
|
||||
}
|
||||
|
||||
if (guiCoordinates.button11Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
string desc = recipes[modCraftingIndex].Value.output;
|
||||
if (GetComponent<BuildController>().blockDictionary.machineDictionary.ContainsKey(recipes[modCraftingIndex].Value.output))
|
||||
{
|
||||
desc = GetComponent<BuildController>().blockDictionary.GetMachineDescription(recipes[modCraftingIndex].Value.output);
|
||||
}
|
||||
string[] crafting = new string[recipes[modCraftingIndex].Value.ingredients.Length];
|
||||
for (int i = 0; i < recipes[modCraftingIndex].Value.ingredients.Length; i++)
|
||||
{
|
||||
crafting[i] = recipes[modCraftingIndex].Value.amounts[i] + "x " + recipes[modCraftingIndex].Value.ingredients[i];
|
||||
}
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, desc + "\n\n[CRAFTING]\n" + string.Join("\n", crafting));
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.craftingPreviousRect, "<-"))
|
||||
{
|
||||
|
@ -69,17 +69,20 @@ public class CraftingManager : MonoBehaviour
|
||||
}
|
||||
missingItem = itemNotFound;
|
||||
|
||||
if (!missingItem)
|
||||
if (!missingItem || playerController.creativeMode == true)
|
||||
{
|
||||
inventoryManager.AddItem(recipe.output, outputAmount);
|
||||
if (inventoryManager.itemAdded)
|
||||
{
|
||||
for (int i = 0; i < recipe.ingredients.Length; i++)
|
||||
if (playerController.creativeMode == false)
|
||||
{
|
||||
slots[i].amountInSlot -= amounts[i];
|
||||
if (slots[i].amountInSlot <= 0)
|
||||
for (int i = 0; i < recipe.ingredients.Length; i++)
|
||||
{
|
||||
slots[i].typeInSlot = "nothing";
|
||||
slots[i].amountInSlot -= amounts[i];
|
||||
if (slots[i].amountInSlot <= 0)
|
||||
{
|
||||
slots[i].typeInSlot = "nothing";
|
||||
}
|
||||
}
|
||||
}
|
||||
playerController.PlayCraftingSound();
|
||||
|
@ -38,13 +38,16 @@ public class DarkMatterCollector : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -38,15 +38,17 @@ public class DarkMatterConduit : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
if (stateManager.Busy())
|
||||
|
@ -74,7 +74,9 @@
|
||||
" Must be connected to a power source such as a solar panel, nuclear reactor or power conduit" +
|
||||
" and has an adjustable output measured in items per cycle.";
|
||||
|
||||
public string quantumHatchway = "Hatchway used for entering structures.";
|
||||
public string door = "Standard door used for entering structures.";
|
||||
|
||||
public string quantumHatchway = "Forcefield door used for entering structures.";
|
||||
|
||||
public string railCart = "A mobile storage container that rides on rails from one rail cart hub to the next." +
|
||||
" Configure the hubs to stop the cart near a conduit or retriever so it can be loaded or unloaded." +
|
||||
|
120
Door.cs
Normal file
120
Door.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Door : MonoBehaviour
|
||||
{
|
||||
private float updateTick;
|
||||
private StateManager stateManager;
|
||||
public string ID = "unassigned";
|
||||
public int address;
|
||||
public string type;
|
||||
public bool open;
|
||||
public AudioClip clip1;
|
||||
public AudioClip clip2;
|
||||
public AudioClip clip3;
|
||||
public AudioClip[] audioClips;
|
||||
public GameObject openObject;
|
||||
public GameObject closedObject;
|
||||
public GameObject effects;
|
||||
private List<string> textureList;
|
||||
public string[] textures;
|
||||
public int textureIndex;
|
||||
public string material;
|
||||
public int audioClip;
|
||||
public bool edited;
|
||||
private bool init;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
audioClips = new AudioClip[] { clip1, clip2, clip3 };
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
textureList = new List<string>();
|
||||
Dictionary<string, Texture2D> textureDictionary = GameObject.Find("Player").GetComponent<TextureDictionary>().dictionary;
|
||||
Dictionary<string, GameObject> blockDictionary = GameObject.Find("Player").GetComponent<BuildController>().blockDictionary.blockDictionary;
|
||||
foreach (KeyValuePair<string, GameObject> kvp in blockDictionary)
|
||||
{
|
||||
if (textureDictionary.ContainsKey(kvp.Key) && !textureDictionary.ContainsKey(kvp.Key+"_Icon") && !kvp.Key.ToUpper().Contains("RAMP"))
|
||||
{
|
||||
textureList.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
textures = textureList.ToArray();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
if (stateManager.Busy())
|
||||
{
|
||||
updateTick = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (edited == true && init == false)
|
||||
{
|
||||
GetComponent<AudioSource>().clip = audioClips[audioClip];
|
||||
GameManager gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
gameManager.meshManager.SetMaterial(closedObject, material);
|
||||
init = true;
|
||||
}
|
||||
|
||||
if (QualitySettings.GetQualityLevel() < 3 && type == "Quantum Hatchway")
|
||||
{
|
||||
effects.SetActive(false);
|
||||
}
|
||||
|
||||
GetComponent<PhysicsHandler>().UpdatePhysics();
|
||||
updateTick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//! Toggle the open or closed state of the hatchway.
|
||||
public void ToggleOpen()
|
||||
{
|
||||
if (open == false)
|
||||
{
|
||||
openObject.SetActive(true);
|
||||
closedObject.SetActive(false);
|
||||
GetComponent<Collider>().isTrigger = true;
|
||||
open = true;
|
||||
Door[] doors = Object.FindObjectsOfType<Door>();
|
||||
foreach (Door d in doors)
|
||||
{
|
||||
if (d.type == type)
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, d.transform.position);
|
||||
if (distance <= 5 && d.open != open)
|
||||
{
|
||||
d.ToggleOpen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
openObject.SetActive(false);
|
||||
closedObject.SetActive(true);
|
||||
GetComponent<Collider>().isTrigger = false;
|
||||
open = false;
|
||||
Door[] doors = Object.FindObjectsOfType<Door>();
|
||||
foreach (Door d in doors)
|
||||
{
|
||||
if (d.type == type)
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, d.transform.position);
|
||||
if (distance <= 5 && d.open != open)
|
||||
{
|
||||
d.ToggleOpen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,9 @@ public class ElectricLight : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 1 + (address * 0.001f))
|
||||
{
|
||||
|
227
GameManager.cs
227
GameManager.cs
@ -4,26 +4,26 @@ using UnityEngine;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public bool fileBasedPrefsInitialized;
|
||||
private HazardManager hazardManager;
|
||||
public CombinedMeshManager meshManager;
|
||||
public GameObject pirateObject;
|
||||
public GameObject meteorObject;
|
||||
public GameObject[] ironBlocks;
|
||||
public GameObject[] glass;
|
||||
public GameObject[] steel;
|
||||
public GameObject[] bricks;
|
||||
public GameObject[] ironBlocksDummy;
|
||||
public GameObject[] glassDummy;
|
||||
public GameObject[] steelDummy;
|
||||
public GameObject[] bricksDummy;
|
||||
private List<GameObject> blocksToRemove;
|
||||
public GameObject[] ironHolders;
|
||||
public GameObject[] glassHolders;
|
||||
public GameObject[] steelHolders;
|
||||
public GameObject[] brickHolders;
|
||||
public List<string> modBlockNames;
|
||||
public List<GameObject[]> modBlockHolders;
|
||||
public GameObject ironHolder;
|
||||
public GameObject glassHolder;
|
||||
public GameObject steelHolder;
|
||||
public GameObject brickHolder;
|
||||
public GameObject modBlockHolder;
|
||||
public GameObject lander;
|
||||
public GameObject rocketObject;
|
||||
public GameObject builtObjects;
|
||||
public Material glassMaterial;
|
||||
public int chunkSize;
|
||||
public bool blockPhysics;
|
||||
public bool hazardsEnabled = true;
|
||||
@ -33,7 +33,7 @@ public class GameManager : MonoBehaviour
|
||||
public bool blocksCombined;
|
||||
public bool working;
|
||||
public bool replacingMeshFilters;
|
||||
public bool checkingForDuplicates;
|
||||
public bool runningUndo;
|
||||
private float mfDelay;
|
||||
public bool clearBrickDummies;
|
||||
public bool clearGlassDummies;
|
||||
@ -53,10 +53,23 @@ public class GameManager : MonoBehaviour
|
||||
public Coroutine meshCombineCoroutine;
|
||||
public Coroutine blockCombineCoroutine;
|
||||
public Coroutine hazardRemovalCoroutine;
|
||||
private Coroutine duplicateRemovalCoroutine;
|
||||
private Coroutine duplicateDestructionCoroutine;
|
||||
private Coroutine undoCoroutine;
|
||||
public List<Vector3> meteorShowerLocationList;
|
||||
|
||||
public class Block
|
||||
{
|
||||
public string blockType;
|
||||
public GameObject blockObject;
|
||||
|
||||
public Block(string blockType, GameObject blockObject)
|
||||
{
|
||||
this.blockType = blockType;
|
||||
this.blockObject = blockObject;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Block> undoBlocks;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
@ -75,44 +88,60 @@ public class GameManager : MonoBehaviour
|
||||
// Create the combined mesh manager.
|
||||
meshManager = new CombinedMeshManager(this);
|
||||
|
||||
// Create an object list to hold the player's most recently built objects for the 'undo' function.
|
||||
undoBlocks = new List<Block>();
|
||||
|
||||
// Create mod block name list.
|
||||
modBlockNames = new List<string>();
|
||||
modBlockHolders = new List<GameObject[]>();
|
||||
|
||||
// Load chunk size setting.
|
||||
int cs = PlayerPrefs.GetInt("chunkSize");
|
||||
chunkSize = cs > 0 ? cs : 300;
|
||||
|
||||
// Initial list to hold duplicate blocks pending removal.
|
||||
blocksToRemove = new List<GameObject>();
|
||||
chunkSize = cs > 0 ? cs : 40;
|
||||
|
||||
// Create initial iron block holder for mesh manager.
|
||||
GameObject ironInit = Instantiate(ironHolder, transform.position, transform.rotation);
|
||||
ironInit.transform.parent = builtObjects.transform;
|
||||
ironInit.GetComponent<MeshPainter>().ID = 0;
|
||||
ironInit.SetActive(false);
|
||||
ironBlocks = new GameObject[] { ironInit };
|
||||
ironBlocksDummy = new GameObject[ironBlocks.Length];
|
||||
ironHolders = new GameObject[] { ironInit };
|
||||
|
||||
// Create initial iron block holder for mesh manager.
|
||||
GameObject glassInit = Instantiate(glassHolder, transform.position, transform.rotation);
|
||||
glassInit.transform.parent = builtObjects.transform;
|
||||
glassInit.GetComponent<MeshPainter>().ID = 0;
|
||||
glassInit.SetActive(false);
|
||||
glass = new GameObject[] { glassInit };
|
||||
glassDummy = new GameObject[glass.Length];
|
||||
glassHolders = new GameObject[] { glassInit };
|
||||
|
||||
// Create initial iron block holder for mesh manager.
|
||||
GameObject steelInit = Instantiate(steelHolder, transform.position, transform.rotation);
|
||||
steelInit.transform.parent = builtObjects.transform;
|
||||
steelInit.GetComponent<MeshPainter>().ID = 0;
|
||||
steelInit.SetActive(false);
|
||||
steel = new GameObject[] { steelInit };
|
||||
steelDummy = new GameObject[steel.Length];
|
||||
steelHolders = new GameObject[] { steelInit };
|
||||
|
||||
// Create initial iron block holder for mesh manager.
|
||||
GameObject brickInit = Instantiate(brickHolder, transform.position, transform.rotation);
|
||||
brickInit.transform.parent = builtObjects.transform;
|
||||
brickInit.GetComponent<MeshPainter>().ID = 0;
|
||||
brickInit.SetActive(false);
|
||||
bricks = new GameObject[] { brickInit };
|
||||
bricksDummy = new GameObject[bricks.Length];
|
||||
brickHolders = new GameObject[] { brickInit };
|
||||
}
|
||||
|
||||
public void InitModBlocks()
|
||||
{
|
||||
// Create initial block holders for mod blocks.
|
||||
int index = 0;
|
||||
int count = modBlockNames.Count;
|
||||
foreach (string blockName in modBlockNames)
|
||||
{
|
||||
GameObject modBlockInit = Instantiate(modBlockHolder, transform.position, transform.rotation);
|
||||
meshManager.SetMaterial(modBlockInit, blockName);
|
||||
modBlockInit.transform.parent = builtObjects.transform;
|
||||
modBlockInit.SetActive(false);
|
||||
modBlockHolders.Add(new GameObject[] { modBlockInit });
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
@ -120,66 +149,32 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
if (FileBasedPrefs.initialized == true)
|
||||
{
|
||||
if (FileBasedPrefs.GetBool(GetComponent<StateManager>().WorldName + "Initialized") == false)
|
||||
if (FileBasedPrefs.GetBool(GetComponent<StateManager>().worldName + "Initialized") == false)
|
||||
{
|
||||
if (lander.GetComponent<InventoryManager>().initialized == true)
|
||||
{
|
||||
if (GetComponent<StateManager>().WorldName.Equals("devMachineTest"))
|
||||
{
|
||||
lander.GetComponent<InventoryManager>().AddItem("Universal Extractor", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Universal Conduit", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Storage Container", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Solar Panel", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Reactor Turbine", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Nuclear Reactor", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Smelter", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Press", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Extruder", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Auger", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Alloy Smelter", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Heat Exchanger", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Turret", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Dark Matter Collector", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Dark Matter Conduit", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Storage Computer", 1000);
|
||||
}
|
||||
else if (GetComponent<StateManager>().WorldName.Equals("devBuildTest"))
|
||||
{
|
||||
lander.GetComponent<InventoryManager>().AddItem("Brick", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Brick", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Brick", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Brick", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Iron Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Iron Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Iron Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Iron Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Steel Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Steel Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Steel Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Steel Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Glass Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Glass Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Glass Block", 1000);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Glass Block", 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
lander.GetComponent<InventoryManager>().AddItem("Solar Panel", 9);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Universal Conduit", 8);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Storage Container", 4);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Smelter", 3);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Universal Extractor", 2);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Dark Matter Conduit", 1);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Dark Matter Collector", 1);
|
||||
}
|
||||
FileBasedPrefs.SetBool(GetComponent<StateManager>().WorldName + "Initialized", true);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Solar Panel", 9);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Universal Conduit", 8);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Storage Container", 4);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Smelter", 3);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Universal Extractor", 2);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Dark Matter Conduit", 1);
|
||||
lander.GetComponent<InventoryManager>().AddItem("Dark Matter Collector", 1);
|
||||
FileBasedPrefs.SetBool(GetComponent<StateManager>().worldName + "Initialized", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (loadedBlockPhysics == false)
|
||||
{
|
||||
blockPhysics = PlayerPrefsX.GetPersistentBool("blockPhysics");
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == false)
|
||||
{
|
||||
blockPhysics = PlayerPrefsX.GetPersistentBool("blockPhysics");
|
||||
}
|
||||
else
|
||||
{
|
||||
blockPhysics = false;
|
||||
}
|
||||
loadedBlockPhysics = true;
|
||||
}
|
||||
if (loadedHazardsEnabled == false)
|
||||
@ -189,12 +184,12 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
if (loadedMeteorTimer == false)
|
||||
{
|
||||
meteorShowerTimer = FileBasedPrefs.GetFloat(GetComponent<StateManager>().WorldName + "meteorShowerTimer");
|
||||
meteorShowerTimer = FileBasedPrefs.GetFloat(GetComponent<StateManager>().worldName + "meteorShowerTimer");
|
||||
loadedMeteorTimer = true;
|
||||
}
|
||||
if (loadedPirateTimer == false)
|
||||
{
|
||||
pirateAttackTimer = FileBasedPrefs.GetFloat(GetComponent<StateManager>().WorldName + "pirateAttackTimer");
|
||||
pirateAttackTimer = FileBasedPrefs.GetFloat(GetComponent<StateManager>().worldName + "pirateAttackTimer");
|
||||
loadedPirateTimer = true;
|
||||
}
|
||||
}
|
||||
@ -225,83 +220,37 @@ public class GameManager : MonoBehaviour
|
||||
if (GetComponent<StateManager>().worldLoaded == true)
|
||||
{
|
||||
hazardManager.UpdateHazards();
|
||||
CheckForDuplicates();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckForDuplicates()
|
||||
public void UndoBuiltObjects()
|
||||
{
|
||||
if (checkingForDuplicates == false)
|
||||
if (runningUndo == false)
|
||||
{
|
||||
duplicateRemovalCoroutine = StartCoroutine(RemoveDuplicates());
|
||||
undoCoroutine = StartCoroutine(RemoveRecent());
|
||||
}
|
||||
}
|
||||
|
||||
//! Checks for multiple blocks placed in the same location and removes the duplicate.
|
||||
private IEnumerator RemoveDuplicates()
|
||||
//! Removes recently placed blocks.
|
||||
private IEnumerator RemoveRecent()
|
||||
{
|
||||
checkingForDuplicates = true;
|
||||
Transform[] blocks = builtObjects.GetComponentsInChildren<Transform>(false);
|
||||
foreach (Transform block in blocks)
|
||||
runningUndo = true;
|
||||
foreach (Block block in undoBlocks)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
int interval = 0;
|
||||
Transform[] otherBlocks = builtObjects.GetComponentsInChildren<Transform>(false);
|
||||
foreach (Transform otherBlock in otherBlocks)
|
||||
if (block.blockObject != null)
|
||||
{
|
||||
if (block.blockObject.activeInHierarchy)
|
||||
{
|
||||
if (block != null && otherBlock != null)
|
||||
{
|
||||
if (block.position == otherBlock.position && block != otherBlock)
|
||||
{
|
||||
PhysicsHandler blockHandler = block.GetComponent<PhysicsHandler>();
|
||||
PhysicsHandler otherBlockHandler = otherBlock.GetComponent<PhysicsHandler>();
|
||||
if (blockHandler != null && otherBlockHandler != null)
|
||||
{
|
||||
if (blockHandler.lifetime > 0 && otherBlockHandler.lifetime > 0)
|
||||
{
|
||||
if (blockHandler.lifetime < otherBlockHandler.lifetime)
|
||||
{
|
||||
block.gameObject.SetActive(false);
|
||||
blocksToRemove.Add(block.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
otherBlock.gameObject.SetActive(false);
|
||||
blocksToRemove.Add(otherBlock.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
interval++;
|
||||
if (interval >= 300)
|
||||
{
|
||||
interval = 0;
|
||||
yield return null;
|
||||
}
|
||||
Destroy(block.blockObject);
|
||||
player.playerInventory.AddItem(block.blockType, 1);
|
||||
player.PlayCraftingSound();
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
duplicateDestructionCoroutine = StartCoroutine(DestroyDuplicates());
|
||||
checkingForDuplicates = false;
|
||||
}
|
||||
|
||||
private IEnumerator DestroyDuplicates()
|
||||
{
|
||||
int interval = 0;
|
||||
GameObject[] blocks = blocksToRemove.ToArray();
|
||||
foreach (GameObject block in blocks)
|
||||
{
|
||||
blocksToRemove.Remove(block);
|
||||
Destroy(block);
|
||||
interval++;
|
||||
if (interval >= 100)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
undoBlocks.Clear();
|
||||
runningUndo = false;
|
||||
}
|
||||
|
||||
//! Saves the game on exit.
|
||||
|
5
Glass.cs
5
Glass.cs
@ -18,12 +18,15 @@ public class Glass : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
if (stateManager.Busy())
|
||||
{
|
||||
updateTick = 0;
|
||||
updateTick = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ public class GuiCoordinates
|
||||
public Rect longHighMessageBackgroundRect;
|
||||
public Rect secondLineHighMessageBackgroundRect;
|
||||
public Rect twoLineHighMessageBackgroundRect;
|
||||
public Rect buildingMessageBackgroundRect;
|
||||
public Rect buildingMessageRect;
|
||||
|
||||
//INVENTORY
|
||||
public Rect inventoryMesageRect;
|
||||
@ -40,6 +42,7 @@ public class GuiCoordinates
|
||||
|
||||
public Rect craftingPreviousRect;
|
||||
public Rect craftingNextRect;
|
||||
public Rect craftingItemRect;
|
||||
|
||||
public Rect inventorySlot1Rect;
|
||||
public Rect inventorySlot2Rect;
|
||||
@ -77,6 +80,12 @@ public class GuiCoordinates
|
||||
public Rect inventorySlot16TexRect;
|
||||
public Rect[] inventorySlotRects;
|
||||
|
||||
public Rect inventoryDropSlotRect;
|
||||
public Rect inventoryDropSlotLabelRect;
|
||||
|
||||
public Rect inventoryTrashSlotRect;
|
||||
public Rect inventoryTrashSlotLabelRect;
|
||||
|
||||
//STORAGE CONTAINERS
|
||||
public Rect storageInventoryBackgroundRect;
|
||||
public Rect storageInventorySlot1Rect;
|
||||
@ -180,6 +189,19 @@ public class GuiCoordinates
|
||||
public Rect escapeButton4Rect;
|
||||
public Rect escapeButton5Rect;
|
||||
|
||||
//BUILD AMOUNT GUI
|
||||
public Rect buildAmountRect;
|
||||
public Rect buildAmountTitleRect;
|
||||
public Rect buildAmountTextFieldRect;
|
||||
public Rect buildAmountButtonRect;
|
||||
|
||||
//DOOR SETTINGS GUI
|
||||
public Rect doorSettingsRect;
|
||||
public Rect doorTitleRect;
|
||||
public Rect doorTextureRect;
|
||||
public Rect doorSoundRect;
|
||||
public Rect doorCloseRect;
|
||||
|
||||
//TABLET MESSAGES
|
||||
public Rect topLeftInfoRect;
|
||||
|
||||
@ -265,6 +287,9 @@ public class GuiCoordinates
|
||||
highMessageBackgroundRect = new Rect((ScreenWidth * 0.42f), (ScreenHeight * 0.28f), (ScreenWidth * 0.18f), (ScreenHeight * 0.05f));
|
||||
longHighMessageBackgroundRect = new Rect((ScreenWidth * 0.42f), (ScreenHeight * 0.28f), (ScreenWidth * 0.23f), (ScreenHeight * 0.05f));
|
||||
|
||||
buildingMessageBackgroundRect = new Rect((ScreenWidth * 0.42f), (ScreenHeight * 0.02f), (ScreenWidth * 0.18f), (ScreenHeight * 0.05f));
|
||||
buildingMessageRect = new Rect((ScreenWidth * 0.45f), (ScreenHeight * 0.032f), (ScreenWidth * 0.55f), (ScreenHeight * 0.5f));
|
||||
|
||||
lowMessageRect = new Rect((ScreenWidth * 0.47f), (ScreenHeight * 0.644f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
|
||||
saveMessageRect = new Rect((ScreenWidth * 0.44f), (ScreenHeight * 0.644f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
|
||||
midMessageRect = new Rect((ScreenWidth * 0.455f), (ScreenHeight * 0.562f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
|
||||
@ -292,13 +317,14 @@ public class GuiCoordinates
|
||||
storageComputerMessageRect = new Rect((ScreenWidth * 0.42f), (ScreenHeight * 0.28f), (ScreenWidth * 0.2f), (ScreenHeight * 0.5f));
|
||||
|
||||
craftingTitleRect = new Rect((ScreenWidth * 0.25f), (ScreenHeight * 0.58f), (ScreenWidth * 0.20f), (ScreenHeight * 0.10f));
|
||||
craftingItemRect = new Rect((ScreenWidth * 0.27f), (ScreenHeight * 0.40f), (ScreenWidth * 0.05f), (ScreenHeight * 0.1f));
|
||||
craftingPreviousRect = new Rect((ScreenWidth * 0.08f), (ScreenHeight * 0.63f), (ScreenWidth * 0.07f), (ScreenHeight * 0.025f));
|
||||
craftingNextRect = new Rect((ScreenWidth * 0.45f), (ScreenHeight * 0.63f), (ScreenWidth * 0.07f), (ScreenHeight * 0.025f));
|
||||
|
||||
marketTitleRect = new Rect((ScreenWidth * 0.265f), (ScreenHeight * 0.58f), (ScreenWidth * 0.20f), (ScreenHeight * 0.10f));
|
||||
marketMoneyRect = new Rect((ScreenWidth * 0.27f), (ScreenHeight * 0.62f), (ScreenWidth * 0.20f), (ScreenHeight * 0.10f));
|
||||
marketMessageRect = new Rect((ScreenWidth * 0.08f), (ScreenHeight * 0.92f), (ScreenWidth * 0.42f), (ScreenHeight * 0.31f));
|
||||
|
||||
craftingPreviousRect = new Rect((ScreenWidth * 0.08f), (ScreenHeight * 0.63f), (ScreenWidth * 0.07f), (ScreenHeight * 0.025f));
|
||||
craftingNextRect = new Rect((ScreenWidth * 0.45f), (ScreenHeight * 0.63f), (ScreenWidth * 0.07f), (ScreenHeight * 0.025f));
|
||||
|
||||
inventorySlot1Rect = new Rect((ScreenWidth * 0.714f), (ScreenHeight * 0.325f), (ScreenWidth * 0.05f), (ScreenHeight * 0.05f));
|
||||
inventorySlot2Rect = new Rect((ScreenWidth * 0.768f), (ScreenHeight * 0.325f), (ScreenWidth * 0.05f), (ScreenHeight * 0.05f));
|
||||
inventorySlot3Rect = new Rect((ScreenWidth * 0.82f), (ScreenHeight * 0.325f), (ScreenWidth * 0.05f), (ScreenHeight * 0.05f));
|
||||
@ -369,6 +395,12 @@ public class GuiCoordinates
|
||||
inventorySlotRects[14] = inventorySlot15TexRect;
|
||||
inventorySlotRects[15] = inventorySlot16TexRect;
|
||||
|
||||
inventoryDropSlotRect = new Rect((ScreenWidth * 0.60f), (ScreenHeight * 0.33f), (ScreenWidth * 0.046f), (ScreenHeight * 0.09f));
|
||||
inventoryDropSlotLabelRect = new Rect((ScreenWidth * 0.612f), (ScreenHeight * 0.36f), (ScreenWidth * 0.046f), (ScreenHeight * 0.05f));
|
||||
|
||||
inventoryTrashSlotRect = new Rect((ScreenWidth * 0.60f), (ScreenHeight * 0.60f), (ScreenWidth * 0.046f), (ScreenHeight * 0.09f));
|
||||
inventoryTrashSlotLabelRect = new Rect((ScreenWidth * 0.61f), (ScreenHeight * 0.63f), (ScreenWidth * 0.046f), (ScreenHeight * 0.05f));
|
||||
|
||||
//STORAGE CONTAINERS
|
||||
storageInventoryBackgroundRect = new Rect(0, (ScreenHeight * 0.20f), (ScreenWidth * 0.60f), (ScreenHeight * 0.62f));
|
||||
storageInventorySlot1Rect = new Rect((ScreenWidth * 0.314f), (ScreenHeight * 0.325f), (ScreenWidth * 0.05f), (ScreenHeight * 0.05f));
|
||||
@ -498,6 +530,19 @@ public class GuiCoordinates
|
||||
escapeButton4Rect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.58f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
escapeButton5Rect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.66f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
|
||||
//BUILD AMOUNT GUI
|
||||
buildAmountRect = new Rect((ScreenWidth * 0.4f), (ScreenHeight * 0.10f), (ScreenWidth * 0.2f), (ScreenHeight * 0.452f));
|
||||
buildAmountTitleRect = new Rect((ScreenWidth * 0.437f), (ScreenHeight * 0.14f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
buildAmountTextFieldRect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.22f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
buildAmountButtonRect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.30f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
|
||||
//DOOR SETTINGS GUI
|
||||
doorSettingsRect = new Rect((ScreenWidth * 0.4f), (ScreenHeight * 0.10f), (ScreenWidth * 0.2f), (ScreenHeight * 0.452f));
|
||||
doorTitleRect = new Rect((ScreenWidth * 0.465f), (ScreenHeight * 0.14f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
doorTextureRect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.22f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
doorSoundRect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.30f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
doorCloseRect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.38f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
|
||||
|
||||
//TABLET MESSAGES
|
||||
topLeftInfoRect = new Rect(0, 0, (ScreenWidth * 0.5f), (ScreenHeight * 0.2f));
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class HazardManager
|
||||
gameManager.pirateAttackTimer += 1 * Time.deltaTime;
|
||||
if (gameManager.loadedPirateTimer == true)
|
||||
{
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().WorldName + "pirateAttackTimer", gameManager.pirateAttackTimer);
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().worldName + "pirateAttackTimer", gameManager.pirateAttackTimer);
|
||||
}
|
||||
if (gameManager.pirateAttackTimer >= 530 & gameManager.pirateAttackTimer < 540)
|
||||
{
|
||||
@ -74,7 +74,10 @@ public class HazardManager
|
||||
else if (gameManager.pirateAttackTimer >= 900)
|
||||
{
|
||||
gameManager.pirateAttackTimer = 0;
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
if (gameManager.player.laserCannonActive == false)
|
||||
{
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +89,7 @@ public class HazardManager
|
||||
|
||||
if (gameManager.loadedMeteorTimer == true)
|
||||
{
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().WorldName + "meteorShowerTimer", gameManager.meteorShowerTimer);
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().worldName + "meteorShowerTimer", gameManager.meteorShowerTimer);
|
||||
}
|
||||
if (gameManager.meteorShowerTimer >= 530 && gameManager.meteorShowerTimer < 540)
|
||||
{
|
||||
@ -131,7 +134,10 @@ public class HazardManager
|
||||
else if (gameManager.meteorShowerTimer >= 900)
|
||||
{
|
||||
gameManager.meteorShowerTimer = 0;
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
if (gameManager.player.laserCannonActive == false)
|
||||
{
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -140,7 +146,10 @@ public class HazardManager
|
||||
gameManager.meteorShowerTimer = 120;
|
||||
if (gameManager.player != null)
|
||||
{
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
if (gameManager.player.laserCannonActive == false)
|
||||
{
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,17 +168,20 @@ public class HazardManager
|
||||
gameManager.meteorShowerTimer = 120;
|
||||
if (gameManager.loadedMeteorTimer == true)
|
||||
{
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().WorldName + "meteorShowerTimer", gameManager.meteorShowerTimer);
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().worldName + "meteorShowerTimer", gameManager.meteorShowerTimer);
|
||||
}
|
||||
if (gameManager.loadedPirateTimer == true)
|
||||
{
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().WorldName + "pirateAttackTimer", gameManager.pirateAttackTimer);
|
||||
FileBasedPrefs.SetFloat(gameManager.GetComponent<StateManager>().worldName + "pirateAttackTimer", gameManager.pirateAttackTimer);
|
||||
}
|
||||
if (gameManager.player != null)
|
||||
{
|
||||
gameManager.player.meteorShowerWarningActive = false;
|
||||
gameManager.player.pirateAttackWarningActive = false;
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
if (gameManager.player.laserCannonActive == false)
|
||||
{
|
||||
gameManager.player.destructionMessageActive = false;
|
||||
}
|
||||
}
|
||||
if (hazardsRemoved == false)
|
||||
{
|
||||
|
@ -31,13 +31,16 @@ public class HeatExchanger : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
124
InfoHUD.cs
124
InfoHUD.cs
@ -20,17 +20,13 @@ public class InfoHUD : MonoBehaviour
|
||||
}
|
||||
|
||||
//! Returns true if the info hud should be drawn.
|
||||
private bool ShouldDrawInfoHud()
|
||||
public bool ShouldDrawInfoHud()
|
||||
{
|
||||
return !playerController.stateManager.Busy()
|
||||
&& playerController.objectInSight != playerController.gameObject
|
||||
&& GetComponent<MainMenu>().finishedLoading == true
|
||||
&& playerController.objectInSight != null
|
||||
&& playerController.building == false
|
||||
&& playerController.inventoryOpen == false
|
||||
&& playerController.marketGUIopen == false
|
||||
&& playerController.escapeMenuOpen == false
|
||||
&& playerController.tabletOpen == false;
|
||||
&& !playerController.GuiOpen();
|
||||
}
|
||||
|
||||
//! Called by unity engine for rendering and handling GUI events.
|
||||
@ -61,9 +57,9 @@ public class InfoHUD : MonoBehaviour
|
||||
{
|
||||
machineDisplayID = playerController.machineID;
|
||||
}
|
||||
else if (playerController.machineID.Length > playerController.stateManager.WorldName.Length)
|
||||
else if (playerController.machineID.Length > playerController.stateManager.worldName.Length)
|
||||
{
|
||||
machineDisplayID = playerController.machineID.Substring(playerController.stateManager.WorldName.Length);
|
||||
machineDisplayID = playerController.machineID.Substring(playerController.stateManager.worldName.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -74,9 +70,9 @@ public class InfoHUD : MonoBehaviour
|
||||
{
|
||||
machineDisplayInputID = playerController.machineInputID;
|
||||
}
|
||||
else if (playerController.machineInputID.Length > playerController.stateManager.WorldName.Length)
|
||||
else if (playerController.machineInputID.Length > playerController.stateManager.worldName.Length)
|
||||
{
|
||||
machineDisplayInputID = playerController.machineInputID.Substring(playerController.stateManager.WorldName.Length);
|
||||
machineDisplayInputID = playerController.machineInputID.Substring(playerController.stateManager.worldName.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -87,9 +83,9 @@ public class InfoHUD : MonoBehaviour
|
||||
{
|
||||
machineDisplayInputID2 = playerController.machineInputID2;
|
||||
}
|
||||
else if (playerController.machineInputID2.Length > playerController.stateManager.WorldName.Length)
|
||||
else if (playerController.machineInputID2.Length > playerController.stateManager.worldName.Length)
|
||||
{
|
||||
machineDisplayInputID2 = playerController.machineInputID2.Substring(playerController.stateManager.WorldName.Length);
|
||||
machineDisplayInputID2 = playerController.machineInputID2.Substring(playerController.stateManager.worldName.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -100,9 +96,9 @@ public class InfoHUD : MonoBehaviour
|
||||
{
|
||||
machineDisplayOutputID = playerController.machineOutputID;
|
||||
}
|
||||
else if (playerController.machineOutputID.Length > playerController.stateManager.WorldName.Length)
|
||||
else if (playerController.machineOutputID.Length > playerController.stateManager.worldName.Length)
|
||||
{
|
||||
machineDisplayOutputID = playerController.machineOutputID.Substring(playerController.stateManager.WorldName.Length);
|
||||
machineDisplayOutputID = playerController.machineOutputID.Substring(playerController.stateManager.worldName.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -113,9 +109,9 @@ public class InfoHUD : MonoBehaviour
|
||||
{
|
||||
machineDisplayOutputID2 = playerController.machineOutputID2;
|
||||
}
|
||||
else if (playerController.machineOutputID2.Length > playerController.stateManager.WorldName.Length)
|
||||
else if (playerController.machineOutputID2.Length > playerController.stateManager.worldName.Length)
|
||||
{
|
||||
machineDisplayOutputID2 = playerController.machineOutputID2.Substring(playerController.stateManager.WorldName.Length);
|
||||
machineDisplayOutputID2 = playerController.machineOutputID2.Substring(playerController.stateManager.worldName.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -141,6 +137,18 @@ public class InfoHUD : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.messageRect, "Storage Container" + "\nPress E to open." + "\nPress F to Collect.");
|
||||
}
|
||||
}
|
||||
else if (obj.GetComponent<NetworkPlayer>() != null)
|
||||
{
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 16;
|
||||
GUIContent content = new GUIContent(obj.name);
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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, obj.name);
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
else if (obj.GetComponent<DarkMatter>() != null || obj.GetComponent<UniversalResource>() != null)
|
||||
{
|
||||
string resourceName = obj.GetComponent<DarkMatter>() != null ? "Dark Matter" : obj.GetComponent<UniversalResource>().type;
|
||||
@ -150,7 +158,7 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (Screen.height - 70) - (size.y / 2), size.x, size.y);
|
||||
GUI.Label(resourceInfoRect, resourceName);
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -162,12 +170,12 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -179,12 +187,12 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -196,12 +204,12 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -213,12 +221,30 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
else if (obj.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
string blockName = obj.GetComponent<ModBlock>().blockName;
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 16;
|
||||
GUIContent content = new GUIContent(blockName);
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
Vector2 size = style.CalcSize(content);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (Screen.height - 70) - (size.y / 2), size.x, size.y);
|
||||
GUI.Label(resourceInfoRect, blockName);
|
||||
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 B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -226,9 +252,9 @@ public class InfoHUD : MonoBehaviour
|
||||
{
|
||||
GUI.Label(guiCoordinates.messageRect, "\nElectric Light" + "\nPress F to Collect.");
|
||||
}
|
||||
else if (obj.GetComponent<AirLock>() != null)
|
||||
else if (obj.GetComponent<Door>() != null)
|
||||
{
|
||||
GUI.Label(guiCoordinates.messageRect, "Quantum Hatchway" + "\nPress E to interact." + "\nPress F to Collect.");
|
||||
GUI.Label(guiCoordinates.messageRect, obj.GetComponent<Door>().type + "\nPress E to operate." + "\nPress Ctrl+E to edit." + "\nPress F to Collect.");
|
||||
}
|
||||
else if (obj.GetComponent<StorageComputer>() != null)
|
||||
{
|
||||
@ -735,12 +761,12 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -752,12 +778,12 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -769,12 +795,12 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
@ -786,12 +812,40 @@ public class InfoHUD : MonoBehaviour
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
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);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (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.Label(guiCoordinates.buildInfoRect, "Press F to remove blocks.\nPress B to add blocks.\nPress B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
if (obj.name.Equals("modBlockHolder(Clone)"))
|
||||
{
|
||||
string blockType = "Mod";
|
||||
Transform[] transforms = obj.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform t in transforms)
|
||||
{
|
||||
ModBlock modBlock = t.gameObject.GetComponentInChildren<ModBlock>();
|
||||
if (modBlock != null)
|
||||
{
|
||||
blockType = modBlock.blockName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 16;
|
||||
GUIContent content = new GUIContent(blockType);
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
Vector2 size = style.CalcSize(content);
|
||||
Rect resourceInfoRect = new Rect((Screen.width / 2) - (size.x / 2.1f), (Screen.height - 70) - (size.y / 2), size.x, size.y);
|
||||
GUI.Label(resourceInfoRect, blockType);
|
||||
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 B to stop building.");
|
||||
}
|
||||
GUI.skin.label.fontSize = f;
|
||||
}
|
||||
|
@ -15,14 +15,9 @@ public class InputManager
|
||||
}
|
||||
|
||||
//! Returns true if the player's current build type is a standard block.
|
||||
private bool PlacingStandardBlock()
|
||||
private bool PlacingStandardBlock(string type)
|
||||
{
|
||||
return playerController.buildType.Equals("Glass Block")
|
||||
|| playerController.buildType.Equals("Brick")
|
||||
|| playerController.buildType.Equals("Iron Block")
|
||||
|| playerController.buildType.Equals("Steel Block")
|
||||
|| playerController.buildType.Equals("Steel Ramp")
|
||||
|| playerController.buildType.Equals("Iron Ramp");
|
||||
return playerController.GetComponent<BuildController>().blockDictionary.blockDictionary.ContainsKey(type);
|
||||
}
|
||||
|
||||
//! Recieves all actions from cInput.
|
||||
@ -189,7 +184,7 @@ public class InputManager
|
||||
}
|
||||
|
||||
// BUILD MULTIPLIER
|
||||
if (playerController.building == true && PlacingStandardBlock())
|
||||
if (playerController.building == true && PlacingStandardBlock(playerController.buildType))
|
||||
{
|
||||
if (cInput.GetKey("Build Amount +") && playerController.buildMultiplier < 100)
|
||||
{
|
||||
@ -201,6 +196,19 @@ public class InputManager
|
||||
}
|
||||
}
|
||||
|
||||
// MANUAL BUILD AMOUNT SELECTION
|
||||
if (cInput.GetKeyDown("Build Amount"))
|
||||
{
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
playerController.buildAmountGUIopen = !playerController.buildAmountGUIopen;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.buildAmountGUIopen = false;
|
||||
}
|
||||
}
|
||||
|
||||
// SELECTING CURRENT BLOCK TO BUILD WITH
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
@ -230,10 +238,21 @@ public class InputManager
|
||||
{
|
||||
if (playerController.building == true)
|
||||
{
|
||||
playerController.buildObject.transform.Rotate(playerController.buildObject.transform.up * 90);
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.PlayButtonSound();
|
||||
Vector3 buildObjectForward = playerController.buildObject.transform.forward;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
playerController.buildObject.transform.Rotate(Vector3.right * 90);
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
else if (buildObjectForward != Vector3.up && buildObjectForward != -Vector3.up)
|
||||
{
|
||||
playerController.buildObject.transform.Rotate(Vector3.up * 90);
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.PlayMissingItemsSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,16 +270,16 @@ public class InputManager
|
||||
playerController.autoAxisMessage = true;
|
||||
}
|
||||
|
||||
// IF THE PLAYER HAS SELECTED AN ITEM AND HAS THAT ITEM IN THE INVENTORY, BEGIN BUILDING ON KEY PRESS
|
||||
if (cInput.GetKeyDown("Build"))
|
||||
// DUPLICATE BLOCK REMOVAL
|
||||
if (cInput.GetKeyDown("Undo"))
|
||||
{
|
||||
actionManager.StartBuildMode();
|
||||
actionManager.Undo();
|
||||
}
|
||||
|
||||
// CANCEL BUILDING ON KEY PRESS
|
||||
if (cInput.GetKeyDown("Stop Building"))
|
||||
// TOGGLE BUILDING MODE
|
||||
if (cInput.GetKeyDown("Build Mode"))
|
||||
{
|
||||
actionManager.StopBuilding();
|
||||
actionManager.ToggleBuilding();
|
||||
}
|
||||
|
||||
// ACTIVATE INVENTORY GUI ON KEY PRESS
|
||||
@ -312,9 +331,23 @@ public class InputManager
|
||||
playerController.paintGunActive = false;
|
||||
playerController.paintColorSelected = false;
|
||||
}
|
||||
else if (playerController.buildAmountGUIopen == true)
|
||||
{
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
playerController.buildAmountGUIopen = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
else if (playerController.doorGUIopen == true)
|
||||
{
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
playerController.doorGUIopen = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
else if (playerController.escapeMenuOpen == false)
|
||||
{
|
||||
playerController.requestedEscapeMenu = true;
|
||||
playerController.OpenEscapeMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Net;
|
||||
|
||||
public class InteractionController : MonoBehaviour
|
||||
{
|
||||
private PlayerController playerController;
|
||||
private MachineInteraction machineInteraction;
|
||||
private StorageInteraction storageInteraction;
|
||||
private BlockInteraction blockInteraction;
|
||||
public BlockInteraction blockInteraction;
|
||||
public Coroutine paintingCoroutine;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
@ -24,13 +25,13 @@ public class InteractionController : MonoBehaviour
|
||||
if (!playerController.stateManager.Busy())
|
||||
{
|
||||
// Raycast and associated data for interacting with machines and other objects.
|
||||
float range = playerController.gameManager.chunkSize - 40;
|
||||
float range = playerController.gameManager.chunkSize * 0.75f;
|
||||
Transform camPos = Camera.main.gameObject.transform;
|
||||
if (Physics.Raycast(camPos.position, camPos.forward, out RaycastHit hit, range))
|
||||
{
|
||||
float distance = Vector3.Distance(camPos.position, hit.point);
|
||||
GameObject obj = hit.collider.gameObject;
|
||||
if (GuiFree() && !IsResource(obj))
|
||||
if (GuiFree() && !IsNonInteractive(obj))
|
||||
{
|
||||
playerController.objectInSight = obj;
|
||||
if (IsStorageContainer(obj) && distance <= 40)
|
||||
@ -121,9 +122,9 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
machineInteraction.InteractWithElectricLight();
|
||||
}
|
||||
else if (obj.GetComponent<AirLock>() != null && distance <= 40)
|
||||
else if (obj.GetComponent<Door>() != null && distance <= 40)
|
||||
{
|
||||
machineInteraction.InteractWithAirLock();
|
||||
machineInteraction.InteractWithDoor();
|
||||
}
|
||||
else if (obj.GetComponent<ModMachine>() != null && distance <= 40)
|
||||
{
|
||||
@ -145,6 +146,10 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
blockInteraction.InteractWithBricks();
|
||||
}
|
||||
else if (obj.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
blockInteraction.InteractWithModBlock(obj.GetComponent<ModBlock>().blockName);
|
||||
}
|
||||
else if (obj.tag.Equals("CombinedMesh"))
|
||||
{
|
||||
blockInteraction.InteractWithCombinedMesh();
|
||||
@ -154,7 +159,7 @@ public class InteractionController : MonoBehaviour
|
||||
EndInteraction();
|
||||
}
|
||||
}
|
||||
else if (GuiFree() && distance <= 40 && IsResource(obj))
|
||||
else if (GuiFree() && distance <= 40 && IsNonInteractive(obj))
|
||||
{
|
||||
playerController.objectInSight = obj;
|
||||
}
|
||||
@ -179,14 +184,12 @@ public class InteractionController : MonoBehaviour
|
||||
&& playerController.marketGUIopen == false;
|
||||
}
|
||||
|
||||
//! Returns true if the object in question is a resource node.
|
||||
private Boolean IsResource(GameObject obj)
|
||||
//! Returns true if the object in question cannot be interacted with.
|
||||
private bool IsNonInteractive(GameObject obj)
|
||||
{
|
||||
if (obj.GetComponent<DarkMatter>() != null || obj.GetComponent<UniversalResource>() != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.GetComponent<DarkMatter>() != null
|
||||
|| obj.GetComponent<UniversalResource>() != null
|
||||
|| obj.GetComponent<NetworkPlayer>() != null;
|
||||
}
|
||||
|
||||
//! Returns true if the object in question is a storage container.
|
||||
@ -214,8 +217,13 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
playerController.playerInventory.AddItem(type, 1);
|
||||
Destroy(playerController.objectInSight);
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.PlayCraftingSound();
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
Vector3 pos = playerController.objectInSight.transform.position;
|
||||
Quaternion rot = playerController.objectInSight.transform.rotation;
|
||||
UpdateNetwork(1, type, pos, rot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -229,24 +237,6 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
if (playerController.building == true)
|
||||
{
|
||||
GameManager manager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
if (manager.working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
manager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
playerController.storageGUIopen = false;
|
||||
@ -265,6 +255,18 @@ public class InteractionController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends instantiated block info to the server in multiplayer games.
|
||||
private void UpdateNetwork(int destroy, string type, Vector3 pos, Quaternion rot)
|
||||
{
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
Uri uri = new Uri(PlayerPrefs.GetString("serverURL") + "/blocks");
|
||||
string position = Mathf.Round(pos.x) + "," + Mathf.Round(pos.y) + "," + Mathf.Round(pos.z);
|
||||
string rotation = Mathf.Round(rot.x) + "," + Mathf.Round(rot.y) + "," + Mathf.Round(rot.z) + "," + Mathf.Round(rot.w);
|
||||
client.UploadStringAsync(uri, "POST", "@" + destroy + ":" + type + ":" + position + ":" + rotation);
|
||||
}
|
||||
}
|
||||
|
||||
//! Called when the player is no longer looking at any interactive objects.
|
||||
private void EndInteraction()
|
||||
{
|
||||
|
@ -50,6 +50,10 @@ public class InventoryGUI : MonoBehaviour
|
||||
{
|
||||
gameObject.GetComponent<MSCameraController>().enabled = false;
|
||||
GUI.DrawTexture(guiCoordinates.inventoryBackgroundRect, textureDictionary.dictionary["Container Background"]);
|
||||
GUI.DrawTexture(guiCoordinates.inventoryDropSlotRect, textureDictionary.dictionary["Shaded Box"]);
|
||||
GUI.Label(guiCoordinates.inventoryDropSlotLabelRect, "DROP");
|
||||
GUI.DrawTexture(guiCoordinates.inventoryTrashSlotRect, textureDictionary.dictionary["Shaded Box"]);
|
||||
GUI.Label(guiCoordinates.inventoryTrashSlotLabelRect, "TRASH");
|
||||
|
||||
// Inventory item drawing.
|
||||
int inventorySlotNumber = 0;
|
||||
@ -57,7 +61,14 @@ public class InventoryGUI : MonoBehaviour
|
||||
{
|
||||
if (!slot.typeInSlot.Equals("") && !slot.typeInSlot.Equals("nothing"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.inventorySlotRects[inventorySlotNumber], textureDictionary.dictionary[slot.typeInSlot]);
|
||||
if (textureDictionary.dictionary.ContainsKey(slot.typeInSlot+"_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.inventorySlotRects[inventorySlotNumber], textureDictionary.dictionary[slot.typeInSlot+"_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.inventorySlotRects[inventorySlotNumber], textureDictionary.dictionary[slot.typeInSlot]);
|
||||
}
|
||||
}
|
||||
if (slot.amountInSlot != 0)
|
||||
{
|
||||
@ -78,7 +89,14 @@ public class InventoryGUI : MonoBehaviour
|
||||
{
|
||||
if (!slot.typeInSlot.Equals("") && !slot.typeInSlot.Equals("nothing"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.storageInventorySlotRects[storageInventorySlotNumber], textureDictionary.dictionary[slot.typeInSlot]);
|
||||
if (textureDictionary.dictionary.ContainsKey(slot.typeInSlot+"_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.storageInventorySlotRects[storageInventorySlotNumber], textureDictionary.dictionary[slot.typeInSlot+"_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.storageInventorySlotRects[storageInventorySlotNumber], textureDictionary.dictionary[slot.typeInSlot]);
|
||||
}
|
||||
}
|
||||
if (slot.amountInSlot != 0)
|
||||
{
|
||||
@ -103,7 +121,7 @@ public class InventoryGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.inventoryMesageRect, dragSlot.typeInSlot);
|
||||
if (Input.GetKeyDown(KeyCode.Mouse0))
|
||||
{
|
||||
inventoryHandler.DragItemFromSlot(dragSlot, playerController.storageInventory);
|
||||
inventoryHandler.DragItemFromSlot(inventoryDragSlot, dragSlot, playerController.storageInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +149,7 @@ public class InventoryGUI : MonoBehaviour
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Mouse0))
|
||||
{
|
||||
inventoryHandler.DragItemFromSlot(dragSlot, playerInventory);
|
||||
inventoryHandler.DragItemFromSlot(storageInventoryDragSlot, dragSlot, playerInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,12 +163,20 @@ public class InventoryGUI : MonoBehaviour
|
||||
float orgX = Event.current.mousePosition.x - ScreenWidth * 0.0145f;
|
||||
float orgY = Event.current.mousePosition.y - ScreenHeight * 0.03f;
|
||||
Rect mouseRect = new Rect(orgX, orgY, ScreenWidth * 0.029f, ScreenHeight * 0.06f);
|
||||
GUI.DrawTexture(mouseRect, textureDictionary.dictionary[inventoryHandler.itemToDrag]);
|
||||
if (textureDictionary.dictionary.ContainsKey(inventoryHandler.itemToDrag+"_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(mouseRect, textureDictionary.dictionary[inventoryHandler.itemToDrag+"_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(mouseRect, textureDictionary.dictionary[inventoryHandler.itemToDrag]);
|
||||
}
|
||||
if (Input.GetKeyUp(KeyCode.Mouse0))
|
||||
{
|
||||
inventoryHandler.DropItemInSlot(mousePos, playerController.storageGUIopen);
|
||||
}
|
||||
}
|
||||
|
||||
// // // // // END DRAG AND DROP // // // // //
|
||||
|
||||
// Cycling between inventories connected to a storage computer.
|
||||
|
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Net;
|
||||
|
||||
public class InventoryHandler
|
||||
{
|
||||
@ -8,6 +9,7 @@ public class InventoryHandler
|
||||
private GuiCoordinates guiCoordinates;
|
||||
public string itemToDrag;
|
||||
private int amountToDrag;
|
||||
private int dragSlotIndex;
|
||||
|
||||
//! This class handles inventory related functions that don't directly require the OnGUI method.
|
||||
public InventoryHandler(PlayerController playerController, InventoryManager playerInventory)
|
||||
@ -63,21 +65,50 @@ public class InventoryHandler
|
||||
}
|
||||
|
||||
//! Begins dragging an item from an inventory slot.
|
||||
public void DragItemFromSlot(InventorySlot dragSlot, InventoryManager destination)
|
||||
public void DragItemFromSlot(int index, InventorySlot dragSlot, InventoryManager destination)
|
||||
{
|
||||
bool flag = false;
|
||||
dragSlotIndex = index;
|
||||
if (playerController.storageGUIopen == true)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
flag = true;
|
||||
foreach (InventorySlot slot in destination.inventory)
|
||||
for (int i = 0; i < destination.inventory.Length; i++)
|
||||
{
|
||||
InventorySlot slot = destination.inventory[i];
|
||||
if (CanTransfer(dragSlot, slot))
|
||||
{
|
||||
destination.AddItem(dragSlot.typeInSlot, dragSlot.amountInSlot);
|
||||
dragSlot.typeInSlot = "nothing";
|
||||
dragSlot.amountInSlot = 0;
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (destination == playerController.playerInventory)
|
||||
{
|
||||
Vector3 pos = playerController.storageInventory.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(PlayerPrefs.GetString("serverURL") + "/storage");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":" + index + ";" + dragSlot.typeInSlot + "=" + dragSlot.amountInSlot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 pos = destination.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(PlayerPrefs.GetString("serverURL") + "/storage");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":"+i+";"+slot.typeInSlot+"="+slot.amountInSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,6 +140,21 @@ public class InventoryHandler
|
||||
public void DropItemInSlot(Vector2 mousePos, bool usingContainer)
|
||||
{
|
||||
playerController.draggingItem = false;
|
||||
|
||||
if (guiCoordinates.inventoryDropSlotRect.Contains(mousePos))
|
||||
{
|
||||
playerController.DropItem(slotDraggingFrom);
|
||||
return;
|
||||
}
|
||||
|
||||
if (guiCoordinates.inventoryTrashSlotRect.Contains(mousePos))
|
||||
{
|
||||
slotDraggingFrom.amountInSlot = 0;
|
||||
slotDraggingFrom.typeInSlot = "nothing";
|
||||
playerController.PlayCraftingSound();
|
||||
return;
|
||||
}
|
||||
|
||||
int inventoryDropSlot = 0;
|
||||
foreach (Rect rect in guiCoordinates.inventorySlotRects)
|
||||
{
|
||||
@ -134,6 +180,18 @@ public class InventoryHandler
|
||||
dropSlot.typeInSlot = itemToDrag;
|
||||
dropSlot.amountInSlot = amountToDrag;
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
Vector3 pos = playerController.storageInventory.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(PlayerPrefs.GetString("serverURL") + "/storage");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":"+dragSlotIndex+";"+slotDraggingFrom.typeInSlot+"="+slotDraggingFrom.amountInSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
inventoryDropSlot++;
|
||||
}
|
||||
@ -165,6 +223,18 @@ public class InventoryHandler
|
||||
dropSlot.typeInSlot = itemToDrag;
|
||||
dropSlot.amountInSlot = amountToDrag;
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true && PlayerPrefsX.GetPersistentBool("hosting") == false)
|
||||
{
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(PlayerPrefs.GetString("serverURL") + "/storage");
|
||||
Vector3 pos = playerController.storageInventory.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":"+storageInventoryDropSlot+";"+dropSlot.typeInSlot+"="+dropSlot.amountInSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
storageInventoryDropSlot++;
|
||||
}
|
||||
|
@ -22,34 +22,37 @@ public class InventoryManager : MonoBehaviour
|
||||
{
|
||||
if (!stateManager.Busy())
|
||||
{
|
||||
if (ID != "unassigned" && initialized == false)
|
||||
{
|
||||
inventory = new InventorySlot[16];
|
||||
int count = 0;
|
||||
while (count <= 15)
|
||||
if (ID != "unassigned")
|
||||
{
|
||||
if (initialized == false)
|
||||
{
|
||||
inventory[count] = gameObject.AddComponent<InventorySlot>();
|
||||
string countType = FileBasedPrefs.GetString(stateManager.WorldName + "inventory" + ID + "slot" + count + "type");
|
||||
if (!countType.Equals(""))
|
||||
{
|
||||
inventory[count].typeInSlot = FileBasedPrefs.GetString(stateManager.WorldName + "inventory" + ID + "slot" + count + "type");
|
||||
inventory[count].amountInSlot = FileBasedPrefs.GetInt(stateManager.WorldName + "inventory" + ID + "slot" + count + "amount");
|
||||
}
|
||||
count++;
|
||||
inventory = new InventorySlot[16];
|
||||
int count = 0;
|
||||
while (count <= 15)
|
||||
{
|
||||
inventory[count] = gameObject.AddComponent<InventorySlot>();
|
||||
string countType = FileBasedPrefs.GetString(stateManager.worldName + "inventory" + ID + "slot" + count + "type");
|
||||
if (!countType.Equals(""))
|
||||
{
|
||||
inventory[count].typeInSlot = FileBasedPrefs.GetString(stateManager.worldName + "inventory" + ID + "slot" + count + "type");
|
||||
inventory[count].amountInSlot = FileBasedPrefs.GetInt(stateManager.worldName + "inventory" + ID + "slot" + count + "amount");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
originalID = ID;
|
||||
initialized = true;
|
||||
maxStackSize = ID.Equals("Rocket") ? 100000 : 1000;
|
||||
}
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
if (IsStorageContainer())
|
||||
{
|
||||
GetComponent<PhysicsHandler>().UpdatePhysics();
|
||||
}
|
||||
updateTick = 0;
|
||||
}
|
||||
originalID = ID;
|
||||
initialized = true;
|
||||
maxStackSize = ID.Equals("Rocket") ? 100000 : 1000;
|
||||
}
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
if (IsStorageContainer())
|
||||
{
|
||||
GetComponent<PhysicsHandler>().UpdatePhysics();
|
||||
}
|
||||
updateTick = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,8 +77,8 @@ public class InventoryManager : MonoBehaviour
|
||||
int originalCount = 0;
|
||||
while (originalCount <= 15)
|
||||
{
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + "inventory" + originalID + "slot" + originalCount + "type", "nothing");
|
||||
FileBasedPrefs.SetInt(stateManager.WorldName + "inventory" + originalID + "slot" + originalCount + "amount", 0);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + "inventory" + originalID + "slot" + originalCount + "type", "nothing");
|
||||
FileBasedPrefs.SetInt(stateManager.worldName + "inventory" + originalID + "slot" + originalCount + "amount", 0);
|
||||
originalCount++;
|
||||
}
|
||||
originalID = ID;
|
||||
@ -83,8 +86,8 @@ public class InventoryManager : MonoBehaviour
|
||||
int count = 0;
|
||||
while (count <= 15)
|
||||
{
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + "inventory" + ID + "slot" + count + "type", inventory[count].typeInSlot);
|
||||
FileBasedPrefs.SetInt(stateManager.WorldName + "inventory" + ID + "slot" + count + "amount", inventory[count].amountInSlot);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + "inventory" + ID + "slot" + count + "type", inventory[count].typeInSlot);
|
||||
FileBasedPrefs.SetInt(stateManager.worldName + "inventory" + ID + "slot" + count + "amount", inventory[count].amountInSlot);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ public class IronBlock : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
54
Item.cs
Normal file
54
Item.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Item : MonoBehaviour
|
||||
{
|
||||
public string type = "nothing";
|
||||
public int amount;
|
||||
public GameObject billboard;
|
||||
private StateManager stateManager;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
billboard.GetComponent<Renderer>().enabled = false;
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (!stateManager.Busy())
|
||||
{
|
||||
if (type != "nothing")
|
||||
{
|
||||
if (GetComponent<TextureDictionary>() != null)
|
||||
{
|
||||
if (GetComponent<TextureDictionary>().dictionary != null)
|
||||
{
|
||||
if (GetComponent<TextureDictionary>().dictionary.ContainsKey(type + "_Icon"))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = GetComponent<TextureDictionary>().dictionary[type + "_Icon"];
|
||||
billboard.GetComponent<Renderer>().enabled = true;
|
||||
}
|
||||
else if (GetComponent<TextureDictionary>().dictionary.ContainsKey(type))
|
||||
{
|
||||
billboard.GetComponent<Renderer>().material.mainTexture = GetComponent<TextureDictionary>().dictionary[type];
|
||||
billboard.GetComponent<Renderer>().enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform.Rotate(transform.up * 100 * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
//! Items fall to the ground faster than gravity would allow otherwise.
|
||||
public void FixedUpdate()
|
||||
{
|
||||
if (!Physics.Raycast(transform.position, -Vector3.up, out RaycastHit hit, 1))
|
||||
{
|
||||
GetComponent<Rigidbody>().AddForce(-Vector3.up * 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ public class LaserController
|
||||
//! Called when the player's laser cannon shoots something.
|
||||
public void HitTarget(GameObject target,RaycastHit hit)
|
||||
{
|
||||
string objName;
|
||||
|
||||
if (target.GetComponent<Meteor>() != null)
|
||||
{
|
||||
target.GetComponent<Meteor>().Explode();
|
||||
@ -33,10 +35,20 @@ public class LaserController
|
||||
|
||||
if (target.tag.Equals("Built"))
|
||||
{
|
||||
if (target.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
objName = target.GetComponent<ModBlock>().blockName;
|
||||
}
|
||||
else
|
||||
{
|
||||
objName = hit.collider.gameObject.name.Split('(')[0];
|
||||
}
|
||||
|
||||
if (target.GetComponent<PhysicsHandler>() != null)
|
||||
{
|
||||
target.GetComponent<PhysicsHandler>().Explode();
|
||||
}
|
||||
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
@ -44,10 +56,10 @@ public class LaserController
|
||||
playerController.destructionMessageActive = true;
|
||||
playerController.currentTabletMessage = "";
|
||||
}
|
||||
string objName = hit.collider.gameObject.name.Split('(')[0];
|
||||
playerController.currentTabletMessage += "ALERT: " + objName + " destroyed by your laser cannon!\n";
|
||||
playerController.destructionMessageCount += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (target.tag.Equals("CombinedMesh"))
|
||||
@ -78,7 +90,7 @@ public class LaserController
|
||||
{
|
||||
if (chanceOfDestruction > 50)
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, "brick",false);
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, "brick", false);
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
@ -99,7 +111,7 @@ public class LaserController
|
||||
{
|
||||
if (chanceOfDestruction > 75)
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, "iron",false);
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, "iron", false);
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
@ -119,7 +131,7 @@ public class LaserController
|
||||
{
|
||||
if (chanceOfDestruction > 99)
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, "steel",false);
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, "steel", false);
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
@ -133,6 +145,48 @@ public class LaserController
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("modBlockHolder(Clone)"))
|
||||
{
|
||||
string type = "all";
|
||||
int toughness = 75;
|
||||
|
||||
Transform[] transforms = hit.collider.gameObject.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform t in transforms)
|
||||
{
|
||||
if (t.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
type = t.GetComponent<ModBlock>().blockName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type.ToUpper().Contains("GLASS"))
|
||||
{
|
||||
toughness = 25;
|
||||
}
|
||||
else if (type.ToUpper().Contains("STEEL"))
|
||||
{
|
||||
toughness = 99;
|
||||
}
|
||||
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
if (chanceOfDestruction > toughness)
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(hit.point, type, false);
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
{
|
||||
playerController.destructionMessageActive = true;
|
||||
playerController.currentTabletMessage = "";
|
||||
}
|
||||
playerController.currentTabletMessage += "ALERT: " + type + " was hit by your laser cannon!\n";
|
||||
playerController.destructionMessageCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
220
MachineGUI.cs
220
MachineGUI.cs
@ -5,6 +5,8 @@ public class MachineGUI : MonoBehaviour
|
||||
private PlayerController playerController;
|
||||
private GuiCoordinates guiCoordinates;
|
||||
private TextureDictionary textureDictionary;
|
||||
private Coroutine updateNetworkConduitCoroutine;
|
||||
private Coroutine updateNetworkMachineCoroutine;
|
||||
private bool hubStopWindowOpen;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
@ -42,6 +44,7 @@ public class MachineGUI : MonoBehaviour
|
||||
|
||||
if (obj.GetComponent<PowerConduit>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
PowerConduit powerConduit = obj.GetComponent<PowerConduit>();
|
||||
if (powerConduit.connectionFailed == false)
|
||||
{
|
||||
@ -72,15 +75,30 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
powerConduit.connectionAttempts = 0;
|
||||
powerConduit.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
bool rangeDeSync = powerConduit.range != playerController.networkedConduitRange;
|
||||
bool outputDeSync = powerConduit.dualOutput != playerController.networkedDualPower;
|
||||
if (rangeDeSync || outputDeSync || netFlag)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = powerConduit.gameObject.transform.position;
|
||||
updateNetworkConduitCoroutine = StartCoroutine(net.SendPowerData(location,powerConduit.range,powerConduit.dualOutput));
|
||||
playerController.networkedConduitRange = powerConduit.range;
|
||||
playerController.networkedDualPower = powerConduit.dualOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<RailCartHub>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
RailCartHub hub = obj.GetComponent<RailCartHub>();
|
||||
if (hub.connectionFailed == false)
|
||||
{
|
||||
@ -148,15 +166,32 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
hub.connectionAttempts = 0;
|
||||
hub.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
bool rangeDeSync = hub.range != playerController.networkedHubRange;
|
||||
bool stopDeSync = hub.stop != playerController.networkedHubStop;
|
||||
bool timeDeSync = (int)hub.stopTime != (int)playerController.networkedHubStopTime;
|
||||
if (rangeDeSync || stopDeSync || timeDeSync || netFlag)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = hub.gameObject.transform.position;
|
||||
updateNetworkConduitCoroutine = StartCoroutine(net.SendHubData(location,hub.range,hub.stop,hub.stopTime));
|
||||
playerController.networkedHubRange = hub.range;
|
||||
playerController.networkedHubStop = hub.stop;
|
||||
playerController.networkedHubStopTime = hub.stopTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<Retriever>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
Retriever retriever = obj.GetComponent<Retriever>();
|
||||
if (retriever.connectionFailed == false)
|
||||
{
|
||||
@ -192,15 +227,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
retriever.connectionAttempts = 0;
|
||||
retriever.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (retriever.speed != playerController.networkedConduitRange || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = retriever.gameObject.transform.position;
|
||||
updateNetworkConduitCoroutine = StartCoroutine(net.SendConduitData(location,retriever.speed));
|
||||
playerController.networkedConduitRange = retriever.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<AutoCrafter>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
AutoCrafter autoCrafter = obj.GetComponent<AutoCrafter>();
|
||||
if (autoCrafter.connectionFailed == false)
|
||||
{
|
||||
@ -236,15 +283,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
autoCrafter.connectionAttempts = 0;
|
||||
autoCrafter.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (autoCrafter.speed != playerController.networkedConduitRange || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = autoCrafter.gameObject.transform.position;
|
||||
updateNetworkConduitCoroutine = StartCoroutine(net.SendConduitData(location,autoCrafter.speed));
|
||||
playerController.networkedConduitRange = autoCrafter.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<UniversalConduit>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
UniversalConduit conduit = obj.GetComponent<UniversalConduit>();
|
||||
if (conduit.connectionFailed == false)
|
||||
@ -257,15 +316,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
conduit.connectionAttempts = 0;
|
||||
conduit.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (conduit.range != playerController.networkedConduitRange || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = conduit.gameObject.transform.position;
|
||||
updateNetworkConduitCoroutine = StartCoroutine(net.SendConduitData(location,conduit.range));
|
||||
playerController.networkedConduitRange = conduit.range;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<DarkMatterConduit>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
DarkMatterConduit conduit = obj.GetComponent<DarkMatterConduit>();
|
||||
if (conduit.connectionFailed == false)
|
||||
@ -278,15 +349,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
conduit.connectionAttempts = 0;
|
||||
conduit.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (conduit.range != playerController.networkedConduitRange || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = conduit.gameObject.transform.position;
|
||||
updateNetworkConduitCoroutine = StartCoroutine(net.SendConduitData(location,conduit.range));
|
||||
playerController.networkedConduitRange = conduit.range;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<HeatExchanger>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
HeatExchanger hx = obj.GetComponent<HeatExchanger>();
|
||||
if (hx.inputObject != null)
|
||||
@ -303,11 +386,22 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
hx.connectionAttempts = 0;
|
||||
hx.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (hx.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = hx.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,hx.speed));
|
||||
playerController.networkedMachineSpeed = hx.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -353,10 +447,21 @@ public class MachineGUI : MonoBehaviour
|
||||
{
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "No Power");
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (auger.speed != playerController.networkedMachineSpeed)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = auger.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,auger.speed));
|
||||
playerController.networkedMachineSpeed = auger.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<UniversalExtractor>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
UniversalExtractor extractor = obj.GetComponent<UniversalExtractor>();
|
||||
if (extractor.connectionFailed == false)
|
||||
@ -377,14 +482,26 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
extractor.connectionAttempts = 0;
|
||||
extractor.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (extractor.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = extractor.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,extractor.speed));
|
||||
playerController.networkedMachineSpeed = extractor.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (obj.GetComponent<DarkMatterCollector>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
DarkMatterCollector collector = obj.GetComponent<DarkMatterCollector>();
|
||||
if (collector.connectionFailed == false)
|
||||
@ -404,15 +521,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
collector.connectionAttempts = 0;
|
||||
collector.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (collector.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = collector.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,collector.speed));
|
||||
playerController.networkedMachineSpeed = collector.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<Smelter>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
Smelter smelter = obj.GetComponent<Smelter>();
|
||||
if (smelter.connectionFailed == false)
|
||||
@ -433,15 +562,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
smelter.connectionAttempts = 0;
|
||||
smelter.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (smelter.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = smelter.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,smelter.speed));
|
||||
playerController.networkedMachineSpeed = smelter.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<AlloySmelter>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
AlloySmelter alloySmelter = obj.GetComponent<AlloySmelter>();
|
||||
if (alloySmelter.connectionFailed == false)
|
||||
@ -461,15 +602,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
alloySmelter.connectionAttempts = 0;
|
||||
alloySmelter.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (alloySmelter.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = alloySmelter.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,alloySmelter.speed));
|
||||
playerController.networkedMachineSpeed = alloySmelter.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<Press>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
Press press = obj.GetComponent<Press>();
|
||||
if (press.connectionFailed == false)
|
||||
@ -489,15 +642,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
press.connectionAttempts = 0;
|
||||
press.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (press.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = press.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,press.speed));
|
||||
playerController.networkedMachineSpeed = press.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<Extruder>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
Extruder extruder = obj.GetComponent<Extruder>();
|
||||
if (extruder.connectionFailed == false)
|
||||
@ -517,15 +682,27 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
extruder.connectionAttempts = 0;
|
||||
extruder.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (extruder.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = extruder.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,extruder.speed));
|
||||
playerController.networkedMachineSpeed = extruder.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<ModMachine>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
ModMachine modMachine = obj.GetComponent<ModMachine>();
|
||||
if (modMachine.connectionFailed == false)
|
||||
@ -545,11 +722,22 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
modMachine.connectionAttempts = 0;
|
||||
modMachine.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (modMachine.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = modMachine.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,modMachine.speed));
|
||||
playerController.networkedMachineSpeed = modMachine.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<Turret>() != null)
|
||||
@ -572,6 +760,16 @@ public class MachineGUI : MonoBehaviour
|
||||
{
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "No Power");
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (turret.speed != playerController.networkedMachineSpeed)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = turret.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,turret.speed));
|
||||
playerController.networkedMachineSpeed = turret.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<MissileTurret>() != null)
|
||||
@ -594,10 +792,21 @@ public class MachineGUI : MonoBehaviour
|
||||
{
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "No Power");
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (turret.speed != playerController.networkedMachineSpeed)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = turret.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,turret.speed));
|
||||
playerController.networkedMachineSpeed = turret.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.GetComponent<GearCutter>() != null)
|
||||
{
|
||||
bool netFlag = false;
|
||||
GUI.DrawTexture(guiCoordinates.speedControlBGRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GearCutter gearCutter = obj.GetComponent<GearCutter>();
|
||||
if (gearCutter.connectionFailed == false)
|
||||
@ -617,11 +826,22 @@ public class MachineGUI : MonoBehaviour
|
||||
GUI.Label(guiCoordinates.outputLabelRect, "Offline");
|
||||
if (GUI.Button(guiCoordinates.outputControlButton2Rect, "Reboot"))
|
||||
{
|
||||
netFlag = true;
|
||||
gearCutter.connectionAttempts = 0;
|
||||
gearCutter.connectionFailed = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (gearCutter.speed != playerController.networkedMachineSpeed || netFlag == true)
|
||||
{
|
||||
NetworkSend net = playerController.networkController.networkSend;
|
||||
Vector3 location = gearCutter.gameObject.transform.position;
|
||||
updateNetworkMachineCoroutine = StartCoroutine(net.SendMachineData(location,gearCutter.speed));
|
||||
playerController.networkedMachineSpeed = gearCutter.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -21,31 +21,35 @@ public class MachineInteraction
|
||||
}
|
||||
}
|
||||
|
||||
//! Called when the player is looking at a quantum hatchway.
|
||||
public void InteractWithAirLock()
|
||||
//! Called when the player is looking at a door.
|
||||
public void InteractWithDoor()
|
||||
{
|
||||
AirLock airLock = playerController.objectInSight.GetComponent<AirLock>();
|
||||
Door door = playerController.objectInSight.GetComponent<Door>();
|
||||
string doorType = playerController.objectInSight.GetComponent<Door>().type;
|
||||
playerController.doorToEdit = door;
|
||||
|
||||
if (cInput.GetKeyDown("Collect Object"))
|
||||
{
|
||||
interactionController.CollectObject("Quantum Hatchway");
|
||||
interactionController.CollectObject(doorType);
|
||||
}
|
||||
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
AirLock[] airLocks = Object.FindObjectsOfType<AirLock>();
|
||||
foreach (AirLock a in airLocks)
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Vector3.Distance(playerController.transform.position, a.transform.position) < 40)
|
||||
if (!playerController.GuiOpen())
|
||||
{
|
||||
a.ToggleOpen();
|
||||
playerController.doorGUIopen = !playerController.doorGUIopen;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.doorGUIopen = false;
|
||||
}
|
||||
}
|
||||
if (airLock.open == true)
|
||||
{
|
||||
airLock.openObject.GetComponent<AudioSource>().Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
airLock.closedObject.GetComponent<AudioSource>().Play();
|
||||
door.GetComponent<AudioSource>().Play();
|
||||
door.ToggleOpen();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,6 +141,8 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedConduitRange = powerConduit.range;
|
||||
playerController.networkedDualPower = powerConduit.dualOutput;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -158,6 +164,7 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedMachineSpeed = turret.speed;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -181,6 +188,7 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedMachineSpeed = turret.speed;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -204,6 +212,7 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedMachineSpeed = extractor.speed;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -226,6 +235,7 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedMachineSpeed = auger.speed;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -250,6 +260,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = collector.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -450,6 +461,7 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedConduitRange = conduit.range;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -528,6 +540,7 @@ public class MachineInteraction
|
||||
}
|
||||
if (cInput.GetKeyDown("Interact"))
|
||||
{
|
||||
playerController.networkedConduitRange = dmConduit.range;
|
||||
interactionController.ToggleMachineGUI();
|
||||
}
|
||||
}
|
||||
@ -571,6 +584,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = smelter.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -630,6 +644,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = alloySmelter.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -678,6 +693,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = extruder.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -726,6 +742,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = modMachine.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -822,6 +839,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = retriever.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
playerController.remoteStorageActive = false;
|
||||
}
|
||||
@ -917,6 +935,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = heatExchanger.speed;
|
||||
playerController.hxAmount = heatExchanger.amount;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
@ -966,6 +985,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = gearCutter.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -1014,6 +1034,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = press.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
}
|
||||
else
|
||||
@ -1055,6 +1076,7 @@ public class MachineInteraction
|
||||
{
|
||||
if (playerController.machineGUIopen == false)
|
||||
{
|
||||
playerController.networkedMachineSpeed = autoCrafter.speed;
|
||||
playerController.machineGUIopen = true;
|
||||
playerController.remoteStorageActive = false;
|
||||
}
|
||||
|
682
MainMenu.cs
682
MainMenu.cs
@ -3,6 +3,10 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
@ -10,36 +14,56 @@ public class MainMenu : MonoBehaviour
|
||||
public Texture2D titleTexture;
|
||||
public Texture2D title2Texture;
|
||||
public Texture2D titleTextureSD;
|
||||
public Texture2D worlListBackground;
|
||||
public Texture2D guiBackground;
|
||||
public Texture2D worldListBackground;
|
||||
public Texture2D playerModel;
|
||||
private Texture2D colorSelectTexture;
|
||||
public GameObject videoPlayer;
|
||||
public GameObject menuSoundObject;
|
||||
public GameObject ambientSoundObject;
|
||||
public bool worldSelected;
|
||||
public bool finishedLoading;
|
||||
private string worldName = "Enter World Name";
|
||||
private string worldName = "Enter world name.";
|
||||
private string username = "Enter user name.";
|
||||
private string serverURL = "Enter server IP address.";
|
||||
private string[] worlds;
|
||||
private StateManager stateManager;
|
||||
private List<string> worldList;
|
||||
private AudioSource buttonSounds;
|
||||
private AudioSource ambient;
|
||||
private int scene;
|
||||
private bool local;
|
||||
private float waitForVideoTimer;
|
||||
private bool notWideScreen;
|
||||
private bool worldSelectPrompt;
|
||||
private bool playingVideo;
|
||||
private bool hosting;
|
||||
private bool downloadPrompt;
|
||||
private bool worldNamePrompt;
|
||||
private bool deletePrompt;
|
||||
private bool escapePrompt;
|
||||
private bool multiplayerPrompt;
|
||||
private bool localPrompt;
|
||||
private bool playerColorPrompt;
|
||||
private bool userNamePrompt;
|
||||
private bool networkAddressPrompt;
|
||||
private float playerRed = 0.5f;
|
||||
private float playerGreen = 0.5f;
|
||||
private float playerBlue = 0.5f;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
worldList = new List<string>();
|
||||
colorSelectTexture = new Texture2D(512, 128);
|
||||
videoPlayer.GetComponent<VP>().PlayVideo("QE_Title.webm",true,0);
|
||||
buttonSounds = menuSoundObject.GetComponent<AudioSource>();
|
||||
ambient = ambientSoundObject.GetComponent<AudioSource>();
|
||||
ambient.Play();
|
||||
if (PlayerPrefsX.GetPersistentBool("changingWorld") == true)
|
||||
{
|
||||
stateManager.WorldName = PlayerPrefs.GetString("worldName");
|
||||
stateManager.worldName = PlayerPrefs.GetString("worldName");
|
||||
PlayerPrefs.DeleteKey("changingWorld");
|
||||
PlayerPrefs.DeleteKey("worldName");
|
||||
PlayerPrefs.Save();
|
||||
@ -48,10 +72,135 @@ public class MainMenu : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (GuiFree())
|
||||
{
|
||||
escapePrompt = !escapePrompt;
|
||||
}
|
||||
else
|
||||
{
|
||||
networkAddressPrompt = false;
|
||||
worldSelectPrompt = false;
|
||||
deletePrompt = false;
|
||||
escapePrompt = false;
|
||||
multiplayerPrompt = false;
|
||||
localPrompt = false;
|
||||
playerColorPrompt = false;
|
||||
userNamePrompt = false;
|
||||
downloadPrompt = false;
|
||||
userNamePrompt = false;
|
||||
}
|
||||
buttonSounds.Play();
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets the local address for LAN games.
|
||||
private string GetLocalAddress()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return "localhost";
|
||||
}
|
||||
string hostName = Dns.GetHostName();
|
||||
string address = Dns.GetHostEntry(hostName).AddressList[0].ToString();
|
||||
return address;
|
||||
}
|
||||
|
||||
//! Gets external IP address for online games.
|
||||
private string GetExternalAddress()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
Uri uri = new Uri("https://api.ipify.org");
|
||||
return client.DownloadString(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Starts the external server program.
|
||||
private void StartServer()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
UnityEngine.Debug.Log("Starting development server...");
|
||||
Process.Start(Application.dataPath + "/Linux_Server/qe_server", "local devel");
|
||||
}
|
||||
else if (local == true)
|
||||
{
|
||||
Process.Start(Application.dataPath + "/Linux_Server/qe_server", "local");
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start(Application.dataPath + "/Linux_Server/qe_server");
|
||||
}
|
||||
}
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
if (local == true)
|
||||
{
|
||||
Process.Start(Application.dataPath + "/Windows_Server/qe_server.exe", "local");
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start(Application.dataPath + "/Windows_Server/qe_server.exe");
|
||||
}
|
||||
}
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
if (local == true)
|
||||
{
|
||||
Process.Start(Application.dataPath + "/Mac_Server/qe_server", "local");
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start(Application.dataPath + "/Mac_Server/qe_server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Downloads saved world from server.
|
||||
private void DownloadWorld()
|
||||
{
|
||||
string savePath = Path.Combine(Application.persistentDataPath, "SaveData");
|
||||
if (Application.isEditor)
|
||||
{
|
||||
savePath = Path.Combine(Application.persistentDataPath, "Downloads");
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(savePath);
|
||||
string saveFileLocation = Path.Combine(savePath + "/" + worldName + ".sav");
|
||||
try
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
string url = PlayerPrefs.GetString("serverURL");
|
||||
client.DownloadFile(url+"/world", saveFileLocation);
|
||||
}
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
worldName = "Enter world name.";
|
||||
downloadPrompt = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(Path.Combine(savePath + "/" + worldName + ".sav")))
|
||||
{
|
||||
UnityEngine.Debug.Log("World downloaded.");
|
||||
PreStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Confirms world selection and loads the world.
|
||||
private void SelectWorld()
|
||||
{
|
||||
if (worldSelected == false && worldName != "Enter World Name")
|
||||
if (worldSelected == false && worldName != "Enter world name.")
|
||||
{
|
||||
FileBasedPrefs.SetWorldName(worldName);
|
||||
worldList = PlayerPrefsX.GetPersistentStringArray("Worlds").ToList();
|
||||
@ -60,35 +209,70 @@ public class MainMenu : MonoBehaviour
|
||||
if (!worldList.Contains(worldName))
|
||||
{
|
||||
worldList.Add(worldName);
|
||||
worldSelectPrompt = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FileBasedPrefs.GetBool(worldName + "sceneChangeRequired") == true)
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
ChangeScene();
|
||||
if (hosting == false)
|
||||
{
|
||||
DownloadWorld();
|
||||
}
|
||||
else
|
||||
{
|
||||
worldSelectPrompt = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StartGame();
|
||||
worldSelectPrompt = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
if (hosting == false)
|
||||
{
|
||||
DownloadWorld();
|
||||
}
|
||||
else
|
||||
{
|
||||
PreStart();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PreStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (worldList.Contains(worldName))
|
||||
{
|
||||
if (FileBasedPrefs.GetBool(worldName + "sceneChangeRequired") == true)
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true && hosting == false)
|
||||
{
|
||||
ChangeScene();
|
||||
DownloadWorld();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartGame();
|
||||
PreStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Called when Kepler-1625 is selected and the scene needs to be changed.
|
||||
//! Selects the scene and starts the game.
|
||||
private void PreStart()
|
||||
{
|
||||
if (FileBasedPrefs.GetBool(worldName + "sceneChangeRequired") == true)
|
||||
{
|
||||
scene = FileBasedPrefs.GetInt(worldName + "scene");
|
||||
ChangeScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartGame();
|
||||
}
|
||||
}
|
||||
|
||||
//! Called when Kepler-1625 or Kepler-452b is selected and the scene needs to be changed.
|
||||
private void ChangeScene()
|
||||
{
|
||||
FileBasedPrefs.SetBool(worldName + "sceneChangeRequired", true);
|
||||
@ -97,7 +281,7 @@ public class MainMenu : MonoBehaviour
|
||||
PlayerPrefs.SetString("worldName", worldName);
|
||||
FileBasedPrefs.ManuallySave();
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene(1);
|
||||
SceneManager.LoadScene(scene);
|
||||
}
|
||||
|
||||
//! Called when Gliese 876 is selected and the scene does not need to be changed.
|
||||
@ -107,7 +291,7 @@ public class MainMenu : MonoBehaviour
|
||||
PlayerPrefsX.SetPersistentStringArray("Worlds", worldList.ToArray());
|
||||
FileBasedPrefs.ManuallySave();
|
||||
PlayerPrefs.Save();
|
||||
stateManager.WorldName = worldName;
|
||||
stateManager.worldName = worldName;
|
||||
worldSelected = true;
|
||||
ambient.enabled = false;
|
||||
}
|
||||
@ -121,6 +305,21 @@ public class MainMenu : MonoBehaviour
|
||||
return style.CalcSize(content);
|
||||
}
|
||||
|
||||
//! Returns true if the GUI is available.
|
||||
private bool GuiFree()
|
||||
{
|
||||
return deletePrompt == false
|
||||
&& worldSelectPrompt == false
|
||||
&& escapePrompt == false
|
||||
&& multiplayerPrompt == false
|
||||
&& userNamePrompt == false
|
||||
&& networkAddressPrompt == false
|
||||
&& playerColorPrompt == false
|
||||
&& localPrompt == false
|
||||
&& downloadPrompt == false
|
||||
&& userNamePrompt == false;
|
||||
}
|
||||
|
||||
private bool LoadingWorld()
|
||||
{
|
||||
return stateManager.worldLoaded == false || stateManager.GetComponent<GameManager>().working == true;
|
||||
@ -146,18 +345,25 @@ public class MainMenu : MonoBehaviour
|
||||
}
|
||||
|
||||
Rect backgroundRect = new Rect(0, 0, Screen.width, Screen.height);
|
||||
Rect textEntryRect = new Rect((ScreenWidth * 0.36f), (ScreenHeight * 0.235f), (ScreenWidth * 0.16f), (ScreenHeight * 0.03f));
|
||||
|
||||
Rect worldListBackgroundRect = new Rect((ScreenWidth * 0.40f), (ScreenHeight * 0.45f), (ScreenWidth * 0.17f), (ScreenHeight * 0.40f));
|
||||
Rect worldListRect = new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.47f), (ScreenWidth * 0.15f), (ScreenHeight * 0.55f));
|
||||
Rect worldListTitleRect = new Rect((ScreenWidth * 0.45f), (ScreenHeight * 0.46f), (ScreenWidth * 0.15f), (ScreenHeight * 0.55f));
|
||||
|
||||
Rect deletePromptBackgroundRect = new Rect(((ScreenWidth / 2) - 200), ScreenHeight * 0.14f, 400, ScreenHeight * 0.20f);
|
||||
Rect promptBackgroundRect = new Rect(((ScreenWidth / 2) - 300), ScreenHeight * 0.14f, 600, ScreenHeight * 0.20f);
|
||||
|
||||
Rect deletePromptLabelRect = new Rect((ScreenWidth * 0.435f), (ScreenHeight * 0.18f), (ScreenWidth * 0.20f), (ScreenHeight * 0.05f));
|
||||
Rect deletePromptButton1Rect = new Rect((ScreenWidth * 0.39f), (ScreenHeight * 0.22f), (ScreenWidth * 0.10f), (ScreenHeight * 0.05f));
|
||||
Rect deletePromptButton2Rect = new Rect((ScreenWidth * 0.51f), (ScreenHeight * 0.22f), (ScreenWidth * 0.10f), (ScreenHeight * 0.05f));
|
||||
|
||||
Rect scenePromptButton1Rect = new Rect((ScreenWidth * 0.33f), (ScreenHeight * 0.22f), (ScreenWidth * 0.10f), (ScreenHeight * 0.05f));
|
||||
Rect scenePromptButton2Rect = new Rect((ScreenWidth * 0.45f), (ScreenHeight * 0.22f), (ScreenWidth * 0.10f), (ScreenHeight * 0.05f));
|
||||
Rect scenePromptButton3Rect = new Rect((ScreenWidth * 0.57f), (ScreenHeight * 0.22f), (ScreenWidth * 0.10f), (ScreenHeight * 0.05f));
|
||||
|
||||
Rect startGameButtonRect = new Rect(ScreenWidth * 0.58f, ScreenHeight * 0.4f, ScreenWidth * 0.15f, ScreenHeight * 0.03f);
|
||||
Rect modioButtonRect = new Rect(ScreenWidth * 0.58f, ScreenHeight * 0.44f, ScreenWidth * 0.15f, ScreenHeight * 0.03f);
|
||||
Rect multiplayerButtonRect = new Rect(ScreenWidth * 0.58f, ScreenHeight * 0.44f, ScreenWidth * 0.15f, ScreenHeight * 0.03f);
|
||||
Rect modioButtonRect = new Rect(ScreenWidth * 0.58f, ScreenHeight * 0.48f, ScreenWidth * 0.15f, ScreenHeight * 0.03f);
|
||||
Rect textFieldRect = new Rect(ScreenWidth * 0.41f, ScreenHeight * 0.4f, ScreenWidth * 0.15f, ScreenHeight * 0.03f);
|
||||
Rect loadingMessageRect = new Rect((ScreenWidth * 0.46f), (ScreenHeight * 0.30f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
|
||||
|
||||
@ -199,177 +405,209 @@ public class MainMenu : MonoBehaviour
|
||||
{
|
||||
GUI.DrawTexture(backgroundRect, title2Texture);
|
||||
}
|
||||
if (GUI.Button(startGameButtonRect, "START GAME") || Event.current.keyCode.Equals(KeyCode.Return))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
SelectWorld();
|
||||
}
|
||||
if (GUI.Button(modioButtonRect, "MODS") || Event.current.keyCode.Equals(KeyCode.Return))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
SceneManager.LoadScene(2);
|
||||
}
|
||||
|
||||
GUI.DrawTexture(worldListBackgroundRect, worlListBackground);
|
||||
GUI.Label(worldListTitleRect, "SAVED WORLDS");
|
||||
if (playerColorPrompt == false)
|
||||
{
|
||||
if (GUI.Button(startGameButtonRect, "SINGLE PLAYER") || Event.current.keyCode.Equals(KeyCode.Return))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worldName != "Enter world name.")
|
||||
{
|
||||
PlayerPrefsX.SetPersistentBool("multiplayer", false);
|
||||
SelectWorld();
|
||||
}
|
||||
else
|
||||
{
|
||||
worldNamePrompt = true;
|
||||
}
|
||||
}
|
||||
|
||||
string[] worlds = PlayerPrefsX.GetPersistentStringArray("Worlds");
|
||||
if (worlds.Length > 0)
|
||||
{
|
||||
GUI.Label(world1Rect, "1. " + worlds[0]);
|
||||
}
|
||||
if (worlds.Length > 1)
|
||||
{
|
||||
GUI.Label(world2Rect, "2. " + worlds[1]);
|
||||
}
|
||||
if (worlds.Length > 2)
|
||||
{
|
||||
GUI.Label(world3Rect, "3. " + worlds[2]);
|
||||
}
|
||||
if (worlds.Length > 3)
|
||||
{
|
||||
GUI.Label(world4Rect, "4. " + worlds[3]);
|
||||
}
|
||||
if (worlds.Length > 4)
|
||||
{
|
||||
GUI.Label(world5Rect, "5. " + worlds[4]);
|
||||
}
|
||||
if (worlds.Length > 5)
|
||||
{
|
||||
GUI.Label(world6Rect, "6. " + worlds[5]);
|
||||
}
|
||||
if (worlds.Length > 6)
|
||||
{
|
||||
GUI.Label(world7Rect, "7. " + worlds[6]);
|
||||
}
|
||||
if (worlds.Length > 7)
|
||||
{
|
||||
GUI.Label(world8Rect, "8. " + worlds[7]);
|
||||
}
|
||||
if (worlds.Length > 8)
|
||||
{
|
||||
GUI.Label(world9Rect, "9. " + worlds[8]);
|
||||
}
|
||||
if (worlds.Length > 9)
|
||||
{
|
||||
GUI.Label(world10Rect, "10. " + worlds[9]);
|
||||
}
|
||||
if (GUI.Button(multiplayerButtonRect, "MULTIPLAYER") || Event.current.keyCode.Equals(KeyCode.Return))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
PlayerPrefsX.SetPersistentBool("multiplayer", true);
|
||||
multiplayerPrompt = true;
|
||||
}
|
||||
|
||||
worldName = GUI.TextField(textFieldRect, worldName, 16);
|
||||
if (GUI.Button(modioButtonRect, "MODS") || Event.current.keyCode.Equals(KeyCode.Return))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
SceneManager.LoadScene(2);
|
||||
}
|
||||
|
||||
if (GUI.Button(buttonRect1, "1"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
GUI.DrawTexture(worldListBackgroundRect, worldListBackground);
|
||||
GUI.Label(worldListTitleRect, "SAVED WORLDS");
|
||||
|
||||
worlds = PlayerPrefsX.GetPersistentStringArray("Worlds");
|
||||
if (worlds.Length > 0)
|
||||
{
|
||||
worldName = worlds[0];
|
||||
GUI.Label(world1Rect, "1. " + worlds[0]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect2, "2"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 1)
|
||||
{
|
||||
worldName = worlds[1];
|
||||
GUI.Label(world2Rect, "2. " + worlds[1]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect3, "3"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 2)
|
||||
{
|
||||
worldName = worlds[2];
|
||||
GUI.Label(world3Rect, "3. " + worlds[2]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect4, "4"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 3)
|
||||
{
|
||||
worldName = worlds[3];
|
||||
GUI.Label(world4Rect, "4. " + worlds[3]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect5, "5"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 4)
|
||||
{
|
||||
worldName = worlds[4];
|
||||
GUI.Label(world5Rect, "5. " + worlds[4]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect6, "6"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 5)
|
||||
{
|
||||
worldName = worlds[5];
|
||||
GUI.Label(world6Rect, "6. " + worlds[5]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect7, "7"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 6)
|
||||
{
|
||||
worldName = worlds[6];
|
||||
GUI.Label(world7Rect, "7. " + worlds[6]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect8, "8"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 7)
|
||||
{
|
||||
worldName = worlds[7];
|
||||
GUI.Label(world8Rect, "8. " + worlds[7]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect9, "9"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 8)
|
||||
{
|
||||
worldName = worlds[8];
|
||||
GUI.Label(world9Rect, "9. " + worlds[8]);
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect10, "10"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 9)
|
||||
{
|
||||
worldName = worlds[9];
|
||||
GUI.Label(world10Rect, "10. " + worlds[9]);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (deletePrompt == false && escapePrompt == false)
|
||||
|
||||
worldName = GUI.TextField(textFieldRect, worldName, 20);
|
||||
|
||||
if (GUI.Button(buttonRect1, "1"))
|
||||
{
|
||||
deletePrompt = true;
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 0)
|
||||
{
|
||||
worldName = worlds[0];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect2, "2"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 1)
|
||||
{
|
||||
worldName = worlds[1];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect3, "3"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 2)
|
||||
{
|
||||
worldName = worlds[2];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect4, "4"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 3)
|
||||
{
|
||||
worldName = worlds[3];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect5, "5"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 4)
|
||||
{
|
||||
worldName = worlds[4];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect6, "6"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 5)
|
||||
{
|
||||
worldName = worlds[5];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect7, "7"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 6)
|
||||
{
|
||||
worldName = worlds[6];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect8, "8"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 7)
|
||||
{
|
||||
worldName = worlds[7];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect9, "9"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 8)
|
||||
{
|
||||
worldName = worlds[8];
|
||||
}
|
||||
}
|
||||
if (GUI.Button(buttonRect10, "10"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (worlds.Length > 9)
|
||||
{
|
||||
worldName = worlds[9];
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
deletePrompt |= GuiFree();
|
||||
buttonSounds.Play();
|
||||
}
|
||||
}
|
||||
|
||||
if (worldSelectPrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(deletePromptBackgroundRect, worlListBackground);
|
||||
GUI.DrawTexture(promptBackgroundRect, worldListBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Choose location.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 3), ScreenHeight * 0.18f, size.x, size.y);
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Choose location.");
|
||||
if (GUI.Button(deletePromptButton1Rect, "Kepler-1625"))
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(scenePromptButton1Rect, "Kepler-1625"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
StartGame();
|
||||
}
|
||||
if (GUI.Button(deletePromptButton2Rect, "Gliese 876"))
|
||||
if (GUI.Button(scenePromptButton2Rect, "Kepler-452b"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
scene = 3;
|
||||
FileBasedPrefs.SetInt(worldName + "scene", scene);
|
||||
ChangeScene();
|
||||
}
|
||||
if (GUI.Button(scenePromptButton3Rect, "Gliese 876"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
scene = 1;
|
||||
FileBasedPrefs.SetInt(worldName + "scene", scene);
|
||||
ChangeScene();
|
||||
}
|
||||
}
|
||||
|
||||
if (deletePrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(deletePromptBackgroundRect, worlListBackground);
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Delete selected world?");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 3), ScreenHeight * 0.18f, size.x, size.y);
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Delete selected world?");
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(deletePromptButton1Rect, "Yes"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
@ -400,27 +638,157 @@ public class MainMenu : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
if (multiplayerPrompt == true)
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (escapePrompt == false && deletePrompt == false)
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Multiplayer.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Multiplayer");
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(deletePromptButton1Rect, "Host"))
|
||||
{
|
||||
escapePrompt = true;
|
||||
hosting = true;
|
||||
multiplayerPrompt = false;
|
||||
localPrompt = true;
|
||||
}
|
||||
if (GUI.Button(deletePromptButton2Rect, "Join"))
|
||||
{
|
||||
multiplayerPrompt = false;
|
||||
networkAddressPrompt = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (localPrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Multiplayer.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Multiplayer");
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(deletePromptButton1Rect, "Local"))
|
||||
{
|
||||
local = true;
|
||||
localPrompt = false;
|
||||
userNamePrompt = true;
|
||||
worldName = local == true ? GetLocalAddress() : GetExternalAddress();
|
||||
StartServer();
|
||||
}
|
||||
if (GUI.Button(deletePromptButton2Rect, "Online"))
|
||||
{
|
||||
local = false;
|
||||
localPrompt = false;
|
||||
userNamePrompt = true;
|
||||
worldName = local == true ? GetLocalAddress() : GetExternalAddress();
|
||||
StartServer();
|
||||
}
|
||||
}
|
||||
|
||||
if (networkAddressPrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Enter server IP address.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Enter server IP address.");
|
||||
GUI.skin.label.fontSize = f;
|
||||
serverURL = GUI.TextField(textEntryRect, serverURL, 30);
|
||||
if (GUI.Button(scenePromptButton3Rect, "OK"))
|
||||
{
|
||||
worldName = serverURL;
|
||||
PlayerPrefs.SetString("serverURL", "http://" + serverURL + ":5000");
|
||||
networkAddressPrompt = false;
|
||||
userNamePrompt = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (userNamePrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Enter user name.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Enter user name.");
|
||||
GUI.skin.label.fontSize = f;
|
||||
username = GUI.TextField(textEntryRect, username, 30);
|
||||
if (GUI.Button(scenePromptButton3Rect, "OK"))
|
||||
{
|
||||
PlayerPrefs.SetString("UserName", username);
|
||||
userNamePrompt = false;
|
||||
playerColorPrompt = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerColorPrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(new Rect((ScreenWidth * 0.4f), (ScreenHeight * 0.18f), (ScreenWidth * 0.2f), (ScreenHeight * 0.60f)), worldListBackground);
|
||||
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
GUIContent content = new GUIContent("Player Color");
|
||||
Vector2 size = style.CalcSize(content);
|
||||
Rect titleRect = new Rect((Screen.width / 2) - (size.x / 2.5f), ScreenHeight * 0.24f, size.x, size.y);
|
||||
GUI.Label(titleRect, "Player Color");
|
||||
|
||||
GUIStyle style2 = GUI.skin.box;
|
||||
style2.alignment = TextAnchor.MiddleCenter;
|
||||
GUIContent content2 = new GUIContent("Select Color");
|
||||
Vector2 size2 = style2.CalcSize(content2);
|
||||
Rect titleRect2 = new Rect((Screen.width / 2) - (size2.x / 2.5f), ScreenHeight * 0.3f, size2.x, size2.y);
|
||||
GUI.Label(titleRect2, "Select Color");
|
||||
|
||||
GUI.skin.label.fontSize = f;
|
||||
|
||||
GUI.Label(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.45f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), "Red");
|
||||
GUI.Label(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.51f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), "Green");
|
||||
GUI.Label(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.57f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), "Blue");
|
||||
|
||||
playerRed = GUI.HorizontalSlider(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.48f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), playerRed, 0, 1);
|
||||
playerGreen = GUI.HorizontalSlider(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.54f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), playerGreen, 0, 1);
|
||||
playerBlue = GUI.HorizontalSlider(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.60f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), playerBlue, 0, 1);
|
||||
|
||||
Color playerColor = new Color(playerRed, playerGreen, playerBlue);
|
||||
|
||||
GUI.color = playerColor;
|
||||
GUI.DrawTexture(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.36f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), colorSelectTexture);
|
||||
GUI.DrawTexture(new Rect((ScreenWidth * 0.2f), (ScreenHeight * 0.2f), (ScreenWidth * 0.2f), (ScreenHeight * 0.56f)), playerModel);
|
||||
GUI.DrawTexture(new Rect((ScreenWidth * 0.6f), (ScreenHeight * 0.2f), (ScreenWidth * 0.2f), (ScreenHeight * 0.56f)), playerModel);
|
||||
GUI.color = Color.white;
|
||||
|
||||
if (GUI.Button(new Rect((ScreenWidth * 0.43f), (ScreenHeight * 0.65f), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f)), "DONE"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
playerColorPrompt = false;
|
||||
PlayerPrefs.SetFloat("playerRed", playerRed);
|
||||
PlayerPrefs.SetFloat("playerGreen", playerGreen);
|
||||
PlayerPrefs.SetFloat("playerBlue", playerBlue);
|
||||
SelectWorld();
|
||||
}
|
||||
}
|
||||
|
||||
if (escapePrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(deletePromptBackgroundRect, worlListBackground);
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Exit the game?");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 3), ScreenHeight * 0.18f, size.x, size.y);
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.2f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Exit the game?");
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(deletePromptButton1Rect, "Yes"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
if (!Application.isEditor)
|
||||
{
|
||||
System.Diagnostics.Process.GetCurrentProcess().Kill();
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
}
|
||||
if (GUI.Button(deletePromptButton2Rect, "No"))
|
||||
@ -429,6 +797,38 @@ public class MainMenu : MonoBehaviour
|
||||
escapePrompt = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldNamePrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Please enter a world name.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.5f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Please enter a world name.");
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(scenePromptButton2Rect, "OK"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
worldNamePrompt = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadPrompt == true)
|
||||
{
|
||||
GUI.DrawTexture(promptBackgroundRect, guiBackground);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 14;
|
||||
Vector2 size = GetStringSize("Unable to connect to server.");
|
||||
Rect messagePos = new Rect((Screen.width / 2) - (size.x / 2.5f), ScreenHeight * 0.18f, size.x, size.y);
|
||||
GUI.Label(messagePos, "Unable to connect to server.");
|
||||
GUI.skin.label.fontSize = f;
|
||||
if (GUI.Button(scenePromptButton2Rect, "OK"))
|
||||
{
|
||||
buttonSounds.Play();
|
||||
downloadPrompt = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (finishedLoading == false && LoadingWorld() == true)
|
||||
{
|
||||
|
51
MarketGUI.cs
51
MarketGUI.cs
@ -33,6 +33,7 @@ public class MarketGUI : MonoBehaviour
|
||||
{ "Universal Conduit", 100 },
|
||||
{ "Universal Extractor", 250 },
|
||||
{ "Auger", 50 },
|
||||
{ "Door", 50 },
|
||||
{ "Quantum Hatchway", 50 },
|
||||
{ "Storage Container", 50 },
|
||||
{ "Smelter", 500 },
|
||||
@ -100,7 +101,7 @@ public class MarketGUI : MonoBehaviour
|
||||
{
|
||||
playerController.money -= priceDictionary[item];
|
||||
priceDictionary[item] += (int)(priceDictionary[item] * 0.025f);
|
||||
FileBasedPrefs.SetInt(playerController.stateManager.WorldName + "money", playerController.money);
|
||||
FileBasedPrefs.SetInt(playerController.stateManager.worldName + "money", playerController.money);
|
||||
SavePrices();
|
||||
playerController.PlayCraftingSound();
|
||||
}
|
||||
@ -140,7 +141,7 @@ public class MarketGUI : MonoBehaviour
|
||||
}
|
||||
playerController.money += priceDictionary[item];
|
||||
priceDictionary[item] -= (int)(priceDictionary[item] * 0.025f);
|
||||
FileBasedPrefs.SetInt(playerController.stateManager.WorldName + "money", playerController.money);
|
||||
FileBasedPrefs.SetInt(playerController.stateManager.worldName + "money", playerController.money);
|
||||
SavePrices();
|
||||
playerController.PlayCraftingSound();
|
||||
}
|
||||
@ -549,39 +550,44 @@ public class MarketGUI : MonoBehaviour
|
||||
if (guiCoordinates.button5Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.quantumHatchway + "\n\n[WORTH]\n$" + priceDictionary["Quantum Hatchway"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.door + "\n\n[WORTH]\n$" + priceDictionary["Door"]);
|
||||
}
|
||||
if (guiCoordinates.button6Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.electricLight + "\n\n[WORTH]\n$" + priceDictionary["Electric Light"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.quantumHatchway + "\n\n[WORTH]\n$" + priceDictionary["Quantum Hatchway"]);
|
||||
}
|
||||
if (guiCoordinates.button7Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.circuitBoard + "\n\n[WORTH]\n$" + priceDictionary["Circuit Board"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.electricLight + "\n\n[WORTH]\n$" + priceDictionary["Electric Light"]);
|
||||
}
|
||||
if (guiCoordinates.button9Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.electricMotor + "\n\n[WORTH]\n$" + priceDictionary["Electric Motor"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.circuitBoard + "\n\n[WORTH]\n$" + priceDictionary["Circuit Board"]);
|
||||
}
|
||||
if (guiCoordinates.button10Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.storageComputer + "\n\n[WORTH]\n$" + priceDictionary["Storage Computer"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.electricMotor + "\n\n[WORTH]\n$" + priceDictionary["Electric Motor"]);
|
||||
}
|
||||
if (guiCoordinates.button11Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.turret + "\n\n[WORTH]\n$" + priceDictionary["Turret"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.storageComputer + "\n\n[WORTH]\n$" + priceDictionary["Storage Computer"]);
|
||||
}
|
||||
if (guiCoordinates.button12Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.missileTurret + "\n\n[WORTH]\n$" + priceDictionary["Missile Turret"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.turret + "\n\n[WORTH]\n$" + priceDictionary["Turret"]);
|
||||
}
|
||||
if (guiCoordinates.button13Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.missileTurret + "\n\n[WORTH]\n$" + priceDictionary["Missile Turret"]);
|
||||
}
|
||||
if (guiCoordinates.button14Rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.craftingInfoBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.craftingInfoRect, descriptions.missile + "\n\n[WORTH]\n$" + priceDictionary["Missile"]);
|
||||
@ -640,7 +646,18 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Steel Ramp");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button5Rect, "Quantum Hatchway"))
|
||||
if (GUI.Button(guiCoordinates.button5Rect, "Door"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
BuyItem("Door");
|
||||
}
|
||||
else
|
||||
{
|
||||
SellItem("Door");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button6Rect, "Quantum Hatchway"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -651,7 +668,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Quantum Hatchway");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button6Rect, "Electric Light"))
|
||||
if (GUI.Button(guiCoordinates.button7Rect, "Electric Light"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -662,7 +679,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Electric Light");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button7Rect, "Circuit Board"))
|
||||
if (GUI.Button(guiCoordinates.button9Rect, "Circuit Board"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -673,7 +690,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Circuit Board");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button9Rect, "Electric Motor"))
|
||||
if (GUI.Button(guiCoordinates.button10Rect, "Electric Motor"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -684,7 +701,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Electric Motor");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button10Rect, "Storage Computer"))
|
||||
if (GUI.Button(guiCoordinates.button11Rect, "Storage Computer"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -695,7 +712,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Storage Computer");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button11Rect, "Turret"))
|
||||
if (GUI.Button(guiCoordinates.button12Rect, "Turret"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -706,7 +723,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Turret");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button12Rect, "Missile Turret"))
|
||||
if (GUI.Button(guiCoordinates.button13Rect, "Missile Turret"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
@ -717,7 +734,7 @@ public class MarketGUI : MonoBehaviour
|
||||
SellItem("Missile Turret");
|
||||
}
|
||||
}
|
||||
if (GUI.Button(guiCoordinates.button13Rect, "Missile"))
|
||||
if (GUI.Button(guiCoordinates.button14Rect, "Missile"))
|
||||
{
|
||||
if (selling == false)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ public class MeshPainter : MonoBehaviour
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
string worldName = FindObjectOfType<StateManager>().WorldName;
|
||||
string worldName = FindObjectOfType<StateManager>().worldName;
|
||||
bool paintedIron = false;
|
||||
bool paintedGlass = false;
|
||||
bool paintedBrick = false;
|
||||
@ -77,8 +77,8 @@ public class MeshPainter : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gameObject.name.Equals("glassHolder(Clone)"))
|
||||
{
|
||||
if (gameObject.name.Equals("glassHolder(Clone)"))
|
||||
{
|
||||
if (FileBasedPrefs.GetBool(worldName + "glassHolder" + ID + "painted") == true)
|
||||
{
|
||||
float r = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Red");
|
||||
@ -109,7 +109,7 @@ public class MeshPainter : MonoBehaviour
|
||||
//! Saves the color of painted objects.
|
||||
private IEnumerator SaveDataCoRoutine()
|
||||
{
|
||||
string worldName = GameObject.Find("GameManager").GetComponent<StateManager>().WorldName;
|
||||
string worldName = GameObject.Find("GameManager").GetComponent<StateManager>().worldName;
|
||||
if (gameObject.name.Equals("ironHolder(Clone)") && FileBasedPrefs.GetBool(worldName + "ironHolder" + ID + "painted") == true)
|
||||
{
|
||||
float r = GetComponent<Renderer>().material.color.r;
|
||||
|
73
Meteor.cs
73
Meteor.cs
@ -36,12 +36,24 @@ public class Meteor : MonoBehaviour
|
||||
}
|
||||
if (Physics.Raycast(transform.position, -transform.up, out RaycastHit hit, 5))
|
||||
{
|
||||
if (hit.collider.gameObject.tag.Equals("Built"))
|
||||
GameObject obj = hit.collider.gameObject;
|
||||
if (obj.tag.Equals("Built"))
|
||||
{
|
||||
if (hit.collider.gameObject.GetComponent<PhysicsHandler>() != null)
|
||||
string objName;
|
||||
if (obj.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
hit.collider.gameObject.GetComponent<PhysicsHandler>().Explode();
|
||||
objName = obj.GetComponent<ModBlock>().blockName;
|
||||
}
|
||||
else
|
||||
{
|
||||
objName = obj.name.Split('(')[0];
|
||||
}
|
||||
|
||||
if (obj.GetComponent<PhysicsHandler>() != null)
|
||||
{
|
||||
obj.GetComponent<PhysicsHandler>().Explode();
|
||||
}
|
||||
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
@ -49,14 +61,14 @@ public class Meteor : MonoBehaviour
|
||||
playerController.destructionMessageActive = true;
|
||||
playerController.currentTabletMessage = "";
|
||||
}
|
||||
playerController.currentTabletMessage += "ALERT: " + hit.collider.gameObject.name.Split('(')[0] + " destroyed by a meteor!\n";
|
||||
playerController.currentTabletMessage += "ALERT: " + objName + " destroyed by a meteor!\n";
|
||||
playerController.destructionMessageCount += 1;
|
||||
}
|
||||
Explode();
|
||||
}
|
||||
else if (hit.collider.gameObject.tag.Equals("CombinedMesh"))
|
||||
else if (obj.tag.Equals("CombinedMesh"))
|
||||
{
|
||||
if (hit.collider.gameObject.name.Equals("glassHolder(Clone)"))
|
||||
if (obj.name.Equals("glassHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -77,7 +89,7 @@ public class Meteor : MonoBehaviour
|
||||
}
|
||||
Explode();
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("brickHolder(Clone)"))
|
||||
else if (obj.name.Equals("brickHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -98,7 +110,7 @@ public class Meteor : MonoBehaviour
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("ironHolder(Clone)"))
|
||||
else if (obj.name.Equals("ironHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -119,7 +131,7 @@ public class Meteor : MonoBehaviour
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("steelHolder(Clone)"))
|
||||
else if (obj.name.Equals("steelHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -140,6 +152,49 @@ public class Meteor : MonoBehaviour
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
else if (obj.name.Equals("modBlockHolder(Clone)"))
|
||||
{
|
||||
string type = "all";
|
||||
int toughness = 75;
|
||||
|
||||
Transform[] transforms = obj.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform t in transforms)
|
||||
{
|
||||
if (t.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
type = t.GetComponent<ModBlock>().blockName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type.ToUpper().Contains("GLASS"))
|
||||
{
|
||||
toughness = 25;
|
||||
}
|
||||
else if (type.ToUpper().Contains("STEEL"))
|
||||
{
|
||||
toughness = 99;
|
||||
}
|
||||
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
if (chanceOfDestruction > toughness)
|
||||
{
|
||||
game.meshManager.SeparateBlocks(hit.point, type, false);
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
{
|
||||
playerController.destructionMessageActive = true;
|
||||
playerController.currentTabletMessage = "";
|
||||
}
|
||||
playerController.currentTabletMessage += "ALERT: Some blocks were hit by a meteor!\n";
|
||||
playerController.destructionMessageCount += 1;
|
||||
}
|
||||
}
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -43,6 +43,9 @@ public class MissileTurret : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
57
ModBlock.cs
Normal file
57
ModBlock.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ModBlock : MonoBehaviour
|
||||
{
|
||||
private Material material;
|
||||
private StateManager stateManager;
|
||||
private PlayerController playerController;
|
||||
private GameManager gameManager;
|
||||
public GameObject glassBreak;
|
||||
private bool init;
|
||||
private float updateTick;
|
||||
public int address;
|
||||
public string ID = "unassigned";
|
||||
public string blockName;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
material = new Material(Shader.Find("Standard"));
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
playerController = GameObject.Find("Player").GetComponent<PlayerController>();
|
||||
stateManager = gameManager.GetComponent<StateManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (!stateManager.Busy() && init == false)
|
||||
{
|
||||
BlockDictionary blockDictionary = playerController.GetComponent<BuildController>().blockDictionary;
|
||||
if (blockDictionary.meshDictionary.ContainsKey(blockName))
|
||||
{
|
||||
GetComponent<MeshFilter>().mesh = blockDictionary.meshDictionary[blockName];
|
||||
}
|
||||
gameManager.meshManager.SetMaterial(gameObject, blockName);
|
||||
if (blockName.ToUpper().Contains("GLASS"))
|
||||
{
|
||||
GetComponent<PhysicsHandler>().explosion = glassBreak;
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
|
||||
if (ID != "unassigned")
|
||||
{
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
if (stateManager.Busy())
|
||||
{
|
||||
updateTick = 0;
|
||||
return;
|
||||
}
|
||||
GetComponent<PhysicsHandler>().UpdatePhysics();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +1,92 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
public class ModMachine : BasicMachine
|
||||
{
|
||||
private Material material;
|
||||
private PlayerController playerController;
|
||||
private GameManager gameManager;
|
||||
private Coroutine modSoundCoroutine;
|
||||
public string machineName;
|
||||
public bool init;
|
||||
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public new void Start()
|
||||
{
|
||||
base.Start();
|
||||
material = new Material(Shader.Find("Standard"));
|
||||
playerController = GameObject.Find("Player").GetComponent<PlayerController>();
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public new void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (!stateManager.Busy())
|
||||
if (!stateManager.Busy() && init == false)
|
||||
{
|
||||
TextureDictionary textureDictionary = GameObject.Find("Player").GetComponent<TextureDictionary>();
|
||||
if (textureDictionary.dictionary.ContainsKey(machineName))
|
||||
BlockDictionary blockDictionary = playerController.GetComponent<BuildController>().blockDictionary;
|
||||
if (blockDictionary != null)
|
||||
{
|
||||
material.mainTexture = GameObject.Find("Player").GetComponent<TextureDictionary>().dictionary[machineName];
|
||||
if (blockDictionary.meshDictionary.ContainsKey(machineName) && GetComponent<MeshFilter>() != null)
|
||||
{
|
||||
GetComponent<MeshFilter>().mesh = blockDictionary.meshDictionary[machineName];
|
||||
}
|
||||
}
|
||||
GetComponent<Renderer>().material = material;
|
||||
if (recipes == null)
|
||||
gameManager.meshManager.SetMaterial(gameObject, machineName);
|
||||
modSoundCoroutine = StartCoroutine(GetAudioFile(this, GetComponent<AudioSource>(), machineName));
|
||||
init = true;
|
||||
}
|
||||
|
||||
if (recipes == null)
|
||||
{
|
||||
recipes = GameObject.Find("Player").GetComponent<BuildController>().blockDictionary.GetMachineRecipes(machineName);
|
||||
}
|
||||
}
|
||||
|
||||
//! Loads sound files.
|
||||
public static IEnumerator GetAudioFile(ModMachine machine, AudioSource source, string machineName)
|
||||
{
|
||||
string modPath = Path.Combine(Application.persistentDataPath, "Mods");
|
||||
Directory.CreateDirectory(modPath);
|
||||
string[] modDirs = Directory.GetDirectories(modPath);
|
||||
foreach (string path in modDirs)
|
||||
{
|
||||
string soundPath = path + "/Sounds/";
|
||||
Directory.CreateDirectory(soundPath);
|
||||
DirectoryInfo d = new DirectoryInfo(soundPath);
|
||||
foreach (FileInfo file in d.GetFiles("*.wav"))
|
||||
{
|
||||
recipes = GameObject.Find("Player").GetComponent<BuildController>().blockDictionary.GetMachineRecipes(machineName);
|
||||
string filePath = soundPath + file.Name;
|
||||
UriBuilder soundUriBuildier = new UriBuilder(filePath) { Scheme = "file" };
|
||||
string url = soundUriBuildier.ToString();
|
||||
using (UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.WAV))
|
||||
{
|
||||
yield return uwr.SendWebRequest();
|
||||
if (!uwr.isNetworkError && !uwr.isHttpError)
|
||||
{
|
||||
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(uwr);
|
||||
string soundName = file.Name.Remove(file.Name.Length - 4);
|
||||
string modName = new DirectoryInfo(path).Name;
|
||||
if (audioClip != null)
|
||||
{
|
||||
if (soundName == machineName)
|
||||
{
|
||||
audioClip.name = soundName;
|
||||
source.clip = audioClip;
|
||||
machine.hasCustomSound = true;
|
||||
Debug.Log("Mod "+"["+modName+"]"+" loaded sound effect [" + soundName + ".wav] "+"for "+machineName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Mod "+"["+modName+"]"+" failed to load sound effect [" + soundName + ".wav] "+"for "+machineName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
286
NetworkController.cs
Normal file
286
NetworkController.cs
Normal file
@ -0,0 +1,286 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class NetworkController
|
||||
{
|
||||
public PlayerController playerController;
|
||||
public NetworkSend networkSend;
|
||||
public NetworkReceive networkReceive;
|
||||
private Dictionary<string, GameObject> networkPlayers;
|
||||
private Dictionary<string, Vector3> playerPositions;
|
||||
private TextureDictionary textureDictionary;
|
||||
private Coroutine blockUpdateCoroutine;
|
||||
private Coroutine storageSendCoroutine;
|
||||
private Coroutine storageReceiveCoroutine;
|
||||
private Coroutine networkPowerCoroutine;
|
||||
private Coroutine networkBlockCoroutine;
|
||||
private Coroutine networkStorageCoroutine;
|
||||
private Coroutine networkConduitCoroutine;
|
||||
private Coroutine networkMachineCoroutine;
|
||||
private Coroutine networkPlayerCoroutine;
|
||||
private Coroutine networkMovementCoroutine;
|
||||
private List<string> playerNames;
|
||||
private float storageUpdateInterval;
|
||||
private float blockNetTimer;
|
||||
private float storageNetTimer;
|
||||
private float playerNetTimer;
|
||||
private float conduitNetTimer;
|
||||
private float powerNetTimer;
|
||||
private float machineNetTimer;
|
||||
public bool storageCoroutineBusy;
|
||||
public bool playerCoroutineBusy;
|
||||
public bool playerMovementCoroutineBusy;
|
||||
public bool blockCoroutineBusy;
|
||||
public bool receivedNetworkStorage;
|
||||
public string playerData;
|
||||
public string blockData;
|
||||
public string storageData;
|
||||
public string serverURL;
|
||||
|
||||
//! Network functions for multiplayer games.
|
||||
public NetworkController(PlayerController playerController)
|
||||
{
|
||||
this.playerController = playerController;
|
||||
serverURL = PlayerPrefs.GetString("serverURL");
|
||||
textureDictionary = playerController.GetComponent<TextureDictionary>();
|
||||
networkPlayers = new Dictionary<string, GameObject>();
|
||||
playerPositions = new Dictionary<string, Vector3>();
|
||||
playerNames = new List<string>();
|
||||
networkSend = new NetworkSend(this);
|
||||
networkReceive = new NetworkReceive(this);
|
||||
}
|
||||
|
||||
//! Handles all network traffic for multiplayer.
|
||||
public void NetWorkUpdate()
|
||||
{
|
||||
if (playerCoroutineBusy == false)
|
||||
{
|
||||
networkPlayerCoroutine = playerController.StartCoroutine(UpdateNetworkPlayers());
|
||||
}
|
||||
|
||||
if (playerMovementCoroutineBusy == false)
|
||||
{
|
||||
networkMovementCoroutine = playerController.StartCoroutine(MoveNetworkPlayers());
|
||||
}
|
||||
|
||||
playerNetTimer += 1 * Time.deltaTime;
|
||||
if (playerNetTimer >= Random.Range(0.75f, 1.0f))
|
||||
{
|
||||
networkSend.SendPlayerInfo();
|
||||
playerNetTimer = 0;
|
||||
}
|
||||
|
||||
blockNetTimer += 1 * Time.deltaTime;
|
||||
if (blockNetTimer >= Random.Range(1.0f, 1.25f))
|
||||
{
|
||||
if (blockCoroutineBusy == false)
|
||||
{
|
||||
networkBlockCoroutine = playerController.StartCoroutine(UpdateNetworkBlocks());
|
||||
}
|
||||
blockNetTimer = 0;
|
||||
}
|
||||
|
||||
conduitNetTimer += 1 * Time.deltaTime;
|
||||
if (conduitNetTimer >= Random.Range(1.25f, 1.5f))
|
||||
{
|
||||
if (networkReceive.conduitDataCoroutineBusy == false)
|
||||
{
|
||||
networkConduitCoroutine = playerController.StartCoroutine(networkReceive.ReceiveConduitData());
|
||||
}
|
||||
conduitNetTimer = 0;
|
||||
}
|
||||
|
||||
powerNetTimer += 1 * Time.deltaTime;
|
||||
if (powerNetTimer >= Random.Range(1.5f, 1.75f))
|
||||
{
|
||||
if (networkReceive.powerDataCoroutineBusy == false)
|
||||
{
|
||||
networkPowerCoroutine = playerController.StartCoroutine(networkReceive.ReceivePowerData());
|
||||
}
|
||||
powerNetTimer = 0;
|
||||
}
|
||||
|
||||
storageNetTimer += 1 * Time.deltaTime;
|
||||
if (storageNetTimer >= Random.Range(1.75f, 2.0f))
|
||||
{
|
||||
if (storageCoroutineBusy == false)
|
||||
{
|
||||
networkStorageCoroutine = playerController.StartCoroutine(UpdateNetworkStorage());
|
||||
storageNetTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
machineNetTimer += 1 * Time.deltaTime;
|
||||
if (machineNetTimer >= Random.Range(2.0f, 2.25f))
|
||||
{
|
||||
if (networkReceive.machineDataCoroutineBusy == false)
|
||||
{
|
||||
networkMachineCoroutine = playerController.StartCoroutine(networkReceive.ReceiveMachineData());
|
||||
}
|
||||
machineNetTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets information about other players from the server.
|
||||
public IEnumerator UpdateNetworkPlayers()
|
||||
{
|
||||
playerCoroutineBusy = true;
|
||||
|
||||
playerData = "none";
|
||||
networkReceive.GetPlayerData();
|
||||
while (playerData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
playerNames.Clear();
|
||||
string[] playerList = playerData.Split('[');
|
||||
for (int i=2; i < playerList.Length; i++)
|
||||
{
|
||||
string playerInfo = playerList[i];
|
||||
string playerName = playerInfo.Split(':')[0].Split(',')[0].TrimStart('"').TrimEnd('"');
|
||||
if (playerName != PlayerPrefs.GetString("UserName"))
|
||||
{
|
||||
if (!playerNames.Contains(playerName))
|
||||
{
|
||||
playerNames.Add(playerName);
|
||||
}
|
||||
if (!networkPlayers.ContainsKey(playerName))
|
||||
{
|
||||
float red = float.Parse(playerInfo.Split(',')[6]);
|
||||
float green = float.Parse(playerInfo.Split(',')[7]);
|
||||
float blue = float.Parse(playerInfo.Split(',')[8].Split(']')[0]);
|
||||
Color playerColor = new Color(red, green, blue);
|
||||
CreateNetworkPlayer(playerName, playerColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPlayerLocation(playerInfo);
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
Dictionary<string, GameObject> allPlayers = new Dictionary<string, GameObject>(networkPlayers);
|
||||
foreach (KeyValuePair<string,GameObject> entry in allPlayers)
|
||||
{
|
||||
if (!playerNames.Contains(entry.Key))
|
||||
{
|
||||
networkPlayers.Remove(entry.Key);
|
||||
Object.Destroy(entry.Value);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
playerCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Sends player positions to server.
|
||||
private void SetPlayerLocation(string playerInfo)
|
||||
{
|
||||
string playerName = playerInfo.Split(':')[0].Split(',')[0].TrimStart('"').TrimEnd('"');
|
||||
float x = float.Parse(playerInfo.Split(',')[1]);
|
||||
float y = float.Parse(playerInfo.Split(',')[2]);
|
||||
float z = float.Parse(playerInfo.Split(',')[3]);
|
||||
float fx = float.Parse(playerInfo.Split(',')[4]);
|
||||
float fz = float.Parse(playerInfo.Split(',')[5]);
|
||||
if (!playerPositions.ContainsKey(playerName))
|
||||
{
|
||||
playerPositions.Add(playerName, new Vector3(x, y, z));
|
||||
}
|
||||
else
|
||||
{
|
||||
playerPositions[playerName] = new Vector3(x, y, z);
|
||||
}
|
||||
if (networkPlayers[playerName] != null)
|
||||
{
|
||||
networkPlayers[playerName].transform.forward = new Vector3(fx,0,fz);
|
||||
}
|
||||
}
|
||||
|
||||
//! Moves network player game objects based on database values.
|
||||
public IEnumerator MoveNetworkPlayers()
|
||||
{
|
||||
playerMovementCoroutineBusy = true;
|
||||
Dictionary<string, GameObject> allPlayers = new Dictionary<string, GameObject>(networkPlayers);
|
||||
foreach (KeyValuePair<string,GameObject> player in allPlayers)
|
||||
{
|
||||
if (playerPositions.ContainsKey(player.Key) && player.Value != null)
|
||||
{
|
||||
if (Vector3.Distance(playerPositions[player.Key], player.Value.transform.position) > 1)
|
||||
{
|
||||
Vector3 moveDir = (playerPositions[player.Key] - player.Value.transform.position ).normalized;
|
||||
player.Value.transform.position += moveDir * 15 * Time.deltaTime;
|
||||
player.Value.GetComponent<NetworkPlayer>().moving = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Value.GetComponent<NetworkPlayer>().moving = false;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
playerMovementCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Instantiates blocks over the network.
|
||||
public IEnumerator UpdateNetworkBlocks()
|
||||
{
|
||||
if (blockCoroutineBusy == false)
|
||||
{
|
||||
blockCoroutineBusy = true;
|
||||
|
||||
blockData = "none";
|
||||
networkReceive.GetBlockData();
|
||||
while (blockData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
blockUpdateCoroutine = playerController.StartCoroutine(networkReceive.ReceiveNetworkBlocks());
|
||||
}
|
||||
}
|
||||
|
||||
//! Updates inventories over the network.
|
||||
public IEnumerator UpdateNetworkStorage()
|
||||
{
|
||||
storageCoroutineBusy = true;
|
||||
|
||||
storageData = "none";
|
||||
networkReceive.GetStorageData();
|
||||
while (storageData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
receivedNetworkStorage = false;
|
||||
storageReceiveCoroutine = playerController.StartCoroutine(networkReceive.ReceiveNetworkStorage());
|
||||
while (receivedNetworkStorage == false)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
storageCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Instantiates a gameobject representing another player over the network.
|
||||
private void CreateNetworkPlayer(string playerName, Color playerColor)
|
||||
{
|
||||
GameObject newPlayer = Object.Instantiate(playerController.networkPlayer);
|
||||
newPlayer.name = playerName;
|
||||
Material playerMaterial = new Material(Shader.Find("Standard"));
|
||||
playerMaterial.SetTexture("_MainTex", textureDictionary.dictionary["Iron Block"]);
|
||||
playerMaterial.color = playerColor;
|
||||
Renderer[] renderers = newPlayer.GetComponentsInChildren<Renderer>();
|
||||
foreach (Renderer renderer in renderers)
|
||||
{
|
||||
Material[] mats = renderer.materials;
|
||||
for (int i = 0; i < mats.Length; i++)
|
||||
{
|
||||
mats[i] = playerMaterial;
|
||||
}
|
||||
renderer.materials = mats;
|
||||
}
|
||||
networkPlayers.Add(playerName, newPlayer);
|
||||
}
|
||||
}
|
36
NetworkPlayer.cs
Normal file
36
NetworkPlayer.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class NetworkPlayer : MonoBehaviour
|
||||
{
|
||||
public bool moving;
|
||||
public bool onGround;
|
||||
public GameObject idle;
|
||||
public GameObject run;
|
||||
private float idleTimer;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
onGround |= Physics.Raycast(transform.position, -transform.up, 12);
|
||||
|
||||
if (moving == true && onGround == true)
|
||||
{
|
||||
idle.SetActive(false);
|
||||
run.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
idleTimer += 1 * Time.deltaTime;
|
||||
if (idleTimer >= 2)
|
||||
{
|
||||
idle.SetActive(true);
|
||||
run.SetActive(false);
|
||||
idleTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
636
NetworkReceive.cs
Normal file
636
NetworkReceive.cs
Normal file
@ -0,0 +1,636 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class NetworkReceive
|
||||
{
|
||||
private NetworkController networkController;
|
||||
private PlayerController playerController;
|
||||
private BlockDictionary blockDictionary;
|
||||
private string serverURL;
|
||||
private string conduitData;
|
||||
private string powerData;
|
||||
private string machineData;
|
||||
private string chatData;
|
||||
private string paintData;
|
||||
private bool chatCoroutineBusy;
|
||||
private List<string> chatMessageList;
|
||||
public bool conduitDataCoroutineBusy;
|
||||
public bool machineDataCoroutineBusy;
|
||||
public bool powerDataCoroutineBusy;
|
||||
|
||||
//! Network functions for multiplayer games.
|
||||
public NetworkReceive(NetworkController networkController)
|
||||
{
|
||||
this.networkController = networkController;
|
||||
playerController = networkController.playerController;
|
||||
blockDictionary = playerController.GetComponent<BuildController>().blockDictionary;
|
||||
serverURL = networkController.serverURL;
|
||||
chatMessageList = new List<string>();
|
||||
}
|
||||
|
||||
//! Processes data from chat database.
|
||||
public IEnumerator ReceiveChatData()
|
||||
{
|
||||
if (chatCoroutineBusy == false)
|
||||
{
|
||||
chatCoroutineBusy = true;
|
||||
|
||||
chatData = "none";
|
||||
|
||||
GetChatData();
|
||||
while (chatData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
string[] chatMessages = chatData.Split('[');
|
||||
if (chatMessages.Length == 2)
|
||||
{
|
||||
chatMessageList.Clear();
|
||||
}
|
||||
|
||||
for (int i=2; i < chatMessages.Length; i++)
|
||||
{
|
||||
string messageInfo = chatMessages[i];
|
||||
string playerName = messageInfo.Split(':')[0].Split(',')[0].TrimStart('"').TrimEnd('"');
|
||||
string message = messageInfo.Split(',')[1].Split(']')[0].Substring(2).TrimEnd('"');
|
||||
string messageToSend = "\n" + playerName + ": " + message;
|
||||
if (!chatMessageList.Contains(messageToSend))
|
||||
{
|
||||
chatMessageList.Add(messageToSend);
|
||||
playerController.GetComponent<ChatGUI>().messages += messageToSend;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
chatCoroutineBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
//! Processes data from block database.
|
||||
public IEnumerator ReceiveNetworkBlocks()
|
||||
{
|
||||
string[] blockList = networkController.blockData.Split('[');
|
||||
for (int i = 2; i < blockList.Length; i++)
|
||||
{
|
||||
string blockInfo = blockList[i];
|
||||
int destroy = int.Parse(blockInfo.Split(',')[0]);
|
||||
string blockType = blockInfo.Split(',')[1].Substring(2).TrimEnd('"');
|
||||
float xPos = float.Parse(blockInfo.Split(',')[2]);
|
||||
float yPos = float.Parse(blockInfo.Split(',')[3]);
|
||||
float zPos = float.Parse(blockInfo.Split(',')[4]);
|
||||
float xRot = float.Parse(blockInfo.Split(',')[5]);
|
||||
float yRot = float.Parse(blockInfo.Split(',')[6]);
|
||||
float zRot = float.Parse(blockInfo.Split(',')[7]);
|
||||
float wRot = float.Parse(blockInfo.Split(',')[8].Split(']')[0]);
|
||||
Vector3 blockPos = new Vector3(xPos, yPos, zPos);
|
||||
Quaternion blockRot = new Quaternion(xRot, yRot, zRot, wRot);
|
||||
bool found = false;
|
||||
if (blockDictionary.machineDictionary.ContainsKey(blockType))
|
||||
{
|
||||
int blockCheckInterval = 0;
|
||||
System.Type t = blockDictionary.typeDictionary[blockType];
|
||||
GameObject[] allObjects = Object.FindObjectsOfType<GameObject>();
|
||||
foreach (GameObject obj in allObjects)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
float x = Mathf.Round(obj.transform.position.x);
|
||||
float y = Mathf.Round(obj.transform.position.y);
|
||||
float z = Mathf.Round(obj.transform.position.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (obj.GetComponent(t) != null && foundPos == blockPos)
|
||||
{
|
||||
if (destroy == 1)
|
||||
{
|
||||
Object.Destroy(obj);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
blockCheckInterval++;
|
||||
if (blockCheckInterval >= 10)
|
||||
{
|
||||
blockCheckInterval = 0;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (blockDictionary.blockDictionary.ContainsKey(blockType))
|
||||
{
|
||||
int blockCheckInterval = 0;
|
||||
Transform[] allBlocks = playerController.gameManager.builtObjects.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform block in allBlocks)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
float x = Mathf.Round(block.position.x);
|
||||
float y = Mathf.Round(block.position.y);
|
||||
float z = Mathf.Round(block.position.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == blockPos)
|
||||
{
|
||||
if (blockDictionary.typeDictionary.ContainsKey(blockType))
|
||||
{
|
||||
System.Type t = blockDictionary.typeDictionary[blockType];
|
||||
if (block.GetComponent(t) != null)
|
||||
{
|
||||
if (destroy == 1)
|
||||
{
|
||||
Object.Destroy(block.gameObject);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
if (block.GetComponent<ModBlock>().blockName == blockType)
|
||||
{
|
||||
if (destroy == 1)
|
||||
{
|
||||
Object.Destroy(block.gameObject);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
blockCheckInterval++;
|
||||
if (blockCheckInterval >= 10)
|
||||
{
|
||||
blockCheckInterval = 0;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && destroy == 0)
|
||||
{
|
||||
if (blockDictionary.blockDictionary.ContainsKey(blockType))
|
||||
{
|
||||
GameObject obj = Object.Instantiate(blockDictionary.blockDictionary[blockType], blockPos, blockRot);
|
||||
if (obj.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
obj.GetComponent<ModBlock>().blockName = blockType;
|
||||
}
|
||||
obj.transform.parent = playerController.gameManager.builtObjects.transform;
|
||||
}
|
||||
else if (blockDictionary.machineDictionary.ContainsKey(blockType))
|
||||
{
|
||||
Object.Instantiate(blockDictionary.machineDictionary[blockType], blockPos, blockRot);
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
networkController.blockCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Processes data from storge database.
|
||||
public IEnumerator ReceiveNetworkStorage()
|
||||
{
|
||||
string[] storageList = networkController.storageData.Split('[');
|
||||
for (int i = 2; i < storageList.Length; i++)
|
||||
{
|
||||
string storageInfo = storageList[i];
|
||||
float xPos = float.Parse(storageInfo.Split(',')[0]);
|
||||
float yPos = float.Parse(storageInfo.Split(',')[1]);
|
||||
float zPos = float.Parse(storageInfo.Split(',')[2]);
|
||||
Vector3 storagePos = new Vector3(xPos, yPos, zPos);
|
||||
int slot = int.Parse(storageInfo.Split(',')[3]);
|
||||
string type = storageInfo.Split(',')[4].Substring(2).TrimEnd('"');
|
||||
int amount = int.Parse(storageInfo.Split(',')[5].Split(']')[0]);
|
||||
InventoryManager[] allInventories = Object.FindObjectsOfType<InventoryManager>();
|
||||
foreach (InventoryManager manager in allInventories)
|
||||
{
|
||||
if (manager != null)
|
||||
{
|
||||
if (manager.initialized == true)
|
||||
{
|
||||
Vector3 pos = manager.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos== storagePos)
|
||||
{
|
||||
manager.inventory[slot].typeInSlot = type;
|
||||
manager.inventory[slot].amountInSlot = amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
networkController.receivedNetworkStorage = true;
|
||||
}
|
||||
|
||||
//! Processes data from conduit database.
|
||||
public IEnumerator ReceiveConduitData()
|
||||
{
|
||||
conduitDataCoroutineBusy = true;
|
||||
conduitData = "none";
|
||||
GetConduitData();
|
||||
while (conduitData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
string[] conduitList = conduitData.Split('[');
|
||||
for (int i = 2; i < conduitList.Length; i++)
|
||||
{
|
||||
string conduitInfo = conduitList[i];
|
||||
float xPos = float.Parse(conduitInfo.Split(',')[0]);
|
||||
float yPos = float.Parse(conduitInfo.Split(',')[1]);
|
||||
float zPos = float.Parse(conduitInfo.Split(',')[2]);
|
||||
Vector3 conduitPos = new Vector3(xPos, yPos, zPos);
|
||||
int range = int.Parse(conduitInfo.Split(',')[3].Split(']')[0]);
|
||||
|
||||
UniversalConduit[] allConduits = Object.FindObjectsOfType<UniversalConduit>();
|
||||
foreach (UniversalConduit conduit in allConduits)
|
||||
{
|
||||
if (conduit != null)
|
||||
{
|
||||
Vector3 pos = conduit.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == conduitPos && conduit.range != range)
|
||||
{
|
||||
if (conduit.connectionFailed == true)
|
||||
{
|
||||
conduit.connectionAttempts = 0;
|
||||
conduit.connectionFailed = false;
|
||||
}
|
||||
conduit.range = range;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
DarkMatterConduit[] allDarkMatterConduits = Object.FindObjectsOfType<DarkMatterConduit>();
|
||||
foreach (DarkMatterConduit conduit in allDarkMatterConduits)
|
||||
{
|
||||
if (conduit != null)
|
||||
{
|
||||
Vector3 pos = conduit.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == conduitPos && conduit.range != range)
|
||||
{
|
||||
if (conduit.connectionFailed == true)
|
||||
{
|
||||
conduit.connectionAttempts = 0;
|
||||
conduit.connectionFailed = false;
|
||||
}
|
||||
conduit.range = range;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Processes data from machine database.
|
||||
public IEnumerator ReceiveMachineData()
|
||||
{
|
||||
machineDataCoroutineBusy = true;
|
||||
|
||||
machineData = "none";
|
||||
GetMachineData();
|
||||
while (machineData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
string[] machineList = machineData.Split('[');
|
||||
for (int i = 2; i < machineList.Length; i++)
|
||||
{
|
||||
string machineInfo = machineList[i];
|
||||
float xPos = float.Parse(machineInfo.Split(',')[0]);
|
||||
float yPos = float.Parse(machineInfo.Split(',')[1]);
|
||||
float zPos = float.Parse(machineInfo.Split(',')[2]);
|
||||
Vector3 machinePos = new Vector3(xPos, yPos, zPos);
|
||||
int speed = int.Parse(machineInfo.Split(',')[3].Split(']')[0]);
|
||||
BasicMachine[] allMachines = Object.FindObjectsOfType<BasicMachine>();
|
||||
foreach (BasicMachine machine in allMachines)
|
||||
{
|
||||
if (machine != null)
|
||||
{
|
||||
Vector3 pos = machine.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && machine.speed != speed)
|
||||
{
|
||||
if (machine.connectionFailed == true)
|
||||
{
|
||||
machine.connectionAttempts = 0;
|
||||
machine.connectionFailed = false;
|
||||
}
|
||||
machine.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
UniversalExtractor[] allExtractors = Object.FindObjectsOfType<UniversalExtractor>();
|
||||
foreach (UniversalExtractor extractor in allExtractors)
|
||||
{
|
||||
if (extractor != null)
|
||||
{
|
||||
Vector3 pos = extractor.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && extractor.speed != speed)
|
||||
{
|
||||
if (extractor.connectionFailed == true)
|
||||
{
|
||||
extractor.connectionAttempts = 0;
|
||||
extractor.connectionFailed = false;
|
||||
}
|
||||
extractor.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
DarkMatterCollector[] allCollectors = Object.FindObjectsOfType<DarkMatterCollector>();
|
||||
foreach (DarkMatterCollector collector in allCollectors)
|
||||
{
|
||||
if (collector != null)
|
||||
{
|
||||
Vector3 pos = collector.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && collector.speed != speed)
|
||||
{
|
||||
if (collector.connectionFailed == true)
|
||||
{
|
||||
collector.connectionAttempts = 0;
|
||||
collector.connectionFailed = false;
|
||||
}
|
||||
collector.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
HeatExchanger[] allHX = Object.FindObjectsOfType<HeatExchanger>();
|
||||
foreach (HeatExchanger hx in allHX)
|
||||
{
|
||||
if (hx != null)
|
||||
{
|
||||
Vector3 pos = hx.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && hx.speed != speed)
|
||||
{
|
||||
if (hx.connectionFailed == true)
|
||||
{
|
||||
hx.connectionAttempts = 0;
|
||||
hx.connectionFailed = false;
|
||||
}
|
||||
hx.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
AlloySmelter[] allAlloySmelters = Object.FindObjectsOfType<AlloySmelter>();
|
||||
foreach (AlloySmelter alloySmelter in allAlloySmelters)
|
||||
{
|
||||
if (alloySmelter != null)
|
||||
{
|
||||
Vector3 pos = alloySmelter.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && alloySmelter.speed != speed)
|
||||
{
|
||||
if (alloySmelter.connectionFailed == true)
|
||||
{
|
||||
alloySmelter.connectionAttempts = 0;
|
||||
alloySmelter.connectionFailed = false;
|
||||
}
|
||||
alloySmelter.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
Auger[] allAugers = Object.FindObjectsOfType<Auger>();
|
||||
foreach (Auger auger in allAugers)
|
||||
{
|
||||
if (auger != null)
|
||||
{
|
||||
Vector3 pos = auger.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && auger.speed != speed)
|
||||
{
|
||||
auger.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
AutoCrafter[] allAutoCrafters = Object.FindObjectsOfType<AutoCrafter>();
|
||||
foreach (AutoCrafter autoCrafter in allAutoCrafters)
|
||||
{
|
||||
if (autoCrafter != null)
|
||||
{
|
||||
Vector3 pos = autoCrafter.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && autoCrafter.speed != speed)
|
||||
{
|
||||
autoCrafter.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
Retriever[] allRetrievers = Object.FindObjectsOfType<Retriever>();
|
||||
foreach (Retriever retriever in allRetrievers)
|
||||
{
|
||||
if (retriever != null)
|
||||
{
|
||||
Vector3 pos = retriever.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && retriever.speed != speed)
|
||||
{
|
||||
retriever.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
Turret[] allTurrets = Object.FindObjectsOfType<Turret>();
|
||||
foreach (Turret turret in allTurrets)
|
||||
{
|
||||
if (turret != null)
|
||||
{
|
||||
Vector3 pos = turret.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == machinePos && turret.speed != speed)
|
||||
{
|
||||
turret.speed = speed;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
machineDataCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Processes data from power conduit database.
|
||||
public IEnumerator ReceivePowerData()
|
||||
{
|
||||
powerDataCoroutineBusy = true;
|
||||
powerData = "none";
|
||||
GetPowerData();
|
||||
while (powerData == "none")
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
string[] powerlist = powerData.Split('[');
|
||||
for (int i = 2; i < powerlist.Length; i++)
|
||||
{
|
||||
string powerInfo = powerlist[i];
|
||||
float xPos = float.Parse(powerInfo.Split(',')[0]);
|
||||
float yPos = float.Parse(powerInfo.Split(',')[1]);
|
||||
float zPos = float.Parse(powerInfo.Split(',')[2]);
|
||||
Vector3 powerPos = new Vector3(xPos, yPos, zPos);
|
||||
int range = int.Parse(powerInfo.Split(',')[3]);
|
||||
bool dual = bool.Parse(powerInfo.Split(',')[4].Split(']')[0].Substring(2).TrimEnd('"'));
|
||||
|
||||
PowerConduit[] allPowerConduits = Object.FindObjectsOfType<PowerConduit>();
|
||||
foreach (PowerConduit powerConduit in allPowerConduits)
|
||||
{
|
||||
if (powerConduit != null)
|
||||
{
|
||||
Vector3 pos = powerConduit.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
Vector3 foundPos = new Vector3(x, y, z);
|
||||
if (foundPos == powerPos && powerConduit.range != range)
|
||||
{
|
||||
if (powerConduit.connectionFailed == true)
|
||||
{
|
||||
powerConduit.connectionAttempts = 0;
|
||||
powerConduit.connectionFailed = false;
|
||||
}
|
||||
powerConduit.dualOutput = dual == true;
|
||||
powerConduit.range = range;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
powerDataCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Gets chat messages from server.
|
||||
private async Task GetChatData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/chat");
|
||||
chatData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets inventory contents from server.
|
||||
public async Task GetStorageData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/storage");
|
||||
networkController.storageData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets data on recently instantiated blocks from server.
|
||||
public async Task GetBlockData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/blocks");
|
||||
networkController.blockData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets player data from server.
|
||||
public async Task GetPlayerData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/players");
|
||||
networkController.playerData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets universal and dark matter conduit data from server.
|
||||
private async Task GetConduitData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/conduits");
|
||||
conduitData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets power conduit data from server.
|
||||
private async Task GetPowerData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/power");
|
||||
powerData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets machine data from server.
|
||||
private async Task GetMachineData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/machines");
|
||||
machineData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets painted block colors from server.
|
||||
private async Task GetPaintData()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/paint");
|
||||
paintData = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
}
|
||||
}
|
198
NetworkSend.cs
Normal file
198
NetworkSend.cs
Normal file
@ -0,0 +1,198 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
public class NetworkSend
|
||||
{
|
||||
private NetworkController networkController;
|
||||
private PlayerController playerController;
|
||||
private string serverURL;
|
||||
private bool conduitCoroutineBusy;
|
||||
private bool machineCoroutineBusy;
|
||||
private bool paintCoroutineBusy;
|
||||
private bool hubCoroutineBusy;
|
||||
public bool sentNetworkStorage;
|
||||
private string playerRed;
|
||||
private string playerGreen;
|
||||
private string playerBlue;
|
||||
|
||||
//! Network functions for multiplayer games.
|
||||
public NetworkSend(NetworkController networkController)
|
||||
{
|
||||
this.networkController = networkController;
|
||||
playerController = networkController.playerController;
|
||||
serverURL = networkController.serverURL;
|
||||
playerRed = PlayerPrefs.GetFloat("playerRed").ToString();
|
||||
playerGreen = PlayerPrefs.GetFloat("playerGreen").ToString();
|
||||
playerBlue = PlayerPrefs.GetFloat("playerBlue").ToString();
|
||||
}
|
||||
|
||||
//! Sends a chat message to the server.
|
||||
public void SendChatMessage(string message)
|
||||
{
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/chat");
|
||||
client.UploadStringAsync(uri, "POST", "@" + PlayerPrefs.GetString("UserName") + ":" + message);
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets external IP address for online games.
|
||||
private string GetExternalAddress()
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri("https://api.ipify.org");
|
||||
return client.DownloadString(uri);
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends player name, location and color to the server.
|
||||
public void SendPlayerInfo()
|
||||
{
|
||||
Dictionary<string, string> values = new Dictionary<string, string>
|
||||
{
|
||||
{ "name", PlayerPrefs.GetString("UserName") },
|
||||
{ "x", playerController.gameObject.transform.position.x.ToString() },
|
||||
{ "y", playerController.gameObject.transform.position.y.ToString() },
|
||||
{ "z", playerController.gameObject.transform.position.z.ToString() },
|
||||
{ "fx", Camera.main.transform.forward.x.ToString() },
|
||||
{ "fz", Camera.main.transform.forward.z.ToString() },
|
||||
{ "r", playerRed },
|
||||
{ "g", playerGreen },
|
||||
{ "b", playerBlue }
|
||||
};
|
||||
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/players");
|
||||
client.UploadStringAsync(uri, "POST", "@" + values["name"] + ":"
|
||||
+ values["x"] + "," + values["y"] + "," + values["z"]
|
||||
+ "," + values["fx"] + "," + values["fz"] + ","
|
||||
+ values["r"] + "," + values["g"] + "," + values["b"]);
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends conduit range to the server when changed by the player.
|
||||
public IEnumerator SendConduitData(Vector3 pos, int range)
|
||||
{
|
||||
if (conduitCoroutineBusy == false)
|
||||
{
|
||||
conduitCoroutineBusy = true;
|
||||
yield return new WaitForSeconds(1);
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/conduits");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":" + range);
|
||||
}
|
||||
conduitCoroutineBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends machine speed to the server when changed by the player.
|
||||
public IEnumerator SendMachineData(Vector3 pos, int speed)
|
||||
{
|
||||
if (machineCoroutineBusy == false)
|
||||
{
|
||||
machineCoroutineBusy = true;
|
||||
yield return new WaitForSeconds(1);
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/machines");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":" + speed);
|
||||
}
|
||||
machineCoroutineBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends rail cart hub data to the server when changed by the player.
|
||||
public IEnumerator SendHubData(Vector3 pos, int range, bool stop, float stopTime)
|
||||
{
|
||||
if (hubCoroutineBusy == false)
|
||||
{
|
||||
hubCoroutineBusy = true;
|
||||
yield return new WaitForSeconds(1);
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/hubs");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":" + range + "," + stop + "," + "," + stopTime);
|
||||
}
|
||||
hubCoroutineBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends inventory data to the server.
|
||||
public IEnumerator SendNetworkStorage()
|
||||
{
|
||||
InventoryManager[] allInventories = Object.FindObjectsOfType<InventoryManager>();
|
||||
foreach (InventoryManager manager in allInventories)
|
||||
{
|
||||
if (manager != null)
|
||||
{
|
||||
if (manager.ID != "player")
|
||||
{
|
||||
InventorySlot[] inventory = manager.inventory;
|
||||
for (int i = 0; i < inventory.Length; i++)
|
||||
{
|
||||
using(WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/storage");
|
||||
Vector3 pos = manager.gameObject.transform.position;
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":"+i+";"+inventory[i].typeInSlot+"="+inventory[i].amountInSlot);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sentNetworkStorage = true;
|
||||
}
|
||||
|
||||
//! Sends power conduit data to the server.
|
||||
public IEnumerator SendPowerData(Vector3 pos, int range, bool dual)
|
||||
{
|
||||
if (conduitCoroutineBusy == false)
|
||||
{
|
||||
conduitCoroutineBusy = true;
|
||||
yield return new WaitForSeconds(1);
|
||||
float x = Mathf.Round(pos.x);
|
||||
float y = Mathf.Round(pos.y);
|
||||
float z = Mathf.Round(pos.z);
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/power");
|
||||
client.UploadStringAsync(uri, "POST", "@" + x + "," + y + "," + z + ":" + range + "," + dual);
|
||||
}
|
||||
conduitCoroutineBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
//! Sends painted block colors to the sever.
|
||||
public IEnumerator SendPaintData(string block, float red, float green, float blue)
|
||||
{
|
||||
if (paintCoroutineBusy == false)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
System.Uri uri = new System.Uri(serverURL+"/paint");
|
||||
client.UploadStringAsync(uri, "POST", "@" + block + ":" + red + "," + green + "," + blue);
|
||||
}
|
||||
paintCoroutineBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,11 @@ public class NuclearReactor : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f) && stateMananger.worldLoaded == true)
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
GetComponent<PhysicsHandler>().UpdatePhysics();
|
||||
updateTick = 0;
|
||||
|
247
ObjImporter.cs
Normal file
247
ObjImporter.cs
Normal file
@ -0,0 +1,247 @@
|
||||
/* This version of ObjImporter first reads through the entire file, getting a count of how large
|
||||
* the final arrays will be, and then uses standard arrays for everything (as opposed to ArrayLists
|
||||
* or any other fancy things).
|
||||
*/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
public class ObjImporter {
|
||||
|
||||
private struct meshStruct
|
||||
{
|
||||
public Vector3[] vertices;
|
||||
public Vector3[] normals;
|
||||
public Vector2[] uv;
|
||||
public Vector2[] uv1;
|
||||
public Vector2[] uv2;
|
||||
public int[] triangles;
|
||||
public int[] faceVerts;
|
||||
public int[] faceUVs;
|
||||
public Vector3[] faceData;
|
||||
public string name;
|
||||
public string fileName;
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
public Mesh ImportFile (string filePath) {
|
||||
meshStruct newMesh = createMeshStruct(filePath);
|
||||
populateMeshStruct(ref newMesh);
|
||||
|
||||
Vector3[] newVerts = new Vector3[newMesh.faceData.Length];
|
||||
Vector2[] newUVs = new Vector2[newMesh.faceData.Length];
|
||||
Vector3[] newNormals = new Vector3[newMesh.faceData.Length];
|
||||
int i = 0;
|
||||
/* The following foreach loops through the facedata and assigns the appropriate vertex, uv, or normal
|
||||
* for the appropriate Unity mesh array.
|
||||
*/
|
||||
foreach (Vector3 v in newMesh.faceData)
|
||||
{
|
||||
newVerts[i] = newMesh.vertices[(int)v.x - 1];
|
||||
if (v.y >= 1)
|
||||
newUVs[i] = newMesh.uv[(int)v.y - 1];
|
||||
|
||||
if (v.z >= 1)
|
||||
newNormals[i] = newMesh.normals[(int)v.z - 1];
|
||||
i++;
|
||||
}
|
||||
|
||||
Mesh mesh = new Mesh();
|
||||
|
||||
mesh.vertices = newVerts;
|
||||
mesh.uv = newUVs;
|
||||
mesh.normals = newNormals;
|
||||
mesh.triangles = newMesh.triangles;
|
||||
|
||||
mesh.RecalculateBounds();
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
private static meshStruct createMeshStruct(string filename)
|
||||
{
|
||||
int triangles = 0;
|
||||
int vertices = 0;
|
||||
int vt = 0;
|
||||
int vn = 0;
|
||||
int face = 0;
|
||||
meshStruct mesh = new meshStruct();
|
||||
mesh.fileName = filename;
|
||||
StreamReader stream = File.OpenText(filename);
|
||||
string entireText = stream.ReadToEnd();
|
||||
stream.Close();
|
||||
using (StringReader reader = new StringReader(entireText))
|
||||
{
|
||||
string currentText = reader.ReadLine();
|
||||
char[] splitIdentifier = { ' ' };
|
||||
string[] brokenString;
|
||||
while (currentText != null)
|
||||
{
|
||||
if (!currentText.StartsWith("f ") && !currentText.StartsWith("v ") && !currentText.StartsWith("vt ")
|
||||
&& !currentText.StartsWith("vn "))
|
||||
{
|
||||
currentText = reader.ReadLine();
|
||||
if (currentText != null)
|
||||
{
|
||||
currentText = currentText.Replace(" ", " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentText = currentText.Trim(); //Trim the current line
|
||||
brokenString = currentText.Split(splitIdentifier, 50); //Split the line into an array, separating the original line by blank spaces
|
||||
switch (brokenString[0])
|
||||
{
|
||||
case "v":
|
||||
vertices++;
|
||||
break;
|
||||
case "vt":
|
||||
vt++;
|
||||
break;
|
||||
case "vn":
|
||||
vn++;
|
||||
break;
|
||||
case "f":
|
||||
face = face + brokenString.Length - 1;
|
||||
triangles = triangles + 3 * (brokenString.Length - 2); /*brokenString.Length is 3 or greater since a face must have at least
|
||||
3 vertices. For each additional vertice, there is an additional
|
||||
triangle in the mesh (hence this formula).*/
|
||||
break;
|
||||
}
|
||||
currentText = reader.ReadLine();
|
||||
if (currentText != null)
|
||||
{
|
||||
currentText = currentText.Replace(" ", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mesh.triangles = new int[triangles];
|
||||
mesh.vertices = new Vector3[vertices];
|
||||
mesh.uv = new Vector2[vt];
|
||||
mesh.normals = new Vector3[vn];
|
||||
mesh.faceData = new Vector3[face];
|
||||
return mesh;
|
||||
}
|
||||
|
||||
private static void populateMeshStruct(ref meshStruct mesh)
|
||||
{
|
||||
StreamReader stream = File.OpenText(mesh.fileName);
|
||||
string entireText = stream.ReadToEnd();
|
||||
stream.Close();
|
||||
using (StringReader reader = new StringReader(entireText))
|
||||
{
|
||||
string currentText = reader.ReadLine();
|
||||
|
||||
char[] splitIdentifier = { ' ' };
|
||||
char[] splitIdentifier2 = { '/' };
|
||||
string[] brokenString;
|
||||
string[] brokenBrokenString;
|
||||
int f = 0;
|
||||
int f2 = 0;
|
||||
int v = 0;
|
||||
int vn = 0;
|
||||
int vt = 0;
|
||||
int vt1 = 0;
|
||||
int vt2 = 0;
|
||||
while (currentText != null)
|
||||
{
|
||||
if (!currentText.StartsWith("f ") && !currentText.StartsWith("v ") && !currentText.StartsWith("vt ") &&
|
||||
!currentText.StartsWith("vn ") && !currentText.StartsWith("g ") && !currentText.StartsWith("usemtl ") &&
|
||||
!currentText.StartsWith("mtllib ") && !currentText.StartsWith("vt1 ") && !currentText.StartsWith("vt2 ") &&
|
||||
!currentText.StartsWith("vc ") && !currentText.StartsWith("usemap "))
|
||||
{
|
||||
currentText = reader.ReadLine();
|
||||
if (currentText != null)
|
||||
{
|
||||
currentText = currentText.Replace(" ", " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentText = currentText.Trim();
|
||||
brokenString = currentText.Split(splitIdentifier, 50);
|
||||
switch (brokenString[0])
|
||||
{
|
||||
case "g":
|
||||
break;
|
||||
case "usemtl":
|
||||
break;
|
||||
case "usemap":
|
||||
break;
|
||||
case "mtllib":
|
||||
break;
|
||||
case "v":
|
||||
mesh.vertices[v] = new Vector3(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]),
|
||||
System.Convert.ToSingle(brokenString[3]));
|
||||
v++;
|
||||
break;
|
||||
case "vt":
|
||||
mesh.uv[vt] = new Vector2(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]));
|
||||
vt++;
|
||||
break;
|
||||
case "vt1":
|
||||
mesh.uv[vt1] = new Vector2(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]));
|
||||
vt1++;
|
||||
break;
|
||||
case "vt2":
|
||||
mesh.uv[vt2] = new Vector2(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]));
|
||||
vt2++;
|
||||
break;
|
||||
case "vn":
|
||||
mesh.normals[vn] = new Vector3(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]),
|
||||
System.Convert.ToSingle(brokenString[3]));
|
||||
vn++;
|
||||
break;
|
||||
case "vc":
|
||||
break;
|
||||
case "f":
|
||||
|
||||
int j = 1;
|
||||
List<int> intArray = new List<int>();
|
||||
while (j < brokenString.Length && ("" + brokenString[j]).Length > 0)
|
||||
{
|
||||
Vector3 temp = new Vector3();
|
||||
brokenBrokenString = brokenString[j].Split(splitIdentifier2, 3); //Separate the face into individual components (vert, uv, normal)
|
||||
temp.x = System.Convert.ToInt32(brokenBrokenString[0]);
|
||||
if (brokenBrokenString.Length > 1) //Some .obj files skip UV and normal
|
||||
{
|
||||
if (brokenBrokenString[1] != "") //Some .obj files skip the uv and not the normal
|
||||
{
|
||||
temp.y = System.Convert.ToInt32(brokenBrokenString[1]);
|
||||
}
|
||||
temp.z = System.Convert.ToInt32(brokenBrokenString[2]);
|
||||
}
|
||||
j++;
|
||||
|
||||
mesh.faceData[f2] = temp;
|
||||
intArray.Add(f2);
|
||||
f2++;
|
||||
}
|
||||
j = 1;
|
||||
while (j + 2 < brokenString.Length) //Create triangles out of the face data. There will generally be more than 1 triangle per face.
|
||||
{
|
||||
mesh.triangles[f] = intArray[0];
|
||||
f++;
|
||||
mesh.triangles[f] = intArray[j];
|
||||
f++;
|
||||
mesh.triangles[f] = intArray[j+1];
|
||||
f++;
|
||||
|
||||
j++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
currentText = reader.ReadLine();
|
||||
if (currentText != null)
|
||||
{
|
||||
currentText = currentText.Replace(" ", " "); //Some .obj files insert double spaces, this removes them.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,6 @@ public class PhysicsHandler : MonoBehaviour
|
||||
private int supportedXpositive;
|
||||
private int supportedXnegative;
|
||||
private int supportCount;
|
||||
public float lifetime;
|
||||
private float missingBlockTimer;
|
||||
private float supportCheckTimer;
|
||||
private float worldLoadTimer;
|
||||
@ -61,7 +60,6 @@ public class PhysicsHandler : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
lifetime += 0.01f * Time.deltaTime;
|
||||
if (GameObject.Find("GameManager").GetComponent<GameManager>().blockPhysics == true)
|
||||
{
|
||||
if (transform.position.y > 500 || transform.position.y < -5000)
|
||||
@ -369,7 +367,7 @@ public class PhysicsHandler : MonoBehaviour
|
||||
{
|
||||
if (separatedBlocks == false)
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(transform.position, "all",false);
|
||||
gameManager.meshManager.SeparateBlocks(transform.position, "all", false);
|
||||
separatedBlocks = true;
|
||||
}
|
||||
falling = true;
|
||||
|
81
Pirate.cs
81
Pirate.cs
@ -185,13 +185,32 @@ public class Pirate : MonoBehaviour
|
||||
{
|
||||
if (Physics.Linecast(transform.position, target.transform.position, out RaycastHit hit))
|
||||
{
|
||||
if (hit.collider.gameObject.tag.Equals("Built"))
|
||||
string objName;
|
||||
GameObject obj = hit.collider.gameObject;
|
||||
if (obj.tag.Equals("Built"))
|
||||
{
|
||||
if (obj.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
objName = obj.GetComponent<ModBlock>().blockName;
|
||||
}
|
||||
else
|
||||
{
|
||||
objName = obj.name.Split('(')[0];
|
||||
}
|
||||
|
||||
int RandomDamage = Random.Range(1, 101);
|
||||
if (RandomDamage > 75)
|
||||
{
|
||||
Instantiate(targetExplosion, hit.point, transform.rotation);
|
||||
Destroy(hit.collider.gameObject);
|
||||
if (objName.ToUpper().Contains("GLASS") && obj.GetComponent<PhysicsHandler>() != null)
|
||||
{
|
||||
obj.GetComponent<PhysicsHandler>().Explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(obj);
|
||||
}
|
||||
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
@ -199,7 +218,6 @@ public class Pirate : MonoBehaviour
|
||||
playerController.destructionMessageActive = true;
|
||||
playerController.currentTabletMessage = "";
|
||||
}
|
||||
string objName = hit.collider.gameObject.name.Split('(')[0];
|
||||
playerController.currentTabletMessage += "ALERT: " + objName + " destroyed by hostile spacecraft!\n";
|
||||
playerController.destructionMessageCount += 1;
|
||||
}
|
||||
@ -209,9 +227,9 @@ public class Pirate : MonoBehaviour
|
||||
Instantiate(damageExplosion, hit.point, transform.rotation);
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.tag.Equals("CombinedMesh"))
|
||||
else if (obj.tag.Equals("CombinedMesh"))
|
||||
{
|
||||
if (hit.collider.gameObject.name.Equals("glassHolder(Clone)"))
|
||||
if (obj.name.Equals("glassHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -232,7 +250,7 @@ public class Pirate : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("brickHolder(Clone)"))
|
||||
else if (obj.name.Equals("brickHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -257,7 +275,7 @@ public class Pirate : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("ironHolder(Clone)"))
|
||||
else if (obj.name.Equals("ironHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -282,7 +300,7 @@ public class Pirate : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hit.collider.gameObject.name.Equals("steelHolder(Clone)"))
|
||||
else if (obj.name.Equals("steelHolder(Clone)"))
|
||||
{
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
@ -307,6 +325,53 @@ public class Pirate : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj.name.Equals("modBlockHolder(Clone)"))
|
||||
{
|
||||
string type = "all";
|
||||
int toughness = 75;
|
||||
|
||||
Transform[] transforms = obj.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform t in transforms)
|
||||
{
|
||||
if (t.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
type = t.GetComponent<ModBlock>().blockName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type.ToUpper().Contains("GLASS"))
|
||||
{
|
||||
toughness = 25;
|
||||
}
|
||||
else if (type.ToUpper().Contains("STEEL"))
|
||||
{
|
||||
toughness = 99;
|
||||
}
|
||||
|
||||
int chanceOfDestruction = Random.Range(1, 101);
|
||||
{
|
||||
if (chanceOfDestruction > toughness)
|
||||
{
|
||||
Instantiate(targetExplosion, hit.point, transform.rotation);
|
||||
game.meshManager.SeparateBlocks(hit.point, type, false);
|
||||
if (CanSendDestructionMessage())
|
||||
{
|
||||
if (playerController.destructionMessageActive == false)
|
||||
{
|
||||
playerController.destructionMessageActive = true;
|
||||
playerController.currentTabletMessage = "";
|
||||
}
|
||||
playerController.currentTabletMessage += "ALERT: Some blocks were attacked by hostile spacecraft!\n";
|
||||
playerController.destructionMessageCount += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Instantiate(damageExplosion, hit.point, transform.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fireTimer = 0;
|
||||
|
@ -7,6 +7,7 @@ using UnityEngine.SceneManagement;
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
private InputManager inputManager;
|
||||
public NetworkController networkController;
|
||||
private Coroutine saveCoroutine;
|
||||
private Vector3 originalPosition;
|
||||
|
||||
@ -23,6 +24,7 @@ public class PlayerController : MonoBehaviour
|
||||
public GameObject machineInSight;
|
||||
public LaserController laserController;
|
||||
public BlockSelector blockSelector;
|
||||
public Door doorToEdit;
|
||||
|
||||
public bool cannotCollect;
|
||||
public bool building;
|
||||
@ -31,12 +33,15 @@ public class PlayerController : MonoBehaviour
|
||||
public bool machineGUIopen;
|
||||
public bool craftingGUIopen;
|
||||
public bool marketGUIopen;
|
||||
public bool buildAmountGUIopen;
|
||||
public bool doorGUIopen;
|
||||
public bool remoteStorageActive;
|
||||
public bool escapeMenuOpen;
|
||||
public bool machineHasPower;
|
||||
public bool lookingAtCombinedMesh;
|
||||
public bool tabletOpen;
|
||||
public bool optionsGUIopen;
|
||||
public bool creativeMode;
|
||||
public bool timeToDeliverWarningRecieved;
|
||||
public bool draggingItem;
|
||||
public bool displayingBuildItem;
|
||||
@ -61,7 +66,6 @@ public class PlayerController : MonoBehaviour
|
||||
public bool destroying;
|
||||
public bool requestedChunkLoad;
|
||||
public bool blockLimitMessage;
|
||||
public bool requestedEscapeMenu;
|
||||
public bool laserCannonActive;
|
||||
public bool scannerActive;
|
||||
public bool firing;
|
||||
@ -76,6 +80,7 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
private bool gotPosition;
|
||||
private bool gameStarted;
|
||||
private bool checkedForCreativeMode;
|
||||
private bool meteorShowerWarningReceived;
|
||||
private bool pirateAttackWarningReceived;
|
||||
private bool destructionMessageReceived;
|
||||
@ -110,8 +115,6 @@ public class PlayerController : MonoBehaviour
|
||||
public float buildItemDisplayTimer;
|
||||
public float footStepTimer;
|
||||
public float footStepSoundFrquency;
|
||||
public float destroyTimer;
|
||||
public float buildTimer;
|
||||
public float buildIncrementTimer;
|
||||
public float invalidAugerPlacementTimer;
|
||||
public float autoAxisMessageTimer;
|
||||
@ -126,6 +129,12 @@ public class PlayerController : MonoBehaviour
|
||||
public int machinePower;
|
||||
public int machineSpeed;
|
||||
public double machineRange;
|
||||
public int networkedConduitRange;
|
||||
public int networkedMachineSpeed;
|
||||
public bool networkedDualPower;
|
||||
public int networkedHubRange;
|
||||
public bool networkedHubStop;
|
||||
public float networkedHubStopTime;
|
||||
public int machineHeat;
|
||||
public int machineCooling;
|
||||
public int buildMultiplier = 1;
|
||||
@ -166,7 +175,8 @@ public class PlayerController : MonoBehaviour
|
||||
public GameObject storageContainer;
|
||||
public GameObject universalExtractor;
|
||||
public GameObject auger;
|
||||
public GameObject airlock;
|
||||
public GameObject quantumHatchway;
|
||||
public GameObject door;
|
||||
public GameObject universalConduit;
|
||||
public GameObject glass;
|
||||
public GameObject brick;
|
||||
@ -196,10 +206,13 @@ public class PlayerController : MonoBehaviour
|
||||
public GameObject currentStorageComputer;
|
||||
public GameObject buildObject;
|
||||
public GameObject modMachine;
|
||||
public GameObject modBlock;
|
||||
public GameObject item;
|
||||
public GameObject networkPlayer;
|
||||
|
||||
public Material constructionMat;
|
||||
|
||||
private bool addedModMachines;
|
||||
public bool addedModBlocks;
|
||||
|
||||
// Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
@ -259,16 +272,22 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
inputManager = new InputManager(this);
|
||||
blockSelector = new BlockSelector(this);
|
||||
networkController = new NetworkController(this);
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ReadyToLoadModMachines() == true)
|
||||
if (addedModBlocks == false)
|
||||
{
|
||||
BlockDictionary blockDictionary = GetComponent<BuildController>().blockDictionary;
|
||||
blockDictionary.AddModMachines(blockDictionary.machineDictionary);
|
||||
addedModMachines = true;
|
||||
if (ReadyToLoadModBlocks())
|
||||
{
|
||||
BlockDictionary blockDictionary = GetComponent<BuildController>().blockDictionary;
|
||||
blockDictionary.AddModBlocks(blockDictionary.blockDictionary);
|
||||
blockDictionary.AddModMachines(blockDictionary.machineDictionary);
|
||||
blockDictionary.AddModMeshes(blockDictionary.meshDictionary);
|
||||
addedModBlocks = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Get a refrence to the camera.
|
||||
@ -303,7 +322,7 @@ public class PlayerController : MonoBehaviour
|
||||
{
|
||||
gameStarted = true;
|
||||
|
||||
if (FileBasedPrefs.GetBool(stateManager.WorldName + "oldWorld") == false)
|
||||
if (FileBasedPrefs.GetBool(stateManager.worldName + "oldWorld") == false)
|
||||
{
|
||||
OpenTabletOnFirstLoad();
|
||||
}
|
||||
@ -317,6 +336,17 @@ public class PlayerController : MonoBehaviour
|
||||
ShowTabletIntro();
|
||||
}
|
||||
|
||||
if (checkedForCreativeMode == false && stateManager.worldLoaded == true)
|
||||
{
|
||||
string worldName = stateManager.worldName.ToUpper();
|
||||
if (worldName.Contains("CREATIVE"))
|
||||
{
|
||||
creativeMode = true;
|
||||
Debug.Log("World [" + stateManager.worldName + "] running in creative mode.");
|
||||
}
|
||||
checkedForCreativeMode = true;
|
||||
}
|
||||
|
||||
// Destruction messages.
|
||||
if (destructionMessageActive == true)
|
||||
{
|
||||
@ -411,11 +441,6 @@ public class PlayerController : MonoBehaviour
|
||||
gameObject.GetComponent<MSCameraController>().enabled = true;
|
||||
}
|
||||
|
||||
if (requestedEscapeMenu == true)
|
||||
{
|
||||
HandleEscapeMenuRequest();
|
||||
}
|
||||
|
||||
if (requestedSave == true)
|
||||
{
|
||||
HandleSaveRequest();
|
||||
@ -431,6 +456,11 @@ public class PlayerController : MonoBehaviour
|
||||
inputManager.HandleInput();
|
||||
EnforceWorldLimits();
|
||||
}
|
||||
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
|
||||
{
|
||||
networkController.NetWorkUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -485,9 +515,10 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
|
||||
//! Returns true when prerequisites are met for loading machines added by mods.
|
||||
private bool ReadyToLoadModMachines()
|
||||
private bool ReadyToLoadModBlocks()
|
||||
{
|
||||
return addedModMachines == false
|
||||
return addedModBlocks == false
|
||||
&& modBlock != null
|
||||
&& modMachine != null
|
||||
&& blockSelector != null
|
||||
&& BlockDictionaryInitiazlied()
|
||||
@ -519,10 +550,10 @@ public class PlayerController : MonoBehaviour
|
||||
{
|
||||
playerInventory.SaveData();
|
||||
GameObject.Find("LanderCargo").GetComponent<InventoryManager>().SaveData();
|
||||
PlayerPrefsX.SetVector3(stateManager.WorldName + "playerPosition", transform.position);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.WorldName + "playerRotation", transform.rotation);
|
||||
FileBasedPrefs.SetInt(stateManager.WorldName + "money", money);
|
||||
FileBasedPrefs.SetBool(stateManager.WorldName + "oldWorld", true);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + "playerPosition", transform.position);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + "playerRotation", transform.rotation);
|
||||
FileBasedPrefs.SetInt(stateManager.worldName + "money", money);
|
||||
FileBasedPrefs.SetBool(stateManager.worldName + "oldWorld", true);
|
||||
}
|
||||
|
||||
//! Applies global settings.
|
||||
@ -576,7 +607,9 @@ public class PlayerController : MonoBehaviour
|
||||
|| machineGUIopen == true
|
||||
|| tabletOpen == true
|
||||
|| marketGUIopen == true
|
||||
|| (paintGunActive == true && paintColorSelected == false);
|
||||
|| (paintGunActive == true && paintColorSelected == false)
|
||||
|| buildAmountGUIopen == true
|
||||
|| doorGUIopen == true;
|
||||
}
|
||||
|
||||
//! Returns true at the beginning of the first in-game day when the intro should be displayed on the tablet.
|
||||
@ -600,9 +633,9 @@ public class PlayerController : MonoBehaviour
|
||||
//! Moves the player to their previous location when a game is loaded.
|
||||
private void MovePlayerToSavedLocation()
|
||||
{
|
||||
transform.position = PlayerPrefsX.GetVector3(stateManager.WorldName + "playerPosition");
|
||||
transform.rotation = PlayerPrefsX.GetQuaternion(stateManager.WorldName + "playerRotation");
|
||||
money = FileBasedPrefs.GetInt(stateManager.WorldName + "money");
|
||||
transform.position = PlayerPrefsX.GetVector3(stateManager.worldName + "playerPosition");
|
||||
transform.rotation = PlayerPrefsX.GetQuaternion(stateManager.worldName + "playerRotation");
|
||||
money = FileBasedPrefs.GetInt(stateManager.worldName + "money");
|
||||
movedPlayer = true;
|
||||
}
|
||||
|
||||
@ -654,8 +687,6 @@ public class PlayerController : MonoBehaviour
|
||||
stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
separatedBlocks = false;
|
||||
destroyTimer = 0;
|
||||
buildTimer = 0;
|
||||
building = false;
|
||||
destroying = false;
|
||||
requestedBuildingStop = false;
|
||||
@ -669,40 +700,19 @@ public class PlayerController : MonoBehaviour
|
||||
//! Handles the sending of chunk load requests for modifying combined meshes.
|
||||
private void ModifyCombinedMeshes()
|
||||
{
|
||||
destroyTimer += 1 * Time.deltaTime;
|
||||
if (destroyTimer >= 30)
|
||||
float distance = Vector3.Distance(transform.position, destroyStartPosition);
|
||||
if (distance > gameManager.chunkSize * 0.75f)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
{
|
||||
stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
destroyTimer = 0;
|
||||
buildTimer = 0;
|
||||
building = false;
|
||||
destroying = false;
|
||||
separatedBlocks = false;
|
||||
gameManager.meshManager.SeparateBlocks(transform.position, "all", true);
|
||||
separatedBlocks = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, destroyStartPosition);
|
||||
if (distance > 15)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
{
|
||||
gameManager.meshManager.SeparateBlocks(transform.position, "all", true);
|
||||
separatedBlocks = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
requestedChunkLoad = true;
|
||||
}
|
||||
destroyStartPosition = transform.position;
|
||||
requestedChunkLoad = true;
|
||||
}
|
||||
destroyStartPosition = transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
@ -724,34 +734,13 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
//! Handles requests to open the escape menu, stopping appropriate coroutines.
|
||||
private void HandleEscapeMenuRequest()
|
||||
//! Opens the escape menu.
|
||||
public void OpenEscapeMenu()
|
||||
{
|
||||
if (building == true || destroying == true)
|
||||
{
|
||||
if (gameManager.working == false)
|
||||
{
|
||||
stoppingBuildCoRoutine = true;
|
||||
gameManager.meshManager.CombineBlocks();
|
||||
separatedBlocks = false;
|
||||
destroyTimer = 0;
|
||||
buildTimer = 0;
|
||||
building = false;
|
||||
destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
else if (gameManager.working == false)
|
||||
{
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
gameObject.GetComponent<MSCameraController>().enabled = false;
|
||||
escapeMenuOpen = true;
|
||||
requestedEscapeMenu = false;
|
||||
}
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
gameObject.GetComponent<MSCameraController>().enabled = false;
|
||||
escapeMenuOpen = true;
|
||||
}
|
||||
|
||||
//! Enforces world size limitations.
|
||||
@ -823,6 +812,61 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
//! Drops a stack of items on the ground.
|
||||
public void DropItem(InventorySlot slot)
|
||||
{
|
||||
Vector3 dropPos = mCam.transform.position + mCam.transform.forward * 10;
|
||||
GameObject droppedItem = Instantiate(item, dropPos, mCam.transform.rotation);
|
||||
droppedItem.GetComponent<Item>().type = slot.typeInSlot;
|
||||
droppedItem.GetComponent<Item>().amount = slot.amountInSlot;
|
||||
slot.typeInSlot = "nothing";
|
||||
slot.amountInSlot = 0;
|
||||
PlayCraftingSound();
|
||||
}
|
||||
|
||||
//! Used to handle walking up stairs.
|
||||
public void OnCollisionStay(Collision collision)
|
||||
{
|
||||
if (collision.gameObject.name == "modBlockHolder(Clone)")
|
||||
{
|
||||
Transform[] transforms = collision.gameObject.GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform t in transforms)
|
||||
{
|
||||
if (t.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
string blockName = t.GetComponent<ModBlock>().blockName.ToUpper();
|
||||
if (blockName.Contains("STAIR"))
|
||||
{
|
||||
GetComponent<Rigidbody>().AddForce(Vector3.up * 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (collision.gameObject.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
string blockName = collision.gameObject.GetComponent<ModBlock>().blockName.ToUpper();
|
||||
if (blockName.Contains("STAIR"))
|
||||
{
|
||||
GetComponent<Rigidbody>().AddForce(Vector3.up * 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Used to handle picking up items.
|
||||
public void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if (collision.gameObject.GetComponent<Item>() != null)
|
||||
{
|
||||
Item colItem = collision.gameObject.GetComponent<Item>();
|
||||
playerInventory.AddItem(colItem.type, colItem.amount);
|
||||
if (playerInventory.itemAdded)
|
||||
{
|
||||
Destroy(collision.gameObject);
|
||||
PlayCraftingSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Handles saving world and exiting to the main menu.
|
||||
public static IEnumerator Save()
|
||||
{
|
||||
@ -838,7 +882,7 @@ public class PlayerController : MonoBehaviour
|
||||
{
|
||||
Debug.Log("Game saved to " + FileBasedPrefs.GetSaveFilePath());
|
||||
Debug.Log("Creating backup...");
|
||||
string fileName = GameObject.Find("GameManager").GetComponent<StateManager>().WorldName;
|
||||
string fileName = GameObject.Find("GameManager").GetComponent<StateManager>().worldName;
|
||||
string destinationPath = Path.Combine(Application.persistentDataPath, "SaveData/" + fileName + ".bak");
|
||||
File.Copy(FileBasedPrefs.GetSaveFilePath(), destinationPath, true);
|
||||
Debug.Log("Backup saved to " + destinationPath);
|
||||
|
186
PlayerGUI.cs
186
PlayerGUI.cs
@ -47,12 +47,7 @@ public class PlayerGUI : MonoBehaviour
|
||||
//! Returns true if the block is a building block, used with combined meshes.
|
||||
private bool IsStandardBlock(string type)
|
||||
{
|
||||
return type == "Brick"
|
||||
|| type == "Glass Block"
|
||||
|| type == "Iron Block"
|
||||
|| type == "Iron Ramp"
|
||||
|| type == "Steel Block"
|
||||
|| type == "Steel Ramp";
|
||||
return playerController.GetComponent<BuildController>().blockDictionary.blockDictionary.ContainsKey(type);
|
||||
}
|
||||
|
||||
//! Returns true if the saving world message should be displayed.
|
||||
@ -97,6 +92,13 @@ public class PlayerGUI : MonoBehaviour
|
||||
|| schematic7 == true;
|
||||
}
|
||||
|
||||
private bool ShowCrosshair()
|
||||
{
|
||||
return playerController.crosshairEnabled &&
|
||||
!playerController.GuiOpen() &&
|
||||
!playerController.paintGunActive;
|
||||
}
|
||||
|
||||
//! Called by unity engine for rendering and handling GUI events.
|
||||
public void OnGUI()
|
||||
{
|
||||
@ -121,11 +123,45 @@ public class PlayerGUI : MonoBehaviour
|
||||
if (playerController.displayingBuildItem == true)
|
||||
{
|
||||
GUI.Label(guiCoordinates.topRightInfoRect, "\n\nBuild item set to " + playerController.buildType);
|
||||
GUI.DrawTexture(guiCoordinates.previousBuildItemTextureRect, textureDictionary.dictionary[playerController.previousBuildType]);
|
||||
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
|
||||
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
|
||||
|
||||
if (textureDictionary.dictionary.ContainsKey(playerController.previousBuildType + "_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.previousBuildItemTextureRect, textureDictionary.dictionary[playerController.previousBuildType + "_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.previousBuildItemTextureRect, textureDictionary.dictionary[playerController.previousBuildType]);
|
||||
}
|
||||
|
||||
if (textureDictionary.dictionary.ContainsKey(playerController.buildType + "_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary[playerController.buildType + "_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
|
||||
}
|
||||
|
||||
if (textureDictionary.dictionary.ContainsKey(playerController.buildType + "_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType + "_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
|
||||
}
|
||||
|
||||
GUI.DrawTexture(guiCoordinates.buildItemTextureRect, textureDictionary.dictionary["Selection Box"]);
|
||||
GUI.DrawTexture(guiCoordinates.nextBuildItemTextureRect, textureDictionary.dictionary[playerController.nextBuildType]);
|
||||
|
||||
if (textureDictionary.dictionary.ContainsKey(playerController.nextBuildType + "_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.nextBuildItemTextureRect, textureDictionary.dictionary[playerController.nextBuildType + "_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.nextBuildItemTextureRect, textureDictionary.dictionary[playerController.nextBuildType]);
|
||||
}
|
||||
|
||||
int buildItemCount = 0;
|
||||
foreach (InventorySlot slot in playerInventory.inventory)
|
||||
{
|
||||
@ -500,7 +536,7 @@ public class PlayerGUI : MonoBehaviour
|
||||
|
||||
RenderSettings.fogDensity = GUI.HorizontalSlider(guiCoordinates.optionsButton9Rect, RenderSettings.fogDensity, 0.00025f, 0.025f);
|
||||
|
||||
gameManager.chunkSize = (int)GUI.HorizontalSlider(guiCoordinates.optionsButton10Rect, gameManager.chunkSize, 100, 500);
|
||||
gameManager.chunkSize = (int)GUI.HorizontalSlider(guiCoordinates.optionsButton10Rect, gameManager.chunkSize, 20, 100);
|
||||
|
||||
string vsyncDisplay = QualitySettings.vSyncCount == 1 ? "ON" : "OFF";
|
||||
if (GUI.Button(guiCoordinates.optionsButton11Rect, "Vsync: " + vsyncDisplay))
|
||||
@ -526,7 +562,10 @@ public class PlayerGUI : MonoBehaviour
|
||||
string blockPhysicsDisplay = gameManager.blockPhysics == true ? "ON" : "OFF";
|
||||
if (GUI.Button(guiCoordinates.optionsButton13Rect, "Block Physics: "+ blockPhysicsDisplay))
|
||||
{
|
||||
gameManager.blockPhysics = !gameManager.blockPhysics;
|
||||
if (PlayerPrefsX.GetPersistentBool("multiplayer") == false)
|
||||
{
|
||||
gameManager.blockPhysics = !gameManager.blockPhysics;
|
||||
}
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
|
||||
@ -614,8 +653,8 @@ public class PlayerGUI : MonoBehaviour
|
||||
|
||||
if (playerController.stoppingBuildCoRoutine == true || playerController.requestedBuildingStop == true)
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.highMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.longHighMessageRect, "Stopping Build System...");
|
||||
GUI.DrawTexture(guiCoordinates.buildingMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
|
||||
GUI.Label(guiCoordinates.buildingMessageRect, "Stopping Build System...");
|
||||
}
|
||||
|
||||
if (playerController.blockLimitMessage == true)
|
||||
@ -634,14 +673,26 @@ public class PlayerGUI : MonoBehaviour
|
||||
}
|
||||
|
||||
// BUILDING INSTRUCTIONS
|
||||
if (playerController.building == true && playerController.tabletOpen == false)
|
||||
bool playerBuilding = playerController.building == true && !playerController.GuiOpen();
|
||||
bool drawingInfoHud = playerController.GetComponent<InfoHUD>().ShouldDrawInfoHud();
|
||||
|
||||
if (playerBuilding && !drawingInfoHud)
|
||||
{
|
||||
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.Label(guiCoordinates.buildInfoRect, "Right click to place block.\nPress F to collect.\nPress R or Ctrl+R to rotate.\nPress B to stop building.");
|
||||
GUI.skin.label.fontSize = f;
|
||||
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
|
||||
|
||||
if (textureDictionary.dictionary.ContainsKey(playerController.buildType + "_Icon"))
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType + "_Icon"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.currentBuildItemTextureRect, textureDictionary.dictionary[playerController.buildType]);
|
||||
}
|
||||
|
||||
int buildItemCount = 0;
|
||||
foreach (InventorySlot slot in playerInventory.inventory)
|
||||
{
|
||||
@ -650,6 +701,7 @@ public class PlayerGUI : MonoBehaviour
|
||||
buildItemCount += slot.amountInSlot;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsStandardBlock(playerController.buildType))
|
||||
{
|
||||
GUI.Label(guiCoordinates.buildItemCountRect, "" + buildItemCount + "\nx" + playerController.buildMultiplier);
|
||||
@ -729,23 +781,95 @@ public class PlayerGUI : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// CROSSHAIR
|
||||
if (!playerController.inventoryOpen && !playerController.machineGUIopen && !playerController.marketGUIopen)
|
||||
// BUILD AMOUNT
|
||||
if (playerController.buildAmountGUIopen)
|
||||
{
|
||||
if (!playerController.escapeMenuOpen && !playerController.tabletOpen && !playerController.paintGunActive)
|
||||
GUI.DrawTexture(guiCoordinates.buildAmountRect, textureDictionary.dictionary["Menu Background"]);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 12;
|
||||
GUI.Label(guiCoordinates.buildAmountTitleRect, "Enter Build Amount");
|
||||
GUI.skin.label.fontSize = f;
|
||||
|
||||
string amountString = GUI.TextField(guiCoordinates.buildAmountTextFieldRect, playerController.buildMultiplier.ToString(), 3);
|
||||
try
|
||||
{
|
||||
if (playerController.crosshairEnabled)
|
||||
{
|
||||
GUIContent content = new GUIContent(Resources.Load("Crosshair") as Texture2D);
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
Vector2 size = style.CalcSize(content);
|
||||
size.x = size.x / 3.5f;
|
||||
size.y = size.y / 4;
|
||||
Rect crosshairRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height / 2) - (size.y / 2), size.x, size.y);
|
||||
GUI.DrawTexture(crosshairRect, textureDictionary.dictionary["Crosshair"]);
|
||||
}
|
||||
playerController.buildMultiplier = int.Parse(amountString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
int i = playerController.buildMultiplier;
|
||||
i = i > 100 ? 100 : i;
|
||||
playerController.buildMultiplier = i;
|
||||
|
||||
if (GUI.Button(guiCoordinates.buildAmountButtonRect, "OK"))
|
||||
{
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
playerController.buildAmountGUIopen = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
|
||||
// DOOR SETTINGS
|
||||
if (playerController.doorGUIopen)
|
||||
{
|
||||
GUI.DrawTexture(guiCoordinates.doorSettingsRect, textureDictionary.dictionary["Menu Background"]);
|
||||
int f = GUI.skin.label.fontSize;
|
||||
GUI.skin.label.fontSize = 12;
|
||||
GUI.Label(guiCoordinates.doorTitleRect, "Door Settings");
|
||||
GUI.skin.label.fontSize = f;
|
||||
|
||||
if (GUI.Button(guiCoordinates.doorTextureRect,"Material"))
|
||||
{
|
||||
Door door = playerController.doorToEdit;
|
||||
|
||||
if (door.textureIndex < door.textures.Length - 1)
|
||||
door.textureIndex++;
|
||||
else
|
||||
door.textureIndex = 0;
|
||||
|
||||
door.material = door.textures[door.textureIndex];
|
||||
gameManager.meshManager.SetMaterial(door.closedObject, door.material);
|
||||
door.edited = true;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
|
||||
if (GUI.Button(guiCoordinates.doorSoundRect,"Sound"))
|
||||
{
|
||||
Door door = playerController.doorToEdit;
|
||||
|
||||
if (door.audioClip < door.audioClips.Length - 1)
|
||||
door.audioClip++;
|
||||
else
|
||||
door.audioClip = 0;
|
||||
|
||||
door.GetComponent<AudioSource>().clip = door.audioClips[door.audioClip];
|
||||
door.GetComponent<AudioSource>().Play();
|
||||
}
|
||||
|
||||
if (GUI.Button(guiCoordinates.doorCloseRect, "OK"))
|
||||
{
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
playerController.doorGUIopen = false;
|
||||
playerController.PlayButtonSound();
|
||||
}
|
||||
}
|
||||
|
||||
// CROSSHAIR
|
||||
if (ShowCrosshair() == true)
|
||||
{
|
||||
GUIContent content = new GUIContent(Resources.Load("Crosshair") as Texture2D);
|
||||
GUIStyle style = GUI.skin.box;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
Vector2 size = style.CalcSize(content);
|
||||
size.x = size.x / 3.5f;
|
||||
size.y = size.y / 4;
|
||||
Rect crosshairRect = new Rect((Screen.width / 2) - (size.x / 2), (Screen.height / 2) - (size.y / 2), size.x, size.y);
|
||||
GUI.DrawTexture(crosshairRect, textureDictionary.dictionary["Crosshair"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,13 +38,16 @@ public class PowerConduit : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
outputObjects = new GameObject[] { outputObject1, outputObject2 };
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -36,13 +36,16 @@ public class PowerSource : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
@ -127,7 +130,7 @@ public class PowerSource : MonoBehaviour
|
||||
private void ConnectToOutput(GameObject obj)
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, obj.transform.position);
|
||||
if (distance < 40)
|
||||
if (distance <= 40)
|
||||
{
|
||||
if (obj.GetComponent<PowerReceiver>() != null && outputObject == null)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public class RailCart : MonoBehaviour
|
||||
//! Called by unity engine on start up to initialize variables.
|
||||
public void Start()
|
||||
{
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,9 @@ public class RailCartHub : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -53,12 +53,15 @@ public class Retriever : MonoBehaviour
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
20
Rocket.cs
20
Rocket.cs
@ -31,7 +31,7 @@ public class Rocket : MonoBehaviour
|
||||
}
|
||||
|
||||
gameTime += 1 * Time.deltaTime;
|
||||
FileBasedPrefs.SetFloat(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "gameTime", gameTime);
|
||||
FileBasedPrefs.SetFloat(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "gameTime", gameTime);
|
||||
|
||||
if (gameTime >= 2400)
|
||||
{
|
||||
@ -74,15 +74,15 @@ public class Rocket : MonoBehaviour
|
||||
//! Initializes variables when the world is loaded.
|
||||
private void Init()
|
||||
{
|
||||
if (FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "payloadRequired") != 0)
|
||||
if (FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "payloadRequired") != 0)
|
||||
{
|
||||
payloadRequired = FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "payloadRequired");
|
||||
payloadRequired = FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "payloadRequired");
|
||||
}
|
||||
if (FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "day") != 0)
|
||||
if (FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "day") != 0)
|
||||
{
|
||||
day = FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "day");
|
||||
day = FileBasedPrefs.GetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "day");
|
||||
}
|
||||
gameTime = FileBasedPrefs.GetFloat(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "gameTime");
|
||||
gameTime = FileBasedPrefs.GetFloat(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "gameTime");
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@ -100,13 +100,13 @@ public class Rocket : MonoBehaviour
|
||||
if (amountInRocket >= payloadRequired && ascending == false)
|
||||
{
|
||||
player.money += 1000;
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "money", player.money);
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "money", player.money);
|
||||
ascending = true;
|
||||
}
|
||||
else if (liftOffTimer >= 600 && ascending == false)
|
||||
{
|
||||
player.money -= 500;
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "money", player.money);
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "money", player.money);
|
||||
ascending = true;
|
||||
}
|
||||
}
|
||||
@ -120,8 +120,8 @@ public class Rocket : MonoBehaviour
|
||||
{
|
||||
payloadRequired = payloadRequired * 2;
|
||||
}
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "day", day);
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().WorldName + "payloadRequired", payloadRequired);
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "day", day);
|
||||
FileBasedPrefs.SetInt(GameObject.Find("GameManager").GetComponent<StateManager>().worldName + "payloadRequired", payloadRequired);
|
||||
player.timeToDeliver = true;
|
||||
}
|
||||
|
||||
|
137
SaveManager.cs
137
SaveManager.cs
@ -27,7 +27,7 @@ public class SaveManager
|
||||
List<int> idList = new List<int>();
|
||||
|
||||
GameObject[] machines = GameObject.FindGameObjectsWithTag("Built");
|
||||
Transform[] blocks = stateManager.BuiltObjects.GetComponentsInChildren<Transform>(true);
|
||||
Transform[] blocks = stateManager.builtObjects.GetComponentsInChildren<Transform>(true);
|
||||
MeshPainter[] meshPainters = Object.FindObjectsOfType<MeshPainter>();
|
||||
|
||||
if (totalObjects == 0)
|
||||
@ -39,13 +39,13 @@ public class SaveManager
|
||||
{
|
||||
if (go != null)
|
||||
{
|
||||
if (go.transform.parent != stateManager.BuiltObjects.transform)
|
||||
if (go.transform.parent != stateManager.builtObjects.transform)
|
||||
{
|
||||
Vector3 objectPosition = go.transform.position;
|
||||
Quaternion objectRotation = go.transform.rotation;
|
||||
if (go.GetComponent<Auger>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Auger";
|
||||
objectName = stateManager.worldName + "Auger";
|
||||
worldID = go.GetComponent<Auger>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -58,7 +58,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<ElectricLight>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "ElectricLight";
|
||||
objectName = stateManager.worldName + "ElectricLight";
|
||||
worldID = go.GetComponent<ElectricLight>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -67,7 +67,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<DarkMatterCollector>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "DarkMatterCollector";
|
||||
objectName = stateManager.worldName + "DarkMatterCollector";
|
||||
worldID = go.GetComponent<DarkMatterCollector>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -80,7 +80,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<DarkMatterConduit>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "DarkMatterConduit";
|
||||
objectName = stateManager.worldName + "DarkMatterConduit";
|
||||
worldID = go.GetComponent<DarkMatterConduit>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -99,7 +99,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<RailCart>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "RailCart";
|
||||
objectName = stateManager.worldName + "RailCart";
|
||||
worldID = go.GetComponent<RailCart>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -112,7 +112,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<RailCartHub>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "RailCartHub";
|
||||
objectName = stateManager.worldName + "RailCartHub";
|
||||
worldID = go.GetComponent<RailCartHub>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -135,7 +135,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<UniversalConduit>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "UniversalConduit";
|
||||
objectName = stateManager.worldName + "UniversalConduit";
|
||||
worldID = go.GetComponent<UniversalConduit>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -156,7 +156,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<HeatExchanger>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "HeatExchanger";
|
||||
objectName = stateManager.worldName + "HeatExchanger";
|
||||
worldID = go.GetComponent<HeatExchanger>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -175,7 +175,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<Retriever>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Retriever";
|
||||
objectName = stateManager.worldName + "Retriever";
|
||||
worldID = go.GetComponent<Retriever>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -196,7 +196,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<AutoCrafter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "AutoCrafter";
|
||||
objectName = stateManager.worldName + "AutoCrafter";
|
||||
worldID = go.GetComponent<AutoCrafter>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -213,7 +213,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<Smelter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Smelter";
|
||||
objectName = stateManager.worldName + "Smelter";
|
||||
worldID = go.GetComponent<Smelter>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -234,7 +234,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<Turret>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Turret";
|
||||
objectName = stateManager.worldName + "Turret";
|
||||
worldID = go.GetComponent<Turret>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -245,7 +245,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<MissileTurret>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "MissileTurret";
|
||||
objectName = stateManager.worldName + "MissileTurret";
|
||||
worldID = go.GetComponent<MissileTurret>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -262,15 +262,15 @@ public class SaveManager
|
||||
{
|
||||
if (go.GetComponent<PowerSource>().type == "Solar Panel")
|
||||
{
|
||||
objectName = stateManager.WorldName + "SolarPanel";
|
||||
objectName = stateManager.worldName + "SolarPanel";
|
||||
}
|
||||
else if (go.GetComponent<PowerSource>().type == "Generator")
|
||||
{
|
||||
objectName = stateManager.WorldName + "Generator";
|
||||
objectName = stateManager.worldName + "Generator";
|
||||
}
|
||||
else if (go.GetComponent<PowerSource>().type == "Reactor Turbine")
|
||||
{
|
||||
objectName = stateManager.WorldName + "ReactorTurbine";
|
||||
objectName = stateManager.worldName + "ReactorTurbine";
|
||||
}
|
||||
worldID = go.GetComponent<PowerSource>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
@ -286,7 +286,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<NuclearReactor>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "NuclearReactor";
|
||||
objectName = stateManager.worldName + "NuclearReactor";
|
||||
worldID = go.GetComponent<NuclearReactor>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -295,7 +295,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<PowerConduit>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "PowerConduit";
|
||||
objectName = stateManager.worldName + "PowerConduit";
|
||||
worldID = go.GetComponent<PowerConduit>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -315,7 +315,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<AlloySmelter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "AlloySmelter";
|
||||
objectName = stateManager.worldName + "AlloySmelter";
|
||||
worldID = go.GetComponent<AlloySmelter>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -344,7 +344,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<Press>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Press";
|
||||
objectName = stateManager.worldName + "Press";
|
||||
worldID = go.GetComponent<Press>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -365,7 +365,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<Extruder>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Extruder";
|
||||
objectName = stateManager.worldName + "Extruder";
|
||||
worldID = go.GetComponent<Extruder>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -386,7 +386,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<GearCutter>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "GearCutter";
|
||||
objectName = stateManager.worldName + "GearCutter";
|
||||
worldID = go.GetComponent<GearCutter>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -407,7 +407,7 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<UniversalExtractor>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "UniversalExtractor";
|
||||
objectName = stateManager.worldName + "UniversalExtractor";
|
||||
worldID = go.GetComponent<UniversalExtractor>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -422,7 +422,7 @@ public class SaveManager
|
||||
}
|
||||
if (stateManager.IsStorageContainer(go))
|
||||
{
|
||||
objectName = stateManager.WorldName + "StorageContainer";
|
||||
objectName = stateManager.worldName + "StorageContainer";
|
||||
worldID = go.GetComponent<InventoryManager>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -432,25 +432,42 @@ public class SaveManager
|
||||
}
|
||||
if (go.GetComponent<StorageComputer>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "StorageComputer";
|
||||
objectName = stateManager.worldName + "StorageComputer";
|
||||
worldID = go.GetComponent<StorageComputer>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
if (go.GetComponent<AirLock>() != null)
|
||||
if (go.GetComponent<Door>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "AirLock";
|
||||
worldID = go.GetComponent<AirLock>().ID;
|
||||
Debug.Log("trying to save door with type: " + go.GetComponent<Door>().type);
|
||||
if (go.GetComponent<Door>().type == "Door")
|
||||
{
|
||||
objectName = stateManager.worldName + "Door";
|
||||
}
|
||||
else if (go.GetComponent<Door>().type == "Quantum Hatchway")
|
||||
{
|
||||
Debug.Log("Saving hatch");
|
||||
objectName = stateManager.worldName + "QuantumHatchway";
|
||||
}
|
||||
worldID = go.GetComponent<Door>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
int audioClip = go.GetComponent<Door>().audioClip;
|
||||
int texture = go.GetComponent<Door>().textureIndex;
|
||||
string material = go.GetComponent<Door>().material;
|
||||
bool edited = go.GetComponent<Door>().edited;
|
||||
FileBasedPrefs.SetInt(worldID + "audioClip", audioClip);
|
||||
FileBasedPrefs.SetInt(worldID + "texture", texture);
|
||||
FileBasedPrefs.SetString(worldID + "material", material);
|
||||
FileBasedPrefs.SetBool(worldID + "edited", edited);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
if (go.GetComponent<ModMachine>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "ModMachine";
|
||||
objectName = stateManager.worldName + "ModMachine";
|
||||
worldID = go.GetComponent<ModMachine>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
@ -472,9 +489,9 @@ public class SaveManager
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.WorldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.WorldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + objectID + "Rotation", objectRotation);
|
||||
|
||||
currentObject++;
|
||||
saveInterval++;
|
||||
@ -497,18 +514,18 @@ public class SaveManager
|
||||
{
|
||||
if (T.gameObject.name.Equals("IronRamp(Clone)"))
|
||||
{
|
||||
objectName = stateManager.WorldName + "IronRamp";
|
||||
objectName = stateManager.worldName + "IronRamp";
|
||||
}
|
||||
else
|
||||
{
|
||||
objectName = stateManager.WorldName + "IronBlock";
|
||||
objectName = stateManager.worldName + "IronBlock";
|
||||
}
|
||||
worldID = T.gameObject.GetComponent<IronBlock>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.WorldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.WorldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
@ -516,42 +533,56 @@ public class SaveManager
|
||||
{
|
||||
if (T.gameObject.name.Equals("SteelRamp(Clone)"))
|
||||
{
|
||||
objectName = stateManager.WorldName + "SteelRamp";
|
||||
objectName = stateManager.worldName + "SteelRamp";
|
||||
}
|
||||
else
|
||||
{
|
||||
objectName = stateManager.WorldName + "Steel";
|
||||
objectName = stateManager.worldName + "Steel";
|
||||
}
|
||||
worldID = T.gameObject.GetComponent<Steel>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.WorldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.WorldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
if (T.gameObject.GetComponent<Brick>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Brick";
|
||||
objectName = stateManager.worldName + "Brick";
|
||||
worldID = T.gameObject.GetComponent<Brick>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.WorldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.WorldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
if (T.gameObject.GetComponent<Glass>() != null)
|
||||
{
|
||||
objectName = stateManager.WorldName + "Glass";
|
||||
objectName = stateManager.worldName + "Glass";
|
||||
worldID = T.gameObject.GetComponent<Glass>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
FileBasedPrefs.SetString(stateManager.WorldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.WorldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.WorldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
if (T.gameObject.GetComponent<ModBlock>() != null)
|
||||
{
|
||||
objectName = stateManager.worldName + "ModBlock";
|
||||
worldID = T.gameObject.GetComponent<ModBlock>().ID;
|
||||
objectID = int.Parse(worldID.Substring(objectName.Length));
|
||||
idList.Add(objectID);
|
||||
string blockName = T.gameObject.GetComponent<ModBlock>().blockName;
|
||||
FileBasedPrefs.SetString(worldID + "blockName", blockName);
|
||||
FileBasedPrefs.SetString(stateManager.worldName + objectID + "Name", objectName);
|
||||
PlayerPrefsX.SetVector3(stateManager.worldName + objectID + "Position", objectPosition);
|
||||
PlayerPrefsX.SetQuaternion(stateManager.worldName + objectID + "Rotation", objectRotation);
|
||||
FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent<PhysicsHandler>().falling);
|
||||
FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent<PhysicsHandler>().fallingStack);
|
||||
}
|
||||
@ -580,7 +611,7 @@ public class SaveManager
|
||||
|
||||
if (idList.Count > 0)
|
||||
{
|
||||
PlayerPrefsX.SetIntArray(stateManager.WorldName + "idList", idList.ToArray());
|
||||
PlayerPrefsX.SetIntArray(stateManager.worldName + "idList", idList.ToArray());
|
||||
}
|
||||
|
||||
FileBasedPrefs.ManuallySave();
|
||||
|
580
StateManager.cs
580
StateManager.cs
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
//! This class handles unique ID assignment and saving & loading of worlds.
|
||||
public class StateManager : MonoBehaviour
|
||||
@ -12,55 +12,57 @@ public class StateManager : MonoBehaviour
|
||||
public int[] idList;
|
||||
public List<string> modTextureList;
|
||||
public List<string> modRecipeList;
|
||||
public GameObject DarkMatterCollector;
|
||||
public GameObject DarkMatterConduit;
|
||||
public GameObject IronBlock;
|
||||
public GameObject IronRamp;
|
||||
public GameObject Steel;
|
||||
public GameObject SteelRamp;
|
||||
public GameObject StorageContainer;
|
||||
public GameObject Glass;
|
||||
public GameObject UniversalExtractor;
|
||||
public GameObject UniversalConduit;
|
||||
public GameObject PowerConduit;
|
||||
public GameObject Smelter;
|
||||
public GameObject Press;
|
||||
public GameObject GearCutter;
|
||||
public GameObject AlloySmelter;
|
||||
public GameObject SolarPanel;
|
||||
public GameObject Generator;
|
||||
public GameObject Extruder;
|
||||
public GameObject Turret;
|
||||
public GameObject MissileTurret;
|
||||
public GameObject Auger;
|
||||
public GameObject HeatExchanger;
|
||||
public GameObject ElectricLight;
|
||||
public GameObject Retriever;
|
||||
public GameObject AirLock;
|
||||
public GameObject NuclearReactor;
|
||||
public GameObject ReactorTurbine;
|
||||
public GameObject StorageComputer;
|
||||
public GameObject AutoCrafter;
|
||||
public GameObject RailCartHub;
|
||||
public GameObject RailCart;
|
||||
public GameObject Brick;
|
||||
public GameObject darkMatterCollector;
|
||||
public GameObject darkMatterConduit;
|
||||
public GameObject ironBlock;
|
||||
public GameObject ironRamp;
|
||||
public GameObject steel;
|
||||
public GameObject steelRamp;
|
||||
public GameObject storageContainer;
|
||||
public GameObject glass;
|
||||
public GameObject universalExtractor;
|
||||
public GameObject universalConduit;
|
||||
public GameObject powerConduit;
|
||||
public GameObject smelter;
|
||||
public GameObject press;
|
||||
public GameObject gearCutter;
|
||||
public GameObject alloySmelter;
|
||||
public GameObject solarPanel;
|
||||
public GameObject generator;
|
||||
public GameObject extruder;
|
||||
public GameObject turret;
|
||||
public GameObject missileTurret;
|
||||
public GameObject auger;
|
||||
public GameObject heatExchanger;
|
||||
public GameObject electricLight;
|
||||
public GameObject retriever;
|
||||
public GameObject door;
|
||||
public GameObject quantumHatchway;
|
||||
public GameObject nuclearReactor;
|
||||
public GameObject reactorTurbine;
|
||||
public GameObject storageComputer;
|
||||
public GameObject autoCrafter;
|
||||
public GameObject railCartHub;
|
||||
public GameObject railCart;
|
||||
public GameObject brick;
|
||||
public GameObject modMachine;
|
||||
public GameObject BuiltObjects;
|
||||
public GameObject modBlock;
|
||||
public GameObject builtObjects;
|
||||
public bool assigningIDs;
|
||||
public string WorldName = "World";
|
||||
public string PartName = "";
|
||||
public string worldName = "World";
|
||||
public string partName = "";
|
||||
public SaveManager saveManager;
|
||||
public Vector3 PartPosition = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
public Quaternion PartRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));
|
||||
private Vector3 EmptyVector = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
private Vector3 ObjectPosition;
|
||||
private Quaternion ObjectRotation;
|
||||
public Vector3 partPosition = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
public Quaternion partRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));
|
||||
private Vector3 emptyVector = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
private Vector3 objectPosition;
|
||||
private Quaternion objectRotation;
|
||||
private AddressManager addressManager;
|
||||
private Coroutine addressingCoroutine;
|
||||
private Coroutine loadCoroutine;
|
||||
private Coroutine saveCoroutine;
|
||||
private float updateTick;
|
||||
private string ObjectName = "";
|
||||
private string objectName = "";
|
||||
private bool loading;
|
||||
|
||||
//! Called by unity engine before the first update.
|
||||
@ -72,8 +74,11 @@ public class StateManager : MonoBehaviour
|
||||
//! Update is called once per frame.
|
||||
public void Update()
|
||||
{
|
||||
MainMenu mainMenu = GameObject.Find("Player").GetComponent<MainMenu>();
|
||||
if (mainMenu.worldSelected == true && loading == false)
|
||||
GameObject player = GameObject.Find("Player");
|
||||
PlayerController playerController = player.GetComponent<PlayerController>();
|
||||
MainMenu mainMenu = player.GetComponent<MainMenu>();
|
||||
|
||||
if (mainMenu.worldSelected == true && playerController.addedModBlocks == true && loading == false)
|
||||
{
|
||||
loadCoroutine = StartCoroutine(LoadWorld());
|
||||
loading = true;
|
||||
@ -100,372 +105,399 @@ public class StateManager : MonoBehaviour
|
||||
//! Loads a saved world.
|
||||
private IEnumerator LoadWorld()
|
||||
{
|
||||
if (worldLoaded == false && PlayerPrefsX.GetIntArray(WorldName + "idList").Length > 0)
|
||||
if (worldLoaded == false && PlayerPrefsX.GetIntArray(worldName + "idList").Length > 0)
|
||||
{
|
||||
int loadInterval = 0;
|
||||
progress = 0;
|
||||
idList = PlayerPrefsX.GetIntArray(WorldName + "idList");
|
||||
idList = PlayerPrefsX.GetIntArray(worldName + "idList");
|
||||
foreach (int objectID in idList)
|
||||
{
|
||||
while (GetComponent<GameManager>().working == true)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
ObjectPosition = PlayerPrefsX.GetVector3(WorldName + objectID + "Position");
|
||||
ObjectRotation = PlayerPrefsX.GetQuaternion(WorldName + objectID + "Rotation");
|
||||
ObjectName = FileBasedPrefs.GetString(WorldName + objectID + "Name");
|
||||
if (ObjectName != "" && ObjectPosition != EmptyVector)
|
||||
objectPosition = PlayerPrefsX.GetVector3(worldName + objectID + "Position");
|
||||
objectRotation = PlayerPrefsX.GetQuaternion(worldName + objectID + "Rotation");
|
||||
objectName = FileBasedPrefs.GetString(worldName + objectID + "Name");
|
||||
if (objectName != "" && objectPosition != emptyVector)
|
||||
{
|
||||
if (ObjectName == WorldName + "AirLock")
|
||||
if (objectName == worldName + "Door")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(AirLock, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
GameObject SpawnedObject = Instantiate(door, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Door>().audioClip = FileBasedPrefs.GetInt(objectName + objectID + "audioClip");
|
||||
SpawnedObject.GetComponent<Door>().textureIndex = FileBasedPrefs.GetInt(objectName + objectID + "textureIndex");
|
||||
SpawnedObject.GetComponent<Door>().material = FileBasedPrefs.GetString(objectName + objectID + "material");
|
||||
SpawnedObject.GetComponent<Door>().edited = FileBasedPrefs.GetBool(objectName + objectID + "edited");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "DarkMatterCollector")
|
||||
if (objectName == worldName + "QuantumHatchway")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(DarkMatterCollector, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<DarkMatterCollector>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<DarkMatterCollector>().darkMatterAmount = FileBasedPrefs.GetFloat(ObjectName + objectID + "darkMatterAmount");
|
||||
GameObject SpawnedObject = Instantiate(quantumHatchway, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (objectName == worldName + "DarkMatterCollector")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(darkMatterCollector, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<DarkMatterCollector>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<DarkMatterCollector>().darkMatterAmount = FileBasedPrefs.GetFloat(objectName + objectID + "darkMatterAmount");
|
||||
SpawnedObject.GetComponent<DarkMatterCollector>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "DarkMatterConduit")
|
||||
if (objectName == worldName + "DarkMatterConduit")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(DarkMatterConduit, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().range = FileBasedPrefs.GetInt(ObjectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().darkMatterAmount = FileBasedPrefs.GetFloat(ObjectName + objectID + "darkMatterAmount");
|
||||
GameObject SpawnedObject = Instantiate(darkMatterConduit, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().range = FileBasedPrefs.GetInt(objectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().darkMatterAmount = FileBasedPrefs.GetFloat(objectName + objectID + "darkMatterAmount");
|
||||
SpawnedObject.GetComponent<DarkMatterConduit>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "RailCartHub")
|
||||
if (objectName == worldName + "RailCartHub")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(RailCartHub, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<RailCartHub>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<RailCartHub>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<RailCartHub>().range = FileBasedPrefs.GetInt(ObjectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<RailCartHub>().stop = FileBasedPrefs.GetBool(ObjectName + objectID + "stop");
|
||||
SpawnedObject.GetComponent<RailCartHub>().circuit = FileBasedPrefs.GetInt(ObjectName + objectID + "circuit");
|
||||
SpawnedObject.GetComponent<RailCartHub>().stopTime = FileBasedPrefs.GetFloat(ObjectName + objectID + "stopTime");
|
||||
SpawnedObject.GetComponent<RailCartHub>().centralHub = FileBasedPrefs.GetBool(ObjectName + objectID + "centralHub");
|
||||
GameObject SpawnedObject = Instantiate(railCartHub, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<RailCartHub>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<RailCartHub>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<RailCartHub>().range = FileBasedPrefs.GetInt(objectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<RailCartHub>().stop = FileBasedPrefs.GetBool(objectName + objectID + "stop");
|
||||
SpawnedObject.GetComponent<RailCartHub>().circuit = FileBasedPrefs.GetInt(objectName + objectID + "circuit");
|
||||
SpawnedObject.GetComponent<RailCartHub>().stopTime = FileBasedPrefs.GetFloat(objectName + objectID + "stopTime");
|
||||
SpawnedObject.GetComponent<RailCartHub>().centralHub = FileBasedPrefs.GetBool(objectName + objectID + "centralHub");
|
||||
SpawnedObject.GetComponent<RailCartHub>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "RailCart")
|
||||
if (objectName == worldName + "RailCart")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(RailCart, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(railCart, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<RailCart>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<RailCart>().targetID = FileBasedPrefs.GetString(ObjectName + objectID + "targetID");
|
||||
SpawnedObject.GetComponent<RailCart>().targetID = FileBasedPrefs.GetString(objectName + objectID + "targetID");
|
||||
}
|
||||
if (ObjectName == WorldName + "UniversalConduit")
|
||||
if (objectName == worldName + "UniversalConduit")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(UniversalConduit, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<UniversalConduit>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().type = FileBasedPrefs.GetString(ObjectName + objectID + "type");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().range = FileBasedPrefs.GetInt(ObjectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(universalConduit, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<UniversalConduit>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().type = FileBasedPrefs.GetString(objectName + objectID + "type");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().range = FileBasedPrefs.GetInt(objectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<UniversalConduit>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Retriever")
|
||||
if (objectName == worldName + "Retriever")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Retriever, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<Retriever>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Retriever>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Retriever>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Retriever>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(retriever, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Retriever>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Retriever>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Retriever>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Retriever>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<Retriever>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "AutoCrafter")
|
||||
if (objectName == worldName + "AutoCrafter")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(AutoCrafter, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<AutoCrafter>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<AutoCrafter>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
GameObject SpawnedObject = Instantiate(autoCrafter, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<AutoCrafter>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<AutoCrafter>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<AutoCrafter>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Smelter")
|
||||
if (objectName == worldName + "Smelter")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Smelter, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<Smelter>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Smelter>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Smelter>().inputType = FileBasedPrefs.GetString(ObjectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<Smelter>().outputType = FileBasedPrefs.GetString(ObjectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<Smelter>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Smelter>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(smelter, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Smelter>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Smelter>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Smelter>().inputType = FileBasedPrefs.GetString(objectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<Smelter>().outputType = FileBasedPrefs.GetString(objectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<Smelter>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Smelter>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<Smelter>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "HeatExchanger")
|
||||
if (objectName == worldName + "HeatExchanger")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(HeatExchanger, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<HeatExchanger>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().inputType = FileBasedPrefs.GetString(ObjectName + objectID + "inputType");
|
||||
GameObject SpawnedObject = Instantiate(heatExchanger, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<HeatExchanger>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().inputType = FileBasedPrefs.GetString(objectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<HeatExchanger>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "SolarPanel")
|
||||
if (objectName == worldName + "SolarPanel")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(SolarPanel, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PowerSource>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
GameObject SpawnedObject = Instantiate(solarPanel, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PowerSource>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<PowerSource>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Generator")
|
||||
if (objectName == worldName + "Generator")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Generator, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PowerSource>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
GameObject SpawnedObject = Instantiate(generator, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PowerSource>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<PowerSource>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PowerSource>().fuelType = FileBasedPrefs.GetString(ObjectName + objectID + "fuelType");
|
||||
SpawnedObject.GetComponent<PowerSource>().fuelAmount = FileBasedPrefs.GetInt(ObjectName + objectID + "fuelAmount");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PowerSource>().fuelType = FileBasedPrefs.GetString(objectName + objectID + "fuelType");
|
||||
SpawnedObject.GetComponent<PowerSource>().fuelAmount = FileBasedPrefs.GetInt(objectName + objectID + "fuelAmount");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "NuclearReactor")
|
||||
if (objectName == worldName + "NuclearReactor")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(NuclearReactor, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(nuclearReactor, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<NuclearReactor>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "ReactorTurbine")
|
||||
if (objectName == worldName + "ReactorTurbine")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(ReactorTurbine, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PowerSource>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
GameObject SpawnedObject = Instantiate(reactorTurbine, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PowerSource>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<PowerSource>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "PowerConduit")
|
||||
if (objectName == worldName + "PowerConduit")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(PowerConduit, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PowerConduit>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<PowerConduit>().outputID1 = FileBasedPrefs.GetString(ObjectName + objectID + "outputID1");
|
||||
SpawnedObject.GetComponent<PowerConduit>().outputID2 = FileBasedPrefs.GetString(ObjectName + objectID + "outputID2");
|
||||
SpawnedObject.GetComponent<PowerConduit>().dualOutput = FileBasedPrefs.GetBool(ObjectName + objectID + "dualOutput");
|
||||
SpawnedObject.GetComponent<PowerConduit>().range = FileBasedPrefs.GetInt(ObjectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<PowerConduit>().powerAmount = FileBasedPrefs.GetInt(ObjectName + objectID + "powerAmount");
|
||||
GameObject SpawnedObject = Instantiate(powerConduit, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PowerConduit>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<PowerConduit>().outputID1 = FileBasedPrefs.GetString(objectName + objectID + "outputID1");
|
||||
SpawnedObject.GetComponent<PowerConduit>().outputID2 = FileBasedPrefs.GetString(objectName + objectID + "outputID2");
|
||||
SpawnedObject.GetComponent<PowerConduit>().dualOutput = FileBasedPrefs.GetBool(objectName + objectID + "dualOutput");
|
||||
SpawnedObject.GetComponent<PowerConduit>().range = FileBasedPrefs.GetInt(objectName + objectID + "range");
|
||||
SpawnedObject.GetComponent<PowerConduit>().powerAmount = FileBasedPrefs.GetInt(objectName + objectID + "powerAmount");
|
||||
SpawnedObject.GetComponent<PowerConduit>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Auger")
|
||||
if (objectName == worldName + "Auger")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Auger, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<Auger>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Auger>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(auger, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Auger>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Auger>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<Auger>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "ElectricLight")
|
||||
if (objectName == worldName + "ElectricLight")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(ElectricLight, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(electricLight, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<ElectricLight>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Turret")
|
||||
if (objectName == worldName + "Turret")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Turret, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<Turret>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
GameObject SpawnedObject = Instantiate(turret, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Turret>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Turret>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "MissileTurret")
|
||||
if (objectName == worldName + "MissileTurret")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(MissileTurret, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<MissileTurret>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<MissileTurret>().ammoType = FileBasedPrefs.GetString(ObjectName + objectID + "ammoType");
|
||||
SpawnedObject.GetComponent<MissileTurret>().ammoAmount = FileBasedPrefs.GetInt(ObjectName + objectID + "ammoAmount");
|
||||
GameObject SpawnedObject = Instantiate(missileTurret, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<MissileTurret>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<MissileTurret>().ammoType = FileBasedPrefs.GetString(objectName + objectID + "ammoType");
|
||||
SpawnedObject.GetComponent<MissileTurret>().ammoAmount = FileBasedPrefs.GetInt(objectName + objectID + "ammoAmount");
|
||||
SpawnedObject.GetComponent<MissileTurret>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "AlloySmelter")
|
||||
if (objectName == worldName + "AlloySmelter")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(AlloySmelter, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputID1 = FileBasedPrefs.GetString(ObjectName + objectID + "inputID1");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputID2 = FileBasedPrefs.GetString(ObjectName + objectID + "inputID2");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputType1 = FileBasedPrefs.GetString(ObjectName + objectID + "inputType1");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputType2 = FileBasedPrefs.GetString(ObjectName + objectID + "inputType2");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().outputType = FileBasedPrefs.GetString(ObjectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().amount2 = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount2");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().outputAmount = FileBasedPrefs.GetFloat(ObjectName + objectID + "outputAmount");
|
||||
GameObject SpawnedObject = Instantiate(alloySmelter, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputID1 = FileBasedPrefs.GetString(objectName + objectID + "inputID1");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputID2 = FileBasedPrefs.GetString(objectName + objectID + "inputID2");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputType1 = FileBasedPrefs.GetString(objectName + objectID + "inputType1");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().inputType2 = FileBasedPrefs.GetString(objectName + objectID + "inputType2");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().outputType = FileBasedPrefs.GetString(objectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().amount2 = FileBasedPrefs.GetFloat(objectName + objectID + "amount2");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().outputAmount = FileBasedPrefs.GetFloat(objectName + objectID + "outputAmount");
|
||||
SpawnedObject.GetComponent<AlloySmelter>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Press")
|
||||
if (objectName == worldName + "Press")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Press, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<Press>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Press>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Press>().inputType = FileBasedPrefs.GetString(ObjectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<Press>().outputType = FileBasedPrefs.GetString(ObjectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<Press>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Press>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(press, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Press>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Press>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Press>().inputType = FileBasedPrefs.GetString(objectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<Press>().outputType = FileBasedPrefs.GetString(objectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<Press>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Press>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<Press>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Extruder")
|
||||
if (objectName == worldName + "Extruder")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Extruder, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<Extruder>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Extruder>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Extruder>().inputType = FileBasedPrefs.GetString(ObjectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<Extruder>().outputType = FileBasedPrefs.GetString(ObjectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<Extruder>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Extruder>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(extruder, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Extruder>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<Extruder>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<Extruder>().inputType = FileBasedPrefs.GetString(objectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<Extruder>().outputType = FileBasedPrefs.GetString(objectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<Extruder>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<Extruder>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<Extruder>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "GearCutter")
|
||||
if (objectName == worldName + "GearCutter")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(GearCutter, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<GearCutter>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<GearCutter>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<GearCutter>().inputType = FileBasedPrefs.GetString(ObjectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<GearCutter>().outputType = FileBasedPrefs.GetString(ObjectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<GearCutter>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<GearCutter>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(gearCutter, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<GearCutter>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<GearCutter>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<GearCutter>().inputType = FileBasedPrefs.GetString(objectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<GearCutter>().outputType = FileBasedPrefs.GetString(objectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<GearCutter>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<GearCutter>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<GearCutter>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "UniversalExtractor")
|
||||
if (objectName == worldName + "UniversalExtractor")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(UniversalExtractor, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().type = FileBasedPrefs.GetString(ObjectName + objectID + "type");
|
||||
GameObject SpawnedObject = Instantiate(universalExtractor, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().type = FileBasedPrefs.GetString(objectName + objectID + "type");
|
||||
SpawnedObject.GetComponent<UniversalExtractor>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "StorageContainer")
|
||||
if (objectName == worldName + "StorageContainer")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(StorageContainer, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
GameObject SpawnedObject = Instantiate(storageContainer, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "StorageComputer")
|
||||
if (objectName == worldName + "StorageComputer")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(StorageComputer, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
GameObject SpawnedObject = Instantiate(storageComputer, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "IronBlock")
|
||||
if (objectName == worldName + "IronBlock")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(IronBlock, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(ironBlock, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<IronBlock>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "IronRamp")
|
||||
if (objectName == worldName + "IronRamp")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(IronRamp, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(ironRamp, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<IronBlock>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Steel")
|
||||
if (objectName == worldName + "Steel")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Steel, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(steel, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Steel>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "SteelRamp")
|
||||
if (objectName == worldName + "SteelRamp")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(SteelRamp, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(steelRamp, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Steel>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Brick")
|
||||
if (objectName == worldName + "Brick")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Brick, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(brick, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Brick>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "Glass")
|
||||
if (objectName == worldName + "Glass")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(Glass, ObjectPosition, ObjectRotation);
|
||||
GameObject SpawnedObject = Instantiate(glass, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<Glass>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
}
|
||||
if (ObjectName == WorldName + "ModMachine")
|
||||
if (objectName == worldName + "ModMachine")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(modMachine, ObjectPosition, ObjectRotation);
|
||||
SpawnedObject.GetComponent<ModMachine>().machineName = FileBasedPrefs.GetString(ObjectName + objectID + "machineName");
|
||||
SpawnedObject.GetComponent<ModMachine>().inputID = FileBasedPrefs.GetString(ObjectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<ModMachine>().outputID = FileBasedPrefs.GetString(ObjectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<ModMachine>().inputType = FileBasedPrefs.GetString(ObjectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<ModMachine>().outputType = FileBasedPrefs.GetString(ObjectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<ModMachine>().speed = FileBasedPrefs.GetInt(ObjectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<ModMachine>().amount = FileBasedPrefs.GetFloat(ObjectName + objectID + "amount");
|
||||
GameObject SpawnedObject = Instantiate(modMachine, objectPosition, objectRotation);
|
||||
SpawnedObject.GetComponent<ModMachine>().machineName = FileBasedPrefs.GetString(objectName + objectID + "machineName");
|
||||
SpawnedObject.GetComponent<ModMachine>().inputID = FileBasedPrefs.GetString(objectName + objectID + "inputID");
|
||||
SpawnedObject.GetComponent<ModMachine>().outputID = FileBasedPrefs.GetString(objectName + objectID + "outputID");
|
||||
SpawnedObject.GetComponent<ModMachine>().inputType = FileBasedPrefs.GetString(objectName + objectID + "inputType");
|
||||
SpawnedObject.GetComponent<ModMachine>().outputType = FileBasedPrefs.GetString(objectName + objectID + "outputType");
|
||||
SpawnedObject.GetComponent<ModMachine>().speed = FileBasedPrefs.GetInt(objectName + objectID + "speed");
|
||||
SpawnedObject.GetComponent<ModMachine>().amount = FileBasedPrefs.GetFloat(objectName + objectID + "amount");
|
||||
SpawnedObject.GetComponent<ModMachine>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(ObjectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
}
|
||||
if (objectName == worldName + "ModBlock")
|
||||
{
|
||||
GameObject SpawnedObject = Instantiate(modBlock, objectPosition, objectRotation);
|
||||
string blockName = FileBasedPrefs.GetString(objectName + objectID + "blockName");
|
||||
SpawnedObject.GetComponent<ModBlock>().blockName = blockName;
|
||||
PlayerController playerController = GameObject.Find("Player").GetComponent<PlayerController>();
|
||||
BlockDictionary blockDictionary = playerController.GetComponent<BuildController>().blockDictionary;
|
||||
if (blockDictionary.meshDictionary.ContainsKey(blockName))
|
||||
{
|
||||
SpawnedObject.GetComponent<MeshFilter>().mesh = blockDictionary.meshDictionary[blockName];
|
||||
}
|
||||
GetComponent<GameManager>().meshManager.SetMaterial(SpawnedObject, blockName);
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().creationMethod = "spawned";
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().falling = FileBasedPrefs.GetBool(objectName + objectID + "falling");
|
||||
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(objectName + objectID + "fallingStack");
|
||||
}
|
||||
}
|
||||
progress++;
|
||||
|
5
Steel.cs
5
Steel.cs
@ -17,7 +17,10 @@ public class Steel : MonoBehaviour
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -32,6 +32,9 @@ public class StorageComputer : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
@ -92,7 +95,7 @@ public class StorageComputer : MonoBehaviour
|
||||
GameObject containerObject = container.gameObject;
|
||||
Transform containerTransform = containerObject.transform;
|
||||
float distance = Vector3.Distance(transform.position, containerObject.transform.position);
|
||||
if (IsValidContainer(containerObject) && distance < 40)
|
||||
if (IsValidContainer(containerObject) && distance <= 40)
|
||||
{
|
||||
computerContainerList.Add(container);
|
||||
GameObject spawnedConnection = Instantiate(connectionObject, containerTransform.position, containerTransform.rotation);
|
||||
|
@ -21,23 +21,6 @@ public class StorageInteraction
|
||||
{
|
||||
if (playerController.storageGUIopen == false)
|
||||
{
|
||||
if (playerController.building == true)
|
||||
{
|
||||
if (GameObject.Find("GameManager").GetComponent<GameManager>().working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
playerController.gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
if (inventory.initialized == true)
|
||||
{
|
||||
Cursor.visible = true;
|
||||
@ -81,11 +64,11 @@ public class StorageInteraction
|
||||
thisContainer.SaveData();
|
||||
if (playerController.objectInSight.GetComponent<RailCart>() != null)
|
||||
{
|
||||
playerController.playerInventory.AddItem("Rail Cart", 1);
|
||||
interactionController.CollectObject("Rail Cart");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.playerInventory.AddItem("Storage Container", 1);
|
||||
interactionController.CollectObject("Storage Container");
|
||||
}
|
||||
Object.Destroy(playerController.objectInSight);
|
||||
playerController.PlayCraftingSound();
|
||||
@ -110,23 +93,6 @@ public class StorageInteraction
|
||||
{
|
||||
if (playerController.storageGUIopen == false)
|
||||
{
|
||||
if (playerController.building == true)
|
||||
{
|
||||
if (GameObject.Find("GameManager").GetComponent<GameManager>().working == false)
|
||||
{
|
||||
playerController.stoppingBuildCoRoutine = true;
|
||||
playerController.gameManager.meshManager.CombineBlocks();
|
||||
playerController.separatedBlocks = false;
|
||||
playerController.destroyTimer = 0;
|
||||
playerController.buildTimer = 0;
|
||||
playerController.building = false;
|
||||
playerController.destroying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerController.requestedBuildingStop = true;
|
||||
}
|
||||
}
|
||||
if (computer.powerON == true && computer.initialized == true)
|
||||
{
|
||||
bool foundContainer = false;
|
||||
|
@ -60,6 +60,7 @@ public class TextureDictionary : MonoBehaviour
|
||||
{ "Container Background", Resources.Load("ContainerBackground") as Texture2D },
|
||||
{ "Crafting Background", Resources.Load("CraftingBackground") as Texture2D },
|
||||
{ "Selection Box", Resources.Load("SelectionBox") as Texture2D },
|
||||
{ "Shaded Box", Resources.Load("ShadedSelectionBox") as Texture2D },
|
||||
{ "Bronze Schematic", Resources.Load("BronzeSchematic") as Texture2D },
|
||||
{ "Dark Matter Schematic", Resources.Load("DarkMatterSchematic") as Texture2D },
|
||||
{ "Gear Schematic", Resources.Load("GearSchematic") as Texture2D },
|
||||
@ -80,6 +81,7 @@ public class TextureDictionary : MonoBehaviour
|
||||
{ "Steel Block", Resources.Load("SteelBlock") as Texture2D },
|
||||
{ "Steel Ramp", Resources.Load("SteelRamp") as Texture2D },
|
||||
{ "Glass Block", Resources.Load("Glass") as Texture2D },
|
||||
{ "Glass Block_Icon", Resources.Load("Glass_Icon") as Texture2D },
|
||||
{ "Brick", Resources.Load("Brick") as Texture2D },
|
||||
{ "Electric Light", Resources.Load("Light") as Texture2D },
|
||||
{ "Dark Matter Collector", Resources.Load("DarkMatterCollector") as Texture2D },
|
||||
@ -87,6 +89,7 @@ public class TextureDictionary : MonoBehaviour
|
||||
{ "Universal Conduit", Resources.Load("UniversalConduit") as Texture2D },
|
||||
{ "Universal Extractor", Resources.Load("UniversalExtractor") as Texture2D },
|
||||
{ "Auger", Resources.Load("Auger") as Texture2D },
|
||||
{ "Door", Resources.Load("Door") as Texture2D },
|
||||
{ "Quantum Hatchway", Resources.Load("Hatch") as Texture2D },
|
||||
{ "Storage Container", Resources.Load("StorageContainer") as Texture2D },
|
||||
{ "Copper Ore", Resources.Load("CopperOre") as Texture2D },
|
||||
|
@ -47,6 +47,9 @@ public class Turret : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@ -26,6 +27,9 @@ public class UniversalConduit : MonoBehaviour
|
||||
private StateManager stateManager;
|
||||
private GameObject builtObjects;
|
||||
private LineRenderer connectionLine;
|
||||
private Coroutine connectionCoroutine;
|
||||
private List<GameObject> objList;
|
||||
private bool connectionCoroutineBusy;
|
||||
private float updateTick;
|
||||
private bool linkedToRailCart;
|
||||
private int findRailCartsInterval;
|
||||
@ -36,17 +40,21 @@ public class UniversalConduit : MonoBehaviour
|
||||
connectionLine = gameObject.AddComponent<LineRenderer>();
|
||||
conduitItem = GetComponentInChildren<ConduitItem>(true);
|
||||
stateManager = FindObjectOfType<StateManager>();
|
||||
objList = new List<GameObject>();
|
||||
connectionLine.startWidth = 0.2f;
|
||||
connectionLine.endWidth = 0.2f;
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
connectionLine.enabled = false;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
}
|
||||
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
@ -79,16 +87,9 @@ public class UniversalConduit : MonoBehaviour
|
||||
}
|
||||
if (connectionFailed == false)
|
||||
{
|
||||
GameObject[] allObjects = GameObject.FindGameObjectsWithTag("Built");
|
||||
List<GameObject> objList = allObjects.ToList();
|
||||
objList.Add(GameObject.Find("Rocket"));
|
||||
objList.Add(GameObject.Find("LanderCargo"));
|
||||
foreach (GameObject obj in objList)
|
||||
if (connectionCoroutineBusy == false)
|
||||
{
|
||||
if (IsValidObject(obj))
|
||||
{
|
||||
ConnectToObject(obj);
|
||||
}
|
||||
connectionCoroutine = StartCoroutine(AttemptConnection());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,6 +154,24 @@ public class UniversalConduit : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
private IEnumerator AttemptConnection()
|
||||
{
|
||||
connectionCoroutineBusy = true;
|
||||
GameObject[] allObjects = GameObject.FindGameObjectsWithTag("Built");
|
||||
objList = allObjects.ToList();
|
||||
objList.Add(GameObject.Find("Rocket"));
|
||||
objList.Add(GameObject.Find("LanderCargo"));
|
||||
foreach (GameObject obj in objList)
|
||||
{
|
||||
if (IsValidObject(obj))
|
||||
{
|
||||
ConnectToObject(obj);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
connectionCoroutineBusy = false;
|
||||
}
|
||||
|
||||
//! Puts items into a storage container or other object with attached inventory manager.
|
||||
private void OutputToInventory()
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ public class UniversalExtractor : MonoBehaviour
|
||||
connectionLine.endWidth = 0.2f;
|
||||
connectionLine.material = lineMat;
|
||||
connectionLine.loop = true;
|
||||
builtObjects = GameObject.Find("Built_Objects");
|
||||
builtObjects = GameObject.Find("BuiltObjects");
|
||||
}
|
||||
|
||||
//! Used to remove the connection line renderer when the block is destroyed.
|
||||
@ -72,6 +72,9 @@ public class UniversalExtractor : MonoBehaviour
|
||||
//! Called once per frame by unity engine.
|
||||
public void Update()
|
||||
{
|
||||
if (ID == "unassigned")
|
||||
return;
|
||||
|
||||
updateTick += 1 * Time.deltaTime;
|
||||
if (updateTick > 0.5f + (address * 0.001f))
|
||||
{
|
||||
|
@ -18,14 +18,15 @@ public class cInputInit : MonoBehaviour
|
||||
cInput.SetKey("Jetpack", "Space", Keys.Space);
|
||||
cInput.SetKey("Fire", "Mouse0", Keys.Mouse0);
|
||||
cInput.SetKey("Interact", "E", Keys.E);
|
||||
cInput.SetKey("Build", "B", Keys.B);
|
||||
cInput.SetKey("Stop Building", "Q", Keys.Q);
|
||||
cInput.SetKey("Build Mode", "B", Keys.B);
|
||||
cInput.SetKey("Next Item", "Mouse Wheel Up", Keys.X);
|
||||
cInput.SetKey("Previous Item", "Mouse Wheel Down", Keys.Z);
|
||||
cInput.SetKey("Build Amount", "Equals", Keys.EqualSign);
|
||||
cInput.SetKey("Build Amount +", "RightBracket", Keys.RightBracket);
|
||||
cInput.SetKey("Build Amount -", "LeftBracket", Keys.LeftBracket);
|
||||
cInput.SetKey("Place Object", "Mouse1", Keys.Mouse1);
|
||||
cInput.SetKey("Collect Object", "F", Keys.F);
|
||||
cInput.SetKey("Undo", "U", Keys.U);
|
||||
cInput.SetKey("Rotate Block", "R", Keys.R);
|
||||
cInput.SetKey("Build Axis", "V", Keys.V);
|
||||
cInput.SetKey("Auto Axis", "Y", Keys.Y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user