public GameObject Instantiate(string name, Vector2 position, float rotation, Vector2 scale, GameObject parent) { var gameObject = Build(name, position, rotation, scale); if (parent != null) { parent.DelayedAdd(gameObject); } else { manager.DelayedAdd(gameObject); } return(gameObject); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { ComponentManager = new ComponentManager(); ComponentManager.DelayedAdd(new Logger()); PhysicsWorld = new PhysicsWorld(); ComponentManager.DelayedAdd(PhysicsWorld); GameObjectManager = new ComponentManager <GameObject>(); ComponentManager.DelayedAdd(GameObjectManager); PrefabFactory = new PrefabFactory(GameObjectManager); ComponentManager.DelayedAdd(PrefabFactory); ComponentManager.Start(); Input = new InputManager(this); Components.Add(Input); Input.AddButton("shoot", new InputButton(Keys.Space)); IsMouseVisible = true; base.Initialize(); }