protected override void HandleEvent(EventData eventData) { //if this event relates to adding, removing, changing an object if (eventData.EventCategoryType == EventCategoryType.Object) { HandleObjectCategoryEvent(eventData); } else if (eventData.EventCategoryType == EventCategoryType.Player) { HandlePlayerCategoryEvent(eventData); } else if (eventData.EventActionType == EventActionType.OnOpaqueToTransparent) { DrawnActor3D actor = eventData.Parameters[0] as DrawnActor3D; opaqueList.Remove(actor); transparentList.Add(actor); } else if (eventData.EventActionType == EventActionType.OnTransparentToOpaque) { DrawnActor3D actor = eventData.Parameters[0] as DrawnActor3D; transparentList.Remove(actor); opaqueList.Add(actor); } //pass event to base (in case it is a menu event) base.HandleEvent(eventData); }
public void Add(DrawnActor3D actor) { if (actor.EffectParameters.GetAlpha() < 1) { transparentList.Add(actor); else opaqueList.Add(actor); }
/// <summary> /// Removes an actor from the list by adding to a batch remove list which is processed before each update /// </summary> /// <param name="actor"></param> public void Remove(DrawnActor3D actor) { if (actor == null) { return; } removeList.Add(actor); }
/// <summary> /// Add the actor to the appropriate list based on actor transparency /// </summary> /// <param name="actor"></param> public void Add(DrawnActor3D actor) { if (actor.EffectParameters.Alpha < 1) { transparentList.Add(actor); } else { opaqueList.Add(actor); } }
private void DemoSetControllerPlayStatus() { DrawnActor3D torusActor = this.object3DManager.Find(actor => actor.ID.Equals("torus 1")); if (torusActor != null && this.keyboardManager.IsFirstKeyPress(Keys.O)) { torusActor.SetControllerPlayStatus(PlayStatusType.Pause, controller => controller.GetControllerType() == ControllerType.Rotation); } else if (torusActor != null && this.keyboardManager.IsFirstKeyPress(Keys.P)) { torusActor.SetControllerPlayStatus(PlayStatusType.Play, controller => controller.GetControllerType() == ControllerType.Rotation); } }
public override void HandleEvent(EventData eventData) { DrawnActor3D actor = null; switch (eventData.EventActionType) { case EventActionType.OnWin: //call code to handle win here... break; case EventActionType.OnLose: //call code to handle win here... break; case EventActionType.OnAddActor: Add(eventData.Parameters[0] as DrawnActor3D); break; case EventActionType.OnRemoveActor: Remove(eventData.Parameters[0] as DrawnActor3D); break; case EventActionType.OnOpaqueToTransparent: actor = eventData.Parameters[0] as DrawnActor3D; opaqueList.Remove(actor); transparentList.Add(actor); break; case EventActionType.OnTransparentToOpaque: actor = eventData.Parameters[0] as DrawnActor3D; transparentList.Remove(actor); opaqueList.Add(actor); break; case EventActionType.OnApplyActionToFirstMatchActor: ApplyActionToActor(eventData); break; case EventActionType.OnApplyActionToAllActors: ApplyActionToAllActors(eventData); break; } //remember to pass the eventData down so the parent class can process pause/unpause base.HandleEvent(eventData); }
//debug method to draw collision skins for collidable objects and zone objects private void ProcessAllDrawnObjects() { for (int i = 0; i < objectManager.OpaqueList.Count; i++) { actor = objectManager.OpaqueList[i]; if (actor is CollidableObject) { AddCollisionSkinVertexData(actor as CollidableObject); } } for (int i = 0; i < objectManager.TransparentList.Count; i++) { actor = objectManager.TransparentList[i]; if (actor is CollidableObject) { AddCollisionSkinVertexData(actor as CollidableObject); } } }
protected override void HandleEvent(EventData eventData) { if (eventData.EventCategoryType == EventCategoryType.Menu) { if (eventData.EventActionType == EventActionType.OnPause) this.StatusType = StatusType.Off; else if (eventData.EventActionType == EventActionType.OnPlay) this.StatusType = StatusType.Drawn | StatusType.Update; } else if (eventData.EventCategoryType == EventCategoryType.Object) { if (eventData.EventActionType == EventActionType.OnRemoveActor) { DrawnActor3D removeObject = eventData.Parameters[0] as DrawnActor3D; opaqueList.Remove(removeObject); } } }
/// <summary> /// Applies an action to an actor found in the object manager based on a predicate (and action) defined in the eventData object /// /// Usage: /// EventDispatcher.Publish(new EventData( /// EventCategoryType.Object, EventActionType.OnApplyActionToActor, /// (actor) => actor.StatusType = StatusType.Drawn, /// (actor) => actor.ActorType == ActorType.Decorator /// && actor.ID.Equals("green key"), null)); /// /// /// </summary> /// <param name="eventData"></param> private void ApplyActionToActor(EventData eventData) { if (eventData.Predicate != null && eventData.Action != null) { DrawnActor3D actor = null; //we need to look in both lists for the actor since we dont know which it is in actor = opaqueList.Find(eventData.Predicate); if (actor != null) { eventData.Action(actor); } actor = transparentList.Find(eventData.Predicate); if (actor != null) { eventData.Action(actor); } } }
/// <summary> /// Add the actor to the appropriate list based on actor transparency /// </summary> /// <param name="actor"></param> public void Add(DrawnActor3D actor) { if (actor == null) { return; } //collidable zone object has no effect parameters if (actor.EffectParameters == null) { opaqueList.Add(actor); } else { if (actor.EffectParameters.Alpha < 1) { transparentList.Add(actor); } else { opaqueList.Add(actor); } } }
public void Remove(DrawnActor3D actor) { removeList.Add(actor); }