예제 #1
0
        public override void Start()
        {
            base.Start();

            Character = Entity.Get <CharacterComponent>();
            Animation = Entity.Get <DroneAnimation>();
            if (Animation == null)
            {
                Animation = new DroneAnimation {
                    Animation = Model.Entity.Get <AnimationComponent>()
                };
                Entity.Add(Animation);
            }

            // Store original bone data, so they can be modified later
            for (int i = 0; i < Model.Skeleton.Nodes.Length; ++i)
            {
                var   nodeRot = Model.Skeleton.NodeTransformations[i].Transform.Rotation;
                var   mat = Matrix.RotationQuaternion(nodeRot);
                float yaw, pitch, roll;
                mat.Decompose(out yaw, out pitch, out roll);
                var node = Model.Model.Skeleton.Nodes[i];
                bones[node.Name] = new Bone
                {
                    EulerAngles = new Vector3(yaw, pitch, roll)
                };
            }

            Entity.Transform.PostOperations.Add(new DronePostTransformUpdater {
                Drone = this
            });

            // Engine sound
            engineSound           = EngineAudioEmitter["Engine"];
            engineSound.IsLooping = true;
            engineSound.Play();

            // Load sounds
            AudioEmitter = Entity.Get <AudioEmitterComponent>();
            deathSound   = AudioEmitter["Death"];

            // Load the variable amount of being hit sounds, "Hit0", "Hit1", etc.
            hitSounds = new RandomSoundSelector(AudioEmitter, "Hit");

            initialHeight = Model.Entity.Transform.Position.Y;

            weapon?.Init(this);
        }
예제 #2
0
        public override void Update()
        {
            // Play a sound
            DebugText.Print($"U to play the Ukelele once", new Int2(200, 580));
            if (Input.IsKeyPressed(Keys.U))
            {
                ukuleleInstance.Stop();
                ukuleleInstance.Play();
            }

            // Press right mouse button for gun fire sound
            DebugText.Print($"Press right mouse button fire gun", new Int2(200, 640));
            if (Input.IsMouseButtonPressed(MouseButton.Right))
            {
                gunSoundEmitter.Play();
            }
        }
예제 #3
0
 private void TestVolumeLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // check that setting the volume before play works.
         mainController.Volume = 0.1f;
         mainController.Play();
     }
     // should hear low volume
     else if (loopCount == 60)
     {
         mainController.Volume = 1f;
         mainController.Play();
     }
     // should hear normal volume
     else if (loopCount == 120)
     {
         // check that setting the volume without listener works too
         game.Audio.RemoveListener(listComps[0]);
         game.Audio.RemoveListener(listComps[1]);
         mainController.Volume = 0.1f;
         game.Audio.AddListener(listComps[0]);
         game.Audio.AddListener(listComps[1]);
         mainController.Play();
     }
     // should hear low volume
     else if (loopCount == 180)
     {
         mainController.Volume = 1f;
         mainController.Play();
     }
     // should hear normal volume
     else if (loopCount == 240)
     {
         mainController.Volume    = 0f;
         mainController.IsLooping = true;
         mainController.Play();
     }
     else if (loopCount > 240)
     {
         // check that sound goes smoothly from nothing to full intensity
         mainController.Volume = Math.Abs((loopCount - 440) / 200f);
     }
     // the sound should go up and down
     if (loopCount == 640)
     {
         game.Exit();
     }
 }