public GameObject(Game game, GameObject parent) : base(game) { this._components = new Dictionary<ComponentType, ObjectComponent>(); this.Children = new List<GameObject>(); this.SetParent(parent); }
public void AddObject(GameObject obj) { this._objects.Add(obj); foreach (GameSystem system in this._systems) { system.TryRegisterObject(obj); } }
public static bool AreRelated(GameObject obj1, GameObject obj2) { if (obj1._parent == obj2 || obj2._parent == obj1 || obj1 == obj2) { return true; } return false; }
public bool TryRegisterObject(GameObject obj) { foreach (ComponentType type in this._componentDependencies) { if (!obj.HasComponent(type)) { return false; } } this._objects.Add(obj); return true; }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; this._systems = new List<GameSystem>(); this._objects = new List<GameObject>(); this._services = new Dictionary<string, GameSystem>(); this._systemsCallOrder = new List<int>(); this.curScreen = ScreenType.Start; this.graphics.PreferredBackBufferWidth = 1200; this.graphics.PreferredBackBufferHeight = 800; this.graphics.ApplyChanges(); this.CurrentPathfindingGraph = new AStarGraph(this, new List<AStarNode>()); this.play1 = SpriteType.None; this.play2 = SpriteType.None; this.winner = 0; this.playe1 = PlayerType.None; this.playe2 = PlayerType.None; gameType = GameTypes.None; LivesOrTime = 0; this.mapType = MapType.Basic; this.Winner = null; }
public ObjectComponent(GameObject parent) { this.ParentEntity = parent; }
public void RemoveObject(GameObject obj) { foreach (GameSystem system in this._systems) { system.UnregisterObject(obj); } }
public void UnregisterObject(GameObject objToRemove) { this._objects.Remove(objToRemove); }
public void SetParent(GameObject parent) { this._parent = parent; if (parent != null) { parent.Children.Add(this); } }