public void InsertGameObject(GameObject go) { if(gameObjects.ContainsKey(go.GetId())) { return; } gameObjects.Add(go.GetId(), go); }
public static void RemoveGameObject(GameObject gameObject) { GetTile((int)gameObject.Position.X / Data.TileSize, (int)gameObject.Position.Y / Data.TileSize).RemoveObject(gameObject); allGameObjects.Remove(gameObject.GetId()); if (gameObject is Mob) { allMobs.Remove(gameObject.GetId()); } if (gameObject is Toon) { allToons.Remove(gameObject.GetId()); } }
public void RemoveObject(GameObject gameObject) { gameObjects.Remove(gameObject.GetId()); }
//use the given GameObjects position to manage what tile to go into public static void InsertGameObject(GameObject go) { //BAD BAD IF STATEMENT, BE GONE, DAMN ARRAYS if (go.Position.X < 0 || go.Position.X > tiles.GetLength(0) * Data.TileSize || go.Position.Y < 0 || go.Position.Y > tiles.GetLength(1) * Data.TileSize) { go.Position = new Vector2(100, 100); //looks and feels horrible } tiles[(int)(go.Position.X / Data.TileSize), (int)(go.Position.Y / Data.TileSize)].InsertGameObject(go); if (!allGameObjects.ContainsKey(go.GetId())) { allGameObjects.Add(go.GetId(), go); } if (go is Mob) { if (!allMobs.ContainsKey(go.GetId())) { allMobs.Add(go.GetId(), (Mob)go); } } if (go is Toon) { if (!allToons.ContainsKey(go.GetId())) { allToons.Add(go.GetId(), (Toon)go); } } }