Пример #1
0
 public GameObject(Game game, GameObject parent)
     : base(game)
 {
     this._components = new Dictionary<ComponentType, ObjectComponent>();
     this.Children = new List<GameObject>();
     this.SetParent(parent);
 }
Пример #2
0
        public void AddObject(GameObject obj)
        {
            this._objects.Add(obj);

            foreach (GameSystem system in this._systems)
            {
                system.TryRegisterObject(obj);
            }
        }
Пример #3
0
        public static bool AreRelated(GameObject obj1, GameObject obj2)
        {
            if (obj1._parent == obj2 ||
                obj2._parent == obj1 ||
                obj1 == obj2)
            {
                return true;
            }

            return false;
        }
Пример #4
0
 public bool TryRegisterObject(GameObject obj)
 {
     foreach (ComponentType type in this._componentDependencies)
     {
         if (!obj.HasComponent(type))
         {
             return false;
         }
     }
     this._objects.Add(obj);
     return true;
 }
Пример #5
0
        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;
        }
Пример #6
0
 public ObjectComponent(GameObject parent)
 {
     this.ParentEntity = parent;
 }
Пример #7
0
 public void RemoveObject(GameObject obj)
 {
     foreach (GameSystem system in this._systems)
     {
         system.UnregisterObject(obj);
     }
 }
Пример #8
0
 public void UnregisterObject(GameObject objToRemove)
 {
     this._objects.Remove(objToRemove);
 }
Пример #9
0
        public void SetParent(GameObject parent)
        {
            this._parent = parent;

            if (parent != null)
            {
                parent.Children.Add(this);
            }
        }