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; } }