private GameObject CreateValve(int id, int typeId, string line) { int startNodeID = FileReaderHelper.GetNextIntNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); int endNodeID = FileReaderHelper.GetNextIntNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); float diameter = FileReaderHelper.GetNextNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); float flow = FileReaderHelper.GetNextNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); float flowVelocity = FileReaderHelper.GetNextNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); int statusID = (int)FileReaderHelper.GetNextNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); int valveTypeID = (int)FileReaderHelper.GetNextNumber(line); Debug.Log("Read valveTypeID is : " + valveTypeID); var startNodePos = MainSimulationManager.ComponentsHelper.GetComponentPosition(startNodeID); var endNodePos = MainSimulationManager.ComponentsHelper.GetComponentPosition(endNodeID); GameStateManager.Instance.SetInactiveState(); GameStateManager.Instance.SetPathCreationState(); var obj = LineGenerator.Instance.CreateAndReturnLineComponent(startNodePos, endNodePos, typeId); var valveScript = new Valve(id, typeId, startNodeID, endNodeID, diameter, flow, flowVelocity, statusID, valveTypeID); obj.GetComponent <Valve>().Init(valveScript); GameStateManager.Instance.SetInactiveState(); GameStateManager.Instance.SetDragComponentsState(); return(obj); }
private GameObject CreatePump(int id, int typeId, string line) { int startNodeID = FileReaderHelper.GetNextIntNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); int endNodeID = FileReaderHelper.GetNextIntNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); float flow = FileReaderHelper.GetNextNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); float flowVelocity = FileReaderHelper.GetNextNumber(line); line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line)); int curveTypeID = (int)FileReaderHelper.GetNextNumber(line); var startNodePos = MainSimulationManager.ComponentsHelper.GetComponentPosition(startNodeID); var endNodePos = MainSimulationManager.ComponentsHelper.GetComponentPosition(endNodeID); GameStateManager.Instance.SetInactiveState(); GameStateManager.Instance.SetPathCreationState(); var obj = LineGenerator.Instance.CreateAndReturnLineComponent(startNodePos, endNodePos, typeId); var pumpScript = new Pump(id, typeId, startNodeID, endNodeID, flow, flowVelocity, curveTypeID); obj.GetComponent <Pump>().Init(pumpScript); GameStateManager.Instance.SetInactiveState(); GameStateManager.Instance.SetDragComponentsState(); return(obj); }