private void MapPayer(IPlayer player, bool newWorld = false) { if (!AllObjects.TryGetValue(player.Guid, out var item)) { item = new AllObjectsDictionaryItem { ItemFromServer = player }; AllObjects.Add(player.Guid, item); item.Controller = Instantiate(PlayerControllerBase, new Vector3(player.X, player.Y, 0), Quaternion.identity); PlayerController = item.Controller as PlayerController; } if (newWorld) { // ReSharper disable once PossibleNullReferenceException (item.Controller as PlayerController).UpdateFromServer(player); } else { Player.IsMoving = player.IsMoving; Player.MoveToX = player.MoveToX; Player.MoveToY = player.MoveToY; Player.WorldGuid = player.WorldGuid; Player.VisibleCities = player.VisibleCities; } item.Updated = true; }
public virtual void Add(T item) { AllObjects.Add(item); currentPageNumber = TotalPagesNumber; Calculate(currentPageNumber); OnTotalChange(); }
//public void OnGUI() //{ // int nbTwippies = GetAll<Twippie>().Count; // GUI.Label(new Rect(Screen.width / 2 - 50, 10, 100, 20), "Twippies : " + nbTwippies.ToString()); //} public void AddObject(ManageableObjet obj) { if (AllObjects.Contains(obj)) { return; } AllObjects.Add(obj); //Debug.Log(obj.name + " ajouté à la liste globale"); }
private async Task OnAddPersonAsync() { var addPersonViewModel = new AddPersonViewModel(); if (await _uiVisualizerService.ShowDialogAsync(addPersonViewModel) ?? false) { var person = addPersonViewModel.Person; var searchable = _dataGenerationService.GenerateSearchable(person); _searchService.AddObjects(new[] { searchable }); AllObjects.Add(searchable); _searchService.Search(Filter); } }
private void MapCity(ICity city, IPlayer player) { if (!AllObjects.TryGetValue(city.Guid, out var item)) { item = new AllObjectsDictionaryItem { ItemFromServer = city }; AllObjects.Add(city.Guid, item); item.Controller = Instantiate(CityControllerBase, new Vector3(city.X, city.Y, 0), Quaternion.identity); } // ReSharper disable once PossibleNullReferenceException (item.Controller as CityController).UpdateFromServer(city, player); item.Updated = true; }
/// <summary> /// Resets each world to the state it was in when first loaded /// </summary> public void ResetWorld() { AllObjects.Clear(); QuadTree = new QuadTreeNode(0, 0, width * 64, height * 64); foreach (Enemy e in initialEnemies) { Enemy clone = e.Clone(e.Texture, e.HP, QuadTree); AllObjects.Add(clone); } foreach (Warp w in warps) { AllObjects.Add(w); } }
void GenerateObjects(GameObject gameObject) { for (var c = 0; c < countObject / 4; ++c) { bool ok = false; float x = RandX(), y = RandY(); while (!ok) { x = RandX(); y = RandY(); ok = checkPlace(x, y, 3); } AllObjects.Add(Instantiate(gameObject, new Vector2(x, y), Quaternion.identity)); } }
void UpdateAllObjects() { List <ThingsListModel> things = thingRepository.GetAll(); List <PersonListModel> persons = personRepository.GetAll(); AllObjects.Clear(); foreach (var thingsListModel in things) { AllObjects.Add(new ObjectsListModel() { Id = thingsListModel.Id, Name = thingsListModel.Name }); } foreach (var personsListModel in persons) { AllObjects.Add(new ObjectsListModel() { Id = personsListModel.Id, Name = personsListModel.Firstname + " " + personsListModel.Surname }); } }
//Imports a world saved in tiles with width and height all generated from a previously created binary file public void Import(Dictionary <string, Texture2D> allTextures, string filePath) { FileStream temp = new FileStream(filePath, FileMode.Open); BinaryReader worldReader = new BinaryReader(temp); width = worldReader.ReadInt32(); height = worldReader.ReadInt32(); QuadTree = new QuadTreeNode(0, 0, width * 64, height * 64); //load tiles tiles = new Tile[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { String source = worldReader.ReadString(); int index = worldReader.ReadInt32(); int depth = worldReader.ReadInt32(); // Set the texture based on the source Texture2D texture; if (source == "Default") { texture = null; } else { texture = allTextures[source + index]; } Tile t = new Tile(texture, allTextures["Background"], depth); t.Position = new Vector2(i * 64, j * 64); t.Size = new Vector2(64, 64); tiles[i, j] = t; QuadTree.AddObject(t); } } int events = worldReader.ReadInt32(); for (int i = 0; i < events; i++) { int type = worldReader.ReadInt32(); if (type == 0) { //Enemy int x = worldReader.ReadInt32(); int y = worldReader.ReadInt32(); Enemy e = new Enemy(x * 64, y * 64, QuadTree, PatrolType.Standing); e.Texture = allTextures["Enemy"]; AllObjects.Add(e); initialEnemies.Add(e.Clone(e.Texture, e.HP, QuadTree)); QuadTree.AddObject(e); } if (type == 1) { //Warp int x = worldReader.ReadInt32() * 64; int y = worldReader.ReadInt32() * 64; String destination = worldReader.ReadString(); int xOffset = worldReader.ReadInt32() * 64; int yOffset = worldReader.ReadInt32() * 64; Warp w = new Warp(x, y, destination, xOffset, yOffset, QuadTree); AllObjects.Add(w); warps.Add(w); } } //Finds Bounds of the world WorldMinX = float.MaxValue; WorldMinY = float.MaxValue; WorldMaxY = float.MinValue; WorldMaxX = float.MinValue; foreach (Tile t in tiles) { if (t.X < WorldMinX) { WorldMinX = t.X; } if (t.Y < WorldMinY) { WorldMinY = t.Y; } if (t.X + t.Size.X > WorldMaxX) { WorldMaxX = t.X + t.Size.X; } if (t.Y + t.Size.Y > WorldMaxY) { WorldMaxY = t.Y + t.Size.Y; } } }
private void GameObject_OnCreate(GameObject sender, EventArgs args) { AllObjects.Add(sender); var hero = sender as AIHeroClient; if (hero != null) { AllHeroes.Add(hero); if (hero.IsEnemy) { EnemyHeroes.Add(hero); AllEnemies.Add(hero); } else { AllyHeroes.Add(hero); AllAllies.Add(hero); } return; } var minion = sender as Obj_AI_Minion; if (minion != null) { if (minion.Team != GameObjectTeam.Neutral) { if (minion.GetMinionType().HasFlag(Extensions.MinionTypes.Ward)) { AllWards.Add(minion); if (minion.IsEnemy) { EnemyWards.Add(minion); } else { AllyWards.Add(minion); } } else { AllMinions.Add(minion); if (minion.IsEnemy) { EnemyMinions.Add(minion); AllEnemies.Add(minion); } else { AllyMinions.Add(minion); AllAllies.Add(minion); } } } else if (minion.Name != "WardCorpse") { switch (minion.GetJungleType()) { case Extensions.JungleType.Small: SmallJungleMinions.Add(minion); break; case Extensions.JungleType.Large: LargeJungleMinions.Add(minion); break; case Extensions.JungleType.Epic: EpicJungleMinions.Add(minion); break; case Extensions.JungleType.Legendary: LegendaryJungleMinions.Add(minion); break; } AllJungleMinions.Add(minion); } return; } var particle = sender as Obj_GeneralParticleEmitter; if (particle != null) { AllParticleEmitters.Add(particle); return; } var turret = sender as Obj_AI_Turret; if (turret != null) { AllTurrets.Add(turret); if (turret.IsEnemy) { EnemyTurrets.Add(turret); } else { AllyTurrets.Add(turret); } return; } var shop = sender as Obj_Shop; if (shop != null) { AllShops.Add(shop); if (shop.IsAlly) { AllyShops.Add(shop); } else { EnemyShops.Add(shop); } return; } var spawnPoint = sender as Obj_SpawnPoint; if (spawnPoint != null) { AllSpawnPoints.Add(spawnPoint); if (spawnPoint.IsAlly) { AllySpawnPoints.Add(spawnPoint); } else { EnemySpawnPoints.Add(spawnPoint); } } var inhibitor = sender as Obj_BarracksDampener; if (inhibitor != null) { AllInhibitors.Add(inhibitor); if (inhibitor.IsAlly) { AllyInhibitors.Add(inhibitor); } else { EnemyInhibitors.Add(inhibitor); } } var nexus = sender as Obj_HQ; if (nexus != null) { AllNexus.Add(nexus); if (nexus.IsAlly) { AllyNexus = nexus; } else { EnemyNexus = nexus; } } var missile = sender as MissileClient; if (missile != null) { AllMissiles.Add(missile); if (missile.IsAlly) { AllyMissiles.Add(missile); } else { EnemyMissiles.Add(missile); } } }