Esempio n. 1
0
        public override void Load()
        {
            base.Load();

            _carBodyNode = this.FindChildNode("rccarBody", true);
            _wingNode    = this.FindChildNode("wing", true);
            _pipeNode    = this.FindChildNode("pipe", true);

            _pipeNode.AddParticleSystem(_exhaust);

            this.Scale       = new SCNVector3(_modelScale, _modelScale, _modelScale);
            this.EulerAngles = new SCNVector3(0, (float)Math.PI / 2, 0);
        }
Esempio n. 2
0
        private void LoadParticles()
        {
            var particleScene = SCNScene.FromFile("art.scnassets/character/jump_dust.scn");
            var particleNode  = particleScene.RootNode.FindChildNode("particle", true);

            this.jumpDustParticle = particleNode.ParticleSystems.FirstOrDefault();

            particleScene = SCNScene.FromFile("art.scnassets/particles/burn.scn");
            var burnParticleNode = particleScene.RootNode.FindChildNode("particles", true);

            var particleEmitter = new SCNNode();

            this.characterOrientation.AddChildNode(particleEmitter);

            this.fireEmitter           = burnParticleNode.FindChildNode("fire", true).ParticleSystems[0];
            this.fireEmitterBirthRate  = fireEmitter.BirthRate;
            this.fireEmitter.BirthRate = 0f;

            this.smokeEmitter           = burnParticleNode.FindChildNode("smoke", true).ParticleSystems[0];
            this.smokeEmitterBirthRate  = smokeEmitter.BirthRate;
            this.smokeEmitter.BirthRate = 0f;

            this.whiteSmokeEmitter           = burnParticleNode.FindChildNode("whiteSmoke", true).ParticleSystems[0];
            this.whiteSmokeEmitterBirthRate  = whiteSmokeEmitter.BirthRate;
            this.whiteSmokeEmitter.BirthRate = 0f;

            particleScene           = SCNScene.FromFile("art.scnassets/particles/particles_spin.scn");
            this.spinParticle       = (particleScene.RootNode.FindChildNode("particles_spin", true)?.ParticleSystems?.FirstOrDefault());
            this.spinCircleParticle = (particleScene.RootNode.FindChildNode("particles_spin_circle", true)?.ParticleSystems?.FirstOrDefault());

            particleEmitter.Position = new SCNVector3(0f, 0.05f, 0f);
            particleEmitter.AddParticleSystem(this.fireEmitter);
            particleEmitter.AddParticleSystem(this.smokeEmitter);
            particleEmitter.AddParticleSystem(this.whiteSmokeEmitter);

            this.spinParticleAttach = this.model.FindChildNode("particles_spin_circle", true);
        }
Esempio n. 3
0
        protected void PerformEnemyDieWithExplosion(SCNNode enemy, SCNVector3 direction)
        {
            var explositionScene = SCNScene.FromFile("art.scnassets/enemy/enemy_explosion.scn");

            if (explositionScene != null)
            {
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration       = 0.4f;
                SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut);

                SCNTransaction.SetCompletionBlock(() =>
                {
                    explositionScene.RootNode.EnumerateHierarchy((SCNNode node, out bool stop) =>
                    {
                        stop = false;
                        if (node.ParticleSystems != null)
                        {
                            foreach (var particle in node.ParticleSystems)
                            {
                                enemy.AddParticleSystem(particle);
                            }
                        }
                    });

                    // Hide
                    if (enemy.ChildNodes.Length > 0)
                    {
                        enemy.ChildNodes[0].Opacity = 0f;
                    }
                });

                direction.Y = 0;
                enemy.RemoveAllAnimations();
                enemy.EulerAngles = new SCNVector3(enemy.EulerAngles.X, enemy.EulerAngles.X + (float)Math.PI * 4.0f, enemy.EulerAngles.Z);

                enemy.WorldPosition += SCNVector3.Normalize(direction) * 1.5f;
                this.PositionAgentFromNode();

                SCNTransaction.Commit();
            }
            else
            {
                Console.WriteLine("Missing enemy_explosion.scn");
            }
        }
Esempio n. 4
0
        SCNNode CreateTorchNode()
        {
            SCNGeometry geometry = SCNBox.Create(20f, 100f, 20f, 0f);

            geometry.FirstMaterial.Diffuse.Contents = AppKit.NSColor.Brown;
            var template = new SCNNode {
                Geometry = geometry
            };

            var particleEmitter = new SCNNode {
                Position = new SCNVector3(0f, 50f, 0f)
            };

            SCNParticleSystem fire = GameSimulation.LoadParticleSystemWithName("torch", "spark");

            particleEmitter.AddParticleSystem(fire);
            particleEmitter.Light = TorchLight;

            template.AddChildNode(particleEmitter);
            return(template);
        }
Esempio n. 5
0
        SCNNode CreateLargeBanana()
        {
            //Create model
            if (largeBananaCollectable == null)
            {
                var   node      = GameSimulation.LoadNodeWithName("banana", GameSimulation.PathForArtResource("level/banana.dae"));
                float scaleMode = 0.5f * 10 / 4;
                node.Scale = new SCNVector3(scaleMode, scaleMode, scaleMode);


                SCNSphere       sphereGeometry = SCNSphere.Create(100);
                SCNPhysicsShape physicsShape   = SCNPhysicsShape.Create(sphereGeometry, new SCNPhysicsShapeOptions());
                node.PhysicsBody = SCNPhysicsBody.CreateBody(SCNPhysicsBodyType.Kinematic, physicsShape);

                // Only collide with player and ground
                node.PhysicsBody.CollisionBitMask = GameCollisionCategory.Player | GameCollisionCategory.Ground;
                // Declare self in the banana category
                node.PhysicsBody.CategoryBitMask = GameCollisionCategory.Coin;

                // Rotate forever.
                SCNAction rotateCoin = SCNAction.RotateBy(0f, 8f, 0f, 2f);
                SCNAction repeat     = SCNAction.RepeatActionForever(rotateCoin);

                node.Rotation = new SCNVector4(0f, 1f, 0f, (nfloat)Math.PI / 2);
                node.RunAction(repeat);

                largeBananaCollectable = node;
            }

            SCNNode nodeSparkle = largeBananaCollectable.Clone();

            SCNParticleSystem newSystem = GameSimulation.LoadParticleSystemWithName("sparkle");

            nodeSparkle.AddParticleSystem(newSystem);

            return(nodeSparkle);
        }
Esempio n. 6
0
		SCNNode CreateTorchNode ()
		{
			SCNGeometry geometry = SCNBox.Create (20f, 100f, 20f, 0f);
			geometry.FirstMaterial.Diffuse.Contents = AppKit.NSColor.Brown;
			var template = new SCNNode {
				Geometry = geometry
			};

			var particleEmitter = new SCNNode {
				Position = new SCNVector3 (0f, 50f, 0f)
			};

			SCNParticleSystem fire = GameSimulation.LoadParticleSystemWithName ("torch", "spark");
			particleEmitter.AddParticleSystem (fire);
			particleEmitter.Light = TorchLight;

			template.AddChildNode (particleEmitter);
			return template;
		}
Esempio n. 7
0
		//present physics field slide
		void ShowPhysicsFields ()
		{
			var dz = 50f;

			SCNTransaction.Begin ();
			SCNTransaction.AnimationDuration = 0.75f;
			SpotLightNode.Light.Color = SKColorHelper.FromCommonWhiteAlpha (0.5f, 1.0f);
			AmbientLightNode.Light.Color = SKColor.Black;
			SCNTransaction.Commit ();

			//remove gravity for this slide
			Scene.PhysicsWorld.Gravity = SCNVector3.Zero;

			//move camera
			var tr = SCNAction.MoveBy (new SCNVector3 (0, 0, dz), 1);
			tr.TimingMode = SCNActionTimingMode.EaseInEaseOut;
			CameraHandle.RunAction (tr);

			//add particles
			FieldEmitter = SCNNode.Create ();
			FieldEmitter.Position = new SCNVector3 (CameraHandle.Position.X, 5, dz);

			var ps = SCNParticleSystem.Create ("bubbles.scnp", "assets.scnassets/particles/");

			ps.ParticleColor = SKColorHelper.FromCommonRGBA (0.8f, 0, 0, 1.0f);
			ps.ParticleColorVariation = new SCNVector4 (0.3f, 0.2f, 0.3f, 0.0f);
			ps.SortingMode = SCNParticleSortingMode.Distance;
			ps.BlendMode = SCNParticleBlendMode.Alpha;
			#if __IOS__
			var right = new UIImage ("images/cubemap/right.jpg");
			var left = new UIImage ("images/cubemap/left.jpg");
			var top = new UIImage ("images/cubemap/top.jpg");
			var bottom = new UIImage ("images/cubemap/bottom.jpg");
			var front = new UIImage ("images/cubemap/front.jpg");
			var back = new UIImage ("images/cubemap/back.jpg");
			#else
			var right = new NSImage (NSBundle.MainBundle.PathForResource ("images/cubemap/right", "jpg"));
			var left = new NSImage (NSBundle.MainBundle.PathForResource ("images/cubemap/left", "jpg"));
			var top = new NSImage (NSBundle.MainBundle.PathForResource ("images/cubemap/top", "jpg"));
			var bottom = new NSImage (NSBundle.MainBundle.PathForResource ("images/cubemap/bottom", "jpg"));
			var front = new NSImage (NSBundle.MainBundle.PathForResource ("images/cubemap/front", "jpg"));
			var back = new NSImage (NSBundle.MainBundle.PathForResource ("images/cubemap/back", "jpg"));
			#endif
			var cubMap = new NSMutableArray ();
			cubMap.AddObjects (new NSObject[] { right, left, top, bottom, front, back });
			ps.ParticleImage = cubMap;
			ps.FresnelExponent = 2;
			ps.ColliderNodes = new [] { FloorNode, MainWall };

			ps.EmitterShape = SCNBox.Create (200, 0, 100, 0);

			FieldEmitter.AddParticleSystem (ps);
			Scene.RootNode.AddChildNode (FieldEmitter);

			//field
			FieldOwner = SCNNode.Create ();
			FieldOwner.Position = new SCNVector3 (CameraHandle.Position.X, 50, dz + 5);

			var field = SCNPhysicsField.CreateRadialGravityField ();
			field.HalfExtent = new SCNVector3 (100, 100, 100);
			field.MinimumDistance = 20.0f;
			field.FalloffExponent = 0;
			FieldOwner.PhysicsField = field;
			FieldOwner.PhysicsField.Strength = 0.0f;
			Scene.RootNode.AddChildNode (FieldOwner);
		}