private InfoScale GetScale(SectorData line) { if (!int.TryParse(line.rawData, out int scale)) { this.eventLogger.AddEvent( new SyntaxError("Invalid INFO scale", line) ); throw new ArgumentException(); } return(new InfoScale(scale, line.definition, line.docblock, line.inlineComment)); }
private InfoAirport GetAirport(SectorData line) { if (!AirportValidator.IcaoValid(line.rawData)) { this.eventLogger.AddEvent( new SyntaxError("Invalid INFO airport", line) ); throw new ArgumentNullException(); } return(new InfoAirport(line.rawData, line.definition, line.docblock, line.inlineComment)); }
private InfoCallsign GetCallsign(SectorData line) { if (!CallsignValidator.Validate(line.rawData)) { this.eventLogger.AddEvent( new SyntaxError("Invalid INFO callsign", line) ); throw new ArgumentNullException(); } return(new InfoCallsign(line.rawData, line.definition, line.docblock, line.inlineComment)); }
private InfoMilesPerDegreeLongitude GetInfoMilesPerDegreeLongitude(SectorData line) { if (!double.TryParse(line.rawData, out double miles)) { this.eventLogger.AddEvent( new SyntaxError("Invalid INFO miles per degree longitude", line) ); throw new ArgumentException(); } return(new InfoMilesPerDegreeLongitude(miles, line.definition, line.docblock, line.inlineComment)); }
private InfoLongitude GetLongitude(SectorData latitude, SectorData longitude) { if (CoordinateParser.Parse(latitude.rawData, longitude.rawData).Equals(CoordinateParser.InvalidCoordinate)) { this.eventLogger.AddEvent( new SyntaxError("Invalid INFO coordinate", latitude.rawData) ); throw new ArgumentNullException(); } return(new InfoLongitude(longitude.rawData, longitude.definition, longitude.docblock, longitude.inlineComment)); }
private GroundNetworkRunwayExit ProcessExit(AbstractSectorDataFile file, List <SectorData> lines) { SectorData declarationLine = lines[0]; if (declarationLine.dataSegments.Count != 5) { errorLog.AddEvent( new SyntaxError("Invalid number of EXIT declaration segments", declarationLine) ); throw new ArgumentException(); } if (!RunwayValidator.RunwayValid(declarationLine.dataSegments[1])) { errorLog.AddEvent( new SyntaxError("Invalid runway in EXIT declaration", declarationLine) ); throw new ArgumentException(); } if (declarationLine.dataSegments[3] != "LEFT" && declarationLine.dataSegments[3] != "RIGHT") { errorLog.AddEvent( new SyntaxError( "Invalid exit direction in EXIT declaration, must be LEFT or RIGHT", declarationLine ) ); throw new ArgumentException(); } if ( !int.TryParse(declarationLine.dataSegments[4], out int maximumSpeed) || maximumSpeed < 1 ) { errorLog.AddEvent( new SyntaxError("Invalid maximum speed in EXIT declaration", declarationLine) ); throw new ArgumentException(); } return(new GroundNetworkRunwayExit( declarationLine.dataSegments[1], declarationLine.dataSegments[2], declarationLine.dataSegments[3], maximumSpeed, ProcessCoordinates(file, lines.GetRange(1, lines.Count - 1), ExitDeclaration), declarationLine.definition, declarationLine.docblock, declarationLine.inlineComment )); }
/** * The name in this format of line can be determined to mean all data segments up until the first coordinate. */ private int GetEndOfNameIndex(SectorData line) { for (int i = 0; i < line.dataSegments.Count - 1; i++) { if (!PointParser.Parse(line.dataSegments[i], line.dataSegments[i + 1]).Equals(PointParser.InvalidPoint)) { return(i); } } return(-1); }
private InfoMagneticVariation GetMagneticVariation(SectorData line) { if (!double.TryParse(line.rawData, out double variation)) { this.eventLogger.AddEvent( new SyntaxError("Invalid INFO variation", line) ); throw new ArgumentException(); } return(new InfoMagneticVariation(variation, line.definition, line.docblock, line.inlineComment)); }
public void Setup() { sectorsContext = SectorData.CreateSectors(); bookingsSectorContext = BookingSectorData.CreateBookingSectorsList(); bookingSectorDTO = BookingSectorData.CreateBookingSectorDTO(); unitOfWorkMock.Setup(u => u.SaveAsync()).ReturnsAsync(true); unitOfWorkMock.Setup(u => u.BookingSectorRepository).Returns(bookingSectorRepositoryMock.Object); unitOfWorkMock.Setup(u => u.SectorRepository).Returns(sectorRepositoryMock.Object); bookingSectorRepositoryMock.Setup(b => b.GetAllEntitiesAsync()).ReturnsAsync(bookingsSectorContext); bookingSectorRepositoryMock.Setup(b => b.GetEntityByIdAsync(It.IsAny <int>())) .ReturnsAsync((int id) => bookingsSectorContext .Find(b => b.Id == id)); }
private List <List <SectorData> > GenerateSectorPartitions(List <SectorData> unoccupied) { List <List <SectorData> > partitions = new List <List <SectorData> >(); HashSet <SectorData> unoccupiedHash = new HashSet <SectorData>(unoccupied); int maxSize = 25; while (unoccupied.Count > 0) { HashSet <SectorData> partitionHash = new HashSet <SectorData>(); List <SectorData> partition = new List <SectorData>(); int randomID = UnityEngine.Random.Range(0, unoccupied.Count); SectorData startPoint = unoccupied[randomID]; partitionHash.Add(startPoint); //add the first sector partition.Add(startPoint); unoccupied.RemoveAt(randomID); unoccupiedHash.Remove(startPoint); while (partitionHash.Count < maxSize) { HashSet <SectorData> neighbours = new HashSet <SectorData>(); foreach (SectorData d in partitionHash) { foreach (SectorData n in d.neighbours) { if (!partitionHash.Contains(n) && unoccupiedHash.Contains(n)) //add neighbours that are outside of the partition { neighbours.Add(n); } } } if (neighbours.Count > 0) { SectorData p = DistanceWeightedRandomWalk(neighbours, startPoint); partitionHash.Add(p); partition.Add(p); unoccupied.Remove(p); unoccupiedHash.Remove(p); } else { break; } } if (partition.Count > 0) { partitions.Add(partition); } } return(partitions); }
/// <summary> /// Converts the parameter value into the sector name /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { SectorData sectorData = new SectorData(); List <tblSector> allSectors = sectorData.GetAllSectors().ToList(); for (int i = 0; i < allSectors.Count; i++) { if (allSectors[i].SectorID == (int)value) { return(allSectors[i].SectorName); } } return(value); }
// Use this for initialization void Start() { int playerCount = ControllerManager.Get().MaximumUsable; playersEnded = new bool[playerCount]; sectorNumber = new int[playerCount]; currentSectors = new SectorData[playerCount]; started = false; ended = false; if (Generator != null) { Generator.Load(currentLevel = Generator.Generate(GeneratorSectorBowl)); InitialCreate(); } }
/// <summary> /// Fills _Operators struct with config received /// </summary> private void CreateOperatorsData() { OperatorData operatorTA = null; List <OperatorData> operatorsCopy = new List <OperatorData>(); foreach (DireccionamientoSIP dirSip in _SystemCfg.PlanDireccionamientoSIP) { SectorData sector = new SectorData(); operatorTA = null; foreach (StrNumeroAbonado num in dirSip.NumerosAbonadoQueAtiende) { if (operatorTA == null) { operatorTA = operatorsCopy.Find(x => x.idGroupName.Equals(num.IdAgrupacion)); if (operatorTA == null) { operatorTA = new OperatorData(); operatorTA.idGroupName = num.IdAgrupacion; foreach (AsignacionUsuariosTV tv in _SystemCfg.PlanAsignacionUsuarios) { if ((tv.IdUsuario != STR_SECTOR_FS) && (tv.IdUsuario != STR_PUESTO_FS)) { if (tv.IdUsuario.Equals(dirSip.IdUsuario)) { operatorTA.idHost = tv.IdHost; break; } } } } } CfgRecursoEnlaceInterno cfg = new CfgRecursoEnlaceInterno(); cfg.NombreRecurso = dirSip.IdUsuario; cfg.NumeroAbonado = num.NumeroAbonado; cfg.Prefijo = num.Prefijo; sector.numberData.Add(cfg); sector.idUser = dirSip.IdUsuario; } operatorTA.sectorData.Add(sector); if (operatorsCopy.Contains(operatorTA) == false) { operatorsCopy.Add(operatorTA); } } _Operators = operatorsCopy; }
private SectorlineDisplayRule ParseDisplayRule(SectorData data) { if (data.dataSegments.Count != 4) { this.errorLog.AddEvent(new SyntaxError("Invalid number of SECTORLINE DISPLAY rule segements", data)); throw new ArgumentException(); } return(new SectorlineDisplayRule( data.dataSegments[1], data.dataSegments[2], data.dataSegments[3], data.definition, data.docblock, data.inlineComment )); }
private int GetEndOfNameIndex(SectorData line) { int count = 0; int i; for (i = 0; i < line.dataSegments.Count; i++) { count += line.dataSegments[i].Count(c => c == '"'); if (count == 2) { return(i + 1); } } return(-1); }
public static Mesh CreateMesh(float fRadius, float fAngle) { foreach (KeyValuePair <SectorData, Mesh> kv in m_dicSector) { if (CMath.IsZero(kv.Key.fAngle - fAngle) && CMath.IsZero(kv.Key.fRadius - fRadius)) { return(kv.Value); } } Mesh cMesh = CreateImpl(fRadius, fAngle); SectorData cData = new SectorData(); cData.fAngle = fAngle; cData.fRadius = fRadius; m_dicSector.Add(cData, cMesh); return(cMesh); }
public GalaxyEntity GetEntity(List <SectorData> territory) { GalaxyEntity g = new GalaxyEntity(); g.flag = LayeredSpriteGenerator.GenerateLayeredSprites(new List <string>() { "FlagBack", "FlagMid", "FlagFront" }, entityPallette)[0]; g.color = g.flag.Colors[0]; string[] entityStrings = StringLoader.GetAllStrings("EntityStrings"); SectorData capital = territory[UnityEngine.Random.Range(0, territory.Count)]; territory.Remove(capital); g.capitalSector = capital; g.GainTerritory(territory); g.capitalSector.AddGalaxyFeature(new GalaxyFeature(g.FullName + " Capital", GalaxyFeatureType.EntityCapital, g.color)); return(g); }
private void UpdateCeilingHeights() { for (int i = 0; i < sectorData.Count; i++) { SectorData sd = sectorData[i]; if (sd.Triangular) { for (int c = 0; c < 3; c++) { HeightOffsetVertexData vd = sd.Verts[c]; vd.JitterCeilingHeight = General.Random(-100, 100) / 100f; sd.Verts[c] = vd; } } sd.JitterCeilingHeight = General.Random(-100, 100) / 100f; sectorData[i] = sd; } }
/* * Parses an individual GEO segment of coordinates and colours */ private GeoSegment ParseGeoSegment(SectorData line) { if (line.dataSegments.Count < 4 || line.dataSegments.Count > 5) { this.eventLogger.AddEvent( new SyntaxError("Incorrect number parts for GEO segment", line) ); throw new ArgumentException(); } // Parse the first coordinate Point parsedStartPoint = PointParser.Parse(line.dataSegments[0], line.dataSegments[1]); if (parsedStartPoint.Equals(PointParser.InvalidPoint)) { this.eventLogger.AddEvent( new SyntaxError("Invalid GEO segment point format", line) ); throw new ArgumentException(); } // Parse the end coordinate Point parsedEndPoint = PointParser.Parse(line.dataSegments[2], line.dataSegments[3]); if (parsedEndPoint.Equals(PointParser.InvalidPoint)) { this.eventLogger.AddEvent( new SyntaxError("Invalid GEO segment point format", line) ); throw new ArgumentException(); } return(new GeoSegment( parsedStartPoint, parsedEndPoint, line.dataSegments.Count > 4 ? line.dataSegments[4] : null, line.definition, line.docblock, line.inlineComment )); }
/* * Parse and valdiate a BORDER line */ private SectorBorder ParseBorder(SectorData line) { if (line.dataSegments.Count < 2) { throw new ArgumentException("Invalid number of BORDER segements"); } List <string> borders = new List <string>(); for (int i = 1; i < line.dataSegments.Count; i++) { borders.Add(line.dataSegments[i]); } return(new SectorBorder( borders, line.definition, line.docblock, line.inlineComment )); }
/* * Parse and validate an OWNER line */ private SectorOwnerHierarchy ParseOwnerHierarchy(SectorData line) { if (line.dataSegments.Count < 2) { throw new ArgumentException("Invalid number of OWNER segements"); } List <string> owners = new List <string>(); for (int i = 1; i < line.dataSegments.Count; i++) { owners.Add(line.dataSegments[i]); } return(new SectorOwnerHierarchy( owners, line.definition, line.docblock, line.inlineComment )); }
// size is the dimensions of the sector in meters (making it a square // cellSize is the size in meters of each individual grid unit // density is the chance for a POI. Nothing is represented by a negative number, otherwise a valid array index is used // maxIndex is the highest index for the array containing POIs to generate from public static int[,] GenerateSectorGrid(SectorData sector) { int gridDimensions = (int)(sector.TotalSize / sector.GridSize); Debug.Log("Generating sector with grid dimensions " + gridDimensions + "x" + gridDimensions); int[,] grid = new int[gridDimensions, gridDimensions]; for (int i = 0; i < gridDimensions; i++) { for (int j = 0; j < gridDimensions; j++) { if (Random.value * 100f <= sector.Density) { grid[i, j] = Random.Range(0, sector.POIList.Count); } else { grid[i, j] = -1; } } } return(grid); }
Sector CreateSector() { //StartCoroutine(HighlightCurrentPlanet()); sectorData = dm.GetCurrentSectorData(currentSector); player.UpdateSectorData(sectorData); currentSector++; Sector nowSector = sectors[sectorIndex]; while (nowSector.transform.childCount > 0) { Destroy(nowSector.transform.GetChild(0).gameObject); nowSector.transform.GetChild(0).SetParent(null); } int rand = Random.Range(1, 4); for (int i = 0; i < rand; i++) { PlanetBase p = planetFactory.GetNewPlanet(currentSector); p.gameObject.SetActive(true); p.transform.SetParent(nowSector.transform); } nowSector.gameObject.SetActive(true); nowSector.SetSectorTile(sectorTiles[5]); for (int i = 0; i < nowSector.transform.childCount; i++) { nowSector.transform.GetChild(i).position = nowSector.transform.GetChild(i).GetComponent <PlanetBase>().targetPos; } sectorIndex++; if (sectorIndex == sectors.Length) { sectorIndex = 0; } return(nowSector); }
void LoadData() { dataObject = JsonMapper.ToObject(dataFile.text); survivablePlanetScript = new string[dataObject["Survivable Planet Script"].Count]; engSurvivablePlanetScript = new string[dataObject["English Survivable Planet Script"].Count]; for (int i = 0; i < dataObject["Survivable Planet Script"].Count; i++) { survivablePlanetScript[i] = dataObject["Survivable Planet Script"][i].ToString(); engSurvivablePlanetScript[i] = dataObject["English Survivable Planet Script"][i].ToString(); } nonviablePlanetScript = new string[dataObject["Nonviable Planet Script"].Count]; engNonviablePlanetScript = new string[dataObject["English Nonviable Planet Script"].Count]; for (int i = 0; i < dataObject["Nonviable Planet Script"].Count; i++) { nonviablePlanetScript[i] = dataObject["Nonviable Planet Script"][i].ToString(); engNonviablePlanetScript[i] = dataObject["English Nonviable Planet Script"][i].ToString(); } SectorData newSectorData; JsonData rawSectorData; for (int i = 0; i < dataObject["Sector Data"].Count; i++) { newSectorData = new SectorData(); rawSectorData = dataObject["Sector Data"][i]; newSectorData.firstSectorNum = int.Parse(rawSectorData["First Sector Number"].ToString()); newSectorData.lastSectorNum = int.Parse(rawSectorData["Last Sector Number"].ToString()); newSectorData.successRate = int.Parse(rawSectorData["Success Rate"].ToString()); newSectorData.minimumSuccessRate = int.Parse(rawSectorData["Minimum Success Rate"].ToString()); newSectorData.hpTime = float.Parse(rawSectorData["Hp Time"].ToString()); newSectorData.population = int.Parse(rawSectorData["Population"].ToString()); newSectorData.sectorMovePoint = int.Parse(rawSectorData["Sector Move Point"].ToString()); sectorDataList.Add(newSectorData); } }
public SectorData DistanceWeightedRandomWalk(HashSet <SectorData> neighbours, SectorData start) { float distTotal = 0.0f; foreach (SectorData s in neighbours) { distTotal += 1 / (start.DistanceTo(s) + 1); } //stochastic choice based on inverse of distance float alpha = UnityEngine.Random.Range(0.0f, distTotal); float currentDist = 0.0f; foreach (SectorData s in neighbours) { currentDist += 1 / (start.DistanceTo(s) + 1); if (alpha <= currentDist) { return(s); } } Debug.LogError("You messed up your implementation of a stochastic process dummy. Or neighbours were null. " + neighbours.Count + "<- is that zero?"); return(null); }
//////////////////////////////////////////////////////////////////// public LevelData Generate(Sector[] sectors) { if (sectors == null) { throw new System.ArgumentNullException("sectors"); } LevelData data = new LevelData(); List <Sector> sectorBowl = new List <Sector>(sectors); int maxSector = Mathf.Min(sectors.Length, sectorCount); Sector s = null; for (int i = 0; i < maxSector; i++) { s = sectorBowl[Util.Randomizer.Next(sectorBowl.Count)]; SectorData sd = new SectorData(modulesPerSectorCount); sd.Generate(s); data.Sectors.Add(sd); sectorBowl.Remove(s); } isLevelGenerated = true; return(data); }
public void UpdateSectorData(SectorData data) { sectorData = data; }
public int GetChecksum256() => SectorData.Sum(b => b % 256);
public float DistanceTo(SectorData sector) { return(Mathf.Sqrt(Mathf.Pow(coord.x - sector.coord.x, 2.0f) + Mathf.Pow(coord.y - sector.coord.y, 2.0f))); }
public Facility(SectorData sectorData, Company company) { this.sectorData = sectorData; this.Owner = company; }
public JitterSectorsForm(string editingModeName) { this.editingModeName = editingModeName; InitializeComponent(); //get selection List <Vertex> verts = new List <Vertex>(); List <Sector> sectors = new List <Sector>(); if (editingModeName == "BaseVisualMode") { VisualMode vm = (VisualMode)General.Editing.Mode; List <VisualGeometry> visualGeometry = vm.GetSelectedSurfaces(); visualSectors = new List <VisualSector>(); //get selected visual and regular sectors foreach (VisualGeometry vg in visualGeometry) { if (vg.GeometryType != VisualGeometryType.CEILING && vg.GeometryType != VisualGeometryType.FLOOR) { continue; } if (vg.Sector != null && vg.Sector.Sector != null) { foreach (Sidedef sd in vg.Sector.Sector.Sidedefs) { if (!verts.Contains(sd.Line.Start)) { verts.Add(sd.Line.Start); } if (!verts.Contains(sd.Line.End)) { verts.Add(sd.Line.End); } } sectors.Add(vg.Sector.Sector); visualSectors.Add(vg.Sector); } } //also get visual sectors around selected ones (because they also may be affected) List <Vertex> affectedVerts = new List <Vertex>(); foreach (Sector s in sectors) { foreach (Sidedef sd in s.Sidedefs) { if (!affectedVerts.Contains(sd.Line.Start)) { affectedVerts.Add(sd.Line.Start); } if (!affectedVerts.Contains(sd.Line.End)) { affectedVerts.Add(sd.Line.End); } } } List <Sector> affectedSectors = new List <Sector>(); foreach (Vertex v in affectedVerts) { foreach (Linedef l in v.Linedefs) { if (l.Front != null && !sectors.Contains(l.Front.Sector) && !affectedSectors.Contains(l.Front.Sector) && vm.VisualSectorExists(l.Front.Sector)) { visualSectors.Add(vm.GetVisualSector(l.Front.Sector)); affectedSectors.Add(l.Front.Sector); } if (l.Back != null && !sectors.Contains(l.Back.Sector) && !affectedSectors.Contains(l.Back.Sector) && vm.VisualSectorExists(l.Back.Sector)) { visualSectors.Add(vm.GetVisualSector(l.Back.Sector)); affectedSectors.Add(l.Back.Sector); } } } visualVerts = new List <VisualVertexPair>(); foreach (Vertex vert in affectedVerts) { if (vm.VisualVertices.ContainsKey(vert)) { visualVerts.Add(vm.VisualVertices[vert]); } } } else if (editingModeName == "SectorsMode") { ICollection <Sector> list = General.Map.Map.GetSelectedSectors(true); foreach (Sector s in list) { foreach (Sidedef sd in s.Sidedefs) { if (!verts.Contains(sd.Line.Start)) { verts.Add(sd.Line.Start); } if (!verts.Contains(sd.Line.End)) { verts.Add(sd.Line.End); } } sectors.Add(s); } } if (verts.Count == 0 || sectors.Count == 0) { General.Interface.DisplayStatus(StatusType.Warning, "Unable to get sectors from selection!"); return; } //create undo General.Map.UndoRedo.ClearAllRedos(); General.Map.UndoRedo.CreateUndo("Randomize " + sectors.Count + (sectors.Count > 1 ? " sectors" : " sector")); //update window header this.Text = "Randomize " + sectors.Count + (sectors.Count > 1 ? " sectors" : " sector"); //store intial properties //process verts... Dictionary <Vertex, TranslationOffsetVertexData> data = new Dictionary <Vertex, TranslationOffsetVertexData>(); foreach (Vertex v in verts) { TranslationOffsetVertexData vd = new TranslationOffsetVertexData(); vd.Vertex = v; vd.InitialPosition = v.Position; data.Add(v, vd); } foreach (Vertex v in verts) { if (v.Linedefs == null) { continue; } //get nearest linedef Linedef closestLine = null; double distance = double.MaxValue; // Go for all linedefs in selection foreach (Linedef l in General.Map.Map.Linedefs) { if (v.Linedefs.Contains(l)) { continue; } // Calculate distance and check if closer than previous find double d = l.SafeDistanceToSq(v.Position, true); if (d < distance) { // This one is closer closestLine = l; distance = d; } } if (closestLine == null) { continue; } double closestLineDistance = Vector2D.Distance(v.Position, closestLine.NearestOnLine(v.Position)); //check SafeDistance of closest line if (data.ContainsKey(closestLine.Start) && data[closestLine.Start].SafeDistance > closestLineDistance) { TranslationOffsetVertexData vd = data[closestLine.Start]; vd.SafeDistance = (int)Math.Floor(closestLineDistance); data[closestLine.Start] = vd; } if (data.ContainsKey(closestLine.End) && data[closestLine.End].SafeDistance > closestLineDistance) { TranslationOffsetVertexData vd = data[closestLine.End]; vd.SafeDistance = (int)Math.Floor(closestLineDistance); data[closestLine.End] = vd; } //save SafeDistance int dist = (int)Math.Floor(closestLineDistance); if (data[v].SafeDistance == 0 || data[v].SafeDistance > dist) { TranslationOffsetVertexData vd = data[v]; vd.SafeDistance = dist; data[v] = vd; } } //store properties vertexData = new TranslationOffsetVertexData[data.Values.Count]; data.Values.CopyTo(vertexData, 0); for (int i = 0; i < data.Count; i++) { if (vertexData[i].SafeDistance > 0) { vertexData[i].SafeDistance /= 2; } if (MaxSafeDistance < vertexData[i].SafeDistance) { MaxSafeDistance = vertexData[i].SafeDistance; } } //process sectors and linedes sectorData = new List <SectorData>(); sidedefData = new List <SidedefData>(); foreach (Sector s in sectors) { SectorData sd = new SectorData(); sd.Sector = s; sd.InitialCeilingHeight = s.CeilHeight; sd.InitialFloorHeight = s.FloorHeight; sd.Triangular = General.Map.UDMF && s.Sidedefs.Count == 3; if (sd.Triangular) { Vertex[] sectorverts = GetSectorVerts(s); sd.Verts = new HeightOffsetVertexData[sectorverts.Length]; for (int i = 0; i < sectorverts.Length; i++) { HeightOffsetVertexData vd = new HeightOffsetVertexData(); vd.Vertex = sectorverts[i]; vd.ZFloor = sectorverts[i].ZFloor; vd.ZCeiling = sectorverts[i].ZCeiling; vd.InitialFloorHeight = double.IsNaN(vd.ZFloor) ? GetHighestFloor(sectorverts[i]) : sectorverts[i].ZFloor; vd.InitialCeilingHeight = double.IsNaN(vd.ZCeiling) ? GetLowestCeiling(sectorverts[i]) : sectorverts[i].ZCeiling; sd.Verts[i] = vd; } } sd.SafeDistance = (s.CeilHeight - s.FloorHeight) / 2; if (sd.SafeDistance > MaxSafeHeightDistance) { MaxSafeHeightDistance = sd.SafeDistance; } sectorData.Add(sd); foreach (Sidedef side in s.Sidedefs) { //store initial sidedef properties SidedefData sdd = new SidedefData(); sdd.Side = side; sdd.LowTexture = side.LowTexture; sdd.HighTexture = side.HighTexture; sdd.PegBottom = side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag); sdd.PegTop = side.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag); if (side.Other != null && !sectors.Contains(side.Other.Sector)) { sdd.UpdateTextureOnOtherSide = true; sdd.OtherHighTexture = side.Other.HighTexture; sdd.OtherLowTexture = side.Other.LowTexture; } sidedefData.Add(sdd); } } positionJitterAmmount.Maximum = MaxSafeDistance; floorHeightAmmount.Maximum = MaxSafeHeightDistance; ceilingHeightAmmount.Maximum = MaxSafeHeightDistance; //set editing settings cbKeepExistingTextures.Checked = keepExistingSideTextures; ceiloffsetmode.SelectedIndex = storedceiloffsetmode; flooroffsetmode.SelectedIndex = storedflooroffsetmode; //vertex heights can not be set in non-UDMF maps if (General.Map.UDMF) { cbUseFloorVertexHeights.Checked = useFloorVertexHeights; cbUseCeilingVertexHeights.Checked = useCeilingVertexHeights; } else { useFloorVertexHeights = false; cbUseFloorVertexHeights.Checked = false; cbUseFloorVertexHeights.Enabled = false; useCeilingVertexHeights = false; cbUseCeilingVertexHeights.Checked = false; cbUseCeilingVertexHeights.Enabled = false; } //texture pickers textureLower.Initialize(); textureUpper.Initialize(); //We can't use floor/ceiling textures when MixTexturesFlats is disabled if (General.Map.Config.MixTexturesFlats) { textureLower.TextureName = General.Settings.DefaultFloorTexture; textureUpper.TextureName = General.Settings.DefaultCeilingTexture; } else { textureLower.TextureName = General.Settings.DefaultTexture; textureUpper.TextureName = General.Settings.DefaultTexture; cbUpperTexStyle.Items[1] = "Use default texture"; cbLowerTexStyle.Items[1] = "Use default texture"; } cbUpperTexStyle.SelectedIndex = 0; cbLowerTexStyle.SelectedIndex = 0; UpdateTextureSelectors(); //update interface //create random values UpdateAngles(); UpdateFloorHeights(); UpdateCeilingHeights(); }
void Start() { planetFactory = GameObject.FindObjectOfType<PlanetFactory>(); gm = GameObject.FindObjectOfType<GameManager>(); dm = GameObject.FindObjectOfType<DataManager>(); player = GameObject.FindObjectOfType<Player>(); for (int i = 0; i < sectorTiles.Length; i++) { sectorTiles[i] = new SectorTile(); sectorTiles[i].index = i; //sectorTiles[i].x = -8f + 3.2f * i; sectorTiles[i].onSector = null; } sectorTiles[0].firstSeat = new Vector2(-1000, -800)/100f; sectorTiles[0].secondSeat = new Vector2(-1000, -800) / 100f; sectorTiles[0].thirdSeat = new Vector2(-1000, -800) / 100f; sectorTiles[0].fourthSeat = new Vector2(-1000, -800) / 100f; sectorTiles[0].fifthSeat = new Vector2(-1000, -800) / 100f; sectorTiles[1].firstSeat = new Vector2(-800, -500) / 100f; sectorTiles[1].secondSeat = new Vector2(-800, -500) / 100f; sectorTiles[1].thirdSeat = new Vector2(-512, -198) / 100f; sectorTiles[1].fourthSeat = new Vector2(-800, -500) / 100f; sectorTiles[1].fifthSeat = new Vector2(-800, -500) / 100f; sectorTiles[2].firstSeat = new Vector2(-512, 114) / 100f; sectorTiles[2].secondSeat = new Vector2(-386, 96) / 100f; sectorTiles[2].thirdSeat = new Vector2(-255, 10) / 100f; sectorTiles[2].fourthSeat = new Vector2(-188, -117) / 100f; sectorTiles[2].fifthSeat = new Vector2(-175, -207) / 100f; sectorTiles[3].firstSeat = new Vector2(-23, 255) / 100f; sectorTiles[3].secondSeat = new Vector2(47, 139) / 100f; sectorTiles[3].thirdSeat = new Vector2(90, 64) / 100f; sectorTiles[3].fourthSeat = new Vector2(119, -30) / 100f; sectorTiles[3].fifthSeat = new Vector2(134, -117) / 100f; sectorTiles[4].firstSeat = new Vector2(368, 258) / 100f; sectorTiles[4].secondSeat = new Vector2(430, 150) / 100f; sectorTiles[4].thirdSeat = new Vector2(452, 80) / 100f; sectorTiles[4].fourthSeat = new Vector2(470, -10) / 100f; sectorTiles[4].fifthSeat = new Vector2(486, -95) / 100f; sectorTiles[5].firstSeat = new Vector2(800, 500) / 100f; sectorTiles[5].secondSeat = new Vector2(800, 500) / 100f; sectorTiles[5].thirdSeat = new Vector2(800, 500) / 100f; sectorTiles[5].fourthSeat = new Vector2(800, 500) / 100f; sectorTiles[5].fifthSeat = new Vector2(800, 500) / 100f; for (int i = 0; i < sectors.Length; i++) { sectors[i] = Instantiate(sector); sectors[i].gameObject.SetActive(false); } for (int i = 0; i < 6; i++) { if (i == 1) continue; Sector s = CreateSector(); s.SetSectorTile(sectorTiles[i]); for (int j = 0; j < s.transform.childCount; j++) s.transform.GetChild(j).position = s.transform.GetChild(j).GetComponent<PlanetBase>().targetPos; } startSector.SetSectorTile(sectorTiles[1]); for (int i = 0; i < startSector.transform.childCount; i++) startSector.transform.GetChild(i).position = startSector.transform.GetChild(i).GetComponent<PlanetBase>().targetPos; ProbabilityRevision(); sectorData = dm.GetCurrentSectorData(currentSector); }
Sector CreateSector() { //StartCoroutine(HighlightCurrentPlanet()); sectorData = dm.GetCurrentSectorData(currentSector); player.UpdateSectorData(sectorData); currentSector++; Sector nowSector = sectors[sectorIndex]; while (nowSector.transform.childCount > 0) { Destroy(nowSector.transform.GetChild(0).gameObject); nowSector.transform.GetChild(0).SetParent(null); } int rand = Random.Range(1, 4); for (int i = 0; i < rand; i++) { PlanetBase p = planetFactory.GetNewPlanet(currentSector); p.gameObject.SetActive(true); p.transform.SetParent(nowSector.transform); } nowSector.gameObject.SetActive(true); nowSector.SetSectorTile(sectorTiles[5]); for (int i = 0; i < nowSector.transform.childCount;i++ ) nowSector.transform.GetChild(i).position = nowSector.transform.GetChild(i).GetComponent<PlanetBase>().targetPos; sectorIndex++; if (sectorIndex == sectors.Length) sectorIndex = 0; return nowSector; }