private void InitializeEventDispatcher()
 {
     this.eventDispatcher = new EventDispatcher(this, 25);
     Components.Add(this.eventDispatcher);
 }
Esempio n. 2
0
 //gravity pre-defined
 public PhysicsManager(Game game, EventDispatcher eventDispatcher, StatusType statusType)
     : this(game, eventDispatcher, statusType, -10 * Vector3.UnitY)
 {
 }
Esempio n. 3
0
 protected override void RegisterForEventHandling(EventDispatcher eventDispatcher)
 {
     eventDispatcher.RemoveActorChanged += EventDispatcher_RemoveActorChanged;
     base.RegisterForEventHandling(eventDispatcher);
 }
        public UIProgressController(string id, ControllerType controllerType, int startValue, int maxValue, EventDispatcher eventDispatcher)
            : base(id, controllerType)
        {
            this.StartValue   = startValue;
            this.MaxValue     = maxValue;
            this.CurrentValue = startValue;

            this.eventDispatcher = eventDispatcher;

            //register with the event dispatcher for the events of interest
            RegisterForEventHandling(eventDispatcher);
        }
 protected override void RegisterForEventHandling(EventDispatcher eventDispatcher)
 {
     eventDispatcher.PlayerChanged += EventDispatcher_PlayerChanged;
 }
 protected virtual void RegisterForEventHandling(EventDispatcher eventDispatcher)
 {
     eventDispatcher.MenuChanged += EventDispatcher_MenuChanged;
 }
 protected virtual void RegisterForEventHandling(EventDispatcher eventDispatcher)
 {
     eventDispatcher.OpacityChanged     += EventDispatcher_OpacityChanged;
     eventDispatcher.RemoveActorChanged += EventDispatcher_RemoveActorChanged;
     eventDispatcher.AddActorChanged    += EventDispatcher_AddActorChanged;
 }
Esempio n. 8
0
 public GameStateManager(Game game, EventDispatcher eventDispatcher, StatusType statusType)
     : base(game, eventDispatcher, statusType)
 {
 }
        private void DoPickAndPlace(GameTime gameTime)
        {
            if (this.managerParameters.MouseManager.IsMiddleButtonClicked())
            {
                if (!this.bCurrentlyPicking)
                {
                    this.camera = this.managerParameters.CameraManager.ActiveCamera;
                    this.currentPickedObject = this.managerParameters.MouseManager.GetPickedObject(camera, camera.ViewportCentre,
                                                                                                   this.pickStartDistance, this.pickEndDistance, out pos, out normal) as CollidableObject;

                    this.distanceToObject = (float)Math.Round(Vector3.Distance(camera.Transform.Translation, pos), DefaultDistanceToTargetPrecision);

                    if (this.currentPickedObject != null && IsValidCollision(currentPickedObject, pos, normal))
                    {
                        Vector3 vectorDeltaFromCentreOfMass = pos - this.currentPickedObject.Collision.Owner.Position;
                        vectorDeltaFromCentreOfMass = Vector3.Transform(vectorDeltaFromCentreOfMass, Matrix.Transpose(this.currentPickedObject.Collision.Owner.Orientation));
                        cameraPickDistance          = (this.managerParameters.CameraManager.ActiveCamera.Transform.Translation - pos).Length();

                        //remove any controller from any previous pick-release
                        objectController.Destroy();
                        damperController.Destroy();

                        this.currentPickedObject.Collision.Owner.SetActive();
                        //move object by pos (i.e. point of collision and not centre of mass)
                        this.objectController.Initialise(this.currentPickedObject.Collision.Owner, vectorDeltaFromCentreOfMass, pos);
                        //dampen velocity (linear and angular) on object to Zero
                        this.damperController.Initialise(this.currentPickedObject.Collision.Owner, ConstraintVelocity.ReferenceFrame.Body, Vector3.Zero, Vector3.Zero);
                        this.objectController.EnableConstraint();
                        this.damperController.EnableConstraint();
                        //we're picking a valid object for the first time
                        this.bCurrentlyPicking = true;

                        //update mouse text
                        object[] additionalParameters = { currentPickedObject, this.distanceToObject };
                        EventDispatcher.Publish(new EventData(EventActionType.OnObjectPicked, EventCategoryType.ObjectPicking, additionalParameters));
                    }
                }

                //if we have an object picked from the last update then move it according to the mouse pointer
                if (objectController.IsConstraintEnabled && (objectController.Body != null))
                {
                    // Vector3 delta = objectController.Body.Position - this.managerParameters.CameraManager.ActiveCamera.Transform.Translation;
                    Vector3 direction = this.managerParameters.MouseManager.GetMouseRay(this.managerParameters.CameraManager.ActiveCamera).Direction;
                    cameraPickDistance += this.managerParameters.MouseManager.GetDeltaFromScrollWheel() * 0.1f;
                    Vector3 result = this.managerParameters.CameraManager.ActiveCamera.Transform.Translation + cameraPickDistance * direction;
                    //set the desired world position
                    objectController.WorldPosition = this.managerParameters.CameraManager.ActiveCamera.Transform.Translation + cameraPickDistance * direction;
                    objectController.Body.SetActive();
                }
            }
            else //releasing object
            {
                if (this.bCurrentlyPicking)
                {
                    //release object from constraints and allow to behave as defined by gravity etc
                    objectController.DisableConstraint();
                    damperController.DisableConstraint();

                    //notify listeners that we're no longer picking
                    object[] additionalParameters = { NoObjectSelectedText };
                    EventDispatcher.Publish(new EventData(EventActionType.OnNonePicked, EventCategoryType.ObjectPicking, additionalParameters));

                    this.bCurrentlyPicking = false;
                }
            }
        }
Esempio n. 10
0
 public override void Publish()
 {
     EventDispatcher.Publish(this.eventData);
 }