private RingSector CreateNewSector(int i) { var availableTypes = MapPoint.GetAvailablePointsType(ascension); var pos = GetSectorPosition(i); int x = Random.Range(0, availableTypes.Count); var inpos = GetSectorPosition(i); byte ring = DefineRing(pos.y); RingSector rs; if (availableTypes[x] != MapMarkerType.Star) { MapPoint centralPoint = MapPoint.CreatePointOfType( pos.x, pos.y, availableTypes[x] ); rs = new RingSector(centralPoint, Environment.GetEnvironment(ascension, pos.y)); AddPoint(centralPoint, true); } else { var e = Environment.GetEnvironment(ascension, pos.y); SunPoint sunpoint = new SunPoint( pos.x, pos.y, e.horizonColor ); rs = new RingSector(sunpoint, e); AddPoint(sunpoint, true); } mapSectors[i] = rs; actionsHash++; return(rs); }
public void Prepare() { transform.position = Vector3.up * 0.1f; rotationSpeed = new float[RINGS_COUNT]; rotationSpeed[0] = (Random.value - 0.5f) * MAX_RINGS_ROTATION_SPEED; rotationSpeed[1] = (Random.value - 0.5f) * MAX_RINGS_ROTATION_SPEED; rotationSpeed[2] = (Random.value - 0.5f) * MAX_RINGS_ROTATION_SPEED; rotationSpeed[3] = (Random.value - 0.5f) * MAX_RINGS_ROTATION_SPEED; rotationSpeed[4] = (Random.value - 0.5f) * MAX_RINGS_ROTATION_SPEED; ringsRotation = new float[RINGS_COUNT]; mapPoints = new List <MapPoint>(); int sectorsCount = 0; for (int i = 0; i < RINGS_COUNT; i++) { sectorsCount += (int)(360f / sectorsDegrees[i]); } mapSectors = new RingSector[sectorsCount]; ascension = GameConstants.ASCENSION_STARTVALUE; ascensionTarget = ascension; //start sector: byte ring = RINGS_COUNT / 2; sectorsCount = (int)(360f / sectorsDegrees[ring]); int min = 0; for (int i = 0; i < ring; i++) { min += (int)(360f / sectorsDegrees[i]); } int startSectorIndex = Random.Range(min, min + sectorsCount); Vector2 startPos = GetSectorPosition(startSectorIndex); var sunPoint = new SunPoint(startPos.x, startPos.y, Color.white); RingSector startSector = new RingSector(sunPoint, Environment.defaultEnvironment); startSector.SetFertility(false); mapSectors[startSectorIndex] = startSector; Vector2 dir = Quaternion.AngleAxis(Random.value * 360, Vector3.forward) * Vector2.up; float xpos = startPos.x + dir.x * 0.25f * sectorsDegrees[ring], ypos = startPos.y + dir.y * 0.25f * (ringsBorders[ring] - ringsBorders[ring + 1]); cityPoint = MapPoint.CreatePointOfType( xpos, //angle ypos, MapPointType.MyCity ); mapPoints.Add(cityPoint); // CITY_POINT_INDEX = 0 mapPoints.Add(sunPoint); // starsTypesArray = new BitArray((int)Environment.EnvironmentPreset.TotalCount, false); starsTypesArray[(int)Environment.EnvironmentPreset.Default] = true; createNewStars = true; // actionsHash = 0; prepared = true; //зависимость : Load() }
public void FORCED_CreatePointOfInterest() { int x = GetCurrentSectorIndex() + 1; var pos = GetSectorPosition(x); var centralPoint = MapPoint.CreatePointOfType( pos.x, pos.y, MapPointType.Island ); mapSectors[x] = new RingSector(centralPoint, Environment.GetEnvironment(ascension, pos.y)); AddPoint(centralPoint, true); }
private void AddNewSector(byte index, MapPointType mtype, Environment e) { if (mapSectors[index] != null) { RemoveSector(index); } Vector2 spos = GetSectorPosition(index); MapPoint mpoint = MapPoint.CreatePointOfType(spos.x, spos.y, mtype); AddPoint(mpoint, false); RingSector rs = new RingSector(mpoint, e); mapSectors[index] = rs; actionsHash++; }
public bool CreateNewPoint(byte positionIndex, float ascension, float visibility) { if (innerPointsIDs.ContainsKey(positionIndex) | !fertile) { return(false); } else { var pos = GetInnerPointPosition(positionIndex); MapPoint mp; if (Random.value < visibility) { mp = MapPoint.CreatePointOfType(pos.x, pos.y, environment.PickMainPointType()); } else { mp = MapPoint.CreatePointOfType(pos.x, pos.y, MapMarkerType.Unknown); } if (mp != null) { if (GameMaster.realMaster.globalMap.AddPoint(mp, false)) { innerPointsIDs.Add(positionIndex, mp.ID); return(true); } else { return(false); } } else { return(false); } } }