public Expedition Load(System.IO.Stream fs) { int LENGTH = 28; // (id excluded) var data = new byte[LENGTH]; fs.Read(data, 0, LENGTH); hasConnection = data[0] == 1; crystalsCollected = System.BitConverter.ToUInt16(data, 1); suppliesCount = data[3]; stage = (ExpeditionStage)data[4]; int x = System.BitConverter.ToInt32(data, 5); if (x != NO_VALUE) { destination = GameMaster.realMaster.globalMap.GetMapPointByID(x) as PointOfInterest; destination?.AssignExpedition(this); } else { destination = null; } crew = Crew.GetCrewByID(System.BitConverter.ToInt32(data, 9)); if (crew != null) { crew.SetCurrentExpedition(this); } artifact = Artifact.GetArtifactByID(System.BitConverter.ToInt32(data, 13)); shuttleID = System.BitConverter.ToInt32(data, 17); transmissionID = System.BitConverter.ToInt32(data, 21); planPos = new Vector2Int(data[25], data[26]); if (data[27] == 1) { data = new byte[8]; fs.Read(data, 0, 8); // #creating map marker GlobalMap gmap = GameMaster.realMaster.globalMap; mapMarker = new FlyingExpedition(this, System.BitConverter.ToSingle(data, 0), System.BitConverter.ToSingle(data, 4), stage == ExpeditionStage.WayOut ? gmap.cityPoint : destination, FLY_SPEED); gmap.AddPoint(mapMarker, true); // } missionCompleted = fs.ReadByte() == 1; return(this); }
/// =============================== public Expedition(PointOfInterest i_destination, Crew c, int i_shuttleID, QuantumTransmitter transmitter, float i_supplies, float i_crystals) { // СДЕЛАТЬ: проверка компонентов и вывод ошибок ID = nextID++; stage = ExpeditionStage.WayIn; destination = i_destination; destination.AssignExpedition(this); crew = c; c.SetCurrentExpedition(this); if (Hangar.OccupyShuttle(i_shuttleID)) { shuttleID = i_shuttleID; } else { AnnouncementCanvasController.MakeAnnouncement(Localization.GetExpeditionErrorText(ExpeditionComposingErrors.ShuttleUnavailable)); Dismiss(); } if (transmitter != null) { transmissionID = transmitter.StartTransmission(); hasConnection = true; } else { transmissionID = QuantumTransmitter.NO_TRANSMISSION_VALUE; hasConnection = false; } suppliesCount = (byte)i_supplies; crystalsCollected = (ushort)i_crystals; //#creating map marker GlobalMap gmap = GameMaster.realMaster.globalMap; mapMarker = new FlyingExpedition(this, gmap.cityPoint, destination, FLY_SPEED); gmap.AddPoint(mapMarker, true); // expeditionsList.Add(this); listChangesMarker++; }
public void EndMission() { switch (stage) { case ExpeditionStage.OnMission: stage = ExpeditionStage.WayOut; // #creating map marker GlobalMap gmap = GameMaster.realMaster.globalMap; mapMarker = new FlyingExpedition(this, destination, gmap.cityPoint, FLY_SPEED); gmap.AddPoint(mapMarker, true); // changesMarkerValue++; break; case ExpeditionStage.WayIn: mapMarker.ChangeDestination(GameMaster.realMaster.globalMap.cityPoint); changesMarkerValue++; break; } }
private void Update() { if (!prepared) { return; } float t = Time.deltaTime * GameMaster.gameSpeed; float f = 0, a; float[] thisCycleRotations = new float[RINGS_COUNT]; for (int i = 0; i < RINGS_COUNT; i++) { a = rotationSpeed[i] * t; thisCycleRotations[i] = a; f = ringsRotation[i]; f -= thisCycleRotations[i]; if (f > 360) { f = f % 360f; } else { if (f < 0) { f = 360f - Mathf.Abs(f % 360f); } } ringsRotation[i] = f; } var prefAsc = ascension; updateTimer -= t; if (updateTimer <= 0f) { updateTimer = ASCENSION_UPDATE_TIME; ascensionTarget = ProgressionMaster.DefineAscension(colonyController); a = GetGlobalMapAscension(); if (ascensionTarget > a) { ascensionTarget = a; } a = Knowledge.GetCurrent()?.GetCompleteness() ?? 0f; if (ascensionTarget > a) { ascensionTarget = a; } } if (ascension != ascensionTarget) { ascension = Mathf.MoveTowards(ascension, ascensionTarget, GameConstants.ASCENSION_CHANGE_SPEED * t * (1.5f - GameMaster.stability)); } float ascensionChange = prefAsc - ascension; // float prevX = cityPoint.angle, prevY = cityPoint.height; if (mapPoints.Count > 0) { if (GameMaster.realMaster.colonyController != null && cityPoint.ringIndex != 2) { float speed = RING_RESIST_CF; if (cityPoint.ringIndex == 0 || cityPoint.ringIndex == 4) { speed *= speed; } a = Mathf.MoveTowards(cityPoint.height, 0.5f, speed * t); ChangeCityPointHeight(a - cityPoint.height); // Использование stability? } int i = 0; while (i < mapPoints.Count) { MapPoint mp = mapPoints[i]; mp.angle += thisCycleRotations[mp.ringIndex]; if (mp.type == MapPointType.FlyingExpedition) { FlyingExpedition fe = (mp as FlyingExpedition); MapPoint d = fe.destination; if (d != null) { if (mp.height != d.height) { mp.height = Mathf.MoveTowards(mp.height, d.height, fe.speed * t * 0.01f); } else { if (mp.angle != d.angle) { mp.angle = Mathf.MoveTowardsAngle(mp.angle, d.angle, fe.speed * t); } else { mapPoints.RemoveAt(i); fe.expedition.DropMapMarker(); pointsExploringEvent?.Invoke(d); if (fe.expedition.stage == Expedition.ExpeditionStage.WayIn) { fe.expedition.StartMission(); } else { fe.expedition.Dismiss(); } actionsHash++; continue; } } } else { AnnouncementCanvasController.MakeAnnouncement(Localization.GetCrewAction(LocalizedCrewAction.CannotReachDestination, fe.expedition.crew)); fe.expedition.EndMission(); } } i++; } } // cityLookVector = Quaternion.AngleAxis(cityPoint.angle, Vector3.up) * Vector3.forward; cityFlyDirection = new Vector3(cityPoint.angle - prevX + rotationSpeed[cityPoint.ringIndex], ascensionChange, cityPoint.height - prevY); SYSTEM_envWasCalculatedThisTick = false; }
private void Update() { if (!prepared) { return; } float t = Time.deltaTime * GameMaster.gameSpeed; float f = 0, a; float[] thisCycleRotations = new float[RINGS_COUNT]; for (int i = 0; i < RINGS_COUNT; i++) { a = rotationSpeed[i] * t; thisCycleRotations[i] = a; f = ringsRotation[i]; f -= thisCycleRotations[i]; if (f > 360) { f = f % 360f; } else { if (f < 0) { f = 360f - Mathf.Abs(f % 360f); } } ringsRotation[i] = f; } float ascensionChange = 0; float prevX = cityPoint.angle, prevY = cityPoint.height; if (mapPoints.Count > 0) { if (GameMaster.realMaster.colonyController != null) { //float s = GameMaster.realMaster.stability; //if (s > 1f) s = 1f; //if (cpoint.height != s) //{ // cpoint.height = 1f - s; // cpoint.ringIndex = DefineRing(s); //} } int i = 0; while (i < mapPoints.Count) { MapPoint mp = mapPoints[i]; mp.angle += thisCycleRotations[mp.ringIndex]; if (mp.type == MapMarkerType.FlyingExpedition) { FlyingExpedition fe = (mp as FlyingExpedition); MapPoint d = fe.destination; if (d != null) { if (mp.height != d.height) { mp.height = Mathf.MoveTowards(mp.height, d.height, fe.speed * t * 0.01f); } else { if (mp.angle != d.angle) { mp.angle = Mathf.MoveTowardsAngle(mp.angle, d.angle, fe.speed * t); } else { mapPoints.RemoveAt(i); fe.expedition.DropMapMarker(); pointsExploringEvent?.Invoke(d); if (fe.expedition.stage == Expedition.ExpeditionStage.WayIn) { fe.expedition.StartMission(); } else { fe.expedition.Dismiss(); } actionsHash++; continue; } } } else { GameLogUI.MakeAnnouncement(Localization.GetCrewAction(LocalizedCrewAction.CannotReachDestination, fe.expedition.crew)); fe.expedition.EndMission(); } } i++; } } // cityLookVector = Quaternion.AngleAxis(cityPoint.angle, Vector3.up) * Vector3.forward; cityFlyDirection = new Vector3(cityPoint.angle - prevX + rotationSpeed[cityPoint.ringIndex], ascensionChange, cityPoint.height - prevY); }
public void DropMapMarker() { mapMarker = null; GlobalMapCanvasController.needExpeditionsRedraw = true; }
public void DropMapMarker() { mapMarker = null; }