Esempio n. 1
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            // Preload the audio file.
            this.source       = SCNAudioSource.FromFile("art.scnassets/ping.aif");
            this.source.Loops = true;
            this.source.Load();

            if (ARConfiguration.IsSupported)
            {
                // Start the ARSession.
                var configuration = new ARWorldTrackingConfiguration {
                    PlaneDetection = ARPlaneDetection.Horizontal
                };
                this.sceneView.Session.Run(configuration, default(ARSessionRunOptions));

                this.screenCenter = new CGPoint(this.sceneView.Bounds.GetMidX(), this.sceneView.Bounds.GetMidY());

                // Prevent the screen from being dimmed after a while as users will likely have
                // long periods of interaction without touching the screen or buttons.
                UIApplication.SharedApplication.IdleTimerDisabled = true;
            }
            else
            {
                this.ShowUnsupportedDeviceError();
            }
        }
Esempio n. 2
0
        private void LoadSounds()
        {
            this.aahSound            = SCNAudioSource.FromFile("audio/aah_extinction.mp3");
            this.aahSound.Volume     = 1f;
            this.aahSound.Positional = false;
            this.aahSound.Load();

            this.catchFireSound            = SCNAudioSource.FromFile("audio/panda_catch_fire.mp3");
            this.catchFireSound.Volume     = 5f;
            this.catchFireSound.Positional = false;
            this.catchFireSound.Load();

            this.ouchSound            = SCNAudioSource.FromFile("audio/ouch_firehit.mp3");
            this.ouchSound.Volume     = 2f;
            this.ouchSound.Positional = false;
            this.ouchSound.Load();

            this.hitSound            = SCNAudioSource.FromFile("audio/hit.mp3");
            this.hitSound.Volume     = 2f;
            this.hitSound.Positional = false;
            this.hitSound.Load();

            this.hitEnemySound            = SCNAudioSource.FromFile("audio/Explosion1.m4a");
            this.hitEnemySound.Volume     = 2f;
            this.hitEnemySound.Positional = false;
            this.hitEnemySound.Load();

            this.explodeEnemySound            = SCNAudioSource.FromFile("audio/Explosion2.m4a");
            this.explodeEnemySound.Volume     = 2f;
            this.explodeEnemySound.Positional = false;
            this.explodeEnemySound.Load();

            this.jumpSound            = SCNAudioSource.FromFile("audio/jump.m4a");
            this.jumpSound.Volume     = 0.2f;
            this.jumpSound.Positional = false;
            this.jumpSound.Load();

            this.attackSound            = SCNAudioSource.FromFile("audio/attack.mp3");
            this.attackSound.Volume     = 1.0f;
            this.attackSound.Positional = false;
            this.attackSound.Load();

            for (var i = 0; i < Character.StepsCount; i++)
            {
                var audioSource = SCNAudioSource.FromFile($"audio/Step_rock_0{i}.mp3");
                audioSource.Volume     = 0.5f;
                audioSource.Positional = false;
                audioSource.Load();

                this.steps.Add(audioSource);
            }
        }
Esempio n. 3
0
        void SetupMusic()
        {
            // Get an arbitrary node to attach the sounds to.
            SCNNode        node   = GameView.Scene.RootNode;
            SCNAudioSource source = SCNAudioSource.FromFile("game.scnassets/sounds/music.m4a");

            source.Loops        = true;
            source.Volume       = 0.25f;
            source.ShouldStream = true;
            source.Positional   = false;

            SCNAudioPlayer player = SCNAudioPlayer.FromSource(source);

            node.AddAudioPlayer(player);
        }
Esempio n. 4
0
        void SetupSounds()
        {
            // Get an arbitrary node to attach the sounds to
            SCNNode node = GameView.Scene.RootNode;
            // The wind sound
            SCNAudioSource source = SCNAudioSource.FromFile("game.scnassets/sounds/wind.m4a");

            source.Volume = .3f;
            SCNAudioPlayer player = SCNAudioPlayer.FromSource(source);

            source.Loops        = true;
            source.ShouldStream = true;
            source.Positional   = false;
            node.AddAudioPlayer(player);

            // fire
            source            = SCNAudioSource.FromFile("game.scnassets/sounds/flamethrower.mp3");
            source.Loops      = true;
            source.Volume     = 0;
            source.Positional = false;
            flameThrowerSound = SCNAudioPlayer.FromSource(source);
            node.AddAudioPlayer(flameThrowerSound);

            // hit
            hitSound        = SCNAudioSource.FromFile("game.scnassets/sounds/ouch_firehit.mp3");
            hitSound.Volume = 2f;
            hitSound.Load();

            pshhhSound        = SCNAudioSource.FromFile("game.scnassets/sounds/fire_extinction.mp3");
            pshhhSound.Volume = 2f;
            pshhhSound.Load();

            aahSound        = SCNAudioSource.FromFile("game.scnassets/sounds/aah_extinction.mp3");
            aahSound.Volume = 2f;
            aahSound.Load();

            // collectable
            collectPearlSound        = SCNAudioSource.FromFile("game.scnassets/sounds/collect1.mp3");
            collectPearlSound.Volume = 0.5f;
            collectPearlSound.Load();

            collectFlowerSound = SCNAudioSource.FromFile("game.scnassets/sounds/collect1.mp3");
            collectFlowerSound.Load();

            // victory
            victoryMusic        = SCNAudioSource.FromFile("game.scnassets/sounds/Music_victory.mp3");
            victoryMusic.Volume = 0.5f;
        }
		void SetupSounds ()
		{
			// Get an arbitrary node to attach the sounds to
			SCNNode node = GameView.Scene.RootNode;
			// The wind sound
			SCNAudioSource source = SCNAudioSource.FromFile ("game.scnassets/sounds/wind.m4a");
			source.Volume = .3f;
			SCNAudioPlayer player = SCNAudioPlayer.FromSource (source);
			source.Loops = true;
			source.ShouldStream = true;
			source.Positional = false;
			node.AddAudioPlayer (player);

			// fire
			source = SCNAudioSource.FromFile ("game.scnassets/sounds/flamethrower.mp3");
			source.Loops = true;
			source.Volume = 0;
			source.Positional = false;
			flameThrowerSound = SCNAudioPlayer.FromSource (source);
			node.AddAudioPlayer (flameThrowerSound);

			// hit
			hitSound = SCNAudioSource.FromFile ("game.scnassets/sounds/ouch_firehit.mp3");
			hitSound.Volume = 2f;
			hitSound.Load ();

			pshhhSound = SCNAudioSource.FromFile ("game.scnassets/sounds/fire_extinction.mp3");
			pshhhSound.Volume = 2f;
			pshhhSound.Load ();

			aahSound = SCNAudioSource.FromFile ("game.scnassets/sounds/aah_extinction.mp3");
			aahSound.Volume = 2f;
			aahSound.Load ();

			// collectable
			collectPearlSound = SCNAudioSource.FromFile ("game.scnassets/sounds/collect1.mp3");
			collectPearlSound.Volume = 0.5f;
			collectPearlSound.Load ();

			collectFlowerSound = SCNAudioSource.FromFile ("game.scnassets/sounds/collect1.mp3");
			collectFlowerSound.Load ();

			// victory
			victoryMusic = SCNAudioSource.FromFile ("game.scnassets/sounds/Music_victory.mp3");
			victoryMusic.Volume = 0.5f;
		}
Esempio n. 6
0
        public Character()
        {
            for (int i = 0; i < StepsSoundCount; i++)
            {
                steps [i, (int)FloorMaterial.Grass]        = SCNAudioSource.FromFile(string.Format("game.scnassets/sounds/Step_grass_0{0}.mp3", i));
                steps [i, (int)FloorMaterial.Grass].Volume = 0.5f;
                steps [i, (int)FloorMaterial.Rock]         = SCNAudioSource.FromFile(string.Format("game.scnassets/sounds/Step_rock_0{0}.mp3", i));
                if (i < StepsInWaterSoundCount)
                {
                    steps [i, (int)FloorMaterial.Water] = SCNAudioSource.FromFile(string.Format("game.scnassets/sounds/Step_splash_0{0}.mp3", i));
                    steps [i, (int)FloorMaterial.Water].Load();
                }
                else
                {
                    steps [i, (int)FloorMaterial.Water] = steps [i % StepsInWaterSoundCount, (int)FloorMaterial.Water];
                }

                steps [i, (int)FloorMaterial.Rock].Load();
                steps [i, (int)FloorMaterial.Grass].Load();

                // Load the character.
                SCNScene characterScene        = SCNScene.FromFile("game.scnassets/panda.scn");
                SCNNode  characterTopLevelNode = characterScene.RootNode.ChildNodes [0];

                Node = SCNNode.Create();
                Node.AddChildNode(characterTopLevelNode);

                // Configure the "idle" animation to repeat forever
                foreach (var childNode in characterTopLevelNode.ChildNodes)
                {
                    foreach (var key in childNode.GetAnimationKeys())
                    {
                        CAAnimation animation = childNode.GetAnimation(key);
                        animation.UsesSceneTimeBase = false;
                        animation.RepeatCount       = float.PositiveInfinity;
                        childNode.AddAnimation(animation, key);
                    }
                }

                // retrieve some particle systems and save their birth rate
                fireEmitter   = characterTopLevelNode.FindChildNode("fire", true);
                fireBirthRate = fireEmitter.ParticleSystems [0].BirthRate;
                fireEmitter.ParticleSystems [0].BirthRate = 0;
                fireEmitter.Hidden = false;

                smokeEmitter   = characterTopLevelNode.FindChildNode("smoke", true);
                smokeBirthRate = smokeEmitter.ParticleSystems [0].BirthRate;
                smokeEmitter.ParticleSystems [0].BirthRate = 0;
                smokeEmitter.Hidden = false;

                whiteSmokeEmitter   = characterTopLevelNode.FindChildNode("whiteSmoke", true);
                whiteSmokeBirthRate = whiteSmokeEmitter.ParticleSystems [0].BirthRate;
                whiteSmokeEmitter.ParticleSystems [0].BirthRate = 0;
                whiteSmokeEmitter.Hidden = false;

                SCNVector3 min = SCNVector3.Zero;
                SCNVector3 max = SCNVector3.Zero;

                Node.GetBoundingBox(ref min, ref max);

                float radius = (max.X - min.X) * .4f;
                float height = (max.Y - min.Y);

                // Create a kinematic with capsule.
                SCNNode colliderNode = SCNNode.Create();
                colliderNode.Name        = "collider";
                colliderNode.Position    = new SCNVector3(0f, height * .51f, 0f);
                colliderNode.PhysicsBody = SCNPhysicsBody.CreateBody(
                    SCNPhysicsBodyType.Kinematic,
                    SCNPhysicsShape.Create(SCNCapsule.Create(radius, height))
                    );

                // We want contact notifications with the collectables, enemies and walls.
                colliderNode.PhysicsBody.ContactTestBitMask = (nuint)(int)(Bitmask.SuperCollectable | Bitmask.Collectable | Bitmask.Collision | Bitmask.Enemy);
                Node.AddChildNode(colliderNode);

                walkAnimation = LoadAnimationFromSceneNamed("game.scnassets/walk.scn");
                walkAnimation.UsesSceneTimeBase = false;
                walkAnimation.FadeInDuration    = .3f;
                walkAnimation.FadeOutDuration   = .3f;
                walkAnimation.RepeatCount       = float.PositiveInfinity;
                walkAnimation.Speed             = CharacterSpeedFactor;

                // Play foot steps at specific times in the animation
                walkAnimation.AnimationEvents = new [] {
                    SCNAnimationEvent.Create(.1f, (animation, animatedObject, playingBackward) => PlayFootStep()),
                    SCNAnimationEvent.Create(.6f, (animation, animatedObject, playingBackward) => PlayFootStep())
                };
            }
        }