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(); }
public GameObjectPool() { this.cannonball = SCNNodeExtensions.LoadSCNAsset("projectiles_ball"); this.chicken = SCNNodeExtensions.LoadSCNAsset("projectiles_chicken"); this.InitialPoolCount = 30; }
private void PrepareForVortexAnimationEnded() { if (this.Delegate == null) { throw new Exception("No Delegate"); } this.EnumerateThroughBlocks((physicsBody) => { physicsBody.Damping = 0.1f; }); // Chasm Expand Object (used for animation) var vortex = SCNNodeExtensions.LoadSCNAsset("chasm_animation"); this.vortexCylinder = vortex.FindChildNode("Cylinder", true); if (this.vortexCylinder == null) { throw new Exception("Vortex has no cone"); } this.Delegate.AddNodeToLevel(this.vortexCylinder); this.vortexCylinder.StopAllAnimations(); this.vortexCylinder.PlayAllAnimations(); this.vortexCylinder.Hidden = true; // Vortex Cylinder is only used for deriving the vortex shape animation // Chasm Expand Object (used for animation) this.chasmExpandObject = vortex.FindChildNode("chasm", true); if (this.chasmExpandObject == null) { throw new Exception("Vortex has no chasm"); } foreach (var child in this.chasmExpandObject.ChildNodes) { if (!string.IsNullOrEmpty(child.Name) && child.Name.StartsWith("occluder", StringComparison.Ordinal)) { child.SetNodeToOccluder(); } } this.Delegate.AddNodeToLevel(this.chasmExpandObject); this.chasmExpandObject.StopAllAnimations(); this.chasmExpandObject.PlayAllAnimations(); var vortexShape = this.vortexCylinder.PresentationNode.Scale; this.lastOuterRadius = vortexShape.X; this.lastVortexCenterY = this.vortexCylinder.PresentationNode.WorldPosition.Y; this.lastVortexHeight = vortexShape.Y; this.lastFront = this.vortexCylinder.PresentationNode.WorldFront; this.startVortexTime = GameTime.Time; }
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) }; } } }
public static SCNNode ReplaceCatapultPlaceholder(SCNNode placeholder) { var node = SCNNodeExtensions.LoadSCNAsset("catapult"); // somehow setting the world transform doesn't update the Euler angles (180, 0, 180) is decoded // but need it to be 0, 180, 0 node.Transform = placeholder.Transform; node.EulerAngles = placeholder.EulerAngles; // Add physics body to it node.WorldPosition += new SCNVector3(0f, 0.2f, 0f); node.PhysicsBody?.ResetTransform(); var baseGeomNode = node.FindChildNode("catapultBase", true); if (baseGeomNode == null) { throw new Exception("No catapultBase"); } var prongGeomNode = node.FindChildNode("catapultProngs", true); if (prongGeomNode == null) { throw new Exception("No catapultProngs"); } // shift center of mass of the prong from the bottom // the 0.55 value is from experimentation var prongPivotShiftUp = new SCNVector3(0f, 0.55f, 0f); prongGeomNode.Pivot = SCNMatrix4.CreateTranslation(prongPivotShiftUp); prongGeomNode.Position += prongPivotShiftUp; var baseShape = SCNPhysicsShape.Create(baseGeomNode, new SCNPhysicsShapeOptions() { ShapeType = SCNPhysicsShapeType.ConvexHull }); var prongShape = SCNPhysicsShape.Create(prongGeomNode, new SCNPhysicsShapeOptions() { ShapeType = SCNPhysicsShapeType.ConvexHull }); var compoundShape = SCNPhysicsShape.Create(new SCNPhysicsShape[] { baseShape, prongShape }, new SCNMatrix4[] { SCNMatrix4.Identity, SCNMatrix4.Identity }); if (node.PhysicsBody != null) { node.PhysicsBody.PhysicsShape = compoundShape; } // rename back to placeholder name must happen after gameObject is assigned // currently placeholders are all Catapult1 to Catapult6, they may be under a teamA, teamB parent // so stash the placeholder name for later if (!string.IsNullOrEmpty(placeholder.Name)) { node.SetValueForKey(new NSString(placeholder.Name), new NSString("nameRestore")); } placeholder.ParentNode.ReplaceChildNode(placeholder, node); node.Name = "catapult"; return(node); }
public VictoryInteraction(IInteractionDelegate @delegate) { this.Delegate = @delegate; this.victoryNode = SCNNodeExtensions.LoadSCNAsset("victory"); }