public Unit Spawn(UnitType type, float x, float z) { float y = YAt(x, z) + type.BoundingSphere.Radius; Vector3 position = new Vector3(x, y, z); var unit = new Unit(type, position); units.Add(unit); sceneManager.AddModel(unit.Model, true, true); //unit.Model.RigidBody.Mass *= type.Density; unit.Model.RigidBody.Material.Restitution = 0.99f; unit.Model.RigidBody.Material.StaticFriction = 0.99f; //unit.Model.RigidBody.Material.DynamicFriction = 0.70f; unit.Model.RigidBody.AllowDeactivation = false; //unit.Controller = new LookAtPhysicsFrameController(unit.Model); if (type.ControllerType != null) { unit.Controller = (IFrameController)System.Activator.CreateInstance(type.ControllerType); IPhysicsController physicsController = unit.Controller as IPhysicsController; if (physicsController != null) { physicsController.PhysicsObject = unit.Model; } } return(unit); }
public SuperController() { FrameController = new FrameController(); InputController = new InputControler(); LevelController = new LevelController(); PhysicsController = new PhysicsController(); FrameController.Init(); InputController.Init(); LevelController.Init(); PhysicsController.Init(); }
/// <summary> /// Adds a controller to the physics manager. /// </summary> /// <param name="controller">The controller which is to be added.</param> public override void AddController(IPhysicsController controller) { if (controller == null) { throw new Exception("PhysicsManager.AddController: null controller."); } JigLibXController wrapper = new JigLibXController(controller); mControllers.Add(wrapper); mPhysicsSystem.AddController(wrapper); }
/// <summary> /// Removes a controller from the physics manager. /// </summary> /// <param name="controller">The controller which is to be removed.</param> public override void RemoveController(IPhysicsController controller) { if (controller == null) { throw new Exception("PhysicsManager.RemoveController: null controller."); } JigLibXController wrapper = mControllers.Find(c => c.Controller == controller); if (wrapper == null) { throw new Exception("PhysicsManager.RemoveController: controller not found."); } mControllers.Remove(wrapper); mPhysicsSystem.RemoveController(wrapper); }
/// <summary> /// Removes a controller from the physics manager. /// </summary> /// <param name="controller">The controller which is to be removed.</param> public abstract void RemoveController(IPhysicsController controller);
/// <summary> /// Adds a controller to the physics manager. /// </summary> /// <param name="controller">The controller which is to be added.</param> public abstract void AddController(IPhysicsController controller);
/// <summary> /// Constructor. /// </summary> public JigLibXController(IPhysicsController controller) : base() { mController = controller; }