Fixing paint gun bugs.

This commit is contained in:
Droog71 2020-09-19 20:29:43 -05:00
parent 36ddbcc57b
commit 58743da7c4
984 changed files with 15802 additions and 1434 deletions

View File

@ -4,6 +4,7 @@ using System.Collections;
public class AddressManager
{
private StateManager stateManager;
private int totalObjects;
//! This class assigns a unique ID to every block in the world.
public AddressManager(StateManager stateManager)
@ -18,8 +19,8 @@ public class AddressManager
int idCount = 0;
int addressingInterval = 0;
string objectName = "";
GameObject[] allObjects = GameObject.FindGameObjectsWithTag("Built");
foreach (GameObject go in allObjects)
GameObject[] machines = GameObject.FindGameObjectsWithTag("Built");
foreach (GameObject go in machines)
{
if (go != null)
{
@ -195,8 +196,8 @@ public class AddressManager
}
}
Transform[] allTransforms = stateManager.BuiltObjects.GetComponentsInChildren<Transform>(true);
foreach (Transform T in allTransforms)
Transform[] blocks = stateManager.BuiltObjects.GetComponentsInChildren<Transform>(true);
foreach (Transform T in blocks)
{
if (T != null)
{

View File

@ -3,6 +3,7 @@
public class AirLock : MonoBehaviour
{
private float updateTick;
private StateManager stateManager;
public string ID = "unassigned";
public int address;
public bool open;
@ -13,6 +14,7 @@ public class AirLock : MonoBehaviour
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
if (QualitySettings.GetQualityLevel() < 3)
{
effects.SetActive(false);
@ -25,6 +27,12 @@ public class AirLock : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
}

View File

@ -33,13 +33,16 @@ public class AlloySmelter : MonoBehaviour
private LineRenderer connectionLine;
private float updateTick;
private int machineTimer;
private int warmup;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine = gameObject.AddComponent<LineRenderer>();
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -52,15 +55,26 @@ public class AlloySmelter : MonoBehaviour
//! Called once per frame by unity engine.
public void Update()
{
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
updateTick = 0;
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

View File

@ -18,8 +18,10 @@ public class Auger : MonoBehaviour
public int address;
public bool powerON;
private LineRenderer connectionLine;
private StateManager stateManager;
private float updateTick;
private int machineTimer;
private int warmup;
//! Called by unity engine on start up to initialize variables.
public void Start()
@ -27,6 +29,7 @@ public class Auger : MonoBehaviour
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine = gameObject.AddComponent<LineRenderer>();
conduitItem = GetComponentInChildren<ConduitItem>(true);
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -40,11 +43,21 @@ public class Auger : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
updateTick = 0;
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

View File

@ -3,13 +3,23 @@
public class AugerBlade : MonoBehaviour
{
public GameObject auger;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
{
if (auger.GetComponent<AudioSource>().enabled == true)
{
transform.Rotate(-Vector3.forward * 600 * Time.deltaTime);
if (!stateManager.Busy())
{
if (auger.GetComponent<AudioSource>().enabled == true)
{
transform.Rotate(-Vector3.forward * 600 * Time.deltaTime);
}
}
}
}

View File

@ -23,10 +23,12 @@ public class AutoCrafter : MonoBehaviour
public Material lineMat;
private float updateTick;
private int machineTimer;
private int warmup;
private LineRenderer connectionLine;
private CraftingManager craftingManager;
private CraftingDictionary craftingDictionary;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
@ -35,6 +37,7 @@ public class AutoCrafter : MonoBehaviour
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine = gameObject.AddComponent<LineRenderer>();
craftingDictionary = new CraftingDictionary();
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -50,11 +53,21 @@ public class AutoCrafter : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
updateTick = 0;
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

View File

@ -28,11 +28,14 @@ public class BasicMachine : MonoBehaviour
public BasicMachineRecipe[] recipes;
private LineRenderer connectionLine;
private GameObject builtObjects;
public StateManager stateManager;
private int machineTimer;
private int warmup;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine = gameObject.AddComponent<LineRenderer>();
conduitItem = GetComponentInChildren<ConduitItem>(true);
@ -50,11 +53,21 @@ public class BasicMachine : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
UpdatePowerReceiver();
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

View File

@ -7,6 +7,13 @@ public class Brick : MonoBehaviour
public string creationMethod;
public int address;
private float updateTick;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
@ -14,6 +21,12 @@ public class Brick : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
}

View File

@ -1,4 +1,5 @@
using UnityEngine;
using System.Collections;
using UnityEngine;
public class BuildController : MonoBehaviour
{
@ -9,6 +10,7 @@ public class BuildController : MonoBehaviour
public Material lineMat;
public GameObject builtObjects;
public bool autoAxis;
private Coroutine buildBlockCoroutine;
//! Called by unity engine on start up to initialize variables
public void Start()
@ -22,44 +24,30 @@ public class BuildController : MonoBehaviour
//! Called once per frame by unity engine
public void Update()
{
if (playerController.building == true)
if (!playerController.stateManager.Busy())
{
playerController.buildTimer += 1 * Time.deltaTime;
if (playerController.buildTimer >= 30)
if (playerController.building == true)
{
if (GameObject.Find("GameManager").GetComponent<GameManager>().working == false)
playerController.buildTimer += 1 * Time.deltaTime;
if (playerController.buildTimer >= 30)
{
playerController.stoppingBuildCoRoutine = true;
gameManager.meshManager.CombineBlocks();
playerController.separatedBlocks = false;
playerController.destroyTimer = 0;
playerController.buildTimer = 0;
playerController.building = false;
playerController.destroying = false;
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;
}
}
else
{
playerController.requestedBuildingStop = true;
}
}
if (playerController.separatedBlocks == false)
{
if (gameManager.working == false)
{
gameManager.meshManager.SeparateBlocks(transform.position, "all", true);
playerController.separatedBlocks = true;
}
else
{
playerController.requestedChunkLoad = true;
}
playerController.buildStartPosition = transform.position;
}
else
{
float distance = Vector3.Distance(transform.position, playerController.buildStartPosition);
if (distance > 15)
if (playerController.separatedBlocks == false)
{
if (gameManager.working == false)
{
@ -72,63 +60,80 @@ public class BuildController : MonoBehaviour
}
playerController.buildStartPosition = transform.position;
}
}
if (playerController.buildObject == null)
{
CreateBuildObject();
}
else
{
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out RaycastHit hit, 100))
else
{
float distance = Vector3.Distance(transform.position, playerController.buildObject.transform.position);
Material buildObjectMaterial = playerController.buildObject.GetComponent<MeshRenderer>().material;
buildObjectMaterial.color = distance > 40 ? Color.red : Color.white;
if (hit.transform.gameObject.tag == "Built")
float distance = Vector3.Distance(transform.position, playerController.buildStartPosition);
if (distance > 15)
{
SetupBuildAxis(hit);
}
else
{
SetupFreePlacement(hit);
}
}
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out RaycastHit buildHit, 40))
{
if (buildHit.collider.gameObject.tag != "CombinedMesh")
{
playerController.buildObject.GetComponent<MeshRenderer>().material.color = Color.white;
if (autoAxis == true)
{
AutoSelectBuildAxis(buildHit);
}
if (cInput.GetKeyDown("Place Object"))
{
if (blockDictionary.machineDictionary.ContainsKey(playerController.buildType))
{
BuildMachine(playerController.buildType, hit);
}
else
{
BuildBlock(playerController.buildType);
}
}
}
else
{
playerController.buildObject.GetComponent<MeshRenderer>().material.color = Color.red;
if (gameManager.working == false)
{
gameManager.meshManager.SeparateBlocks(buildHit.point, "all", true);
gameManager.meshManager.SeparateBlocks(transform.position, "all", true);
playerController.separatedBlocks = true;
}
else
{
playerController.requestedChunkLoad = true;
}
playerController.buildStartPosition = transform.position;
}
}
if (playerController.buildObject == null)
{
CreateBuildObject();
}
else
{
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out RaycastHit hit, 100))
{
float distance = Vector3.Distance(transform.position, playerController.buildObject.transform.position);
Material buildObjectMaterial = playerController.buildObject.GetComponent<MeshRenderer>().material;
buildObjectMaterial.color = distance > 40 ? Color.red : Color.white;
if (hit.transform.gameObject.tag == "Built")
{
SetupBuildAxis(hit);
}
else
{
SetupFreePlacement(hit);
}
}
if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out RaycastHit buildHit, 40))
{
if (buildHit.collider.gameObject.tag != "CombinedMesh")
{
playerController.buildObject.GetComponent<MeshRenderer>().material.color = Color.white;
if (autoAxis == true)
{
AutoSelectBuildAxis(buildHit);
}
if (cInput.GetKeyDown("Place Object"))
{
if (blockDictionary.machineDictionary.ContainsKey(playerController.buildType))
{
BuildMachine(playerController.buildType, hit);
}
else
{
BuildBlock(playerController.buildType);
}
}
}
else
{
playerController.buildObject.GetComponent<MeshRenderer>().material.color = Color.red;
if (gameManager.working == false)
{
gameManager.meshManager.SeparateBlocks(buildHit.point, "all", true);
}
}
}
}
}
}
else if (playerController.buildObject != null)
{
Destroy(playerController.buildObject);
else if (playerController.buildObject != null)
{
Destroy(playerController.buildObject);
}
}
}
@ -235,41 +240,44 @@ public class BuildController : MonoBehaviour
//! Implements the current build axis.
private void SetupBuildAxis(RaycastHit hit)
{
Vector3 placementPoint = hit.transform.position;
Quaternion placementRotation;
Vector3 dirVector;
if (gameManager.working == false)
{
Vector3 placementPoint = hit.transform.position;
Quaternion placementRotation;
Vector3 dirVector;
if (playerController.cubeloc == "up")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y + 5, hit.transform.position.z);
}
else if (playerController.cubeloc == "down")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y - 5, hit.transform.position.z);
}
else if (playerController.cubeloc == "left")
{
placementPoint = new Vector3(hit.transform.position.x + 5, hit.transform.position.y, hit.transform.position.z);
}
else if (playerController.cubeloc == "right")
{
placementPoint = new Vector3(hit.transform.position.x - 5, hit.transform.position.y, hit.transform.position.z);
}
else if (playerController.cubeloc == "front")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z + 5);
}
else if (playerController.cubeloc == "back")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z - 5);
}
if (playerController.cubeloc == "up")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y + 5, hit.transform.position.z);
}
else if (playerController.cubeloc == "down")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y - 5, hit.transform.position.z);
}
else if (playerController.cubeloc == "left")
{
placementPoint = new Vector3(hit.transform.position.x + 5, hit.transform.position.y, hit.transform.position.z);
}
else if (playerController.cubeloc == "right")
{
placementPoint = new Vector3(hit.transform.position.x - 5, hit.transform.position.y, hit.transform.position.z);
}
else if (playerController.cubeloc == "front")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z + 5);
}
else if (playerController.cubeloc == "back")
{
placementPoint = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z - 5);
}
placementRotation = playerController.buildObject.transform.rotation;
playerController.buildObject.transform.position = placementPoint;
playerController.buildObject.transform.rotation = placementRotation;
dirLine.SetPosition(0, playerController.buildObject.transform.position);
dirVector = playerController.buildObject.transform.position + playerController.buildObject.transform.forward * 4;
dirLine.SetPosition(1, dirVector);
placementRotation = playerController.buildObject.transform.rotation;
playerController.buildObject.transform.position = placementPoint;
playerController.buildObject.transform.rotation = placementRotation;
dirLine.SetPosition(0, playerController.buildObject.transform.position);
dirVector = playerController.buildObject.transform.position + playerController.buildObject.transform.forward * 4;
dirLine.SetPosition(1, dirVector);
}
}
//! Prepares cursor for free block placement, ie: not attached to another block.
@ -369,8 +377,13 @@ public class BuildController : MonoBehaviour
}
}
//! Places standard building blocks in the world.
private void BuildBlock(string type)
{
buildBlockCoroutine = StartCoroutine(BuildBlockCoroutine(type));
}
//! Places standard building blocks in the world.
private IEnumerator BuildBlockCoroutine(string type)
{
bool foundItems = false;
foreach (InventorySlot slot in playerController.playerInventory.inventory)
@ -379,49 +392,48 @@ public class BuildController : MonoBehaviour
{
if (slot.amountInSlot >= playerController.buildMultiplier)
{
if (slot.typeInSlot.Equals(type) && GameObject.Find("GameManager").GetComponent<GameManager>().blockLimitReached == false)
if (slot.typeInSlot.Equals(type))
{
foundItems = true;
int h = 0;
Vector3 origin = playerController.buildObject.transform.position;
Quaternion rotation = playerController.buildObject.transform.rotation;
Vector3 multiBuildPlacement = playerController.buildObject.transform.position;
for (int i = 0; i < playerController.buildMultiplier; i++)
{
if (playerController.cubeloc == "up")
{
multiBuildPlacement = new Vector3(playerController.buildObject.transform.position.x, playerController.buildObject.transform.position.y + h, playerController.buildObject.transform.position.z);
multiBuildPlacement = new Vector3(origin.x, origin.y + h, origin.z);
}
if (playerController.cubeloc == "down")
{
multiBuildPlacement = new Vector3(playerController.buildObject.transform.position.x, playerController.buildObject.transform.position.y - h, playerController.buildObject.transform.position.z);
multiBuildPlacement = new Vector3(origin.x, origin.y - h, origin.z);
}
if (playerController.cubeloc == "left")
{
multiBuildPlacement = new Vector3(playerController.buildObject.transform.position.x + h, playerController.buildObject.transform.position.y, playerController.buildObject.transform.position.z);
multiBuildPlacement = new Vector3(origin.x + h, origin.y, origin.z);
}
if (playerController.cubeloc == "right")
{
multiBuildPlacement = new Vector3(playerController.buildObject.transform.position.x - h, playerController.buildObject.transform.position.y, playerController.buildObject.transform.position.z);
multiBuildPlacement = new Vector3(origin.x - h, origin.y, origin.z);
}
if (playerController.cubeloc == "front")
{
multiBuildPlacement = new Vector3(playerController.buildObject.transform.position.x, playerController.buildObject.transform.position.y, playerController.buildObject.transform.position.z + h);
multiBuildPlacement = new Vector3(origin.x, origin.y, origin.z + h);
}
if (playerController.cubeloc == "back")
{
multiBuildPlacement = new Vector3(playerController.buildObject.transform.position.x, playerController.buildObject.transform.position.y, playerController.buildObject.transform.position.z - h);
multiBuildPlacement = new Vector3(origin.x, origin.y, origin.z - h);
}
h += 5;
Instantiate(blockDictionary.blockDictionary[type], multiBuildPlacement, playerController.buildObject.transform.rotation);
Instantiate(blockDictionary.blockDictionary[type], multiBuildPlacement, rotation);
slot.amountInSlot -= 1;
playerController.builderSound.Play();
playerController.destroyTimer = 0;
playerController.buildTimer = 0;
yield return null;
}
}
else if (GameObject.Find("GameManager").GetComponent<GameManager>().blockLimitReached == true)
{
playerController.blockLimitMessage = true;
}
if (slot.amountInSlot == 0)
{
slot.typeInSlot = "nothing";

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
public class ConduitItem : MonoBehaviour
{
private StateManager stateManager;
public Vector3 startPosition;
public Dictionary<string, Texture2D> textureDictionary;
public GameObject target;
@ -14,183 +15,187 @@ public class ConduitItem : MonoBehaviour
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
startPosition = transform.position;
}
//! Called once per frame by unity engine.
public void Update()
{
if (active == true && textureDictionary != null)
if (!stateManager.Busy())
{
if (machine != null)
if (active == true && textureDictionary != null)
{
if (machine.GetComponent<AlloySmelter>() != null)
if (machine != null)
{
if (machine.GetComponent<AlloySmelter>().outputObject != null)
if (machine.GetComponent<AlloySmelter>() != null)
{
target = machine.GetComponent<AlloySmelter>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<AlloySmelter>().outputType))
if (machine.GetComponent<AlloySmelter>().outputObject != null)
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AlloySmelter>().outputType];
target = machine.GetComponent<AlloySmelter>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<AlloySmelter>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AlloySmelter>().outputType];
}
}
}
if (machine.GetComponent<Auger>() != null)
{
if (machine.GetComponent<Auger>().outputObject != null)
{
target = machine.GetComponent<Auger>().outputObject;
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary["Regolith"];
}
}
if (machine.GetComponent<AutoCrafter>() != null)
{
if (machine.GetComponent<AutoCrafter>().inputObject != null)
{
target = machine.GetComponent<AutoCrafter>().inputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<AutoCrafter>().type))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AutoCrafter>().type];
}
}
}
if (machine.GetComponent<DarkMatterCollector>() != null)
{
if (machine.GetComponent<DarkMatterCollector>().outputObject != null)
{
target = machine.GetComponent<DarkMatterCollector>().outputObject;
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary["Dark Matter"];
}
}
if (machine.GetComponent<DarkMatterConduit>() != null)
{
if (machine.GetComponent<DarkMatterConduit>().outputObject != null)
{
target = machine.GetComponent<DarkMatterConduit>().outputObject;
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary["Dark Matter"];
}
}
if (machine.GetComponent<Extruder>() != null)
{
if (machine.GetComponent<Extruder>().outputObject != null)
{
target = machine.GetComponent<Extruder>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<Extruder>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Extruder>().outputType];
}
}
}
if (machine.GetComponent<GearCutter>() != null)
{
if (machine.GetComponent<GearCutter>().outputObject != null)
{
target = machine.GetComponent<GearCutter>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<GearCutter>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<GearCutter>().outputType];
}
}
}
if (machine.GetComponent<Press>() != null)
{
if (machine.GetComponent<Press>().outputObject != null)
{
target = machine.GetComponent<Press>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<Press>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Press>().outputType];
}
}
}
if (machine.GetComponent<ModMachine>() != null)
{
if (machine.GetComponent<ModMachine>().outputObject != null)
{
target = machine.GetComponent<ModMachine>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<ModMachine>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<ModMachine>().outputType];
}
}
}
if (machine.GetComponent<Retriever>() != null)
{
if (machine.GetComponent<Retriever>().outputObject != null)
{
target = machine.GetComponent<Retriever>().outputObject;
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];
}
}
}
if (machine.GetComponent<Smelter>() != null)
{
if (machine.GetComponent<Smelter>().outputObject != null)
{
target = machine.GetComponent<Smelter>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<Smelter>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Smelter>().outputType];
}
}
}
if (machine.GetComponent<UniversalConduit>() != null)
{
if (machine.GetComponent<UniversalConduit>().outputObject != null)
{
target = machine.GetComponent<UniversalConduit>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalConduit>().type))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalConduit>().type];
}
}
}
if (machine.GetComponent<UniversalExtractor>() != null)
{
if (machine.GetComponent<UniversalExtractor>().outputObject != null)
{
target = machine.GetComponent<UniversalExtractor>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalExtractor>().type))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalExtractor>().type];
}
}
}
}
if (machine.GetComponent<Auger>() != null)
if (target != null)
{
if (machine.GetComponent<Auger>().outputObject != null)
billboard.GetComponent<Renderer>().enabled = true;
transform.LookAt(target.transform.position);
transform.position += transform.forward * 10 * Time.deltaTime;
if (Vector3.Distance(transform.position, target.transform.position) < 1)
{
target = machine.GetComponent<Auger>().outputObject;
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary["Regolith"];
transform.position = startPosition;
}
}
if (machine.GetComponent<AutoCrafter>() != null)
else
{
if (machine.GetComponent<AutoCrafter>().inputObject != null)
{
target = machine.GetComponent<AutoCrafter>().inputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<AutoCrafter>().type))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<AutoCrafter>().type];
}
}
}
if (machine.GetComponent<DarkMatterCollector>() != null)
{
if (machine.GetComponent<DarkMatterCollector>().outputObject != null)
{
target = machine.GetComponent<DarkMatterCollector>().outputObject;
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary["Dark Matter"];
}
}
if (machine.GetComponent<DarkMatterConduit>() != null)
{
if (machine.GetComponent<DarkMatterConduit>().outputObject != null)
{
target = machine.GetComponent<DarkMatterConduit>().outputObject;
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary["Dark Matter"];
}
}
if (machine.GetComponent<Extruder>() != null)
{
if (machine.GetComponent<Extruder>().outputObject != null)
{
target = machine.GetComponent<Extruder>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<Extruder>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Extruder>().outputType];
}
}
}
if (machine.GetComponent<GearCutter>() != null)
{
if (machine.GetComponent<GearCutter>().outputObject != null)
{
target = machine.GetComponent<GearCutter>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<GearCutter>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<GearCutter>().outputType];
}
}
}
if (machine.GetComponent<Press>() != null)
{
if (machine.GetComponent<Press>().outputObject != null)
{
target = machine.GetComponent<Press>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<Press>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Press>().outputType];
}
}
}
if (machine.GetComponent<ModMachine>() != null)
{
if (machine.GetComponent<ModMachine>().outputObject != null)
{
target = machine.GetComponent<ModMachine>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<ModMachine>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<ModMachine>().outputType];
}
}
}
if (machine.GetComponent<Retriever>() != null)
{
if (machine.GetComponent<Retriever>().outputObject != null)
{
target = machine.GetComponent<Retriever>().outputObject;
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];
}
}
}
if (machine.GetComponent<Smelter>() != null)
{
if (machine.GetComponent<Smelter>().outputObject != null)
{
target = machine.GetComponent<Smelter>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<Smelter>().outputType))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<Smelter>().outputType];
}
}
}
if (machine.GetComponent<UniversalConduit>() != null)
{
if (machine.GetComponent<UniversalConduit>().outputObject != null)
{
target = machine.GetComponent<UniversalConduit>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalConduit>().type))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalConduit>().type];
}
}
}
if (machine.GetComponent<UniversalExtractor>() != null)
{
if (machine.GetComponent<UniversalExtractor>().outputObject != null)
{
target = machine.GetComponent<UniversalExtractor>().outputObject;
if (textureDictionary.ContainsKey(machine.GetComponent<UniversalExtractor>().type))
{
billboard.GetComponent<Renderer>().material.mainTexture = textureDictionary[machine.GetComponent<UniversalExtractor>().type];
}
}
}
}
if (target != null)
{
billboard.GetComponent<Renderer>().enabled = true;
transform.LookAt(target.transform.position);
transform.position += transform.forward * 10 * Time.deltaTime;
if (Vector3.Distance(transform.position, target.transform.position) < 1)
{
transform.position = startPosition;
billboard.GetComponent<Renderer>().enabled = false;
}
}
else
{
billboard.GetComponent<Renderer>().enabled = false;
textureDictionary = GetComponent<TextureDictionary>().dictionary;
}
}
else
{
billboard.GetComponent<Renderer>().enabled = false;
textureDictionary = GetComponent<TextureDictionary>().dictionary;
}
}
}

View File

@ -4,23 +4,33 @@ public class DarkMatter: MonoBehaviour
{
private float size;
public GameObject collector;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine
public void Update()
{
if (size < 10)
if (!stateManager.Busy())
{
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(10, 10, 10), Time.deltaTime * 0.5f);
size += 1;
}
else if (size >= 10 && size < 20)
{
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(5, 5, 5), Time.deltaTime * 0.5f);
size += 1;
}
else if (size >= 20)
{
size = 0;
if (size < 10)
{
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(10, 10, 10), Time.deltaTime * 0.5f);
size += 1;
}
else if (size >= 10 && size < 20)
{
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(5, 5, 5), Time.deltaTime * 0.5f);
size += 1;
}
else if (size >= 20)
{
size = 0;
}
}
}
}

View File

@ -25,6 +25,7 @@ public class DarkMatterCollector : MonoBehaviour
public bool connectionFailed;
public bool foundDarkMatter;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
private void Start()
@ -38,6 +39,7 @@ public class DarkMatterCollector : MonoBehaviour
connectionLine.loop = true;
connectionLine.enabled = false;
builtObjects = GameObject.Find("Built_Objects");
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
@ -46,6 +48,12 @@ public class DarkMatterCollector : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();

View File

@ -15,7 +15,7 @@ public class DarkMatterConduit : MonoBehaviour
public ConduitItem conduitItem;
public Material darkMatterMat;
public Material lineMat;
LineRenderer connectionLine;
private LineRenderer connectionLine;
private float updateTick;
public int address;
public int range = 6;
@ -24,6 +24,7 @@ public class DarkMatterConduit : MonoBehaviour
public GameObject storageComputerConduitItemObject;
public ConduitItem storageComputerConduitItem;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
@ -36,6 +37,7 @@ public class DarkMatterConduit : MonoBehaviour
connectionLine.loop = true;
connectionLine.enabled = false;
builtObjects = GameObject.Find("Built_Objects");
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
@ -45,6 +47,12 @@ public class DarkMatterConduit : MonoBehaviour
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
if (inputObject == null || outputObject == null)

7
Doxyfile.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5f2df19d5e7a94b198204a52164616b6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,10 +9,12 @@ public class ElectricLight : MonoBehaviour
public bool powerON;
public GameObject powerObject;
public PowerReceiver powerReceiver;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
powerReceiver = gameObject.AddComponent<PowerReceiver>();
}
@ -22,6 +24,12 @@ public class ElectricLight : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 1 + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();

View File

@ -6,8 +6,8 @@ public class Explosion : MonoBehaviour
//! Called once per frame by unity engine.
public void Update()
{
timer += 1 * Time.deltaTime;
{
timer += 1 * Time.deltaTime;
if (timer > 5)
{
Destroy(gameObject);

View File

@ -3,6 +3,7 @@
public class ExtruderPiston : MonoBehaviour
{
public GameObject extruder;
private StateManager stateManager;
private Vector3 originalPosition;
private Vector3 endPosition;
private bool setEndPosition;
@ -13,49 +14,53 @@ public class ExtruderPiston : MonoBehaviour
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
originalPosition = transform.position;
}
//! Called once per frame by unity engine.
public void Update()
{
if (extruder.GetComponent<Light>().enabled == true)
if (!stateManager.Busy())
{
float startDistance = Vector3.Distance(transform.position, originalPosition);
if (startDistance < 1.2f && movingForward == true)
if (extruder.GetComponent<Light>().enabled == true)
{
if (soundPlayed == false)
float startDistance = Vector3.Distance(transform.position, originalPosition);
if (startDistance < 1.2f && movingForward == true)
{
extruder.GetComponent<AudioSource>().Play();
soundPlayed = true;
if (soundPlayed == false)
{
extruder.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
transform.position += transform.right * 1.1f * Time.deltaTime;
}
transform.position += transform.right * 1.1f * Time.deltaTime;
}
else
{
if (setEndPosition == false)
else
{
endPosition = transform.position;
setEndPosition = true;
if (setEndPosition == false)
{
endPosition = transform.position;
setEndPosition = true;
}
movingBack = true;
movingForward = false;
}
movingBack = true;
movingForward = false;
}
float endDistance = Vector3.Distance(transform.position, endPosition);
if (endDistance < 1.2f && movingBack == true)
{
if (soundPlayed == true)
float endDistance = Vector3.Distance(transform.position, endPosition);
if (endDistance < 1.2f && movingBack == true)
{
soundPlayed = false;
if (soundPlayed == true)
{
soundPlayed = false;
}
transform.position -= transform.right * 1.1f * Time.deltaTime;
}
else
{
setEndPosition = false;
movingBack = false;
movingForward = true;
}
transform.position -= transform.right * 1.1f * Time.deltaTime;
}
else
{
setEndPosition = false;
movingBack = false;
movingForward = true;
}
}
}

View File

@ -23,7 +23,6 @@ public class GameManager : MonoBehaviour
public GameObject rocketObject;
public GameObject builtObjects;
public int totalBlockCount;
public bool blockLimitReached;
public bool blockPhysics;
public bool hazardsEnabled = true;
public float meteorTimer;
@ -31,24 +30,12 @@ public class GameManager : MonoBehaviour
public bool dataSaveRequested;
public bool blocksCombined;
public bool working;
public bool waitingForDestroy;
private float waitTime;
public bool initGlass;
public bool initBrick;
public bool initIron;
public bool initSteel;
private float initBrickTimer;
private float initGlassTimer;
private float initIronTimer;
private float initSteelTimer;
public bool replacingMeshFilters;
private float mfDelay;
public bool clearBrickDummies;
public bool clearGlassDummies;
public bool clearIronDummies;
public bool clearSteelDummies;
public bool ironMeshRequired;
public bool steelMeshRequired;
public bool glassMeshRequired;
public bool brickMeshRequired;
public float pirateAttackTimer;
public float meteorShowerTimer;
public float pirateFrequency;
@ -60,7 +47,8 @@ public class GameManager : MonoBehaviour
private bool loadedHazardsEnabled;
public Rocket rocketScript;
public Coroutine separateCoroutine;
public Coroutine combineCoroutine;
public Coroutine meshCombineCoroutine;
public Coroutine blockCombineCoroutine;
public Coroutine hazardRemovalCoroutine;
public List<Vector3> meteorShowerLocationList;
@ -224,102 +212,14 @@ public class GameManager : MonoBehaviour
}
// Used to ensure components are removed before combining meshes.
if (waitingForDestroy == true)
if (replacingMeshFilters == true)
{
waitTime += 1 * Time.deltaTime;
if (waitTime > 1)
mfDelay += 1 * Time.deltaTime;
if (mfDelay > 1)
{
meshManager.CombineMeshes();
waitTime = 0;
waitingForDestroy = false;
}
}
// Clear out dummy objects used for smooth transitions while combining meshes.
if (clearBrickDummies == true)
{
if (initBrickTimer < 3)
{
initBrickTimer += 1 * Time.deltaTime;
}
else
{
BlockDummy[] dummies = FindObjectsOfType<BlockDummy>();
foreach (BlockDummy dummy in dummies)
{
if (dummy.type.Equals("brick"))
{
Destroy(dummy.gameObject);
}
}
initBrickTimer = 0;
clearBrickDummies = false;
}
}
// Clear out dummy objects used for smooth transitions while combining meshes.
if (clearGlassDummies == true)
{
if (initGlassTimer < 3)
{
initGlassTimer += 1 * Time.deltaTime;
}
else
{
BlockDummy[] dummies = FindObjectsOfType<BlockDummy>();
foreach (BlockDummy dummy in dummies)
{
if (dummy.type.Equals("glass"))
{
Destroy(dummy.gameObject);
}
}
initGlassTimer = 0;
clearGlassDummies = false;
}
}
// Clear out dummy objects used for smooth transitions while combining meshes.
if (clearIronDummies == true)
{
if (initIronTimer < 3)
{
initIronTimer += 1 * Time.deltaTime;
}
else
{
BlockDummy[] dummies = FindObjectsOfType<BlockDummy>();
foreach (BlockDummy dummy in dummies)
{
if (dummy.type.Equals("iron"))
{
Destroy(dummy.gameObject);
}
}
initIronTimer = 0;
clearIronDummies = false;
}
}
// Clear out dummy objects used for smooth transitions while combining meshes.
if (clearSteelDummies == true)
{
if (initSteelTimer < 3)
{
initSteelTimer += 1 * Time.deltaTime;
}
else
{
BlockDummy[] dummies = FindObjectsOfType<BlockDummy>();
foreach (BlockDummy dummy in dummies)
{
if (dummy.type.Equals("steel"))
{
Destroy(dummy.gameObject);
}
}
initSteelTimer = 0;
clearSteelDummies = false;
mfDelay = 0;
replacingMeshFilters = false;
}
}

View File

@ -7,6 +7,13 @@ public class Glass : MonoBehaviour
public string creationMethod;
public int address;
private float updateTick;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
@ -14,6 +21,12 @@ public class Glass : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
}

View File

@ -5,11 +5,13 @@ public class GuiCoordinates
//MESSAGES
public Rect messageRect;
public Rect lowMessageRect;
public Rect saveMessageRect;
public Rect midMessageRect;
public Rect highMessageRect;
public Rect secondLineHighMessageRect;
public Rect longHighMessageRect;
public Rect lowMessageBackgroundRect;
public Rect saveMessageBackgroundRect;
public Rect messageBackgroundRect;
public Rect midMessageBackgroundRect;
public Rect highMessageBackgroundRect;
@ -255,11 +257,13 @@ public class GuiCoordinates
messageBackgroundRect = new Rect((Screen.width / 2) - 100, Screen.height - 120, 200, 100);
lowMessageBackgroundRect = new Rect((ScreenWidth * 0.42f), (ScreenHeight * 0.63f), (ScreenWidth * 0.18f), (ScreenHeight * 0.05f));
saveMessageBackgroundRect = new Rect((ScreenWidth * 0.40f), (ScreenHeight * 0.63f), (ScreenWidth * 0.22f), (ScreenHeight * 0.05f));
midMessageBackgroundRect = new Rect((ScreenWidth * 0.42f), (ScreenHeight * 0.55f), (ScreenWidth * 0.18f), (ScreenHeight * 0.05f));
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));
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));
highMessageRect = new Rect((ScreenWidth * 0.48f), (ScreenHeight * 0.30f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
longHighMessageRect = new Rect((ScreenWidth * 0.45f), (ScreenHeight * 0.292f), (ScreenWidth * 0.55f), (ScreenHeight * 0.5f));
@ -556,6 +560,6 @@ public class GuiCoordinates
marketMessageButtonRect = new Rect(((ScreenWidth / 2) - (ScreenWidth * 0.07f)), ((ScreenHeight / 2) + 30), (ScreenWidth * 0.14f), (ScreenHeight * 0.05f));
//PAINT GUN COLOR SELECTION BACKGROUND
paintGunMenuBackgroundRect = new Rect((ScreenWidth * 0.4f), (ScreenHeight * 0.04f), (ScreenWidth * 0.2f), (ScreenHeight * 0.56f));
paintGunMenuBackgroundRect = new Rect((ScreenWidth * 0.4f), (ScreenHeight * 0.04f), (ScreenWidth * 0.2f), (ScreenHeight * 0.56f));
}
}

View File

@ -20,6 +20,7 @@ public class HeatExchanger : MonoBehaviour
public int connectionAttempts;
public bool connectionFailed;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
@ -31,6 +32,7 @@ public class HeatExchanger : MonoBehaviour
connectionLine.loop = true;
connectionLine.enabled = false;
builtObjects = GameObject.Find("Built_Objects");
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
@ -39,6 +41,12 @@ public class HeatExchanger : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
if (outputObject == null)
@ -89,8 +97,15 @@ public class HeatExchanger : MonoBehaviour
}
else if (amount > 0)
{
speed = (int)amount;
providingCooling = true;
if (amount <= inputObject.GetComponent<UniversalConduit>().speed)
{
speed = (int)amount;
providingCooling = true;
}
else
{
speed = inputObject.GetComponent<UniversalConduit>().speed;
}
}
else
{

View File

@ -22,7 +22,7 @@ public class InfoHUD : MonoBehaviour
//! Returns true if the info hud should be drawn.
private bool ShouldDrawInfoHud()
{
return playerController.stateManager.worldLoaded == true
return !playerController.stateManager.Busy()
&& playerController.objectInSight != playerController.gameObject
&& GetComponent<MainMenu>().finishedLoading == true
&& playerController.objectInSight != null

View File

@ -20,6 +20,8 @@ public class InteractionController : MonoBehaviour
//! Called once per frame by unity engine.
public void Update()
{
if (!playerController.stateManager.Busy())
{
// Raycast and associated data for interacting with machines and other objects.
Transform camPos = Camera.main.gameObject.transform;
if (Physics.Raycast(camPos.position, camPos.forward, out playerController.playerLookHit, 40))
@ -152,6 +154,7 @@ public class InteractionController : MonoBehaviour
{
EndInteraction();
}
}
}
//! Returns true if the object in question is a resource node.

View File

@ -47,7 +47,7 @@ public class InventoryGUI : MonoBehaviour
GUI.skin.label.fontSize = 10;
}
if (playerController.stateManager.worldLoaded == true && GetComponent<MainMenu>().finishedLoading == true)
if (!playerController.stateManager.Busy() && GetComponent<MainMenu>().finishedLoading == true)
{
if (playerController.inventoryOpen == true)
{

View File

@ -12,55 +12,58 @@ public class InventoryManager : MonoBehaviour
public int maxStackSize = 1000;
public bool itemAdded;
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
{
if (ID != "unassigned" && initialized == false)
{
stateManager = GameObject.Find("GameManager").GetComponent<StateManager>();
if (stateManager.worldLoaded == true)
{
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;
if (ID.Equals("Rocket"))
{
maxStackSize = 100000;
}
else
{
maxStackSize = 1000;
}
}
}
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (GetComponent<RailCart>() == null && GetComponent<Retriever>() == null && GetComponent<AutoCrafter>() == null && GetComponent<PlayerController>() == null && GetComponent<Rocket>() == null && ID != "Lander")
if (!stateManager.Busy())
{
if (ID != "unassigned" && initialized == false)
{
GetComponent<PhysicsHandler>().UpdatePhysics();
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;
}
if (ID == "player" || ID == "Lander")
{
SaveData();
}
updateTick = 0;
}
}
private bool IsStorageContainer()
{
return GetComponent<RailCart>() == null
&& GetComponent<Retriever>() == null
&& GetComponent<AutoCrafter>() == null
&& GetComponent<PlayerController>() == null
&& GetComponent<Rocket>() == null
&& ID != "Lander";
}
//! Saves the inventory's contents to disk.
public void SaveData()
{

View File

@ -7,6 +7,13 @@ public class IronBlock : MonoBehaviour
public string creationMethod;
public int address;
private float updateTick;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
@ -14,6 +21,12 @@ public class IronBlock : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
}

View File

@ -4,20 +4,30 @@
public class LaserCutter : MonoBehaviour
{
public GameObject gearCutter;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Update is called once per frame.
public void Update()
{
if (gearCutter.GetComponent<Light>().enabled == true)
if (!stateManager.Busy())
{
GetComponentInChildren<Renderer>().enabled = true;
gearCutter.GetComponent<AudioSource>().enabled = true;
transform.Rotate(-Vector3.up * 600 * Time.deltaTime);
}
else
{
gearCutter.GetComponent<AudioSource>().enabled = false;
GetComponentInChildren<Renderer>().enabled = false;
if (gearCutter.GetComponent<Light>().enabled == true)
{
GetComponentInChildren<Renderer>().enabled = true;
gearCutter.GetComponent<AudioSource>().enabled = true;
transform.Rotate(-Vector3.up * 600 * Time.deltaTime);
}
else
{
gearCutter.GetComponent<AudioSource>().enabled = false;
GetComponentInChildren<Renderer>().enabled = false;
}
}
}
}

View File

@ -33,7 +33,7 @@ public class MachineGUI : MonoBehaviour
GUI.skin.label.fontSize = 10;
}
if (playerController.stateManager.worldLoaded == true && GetComponent<MainMenu>().finishedLoading == true)
if (!playerController.stateManager.Busy() && GetComponent<MainMenu>().finishedLoading == true)
{
// MACHINE CONTROL GUI
if (playerController.inventoryOpen == false && playerController.machineGUIopen == true && playerController.objectInSight != null)

View File

@ -29,7 +29,7 @@ public class MainMenu : MonoBehaviour
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = GameObject.Find("GameManager").GetComponent<StateManager>();
stateManager = FindObjectOfType<StateManager>();
worldList = new List<string>();
videoPlayer.GetComponent<VP>().PlayVideo("QE_Title.webm",true,0);
buttonSounds = menuSoundObject.GetComponent<AudioSource>();
@ -144,7 +144,7 @@ public class MainMenu : MonoBehaviour
Rect startGameButtonRect = new Rect(ScreenWidth * 0.58f, ScreenHeight * 0.4f, 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.48f), (ScreenHeight * 0.30f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
Rect loadingMessageRect = new Rect((ScreenWidth * 0.46f), (ScreenHeight * 0.30f), (ScreenWidth * 0.5f), (ScreenHeight * 0.5f));
Rect buttonRect1 = new Rect((ScreenWidth * 0.405f), (ScreenHeight * 0.50f), (ScreenWidth * 0.020f), (ScreenHeight * 0.025f));
Rect buttonRect2 = new Rect((ScreenWidth * 0.405f), (ScreenHeight * 0.532f), (ScreenWidth * 0.020f), (ScreenHeight * 0.025f));
@ -406,17 +406,23 @@ public class MainMenu : MonoBehaviour
}
}
}
else if (stateManager.Loaded == false && finishedLoading == false)
else if (finishedLoading == false && (stateManager.worldLoaded == false || stateManager.GetComponent<GameManager>().working == true))
{
GUI.Label(loadingMessageRect, "Loading...");
if (videoPlayer.GetComponent<VP>().IsPlaying())
{
videoPlayer.GetComponent<VP>().StopVideo();
}
GUI.DrawTexture(backgroundRect, titleTexture);
int f = GUI.skin.label.fontSize;
GUI.skin.label.fontSize = 16;
string loadingMessage = "Loading... " + stateManager.progress + "/" + stateManager.idList.Length;
Vector2 size = GetStringSize(loadingMessage);
Rect messagePos = new Rect((Screen.width / 2) - (size.x/2), Screen.height * 0.4f, size.x, size.y);
GUI.Label(messagePos, loadingMessage);
GUI.skin.label.fontSize = f;
}
else if (stateManager.GetComponent<GameManager>().working == true && finishedLoading == false)
else
{
GUI.Label(loadingMessageRect, "Loading...");
}
else if (finishedLoading == false)
{
videoPlayer.GetComponent<VP>().StopVideo();
finishedLoading = true;
}
}

View File

@ -58,7 +58,7 @@ public class MarketGUI : MonoBehaviour
//! Called once per frame by unity engine.
public void Update()
{
if (playerController.stateManager.worldLoaded == true && loadedValues == false)
if (!playerController.stateManager.Busy() == true && loadedValues == false)
{
Dictionary<string, int> pd = new Dictionary<string, int>();
foreach (KeyValuePair<string, int> i in priceDictionary)

View File

@ -4,7 +4,6 @@ using UnityEngine;
public class MeshPainter : MonoBehaviour
{
public int ID;
private float saveTimer;
private Coroutine saveDataCoRoutine;
//! Called by unity engine on start up to initialize variables.
@ -73,15 +72,10 @@ public class MeshPainter : MonoBehaviour
}
}
//! Called once per frame by unity engine.
public void Update()
//! Saves mesh colors.
public void SaveData()
{
saveTimer += 1 * Time.deltaTime;
if (saveTimer >= 1)
{
saveDataCoRoutine = StartCoroutine(SaveDataCoRoutine());
saveTimer = 0;
}
saveDataCoRoutine = StartCoroutine(SaveDataCoRoutine());
}
//! Saves the color of painted objects.

View File

@ -16,15 +16,18 @@ public class ModMachine : BasicMachine
public new void Update()
{
base.Update();
TextureDictionary textureDictionary = GameObject.Find("Player").GetComponent<TextureDictionary>();
if (textureDictionary.dictionary.ContainsKey(machineName))
if (!stateManager.Busy())
{
material.mainTexture = GameObject.Find("Player").GetComponent<TextureDictionary>().dictionary[machineName];
}
GetComponent<Renderer>().material = material;
if (recipes == null)
{
recipes = GameObject.Find("Player").GetComponent<BuildController>().blockDictionary.GetMachineRecipes(machineName);
TextureDictionary textureDictionary = GameObject.Find("Player").GetComponent<TextureDictionary>();
if (textureDictionary.dictionary.ContainsKey(machineName))
{
material.mainTexture = GameObject.Find("Player").GetComponent<TextureDictionary>().dictionary[machineName];
}
GetComponent<Renderer>().material = material;
if (recipes == null)
{
recipes = GameObject.Find("Player").GetComponent<BuildController>().blockDictionary.GetMachineRecipes(machineName);
}
}
}
}

View File

@ -10,12 +10,18 @@ public class NuclearReactor : MonoBehaviour
public int address;
public int turbineCount;
public bool sufficientCooling;
private StateManager stateMananger;
public void Start()
{
stateMananger = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
{
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
if (updateTick > 0.5f + (address * 0.001f) && stateMananger.worldLoaded == true)
{
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;

View File

@ -56,7 +56,7 @@ public class PhysicsHandler : MonoBehaviour
//! Updates the physics state of the object.
public void UpdatePhysics()
{
if (stateManager.worldLoaded == true)
if (!stateManager.Busy())
{
if (!creationMethod.Equals("spawned"))
{

View File

@ -414,9 +414,11 @@ public class PlayerController : MonoBehaviour
CheckStorageDistance();
}
// Input manager.
inputManager.HandleInput();
EnforceWorldLimits();
if (stateManager.saving == false)
{
inputManager.HandleInput();
EnforceWorldLimits();
}
}
}
}
@ -454,6 +456,8 @@ public class PlayerController : MonoBehaviour
//! Saves the player's location and money.
public void SavePlayerData()
{
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);

View File

@ -218,8 +218,17 @@ public class PlayerGUI : MonoBehaviour
{
if (SavingMessageRequired())
{
GUI.DrawTexture(guiCoordinates.lowMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
GUI.Label(guiCoordinates.lowMessageRect, "Saving world...");
int current = stateManager.saveManager.currentObject;
int total = stateManager.saveManager.totalObjects;
GUI.DrawTexture(guiCoordinates.saveMessageBackgroundRect, textureDictionary.dictionary["Interface Background"]);
if (total > 0)
{
GUI.Label(guiCoordinates.saveMessageRect, "Saving world... "+current+"/"+total);
}
else
{
GUI.Label(guiCoordinates.saveMessageRect, "Saving world... " + "preparing");
}
}
}
}

View File

@ -25,10 +25,12 @@ public class PowerConduit : MonoBehaviour
public bool connectionFailed;
private GameObject builtObjects;
public PowerReceiver powerReceiver;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
connectionLine = gameObject.AddComponent<LineRenderer>();
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine.startWidth = 0.2f;
@ -46,6 +48,12 @@ public class PowerConduit : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
updateTick = 0;
GetComponent<PhysicsHandler>().UpdatePhysics();

View File

@ -25,6 +25,7 @@ public class PowerSource : MonoBehaviour
public Texture2D generatorOffTexture;
public Texture2D generatorOnTexture;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
@ -36,6 +37,7 @@ public class PowerSource : MonoBehaviour
connectionLine.loop = true;
connectionLine.enabled = false;
builtObjects = GameObject.Find("Built_Objects");
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
@ -44,6 +46,12 @@ public class PowerSource : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;

View File

@ -4,6 +4,7 @@
public class PressHammer : MonoBehaviour
{
public GameObject press;
private StateManager stateManager;
public float originalYposition;
bool movingDown = true;
bool movingUp;
@ -12,40 +13,44 @@ public class PressHammer : MonoBehaviour
//! Start is called before the first frame update.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
originalYposition = transform.position.y;
}
//! Update is called once per frame.
public void Update()
{
if (press.GetComponent<Light>().enabled == true)
{
if (transform.position.y > originalYposition - 0.4f && movingDown == true)
{
if (soundPlayed == false)
{
press.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
transform.position -= transform.up * 0.3f * Time.deltaTime;
}
else
{
movingUp = true;
movingDown = false;
}
if (transform.position.y <= originalYposition && movingUp == true)
{
if (soundPlayed == true)
{
soundPlayed = false;
}
transform.position += transform.up * 0.3f * Time.deltaTime;
}
else
{
movingUp = false;
movingDown = true;
if (!stateManager.Busy())
{
if (press.GetComponent<Light>().enabled == true)
{
if (transform.position.y > originalYposition - 0.4f && movingDown == true)
{
if (soundPlayed == false)
{
press.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
transform.position -= transform.up * 0.3f * Time.deltaTime;
}
else
{
movingUp = true;
movingDown = false;
}
if (transform.position.y <= originalYposition && movingUp == true)
{
if (soundPlayed == true)
{
soundPlayed = false;
}
transform.position += transform.up * 0.3f * Time.deltaTime;
}
else
{
movingUp = false;
movingDown = true;
}
}
}
}

View File

@ -9,6 +9,7 @@ public class PrintingArm : MonoBehaviour
public GameObject verticalArm;
private Vector3 horizontalArmStartPosition;
private Vector3 verticalArmStartPosition;
private StateManager stateManager;
bool started;
bool soundPlayed;
float timer;
@ -16,6 +17,7 @@ public class PrintingArm : MonoBehaviour
//! Start is called before the first frame update.
void Start()
{
stateManager = FindObjectOfType<StateManager>();
horizontalArmStartPosition = horizontalArm.transform.position;
verticalArmStartPosition = verticalArm.transform.position;
}
@ -23,100 +25,103 @@ public class PrintingArm : MonoBehaviour
//! Update is called once per frame.
void Update()
{
if (autoCrafter.GetComponent<AutoCrafter>().inputObject != null)
if (!stateManager.Busy())
{
started = true;
}
else
{
started = false;
}
if (autoCrafter.GetComponent<Light>().enabled == true && started == true)
{
laser.SetActive(true);
timer += 1 * Time.deltaTime;
if (timer < 1)
if (autoCrafter.GetComponent<AutoCrafter>().inputObject != null)
{
if (soundPlayed == false)
{
soundPlayed = true;
}
horizontalArm.transform.position += horizontalArm.transform.right * 1 * Time.deltaTime;
started = true;
}
else if (timer >= 1 && timer < 2)
else
{
if (soundPlayed == true)
started = false;
}
if (autoCrafter.GetComponent<Light>().enabled == true && started == true)
{
laser.SetActive(true);
timer += 1 * Time.deltaTime;
if (timer < 1)
{
GetComponent<AudioSource>().Play();
if (soundPlayed == false)
{
soundPlayed = true;
}
horizontalArm.transform.position += horizontalArm.transform.right * 1 * Time.deltaTime;
}
else if (timer >= 1 && timer < 2)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position -= verticalArm.transform.forward * 1 * Time.deltaTime;
}
else if (timer >= 2 && timer < 3)
{
if (soundPlayed == false)
{
GetComponent<AudioSource>().Play();
soundPlayed = true;
}
horizontalArm.transform.position -= horizontalArm.transform.right * 1 * Time.deltaTime;
}
else if (timer >= 3 && timer < 4)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position += verticalArm.transform.forward * 1 * Time.deltaTime;
}
if (timer >= 4 && timer < 5)
{
if (soundPlayed == false)
{
//!retriever.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
horizontalArm.transform.position -= horizontalArm.transform.right * 1 * Time.deltaTime;
}
else if (timer >= 5 && timer < 6)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position += verticalArm.transform.forward * 1 * Time.deltaTime;
}
else if (timer >= 6 && timer < 7)
{
if (soundPlayed == false)
{
GetComponent<AudioSource>().Play();
soundPlayed = true;
}
horizontalArm.transform.position += horizontalArm.transform.right * 1 * Time.deltaTime;
}
else if (timer >= 7 && timer < 8)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position -= verticalArm.transform.forward * 1 * Time.deltaTime;
}
else if (timer >= 8)
{
timer = 0;
soundPlayed = false;
horizontalArm.transform.position = horizontalArmStartPosition;
verticalArm.transform.position = verticalArmStartPosition;
}
verticalArm.transform.position -= verticalArm.transform.forward * 1 * Time.deltaTime;
}
else if (timer >= 2 && timer < 3)
else
{
if (soundPlayed == false)
{
GetComponent<AudioSource>().Play();
soundPlayed = true;
}
horizontalArm.transform.position -= horizontalArm.transform.right * 1 * Time.deltaTime;
laser.SetActive(false);
}
else if (timer >= 3 && timer < 4)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position += verticalArm.transform.forward * 1 * Time.deltaTime;
}
if (timer >= 4 && timer < 5)
{
if (soundPlayed == false)
{
//!retriever.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
horizontalArm.transform.position -= horizontalArm.transform.right * 1 * Time.deltaTime;
}
else if (timer >= 5 && timer < 6)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position += verticalArm.transform.forward * 1 * Time.deltaTime;
}
else if (timer >= 6 && timer < 7)
{
if (soundPlayed == false)
{
GetComponent<AudioSource>().Play();
soundPlayed = true;
}
horizontalArm.transform.position += horizontalArm.transform.right * 1 * Time.deltaTime;
}
else if (timer >= 7 && timer < 8)
{
if (soundPlayed == true)
{
GetComponent<AudioSource>().Play();
soundPlayed = false;
}
verticalArm.transform.position -= verticalArm.transform.forward * 1 * Time.deltaTime;
}
else if (timer >= 8)
{
timer = 0;
soundPlayed = false;
horizontalArm.transform.position = horizontalArmStartPosition;
verticalArm.transform.position = verticalArmStartPosition;
}
}
else
{
laser.SetActive(false);
}
}
}

View File

@ -6,6 +6,7 @@ public class RailCart : MonoBehaviour
public string creationMethod = "built";
public GameObject target;
private Vector3 targetPosition;
private StateManager stateManager;
public int address;
public string targetID;
private bool loadedTarget;
@ -16,45 +17,54 @@ public class RailCart : MonoBehaviour
public void Start()
{
builtObjects = GameObject.Find("Built_Objects");
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
{
GetComponent<InventoryManager>().ID = ID;
if (creationMethod.Equals("spawned"))
if (!stateManager.Busy())
{
if (target == null && loadedTarget == false && !targetID.Equals(""))
GetComponent<InventoryManager>().ID = ID;
if (creationMethod.Equals("spawned"))
{
RailCartHub[] allHubs = FindObjectsOfType<RailCartHub>();
foreach (RailCartHub hub in allHubs)
if (target == null && loadedTarget == false && !targetID.Equals(""))
{
if (hub.ID.Equals(targetID))
RailCartHub[] allHubs = FindObjectsOfType<RailCartHub>();
foreach (RailCartHub hub in allHubs)
{
target = hub.gameObject;
loadedTarget = true;
if (hub.ID.Equals(targetID))
{
target = hub.gameObject;
loadedTarget = true;
}
}
}
}
}
if (target != null)
{
targetPosition = target.transform.position;
transform.LookAt(targetPosition);
if (Vector3.Distance(transform.position, targetPosition) < 1)
if (target != null)
{
if (target.GetComponent<RailCartHub>() != null)
targetPosition = target.transform.position;
transform.LookAt(targetPosition);
if (Vector3.Distance(transform.position, targetPosition) < 1)
{
targetID = target.GetComponent<RailCartHub>().ID;
if (target.GetComponent<RailCartHub>().stop == true)
if (target.GetComponent<RailCartHub>() != null)
{
if (GetComponent<AudioSource>().enabled == true)
targetID = target.GetComponent<RailCartHub>().ID;
if (target.GetComponent<RailCartHub>().stop == true)
{
GetComponent<AudioSource>().enabled = false;
}
if (stopTimer <= target.GetComponent<RailCartHub>().stopTime)
{
stopTimer += 1 * Time.deltaTime;
if (GetComponent<AudioSource>().enabled == true)
{
GetComponent<AudioSource>().enabled = false;
}
if (stopTimer <= target.GetComponent<RailCartHub>().stopTime)
{
stopTimer += 1 * Time.deltaTime;
}
else if (target.GetComponent<RailCartHub>().outputObject != null)
{
stopTimer = 0;
target = target.GetComponent<RailCartHub>().outputObject;
}
}
else if (target.GetComponent<RailCartHub>().outputObject != null)
{
@ -62,35 +72,30 @@ public class RailCart : MonoBehaviour
target = target.GetComponent<RailCartHub>().outputObject;
}
}
else if (target.GetComponent<RailCartHub>().outputObject != null)
{
stopTimer = 0;
target = target.GetComponent<RailCartHub>().outputObject;
}
}
}
else
{
if (Physics.Raycast(transform.position,transform.forward,out RaycastHit crashHit, 5))
{
if (crashHit.collider != null)
{
if (crashHit.collider.gameObject != null)
{
if (crashHit.collider.gameObject.GetComponent<RailCartHub>() != null || crashHit.collider.gameObject.tag.Equals("Landscape"))
{
transform.position += 8 * transform.forward * Time.deltaTime;
}
}
}
}
else
{
transform.position += 8 * transform.forward * Time.deltaTime;
}
if (GetComponent<AudioSource>().enabled == false)
{
GetComponent<AudioSource>().enabled = true;
if (Physics.Raycast(transform.position, transform.forward, out RaycastHit crashHit, 5))
{
if (crashHit.collider != null)
{
if (crashHit.collider.gameObject != null)
{
if (crashHit.collider.gameObject.GetComponent<RailCartHub>() != null || crashHit.collider.gameObject.tag.Equals("Landscape"))
{
transform.position += 8 * transform.forward * Time.deltaTime;
}
}
}
}
else
{
transform.position += 8 * transform.forward * Time.deltaTime;
}
if (GetComponent<AudioSource>().enabled == false)
{
GetComponent<AudioSource>().enabled = true;
}
}
}
}

View File

@ -9,7 +9,8 @@ public class RailCartHub : MonoBehaviour
public string creationMethod = "built";
public GameObject inputObject;
public GameObject outputObject;
LineRenderer connectionLine;
private StateManager stateManager;
private LineRenderer connectionLine;
private float updateTick;
public Material lineMat;
public int address;
@ -25,6 +26,7 @@ public class RailCartHub : MonoBehaviour
public void Start()
{
connectionLine = gameObject.AddComponent<LineRenderer>();
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -38,6 +40,12 @@ public class RailCartHub : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
if (inputObject == null || outputObject == null)

View File

@ -27,6 +27,7 @@ public class Retriever : MonoBehaviour
public int address;
public bool hasHeatExchanger;
private bool retrievingIce;
private int warmup;
public GameObject connectionObject;
private GameObject spawnedConnection;
public int connectionAttempts;
@ -37,6 +38,7 @@ public class Retriever : MonoBehaviour
private InventoryManager storageComputerInventoryManager;
public PowerReceiver powerReceiver;
private GameObject builtObjects;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
void Start()
@ -44,6 +46,7 @@ public class Retriever : MonoBehaviour
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine = gameObject.AddComponent<LineRenderer>();
conduitItem = GetComponentInChildren<ConduitItem>(true);
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -58,11 +61,21 @@ public class Retriever : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
updateTick = 0;
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

View File

@ -6,7 +6,8 @@ public class RoboticArm : MonoBehaviour
public GameObject retriever;
public GameObject item;
public Transform rotationTransform;
Vector3 rotationPoint;
private StateManager stateManager;
private Vector3 rotationPoint;
bool started;
bool soundPlayed;
float timer;
@ -15,81 +16,85 @@ public class RoboticArm : MonoBehaviour
void Start()
{
rotationPoint = rotationTransform.position;
stateManager = FindObjectOfType<StateManager>();
}
//! Update is called once per frame.
void Update()
{
if (retriever.GetComponent<Retriever>().inputObject != null && retriever.GetComponent<Retriever>().outputObject != null)
if (!stateManager.Busy())
{
started = true;
}
else
{
started = false;
item.GetComponent<Renderer>().enabled = false;
}
if (retriever.GetComponent<Light>().enabled == true && started == true)
{
timer += 1 * Time.deltaTime;
if (timer < 1)
if (retriever.GetComponent<Retriever>().inputObject != null && retriever.GetComponent<Retriever>().outputObject != null)
{
if (soundPlayed == false)
{
soundPlayed = true;
}
item.GetComponent<Renderer>().enabled = true;
transform.RotateAround(rotationPoint, Vector3.up, 150 * Time.deltaTime);
started = true;
}
else if (timer >= 1 && timer < 3)
else
{
if (soundPlayed == true)
started = false;
item.GetComponent<Renderer>().enabled = false;
}
if (retriever.GetComponent<Light>().enabled == true && started == true)
{
timer += 1 * Time.deltaTime;
if (timer < 1)
{
retriever.GetComponent<AudioSource>().Play();
if (soundPlayed == false)
{
soundPlayed = true;
}
item.GetComponent<Renderer>().enabled = true;
transform.RotateAround(rotationPoint, Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 1 && timer < 3)
{
if (soundPlayed == true)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = false;
}
item.GetComponent<Renderer>().enabled = false;
transform.RotateAround(rotationPoint, -Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 3 && timer < 4)
{
if (soundPlayed == false)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
item.GetComponent<Renderer>().enabled = true;
transform.RotateAround(rotationPoint, Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 4 && timer < 5)
{
if (soundPlayed == true)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = false;
}
item.GetComponent<Renderer>().enabled = false;
transform.RotateAround(rotationPoint, -Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 5 && timer < 6)
{
if (soundPlayed == false)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
item.GetComponent<Renderer>().enabled = true;
transform.RotateAround(rotationPoint, Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 6)
{
timer = 0;
soundPlayed = false;
}
}
else
{
item.GetComponent<Renderer>().enabled = false;
transform.RotateAround(rotationPoint, -Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 3 && timer < 4)
{
if (soundPlayed == false)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
item.GetComponent<Renderer>().enabled = true;
transform.RotateAround(rotationPoint, Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 4 && timer < 5)
{
if (soundPlayed == true)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = false;
}
item.GetComponent<Renderer>().enabled = false;
transform.RotateAround(rotationPoint, -Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 5 && timer < 6)
{
if (soundPlayed == false)
{
retriever.GetComponent<AudioSource>().Play();
soundPlayed = true;
}
item.GetComponent<Renderer>().enabled = true;
transform.RotateAround(rotationPoint, Vector3.up, 150 * Time.deltaTime);
}
else if (timer >= 6)
{
timer = 0;
soundPlayed = false;
}
}
else
{
item.GetComponent<Renderer>().enabled = false;
}
}
}

View File

@ -23,7 +23,7 @@ public class Rocket : MonoBehaviour
//! Called once per frame by unity engine.
public void Update()
{
if (GameObject.Find("GameManager").GetComponent<StateManager>().worldLoaded == true)
if (!player.stateManager.Busy())
{
if (initialized == false)
{

View File

@ -5,6 +5,8 @@ using System.Collections.Generic;
public class SaveManager
{
private StateManager stateManager;
public int currentObject;
public int totalObjects;
//! This class handles world saving.
public SaveManager(StateManager stateManager)
@ -17,14 +19,23 @@ public class SaveManager
{
stateManager.dataSaved = false;
stateManager.saving = true;
currentObject = 0;
int saveInterval = 0;
int objectID = 0;
string worldID = "";
string objectName = "";
List<int> idList = new List<int>();
GameObject[] allObjects = GameObject.FindGameObjectsWithTag("Built");
foreach (GameObject go in allObjects)
GameObject[] machines = GameObject.FindGameObjectsWithTag("Built");
Transform[] blocks = stateManager.BuiltObjects.GetComponentsInChildren<Transform>(true);
MeshPainter[] meshPainters = Object.FindObjectsOfType<MeshPainter>();
if (totalObjects == 0)
{
totalObjects = machines.Length + blocks.Length + meshPainters.Length;
}
foreach (GameObject go in machines)
{
if (go != null)
{
@ -450,8 +461,9 @@ public class SaveManager
PlayerPrefsX.SetVector3(stateManager.WorldName + objectID + "Position", objectPosition);
PlayerPrefsX.SetQuaternion(stateManager.WorldName + objectID + "Rotation", objectRotation);
currentObject++;
saveInterval++;
if (saveInterval >= 10)
if (saveInterval >= totalObjects * 0.05f)
{
yield return null;
saveInterval = 0;
@ -460,8 +472,7 @@ public class SaveManager
}
}
Transform[] allTransforms = stateManager.BuiltObjects.GetComponentsInChildren<Transform>(true);
foreach (Transform T in allTransforms)
foreach (Transform T in blocks)
{
if (T != null)
{
@ -530,8 +541,9 @@ public class SaveManager
FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent<PhysicsHandler>().fallingStack);
}
currentObject++;
saveInterval++;
if (saveInterval >= 10)
if (saveInterval >= totalObjects * 0.05f)
{
yield return null;
saveInterval = 0;
@ -539,6 +551,18 @@ public class SaveManager
}
}
foreach (MeshPainter painter in meshPainters)
{
painter.SaveData();
currentObject++;
saveInterval++;
if (saveInterval >= totalObjects * 0.05f)
{
yield return null;
saveInterval = 0;
}
}
if (idList.Count > 0)
{
PlayerPrefsX.SetIntArray(stateManager.WorldName + "idList", idList.ToArray());
@ -547,5 +571,7 @@ public class SaveManager
FileBasedPrefs.ManuallySave();
stateManager.dataSaved = true;
stateManager.saving = false;
currentObject = 0;
totalObjects = 0;
}
}

View File

@ -3,30 +3,39 @@
//! This class handles repositioning of the scanner in first person view, based on FOV.
public class ScannerOffset : MonoBehaviour
{
private StateManager stateManager;
public GameObject standardScanner;
public GameObject adjustedScanner;
public GameObject adjustedScanner2;
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
{
if (Camera.main.fieldOfView > 66.6667 && Camera.main.fieldOfView < 73.3334)
if (!stateManager.Busy())
{
standardScanner.SetActive(false);
adjustedScanner.SetActive(true);
adjustedScanner2.SetActive(false);
}
else if (Camera.main.fieldOfView > 73.3334)
{
standardScanner.SetActive(false);
adjustedScanner.SetActive(false);
adjustedScanner2.SetActive(true);
}
else if (Camera.main.fieldOfView < 66.6667)
{
standardScanner.SetActive(true);
adjustedScanner.SetActive(false);
adjustedScanner2.SetActive(false);
if (Camera.main.fieldOfView > 66.6667 && Camera.main.fieldOfView < 73.3334)
{
standardScanner.SetActive(false);
adjustedScanner.SetActive(true);
adjustedScanner2.SetActive(false);
}
else if (Camera.main.fieldOfView > 73.3334)
{
standardScanner.SetActive(false);
adjustedScanner.SetActive(false);
adjustedScanner2.SetActive(true);
}
else if (Camera.main.fieldOfView < 66.6667)
{
standardScanner.SetActive(true);
adjustedScanner.SetActive(false);
adjustedScanner2.SetActive(false);
}
}
}
}

View File

@ -3,11 +3,18 @@
public class SmelterFire : MonoBehaviour
{
public GameObject fireObject;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Update is called once per frame.
public void Update()
{
if (GetComponent<Light>().enabled == true)
if (GetComponent<Light>().enabled == true && !stateManager.Busy())
{
if (GetComponent<AudioSource>().isPlaying == false)
{

View File

@ -1,4 +1,5 @@
using UnityEngine;
using System.Collections;
//! This class handles unique ID assignment and saving & loading of worlds.
public class StateManager : MonoBehaviour
@ -6,6 +7,8 @@ public class StateManager : MonoBehaviour
public bool saving;
public bool dataSaved;
public bool worldLoaded;
public int progress;
public int[] idList;
public GameObject DarkMatterCollector;
public GameObject DarkMatterConduit;
public GameObject IronBlock;
@ -39,21 +42,22 @@ public class StateManager : MonoBehaviour
public GameObject Brick;
public GameObject modMachine;
public GameObject BuiltObjects;
public bool assigningIDs;
public string WorldName = "World";
private float updateTick;
private string ObjectName = "";
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));
public bool Loaded = false;
public bool assigningIDs;
private Vector3 EmptyVector = new Vector3(0.0f, 0.0f, 0.0f);
private Vector3 ObjectPosition;
private Quaternion ObjectRotation;
private AddressManager addressManager;
private SaveManager saveManager;
private Coroutine addressingCoroutine;
private Coroutine loadCoroutine;
private Coroutine saveCoroutine;
private float updateTick;
private string ObjectName = "";
private bool loading;
//! Called by unity engine before the first update.
public void Start()
@ -65,10 +69,10 @@ public class StateManager : MonoBehaviour
public void Update()
{
MainMenu mainMenu = GameObject.Find("Player").GetComponent<MainMenu>();
if (mainMenu.worldSelected == true && worldLoaded == false)
if (mainMenu.worldSelected == true && loading == false)
{
LoadWorld();
worldLoaded = true;
loadCoroutine = StartCoroutine(LoadWorld());
loading = true;
}
if (worldLoaded == true)
{
@ -80,7 +84,7 @@ public class StateManager : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 1)
{
if (saving == false)
if (assigningIDs == false && saving == false)
{
AssignIDs();
}
@ -90,13 +94,19 @@ public class StateManager : MonoBehaviour
}
//! Loads a saved world.
private void LoadWorld()
private IEnumerator LoadWorld()
{
if (Loaded == false && PlayerPrefsX.GetIntArray(WorldName + "idList").Length > 0)
if (worldLoaded == false && PlayerPrefsX.GetIntArray(WorldName + "idList").Length > 0)
{
int[] idList = PlayerPrefsX.GetIntArray(WorldName + "idList");
int loadInterval = 0;
progress = 0;
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");
@ -443,14 +453,18 @@ public class StateManager : MonoBehaviour
SpawnedObject.GetComponent<PhysicsHandler>().fallingStack = FileBasedPrefs.GetBool(ObjectName + objectID + "fallingStack");
}
}
progress++;
loadInterval++;
if (loadInterval >= idList.Length * 0.025f)
{
loadInterval = 0;
GetComponent<GameManager>().meshManager.CombineBlocks();
yield return null;
}
}
}
Loaded = true;
GetComponent<GameManager>().initGlass = FileBasedPrefs.GetBool(WorldName + "initGlass");
GetComponent<GameManager>().initBrick = FileBasedPrefs.GetBool(WorldName + "initBrick");
GetComponent<GameManager>().initIron = FileBasedPrefs.GetBool(WorldName + "initIron");
GetComponent<GameManager>().initSteel = FileBasedPrefs.GetBool(WorldName + "initSteel");
GameObject.Find("GameManager").GetComponent<GameManager>().meshManager.CombineBlocks();
GetComponent<GameManager>().meshManager.CombineBlocks();
worldLoaded = true;
}
//! Assigns ID to objects in the world.
@ -475,4 +489,9 @@ public class StateManager : MonoBehaviour
&& go.GetComponent<Retriever>() == null
&& go.GetComponent<AutoCrafter>() == null;
}
public bool Busy()
{
return worldLoaded == false || saving == true;
}
}

View File

@ -4,18 +4,31 @@
public class Steel : MonoBehaviour
{
public string ID = "unassigned";
private StateManager stateManager;
public string creationMethod;
public int address;
private float updateTick;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called once per frame by unity engine.
public void Update()
{
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
}
}
}

View File

@ -11,6 +11,7 @@ public class StorageComputer : MonoBehaviour
public bool initialized;
public int address;
private float updateTick;
private StateManager stateManager;
private List<GameObject> spawnedConnectionList;
public GameObject connectionObject;
public Material lineMat;
@ -21,6 +22,7 @@ public class StorageComputer : MonoBehaviour
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
powerReceiver = gameObject.AddComponent<PowerReceiver>();
computerContainerList = new List<InventoryManager>();
spawnedConnectionList = new List<GameObject>();
@ -33,6 +35,12 @@ public class StorageComputer : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();

View File

@ -4,13 +4,23 @@
public class TurbineImpeller : MonoBehaviour
{
public GameObject turbine;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Update is called once per frame.
void Update()
{
if (turbine.GetComponent<AudioSource>().isPlaying == true)
if (!stateManager.Busy())
{
transform.Rotate(-Vector3.forward * 600 * Time.deltaTime);
if (turbine.GetComponent<AudioSource>().isPlaying == true)
{
transform.Rotate(-Vector3.forward * 600 * Time.deltaTime);
}
}
}
}

View File

@ -23,7 +23,9 @@ public class Turret : MonoBehaviour
private bool hasTarget;
private Coroutine fireCoroutine;
private bool firing;
private int warmup;
private GameManager game;
private StateManager stateManager;
private LineRenderer laser;
public PowerReceiver powerReceiver;
@ -32,6 +34,7 @@ public class Turret : MonoBehaviour
{
powerReceiver = gameObject.AddComponent<PowerReceiver>();
laser = gameObject.AddComponent<LineRenderer>();
stateManager = FindObjectOfType<StateManager>();
laser.startWidth = 0.2f;
laser.endWidth = 0.2f;
laser.material = laserMat;
@ -47,6 +50,12 @@ public class Turret : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
@ -57,7 +66,11 @@ public class Turret : MonoBehaviour
}
if (game != null)
{
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

View File

@ -23,6 +23,7 @@ public class UniversalConduit : MonoBehaviour
public bool connectionFailed;
public GameObject storageComputerConduitItemObject;
public ConduitItem storageComputerConduitItem;
private StateManager stateManager;
private GameObject builtObjects;
private LineRenderer connectionLine;
private float updateTick;
@ -32,6 +33,7 @@ public class UniversalConduit : MonoBehaviour
{
connectionLine = gameObject.AddComponent<LineRenderer>();
conduitItem = GetComponentInChildren<ConduitItem>(true);
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -46,6 +48,12 @@ public class UniversalConduit : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
if (inputObject == null || outputObject == null)

View File

@ -9,6 +9,7 @@ public class UniversalExtractor : MonoBehaviour
public bool hasHeatExchanger;
private int machineTimer;
public int power;
private int warmup;
public string type;
public GameObject outputObject;
private GameObject inputObject;
@ -26,6 +27,7 @@ public class UniversalExtractor : MonoBehaviour
private bool hasResource;
public int connectionAttempts;
public bool connectionFailed;
private StateManager stateManager;
private GameObject builtObjects;
public PowerReceiver powerReceiver;
@ -35,6 +37,7 @@ public class UniversalExtractor : MonoBehaviour
powerReceiver = gameObject.AddComponent<PowerReceiver>();
connectionLine = gameObject.AddComponent<LineRenderer>();
conduitItem = GetComponentInChildren<ConduitItem>(true);
stateManager = FindObjectOfType<StateManager>();
connectionLine.startWidth = 0.2f;
connectionLine.endWidth = 0.2f;
connectionLine.material = lineMat;
@ -72,11 +75,21 @@ public class UniversalExtractor : MonoBehaviour
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
if (stateManager.Busy())
{
updateTick = 0;
return;
}
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
updateTick = 0;
if (speed > power)
if (warmup < 10)
{
warmup++;
}
else if (speed > power)
{
speed = power > 0 ? power : 1;
}

10
VP.cs
View File

@ -5,7 +5,7 @@ public class VP : MonoBehaviour
{
public GameObject cam;
//! Plays a video
//! Plays a video.
public void PlayVideo(string video,bool looping,float volume)
{
cam.GetComponent<UnityEngine.Video.VideoPlayer>().url = Application.dataPath + "/Video/" + video;
@ -14,9 +14,15 @@ public class VP : MonoBehaviour
cam.GetComponent<UnityEngine.Video.VideoPlayer>().Play();
}
//! Stops a video
//! Stops a video.
public void StopVideo()
{
cam.GetComponent<UnityEngine.Video.VideoPlayer>().Stop();
}
//! Returns true if a video is playing.
public bool IsPlaying()
{
return cam.GetComponent<UnityEngine.Video.VideoPlayer>().isPlaying;
}
}

8
html.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28b9ecc417b6eea1fa69f5f198bbd7f7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f6d275747137b8e2784748dcd8f37bf5
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 14d5571a3b19314dab1ebda3bbaf67cd
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 12b22e7d766a43f9a86530a7358dbc11
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 86246b7d761cb8dea9d6c5d82e53a12c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bca8ad7aea7e9e4149e61ba7541f7196
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
html/Auger_8cs.html.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e72a8ea1a12e7614ca3e150bab1ba166
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5541eb93a4657b7439590c870dc64ebc
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 545d1320f46d9cff8acadd38fe2d7bb6
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 129b0a7e4307a665dbe2cb83fe3a94de
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6d662cf0acc5c2a04b25c33d7a5cac37
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ed9e22f6cf220870a8b7a16339768d31
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f201ccb68684d5d62acaa788186ae485
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fc888035ec49194d28f21d9871ae684a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
html/Brick_8cs.html.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8b04fd3b9e580bbe2ae091be4879c587
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7b2cfc13aa69f3e519fe07d7c47bc01e
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0ab099eaf1251bc0fba3546fc6547727
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 98485d416ad02729599493d4bf93da58
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b0414ed3c2139ff37a6af08bc3231845
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be038d94da81e5fbfbfa5aa754268e72
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b315f3fa10fabe0e4be3667b75898f3d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a9dbb168ff9953b33b3902db06e9d0aa
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6d111a1fc749cc66d9e28cfda1550f91
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 358d620ef5fdb42ed8dbd6c7fdf6ea7e
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 937dc913277419d8890030c901457480
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e3f65bfdd690818d6b7d99c512fec4e6
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 941b4fa1b108fb20d95cf009a9503399
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c0192f6219273b8d7b16876377da6673
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6602ea588bdeac6cf8b5843344547413
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a1efe15cc2c68245587dbc52d5bddae2
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
html/Glass_8cs.html.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cbe117c12185f2b0d83d120772996103
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 765e604ad36d895d8bccd5ba597a60f2
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fc258bcbb52528faf9579faea1d59d0f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4e7498e84ecc423329012521f0ea9582
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 78a7b2cea08cd79f7b38b2b7bc377ee9
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2dddfa9257d758e39a172991b302e4cb
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d2b385be6ed932ef2b6a4b477af1639b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ffadd9397c9a3b175b211e0a9aae329a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0579414d481e5083b8c2dd09b1aed162
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f9753c652059dd1468459183c6c2d91f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f62eeadbd55067011b8df32e61679daf
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8be4ea03d19f25096b742bc8079faedb
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bfbb37ff91f2ee8f58c4b76e30800bc0
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More