public static void Add(Interface.Struct.GameObject obj) { GameObject nobj = new GameObject(obj); Out.Log(Significance.Low, "Added game object " + nobj); AllGameObjects.Add(nobj); }
public void ClearLevel() { // Removing objects from ProcessableObjects: ProcessableObjects.Clear(); // Remove objects from container: AllGameObjects.Clear(); }
public static void Remove(Interface.Struct.GameObjectID obj) { GameObject.ObjectID id = new GameObject.ObjectID(obj); for (int i = 0; i < AllGameObjects.Count; i++) { if (AllGameObjects[i].ID == id) { Out.Log(Significance.Low, "Removed game object " + id); AllGameObjects.RemoveAt(i); return; } } Out.Log(Significance.Unusual, "Unable to locate game object '" + id + "'"); }
// ********************************* // Methods: // ********************************* // - - - - - - - - - - // Managing objects : // - - - - - - - - - - // This method sets object on a map: protected override void AddObject(CGameObject o) { // Adding to all objects: AllGameObjects.Add(o); // if it is processable then add it to corresponding list: if (o is IProcessable) { ProcessableObjects.Add((IProcessable)o); } if ((o is CIconEnemy) || (o is ClevelFlag) || (o is CPlayerIcon)) { StatisticObjects.Add(o); } // Set event handlers: SetEventHandlers(o); //Add to map: CGameObject[,] map; // Choosing the right map: map = (o is CProjectile) ? mapProjectiles : mapMain; // check if transparent: if (!o.Transparent) { int x, y, width, height; GetDimensionsOnMap(o, out x, out y, out width, out height); // Put on the map: for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { map[x + j, y + i] = o; } } } }
// This method removes object from map: protected override void RemoveObject(CGameObject o) { // Removing from all objects: AllGameObjects.Remove(o); // if (o is IProcessable) { ProcessableObjects.Remove((IProcessable)o); } if ((o is CIconEnemy) || (o is ClevelFlag) || (o is CPlayerIcon)) { StatisticObjects.Remove(o); } // Removing from map: CGameObject[,] map; // Choosing the right map: map = (o is CProjectile) ? mapProjectiles : mapMain; // if object is not transparent then removing it: if (!o.Transparent) { int x, y, width, height; GetDimensionsOnMap(o, out x, out y, out width, out height); // Removing from map: for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { map[x + j, y + i] = null; } } } }
/// <summary> /// The get operation from the GameObjects stack. /// </summary> /// <typeparam name="T"> /// The requested <see cref="GameObject" /> type. /// </typeparam> /// <returns> /// The List containing the requested type. /// </returns> public static IEnumerable <T> Get <T>() where T : GameObject, new() { return(AllGameObjects.OfType <T>()); }
protected override void RemoveObject(CGameObject o) { AllGameObjects.Remove(o); //if (o is IProcessable) ProcessableObjects.Remove((IProcessable)o); }
protected override void AddObject(CGameObject o) { AllGameObjects.Add(o); //if (o is IProcessable) ProcessableObjects.Add((IProcessable)o); }
public static void FlushAllData() { AllGameObjects.Clear(); AllControlMarkers.Clear(); }