protected void Undock(ServerUpdate serverUpdate) { Hangar hangar = _data._hangars[_fleet.LastHangar]; serverUpdate.Add(hangar); foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Hangar = -1; ship.AddLog("undocked from station"); serverUpdate.Add(ship); hangar.Ships.Remove(sID); } }
protected void Dock(ServerUpdate serverUpdate) { Hangar hangar = _data._hangars[_fleet.NextHangar]; serverUpdate.Add(hangar); foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.AddLog("Docked to station"); ship.Hangar = _fleet.NextHangar; serverUpdate.Add(ship); hangar.Ships.Add(sID); } }
protected void Fuel(ServerUpdate serverUpdate) { foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.AddLog("Fueled for X ICU"); serverUpdate.Add(ship); } _fleet.FleetParams.Set("currentState", "doneFueling"); }
protected void StartUndock(ServerUpdate serverUpdate) { NextUpdateFrame(50); foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Status = "Undocking"; serverUpdate.Add(ship); } _fleet.FleetParams.Set("currentState", "undocking"); }
public override int Update(ServerUpdate serverUpdate) { SimulatedWideDataManager.SerializeContainer data = SimulatedWideDataManager.Container; foreach (int shipID in _fleet.ShipIDs) { Ship s = data._ships[shipID]; serverUpdate.Add(s); s.Logs += "\n" + "End of flight plan"; } data._fleets.Remove(_fleet.ID); foreach (int shipID in _fleet.ShipIDs) { Ship s = data._ships[shipID]; serverUpdate.Add(s); s.Fleet = 0; } return(_fleet.NextUpdateFrame); }
public override int Update(ServerUpdate serverUpdate) { SimulatedWideDataManager.SerializeContainer data = SimulatedWideDataManager.Container; foreach (int shipID in _fleet.ShipIDs) { Ship s = data._ships[shipID]; serverUpdate.Add(s); s.Logs += "\n" + "Starting flight plan"; } //set to next node foreach (LinkInfo l in _nodes.links) { if (l.FromID == _myID && l.FromParam == "StartOutput") { _fleet.CurrentNode = l.ToID; break; } } return(_fleet.NextUpdateFrame); }
public override int Update(ServerUpdate serverUpdate) { if (_data._currentFrame < _fleet.NextUpdateFrame) { return(_fleet.NextUpdateFrame); } string currentState = _fleet.FleetParams.GetString("currentState", "none"); switch (currentState) { case "none": { Ship s1 = _data._ships[_fleet.ShipIDs[0]]; _fleet.LastHangar = s1.Hangar; Hangar h = _data._hangars[s1.Hangar]; _fleet.LastStation = h.Station; _fleet.NextHangar = _fleet.LastHangar; StartUndock(serverUpdate); } break; case "undocking": { Undock(serverUpdate); //start moveTo NextUpdateFrame(100); foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Hangar = -1; ship.Status = "Moving to explore site"; serverUpdate.Add(ship); } _fleet.FleetParams.Set("currentState", "moveOut"); } break; case "moveOut": { NextUpdateFrame(500); foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Status = "Exploring"; ship.AddLog("Moved to explore site"); serverUpdate.Add(ship); } _fleet.FleetParams.Set("currentState", "explore"); } break; case "explore": { NextUpdateFrame(200); //choisir un POI si possible bool didFound = false; Random r = new Random(); double a = r.NextDouble(); NodeInfos n = _nodes.nodes[_myID]; int sector = n.nodeParams.GetInt("zone", 0); List <PointOfInterest> possible = _data._POIs.Values.Where(p => p.FindProba > a && p.Sector == sector).ToList(); if (possible.Count > 0) { didFound = true; int index = r.Next(possible.Count); PointOfInterest found = possible[index]; Bookmark bookmark = new Bookmark(_data._bookmarkIDs++, index); bookmark.datas = found.DatasToBookmark(); _data._bookmarks.Add(bookmark.ID, bookmark); n.nodeParams.Set("found", bookmark.ID); /* * Corporation c = _container._corps[s.Corp]; * SendMailRequest request = new SendMailRequest(-1, c.Owner); * request.Message = "You found something while exploring, congrat! \n\n" + found.Description; * request.Subject = "Exploration result"; * _manager.SendRequest(request); */ } foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Status = "Moving back to station"; ship.AddLog("Done with exploration"); if (didFound) { ship.AddLog("And found something..."); } serverUpdate.Add(ship); } _fleet.FleetParams.Set("currentState", "moveIn"); } break; case "moveIn": { StartDock(serverUpdate); } break; case "docking": { Dock(serverUpdate); StartFueling(serverUpdate); } break; case "fueling": { Fuel(serverUpdate); } break; case "doneFueling": { foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Status = "Idle in station"; } MoveFlow("ExploreOutput"); } break; } return(_fleet.NextUpdateFrame); }
public override int Update(ServerUpdate serverUpdate) { if (_data._currentFrame >= _fleet.NextUpdateFrame) { string lastDoneStep = _fleet.FleetParams.GetString("currentState", "none"); switch (lastDoneStep) { case "none": { //undocking //preparer les données int hangarID = 1; foreach (LinkInfo l in _nodes.links) { if (l.ToID == _myID && l.ToParam == "Station") { NodeInfos hangarSelectorNode = _nodes.nodes[l.FromID]; hangarID = hangarSelectorNode.nodeParams.GetInt("HangarID"); } } _fleet.NextHangar = hangarID; //demarer StartUndock(serverUpdate); } break; case "undocking": { Undock(serverUpdate); NextUpdateFrame(200); //todo calculer le temps pour se rendre _fleet.ShipIDs.ForEach((sID) => { Ship ship = _data._ships[sID]; ship.Status = "Moving to station"; serverUpdate.Add(ship); }); _fleet.FleetParams.Set("currentState", "moving"); } break; case "moving": { _fleet.ShipIDs.ForEach((sID) => { Ship ship = _data._ships[sID]; ship.AddLog("Moved to target station"); serverUpdate.Add(ship); }); _fleet.FleetParams.Set("currentState", "dock"); } break; case "dock": { StartDock(serverUpdate); } break; case "docking": { Dock(serverUpdate); StartFueling(serverUpdate); } break; case "fueling": { Fuel(serverUpdate); } break; case "doneFueling": { foreach (int sID in _fleet.ShipIDs) { Ship ship = _data._ships[sID]; ship.Status = "Idle in station"; } MoveFlow("MoveOutput"); } break; } } return(_fleet.NextUpdateFrame); }
private void AddLog(Fleet f, string msg) { foreach (int s in f.ShipIDs) { Ship ship = _container._ships[s]; _currentUpdate.Add(ship); ship.Logs += "\n" + msg; } }