void PlaceStarSystems() { List <Vector2> positions = new List <Vector2>(); int starSystemCount = (int)UnityEngine.Random.Range(map.minSystems, map.maxSystems); for (int count = 0; count < starSystemCount;) { Vector2 position = new Vector2((int)UnityEngine.Random.Range((map.size.x / 2 - 2) * -1f, (map.size.x / 2 - 2)), (int)UnityEngine.Random.Range((map.size.y / 2 - 2) * -1f, (map.size.x / 2 - 2))); if (!isPositionSuitable(positions, position)) { continue; } if (UnityEngine.Random.Range(0f, 1f) >= GetTemplateGreyscale(position.x, position.y)) { continue; } positions.Add(position); StarSystem system = CreateStarSystem(position); StarSystems.Add(system); count++; } }
private void StarSystems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (SystemVM systemVM in e.NewItems) { StarSystems.Add(systemVM.StarSystem, systemVM.StarSystem.NameDB.GetName(_gameVM.CurrentFaction)); } break; case NotifyCollectionChangedAction.Remove: foreach (SystemVM systemVM in e.OldItems) { StarSystems.Remove(systemVM.StarSystem); } break; case NotifyCollectionChangedAction.Reset: StarSystems.Clear(); break; default: throw new NotSupportedException("Unsupported change of underlying viewmodel."); } }
private void cbSelectSystem_SelectionChanged(object sender, SelectionChangedEventArgs e) { _loadedSystem = null; TvSystem.Items.Clear(); LoadCompleteSystem(); SetupTreeView(); //TODOLOW Fix the Display of Empty Orbitals }
public void SendSystem(StarSystems ssystem) { lock (_syncObj) { foreach (var callback in _clientsDict.Values) { callback.SendStarSystem(ssystem); } } }
private void PopulateStarSystemList() { StarSystems.Clear(); List <StarSystem> starSystems = _gameVM.Game.GetSystems(_gameVM.CurrentAuthToken); foreach (var item in starSystems) { StarSystems.Add(item, item.NameDB.DefaultName); } StarSystems.SelectedIndex = 0; }
public InfinityObjectData Save() { var result = new Dictionary <string, object> { ["Id"] = Id, ["Storage"] = Storage.Data, ["StarSystems"] = StarSystems.Select(x => x.Id).ToList(), }; return(new InfinityObjectData(TypeName, result)); }
//private int viewport_width; //private int viewport_height; public StarSystemSelectionVM(GameVM gameVM, Game game, Entity factionEntity) { _gameVM = gameVM; foreach (var item in game.GetSystems(gameVM.CurrentAuthToken)) { StarSystems.Add(item, item.NameDB.GetName(factionEntity)); } StarSystems.SelectedIndex = 0; StarSystems.SelectionChangedEvent += StarSystems_SelectionChangedEvent; StarSystems.DisplayList.CollectionChanged += DisplayList_CollectionChanged; //_gameVM.StarSystems.CollectionChanged += StarSystems_CollectionChanged; }
public WorldContext(WorldContextData data) { _creationDate = DateTime.Now; WorldCtl = data.WorldCtlData.GetInstanceFromData(); StarSystems = data.StarSystemsData.GetInstanceFromData(this); SpaceObjects = data.SpaceObjectsData.GetInstanceFromData(this); StarSystems.InitializeFromData(data.StarSystemsData); SpaceObjects.InitializeFromData(data.SpaceObjectsData); Captains = data.CaptainsData.GetInstanceFromData(this); }
private void LoadCompleteSystem() { if (CbSelectSystem.SelectedItem == null) { } else { var context = new Db1Entities(); context.Configuration.ProxyCreationEnabled = false; var query = (from p in context.StarSystems.Include("Stars").Include("Stars").Include("Stars.Planets").Include("Stars.Planets.InnerMoonlets1").Include("Stars.Planets.OuterMoonlets1").Include("Stars.Planets.MajorMoons1") where p.Id == (int)CbSelectSystem.SelectedValue select p).FirstOrDefault(); _loadedSystem = query; } }
// Use this for initialization void Start() { XmlSerializer SerializerObj = new XmlSerializer(typeof(StarSystems)); // Create a new file stream for reading the XML file FileStream ReadFileStream = new FileStream(@"C:\Test\test.xml", FileMode.Open, FileAccess.Read, FileShare.Read); // Load the object saved above by using the Deserialize function StarSystems LoadedObj = (StarSystems)SerializerObj.Deserialize(ReadFileStream); // Cleanup ReadFileStream.Close(); foreach (Stars item in LoadedObj.Stars) { Debug.Log(item.StarOrder); } }
public static void SerializeSystem(StarSystems starSystem) { // Create a new XmlSerializer instance with the type of the test class var serializerObj = new XmlSerializer(typeof(StarSystems)); try { // Create a new file stream to write the serialized object to a file TextWriter writeFileStream = new StreamWriter(@"C:\Test\test.xml"); serializerObj.Serialize(writeFileStream, starSystem); writeFileStream.Close(); } catch (Exception) { // ignored } }
public void SendStarSystem( StarSystems system ) { XmlHandler.SerializeSystem(system); }
public void SendStarSystem(StarSystems system) { XmlHandler.SerializeSystem(system); }