public void Setup(string name, PlanetSquare squareTemplate, int size, float orbitDist, float orbitAlpha, float gravIntensity, float atmDensity, int atmPercentRange, int heightPercentRange) { this.name = name; this.planetName = name; this.maxSubDegree = size; this.squareTemplate = squareTemplate.gameObject; MaterialPosition matPos = this.GetComponent <MaterialPosition> (); matPos.TargetMat = this.squareTemplate.GetComponent <Renderer> ().sharedMaterial; StellarObject sO = this.GetComponent <StellarObject> (); sO.truePos = Quaternion.AngleAxis(orbitAlpha, Vector3.up) * Vector3.forward * (orbitDist); this.gravIntensity = gravIntensity; this.atmDensity = atmDensity; this.atmRangePerCent = atmPercentRange; this.heightRangePerCent = heightPercentRange; }
public Group spawnNext() { NextTetrominoManager _nextPieceManager = FindObjectOfType <NextTetrominoManager> (); if (_nextPieceManager.CheckIfTetroAvailable()) { Group _piece = _nextPieceManager.ExtractTetromino(); _piece.goToSpawner(); return(_piece); } else { MaterialPosition _naturalResources = FindObjectOfType <MaterialPosition> (); _naturalResources.deleteElements(1); // Random Shape int i = Random.Range(0, groups.Length); Shape _shape = (Shape)System.Enum.Parse(typeof(Shape), "" + i); // Spawn Group at current Position Group _piece = spawn(_shape, transform.position); _piece.startPlaying(); return(_piece); } }
private bool ProcessFile(Guid aFolderId, string aSourceFilePath, MaterialFolderIndexRecord aNewRecord, TimeInterval aInterval, string aNewFilePath) { bool result = false; bool waitforIntra = true; Guid clientGuid = Guid.NewGuid(); try { using (FileStream file = File.OpenRead(aSourceFilePath)) { using (IMaterialFile newFile = MaterialFileFactory.CreateMaterialFile(aFolderId, aNewRecord, aNewFilePath)) { int readBytes = 0; int startFrameOffset = 0; bool startFound = false; byte[] buffer = new byte[16 * 1024]; DateTime lastFrameTimeStamp = DateTime.MinValue; List <byte> frameBuffer = new List <byte>(); do { if (_stopTask.IsCancellationRequested) { return(false); } startFrameOffset = 0; readBytes = file.Read(buffer, 0, buffer.Length); for (int pos = 0; pos < readBytes - Constants.FrameStart.Length; ++pos) { if (IsEqual(buffer, pos, Constants.FrameStart)) { startFound = true; startFrameOffset = pos; frameBuffer.Clear(); } if (IsEqual(buffer, pos, Constants.FrameEnd)) { int endFramePos = pos + Constants.FrameEnd.Length; CopyBuffer(frameBuffer, buffer, startFrameOffset, endFramePos); startFound = false; startFrameOffset = 0; Frame frame = null; try { using (MemoryStream stream = new MemoryStream(frameBuffer.ToArray())) { try { frame = new Frame(); frame.Deserialize(stream); } catch { continue; } if (frame.Metadata.Timestamp <= lastFrameTimeStamp) { // Skip old frames continue; } if (frame.Metadata.ChannelId != aNewRecord.ChannelId || frame.DataType != aNewRecord.DataType) { // Skip other data continue; } if (waitforIntra && !frame.Metadata.IsIntra) { // Skip non intra if we wait intra continue; } waitforIntra = false; if (aInterval.Contains(frame.Metadata.Timestamp)) { MaterialPosition position = null; WriteStatus writeStatus = newFile.Write(frame, ref position); if (writeStatus == WriteStatus.OK) { // Update material folder index record if (aNewRecord.BeginTimestamp.Ticks == 0) { aNewRecord.BeginTimestamp = frame.Metadata.Timestamp; } aNewRecord.EndTimestamp = frame.Metadata.Timestamp; // Update result result = true; // Add to frame times lastFrameTimeStamp = frame.Metadata.Timestamp; } else { SendError($"Write frame error, status: {writeStatus}, source file {aSourceFilePath}, destination file {aNewFilePath}!"); waitforIntra = true; } } } } catch (Exception ex) { SendError(ex.Message); waitforIntra = true; } finally { frame?.Release(); } } } if (startFound) { CopyBuffer(frameBuffer, buffer, startFrameOffset, buffer.Length); } } while (readBytes > 0); } } } catch (Exception ex) { SendError(ex.Message); } return(result); }