private void HandleGrabMove(GrabInfo data, Player player, IInteractionDelegate @delegate) { if (this.Grabbables.TryGetValue(data.GrabbableId, out IGrabbable grabbable)) { grabbable.Move(data.CameraInfo); } }
public VortexInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; // Chasm Occluder Box: that will take over the table occluder once table occluder is removed for Vortex Interaction var vortex = SCNNodeExtensions.LoadSCNAsset("chasm_animation"); // Chasm this.chasmPhysics = vortex.FindChildNode("chasm", true); if (this.chasmPhysics == null) { throw new Exception("Vortex has no chasm"); } foreach (var child in this.chasmPhysics.ChildNodes) { if (!String.IsNullOrEmpty(child.Name) && child.Name.StartsWith("occluder", StringComparison.Ordinal)) { child.SetNodeToOccluder(); } } this.chasmPhysics.WorldPosition = new SCNVector3(0f, -0.1f, 0f); // avoid z-fight with ShadowPlane this.chasmPhysics.Scale = this.chasmFinalScale; this.chasmPhysics.StopAllAnimations(); }
private void HandleCatapultReleaseAction(SlingData data, Player player, IInteractionDelegate @delegate) { if (this.catapults.TryGetValue(data.CatapultId, out Catapult catapult)) { catapult.OnLaunch(GameVelocity.Zero); this.ReleaseCatapultGrab(data.CatapultId); } }
public CatapultDisableInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; // Client should try to request the initial catapult disable state from server if (!this.Delegate.IsServer) { this.Delegate.DispatchActionToServer(new GameActionType { Type = GameActionType.GActionType.KnockoutSync }); } }
private void HandleGrabStartAction(GrabInfo data, Player player, IInteractionDelegate @delegate) { if (this.GrabDelegate == null) { throw new Exception("GrabDelegate not set"); } var grabbable = this.GrabbableById(data.GrabbableId); this.GrabbedGrabbable = grabbable; this.GrabDelegate.OnGrabStart(grabbable, data.CameraInfo, player); }
public CatapultInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; this.dummyBall = SCNNodeExtensions.LoadSCNAsset("projectiles_ball_8k"); // stri the geometry out of a low-lod model, assume it doesn't have an lod if (this.dummyBall.Geometry != null) { var lod = SCNNodeExtensions.LoadSCNAsset("projectiles_ball"); if (lod.Geometry != null) { lod.Geometry.Materials = this.dummyBall.Geometry.Materials; // this radius will be replaced by fixLevelsOfDetail // when the level is placed this.dummyBall.Geometry.LevelsOfDetail = new SCNLevelOfDetail[] { SCNLevelOfDetail.CreateWithScreenSpaceRadius(lod.Geometry, 100f) }; } } }
private void HandleTryGrabAction(GrabInfo data, Player player, IInteractionDelegate @delegate) { if (this.GrabDelegate == null) { throw new Exception("GrabDelegate not set"); } // since we can't send a message only to the server, make sure we're the server // when processing. if (@delegate.IsServer) { // Check if player already owned a grabbable // This is to filter tryGrab messages a player might send because it has not received grab message yet foreach (var value in this.Grabbables.Values) { if (value.Player != null && value.Player == player) { return; } } var grabbable = this.GrabbableById(data.GrabbableId); this.GrabDelegate.OnServerGrab(grabbable, data.CameraInfo, player); grabbable.Player = player; // Inform player that the grabbable was grabbed var newData = new GrabInfo(grabbable.GrabbableId, data.CameraInfo); @delegate.DispatchToPlayer(new GameActionType { GrabStart = newData, Type = GameActionType.GActionType.GrabStart }, player); // Update grabbable in the server and clients with a new status // Note: status update only sends the information on whether this.HandleGrabbableStatus(newData); @delegate.ServerDispatchActionToAll(new GameActionType { GrabbableStatus = newData, Type = GameActionType.GActionType.GrabbableStatus }); } }
private void HandleTryReleaseAction(GrabInfo data, Player player, IInteractionDelegate @delegate) { if (this.GrabDelegate == null) { throw new Exception("GrabDelegate not set"); } if (this.Delegate.IsServer) { // Launch if player already grabbed a grabbable var grabbable = this.GrabbableById(data.GrabbableId); if (grabbable.IsGrabbed) { this.GrabDelegate.OnServerRelease(grabbable, data.CameraInfo, player); // Inform player that the grabbable was grabbed var newData = new GrabInfo(grabbable.GrabbableId, data.CameraInfo); @delegate.DispatchToPlayer(new GameActionType { ReleaseEnd = newData, Type = GameActionType.GActionType.ReleaseEnd }, player); } } }
public LeverInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; }
private void HandleReleaseEndAction(GrabInfo data, Player player, IInteractionDelegate @delegate) { this.isTouching = false; }
public GrabInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; }
public HighlightInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; }
public VictoryInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; this.victoryNode = SCNNodeExtensions.LoadSCNAsset("victory"); }