示例#1
0
        public override void GameUpdate(float dtime)
        {
            base.GameUpdate(dtime);

            if (!Running && stomp != null)
            {
                stomp.Stop();
                stomp = null;
            }
        }
示例#2
0
        protected virtual void OnEndsPiranhas()
        {
            if (piranhaFader != null)
            {
                piranhaFader.Fadeout();
                piranhaFader = null;

                //piranhaSwimmingChannel.Looping = false;
                if (piranhaSwimmingChannel != null)
                {
                    piranhaSwimmingChannel.Stop();
                    piranhaSwimmingChannel = null;
                }
            }
        }
示例#3
0
        protected virtual void OnStartsPiranhas()
        {
            piranhas = new Props.Piranha1 {
                Attacking = true
            };
            piranhas.EditorInit();
            piranhaFader             = new EntityFader(piranhas);
            piranhaFader.FadeinTime  = 0.5f;
            piranhaFader.FadeoutTime = 0.5f;
            Scene.Add(piranhas);

            drowningAcc = 0;

            piranhaSwimmingChannel = Program.Instance.SoundManager.GetSFX(Sound.SFX.PiranhaAttack1).Play(new Sound.PlayArgs
            {
                Position = Translation,
                Velocity = MotionUnit.Velocity,
                Looping  = true
            });
        }
示例#4
0
        protected virtual void OnStartsPiranhas()
        {
            piranhas = new Props.Piranha1 { Attacking = true };
            piranhas.EditorInit();
            piranhaFader = new EntityFader(piranhas);
            piranhaFader.FadeinTime = 0.5f;
            piranhaFader.FadeoutTime = 0.5f;
            Scene.Add(piranhas);

            drowningAcc = 0;

            piranhaSwimmingChannel = Program.Instance.SoundManager.GetSFX(Sound.SFX.PiranhaAttack1).Play(new Sound.PlayArgs
            {
                Position = Translation,
                Velocity = MotionUnit.Velocity,
                Looping = true
            });
        }
示例#5
0
        protected virtual void OnEndsPiranhas()
        {
            if (piranhaFader != null)
            {
                piranhaFader.Fadeout();
                piranhaFader = null;

                //piranhaSwimmingChannel.Looping = false;
                if (piranhaSwimmingChannel != null)
                {
                    piranhaSwimmingChannel.Stop();
                    piranhaSwimmingChannel = null;
                }
            }
        }
        public override void Enter()
        {
            base.Enter();
            Program.Instance.Interface.AddChild(new ChallengeMapMenuControl());
            if (MainMenuMusic == null)
            {
                MainMenuMusic = Program.Instance.SoundManager.GetStream(Client.Sound.Stream.MainMenuMusic1).Play(new Sound.PlayArgs { Looping = true });
            }

            if (Program.Instance.Profile == null)
            {
                ShowStartupDialog();
            }
        }
 protected override void EndPerform(bool aborted)
 {
     base.EndPerform(aborted);
     if (timeRunningOut != null)
     {
         timeRunningOut.Stop();
         timeRunningOut = null;
     }
 }
        protected override void StartEffectivePerform()
        {
            base.StartEffectivePerform();

            channel = Program.Instance.SoundManager.GetStream(Stream).Play(new Sound.PlayArgs { Looping = Loop });
        }
 protected override void EndPerform(bool aborted)
 {
     base.EndPerform(aborted);
     if (channel != null)
     {
         if (Loop && !stopped)
         {
             if (FadeoutTime > 0)
                 channel.Stop(FadeoutTime);
             else
                 channel.Stop();
         }
         channel = null;
     }
 }
示例#10
0
        protected override void EndPerform(bool aborted)
        {
            base.EndPerform(aborted);

            //malariaSound.Looping = false;
            malariaSound.Stop();
            malariaSound = null;
            /*Game.Instance.RendererSettingsController.ColorChannelPercentageIncrease.ClearKeys();
            Game.Instance.RendererSettingsController.ColorChannelPercentageIncrease.AddKey(
                new Common.LinearKey<Vector3>
                {
                    Time = 0.2f,
                    TimeType = Common.KeyTimeType.Relative,
                    Value = Program.DefaultSettings.RendererSettings.ColorChannelPercentageIncrease
                });*/
            //mosquitoOpacity.SetTarget(0);
            mosquitos.Remove();
            Game.Instance.Map.MainCharacter.MaxRunSpeed += runSpeedDec;

            //if (text != null && !text.IsRemoved)
            //    text.Remove();
            if (malariaSign != null && !malariaSign.IsRemoved)
            {
                malariaSign.Remove();
                malariaSign = null;
            }
        }
示例#11
0
 protected override void OnRemovedFromScene()
 {
     if (mosquitoSoundChannel != null)
     {
         mosquitoSoundChannel.Stop();
         mosquitoSoundChannel = null;
     }
     base.OnRemovedFromScene();
 }
示例#12
0
 protected override void OnRemovedFromScene()
 {
     if (soundChannel != null)
     {
         soundChannel.Stop();
         soundChannel = null;
     }
     base.OnRemovedFromScene();
 }
示例#13
0
 protected override void OnConstruct()
 {
     base.OnConstruct();
     if (Program.Instance != null && soundChannel == null)
     {
         var sm = Program.Instance.SoundManager;
         soundChannel = sm.GetSFX(Sound.SFX.SilverShot1).Play(new Sound.PlayArgs
         {
             Position = Position,
             Velocity = Vector3.Zero,
             Looping = true
         });
     }
 }
示例#14
0
        public override void Exit()
        {
            Program.Instance.ProgramEvent -= new ProgramEventHandler(Instance_ProgramEvent);

            if (Replay != null)
                Replay.Close();

            if (Mechanics.MotionSimulation is Common.Motion.ThreadSimulationProxy)
                ((Common.Motion.ThreadSimulationProxy)Mechanics.MotionSimulation).Shutdown();

            Scene.Root.ClearChildren();
            ChangeState(null);
            Program.Instance.SoundManager.StopAllChannels();
            Program.Instance.Interface.ClearInterface();
            SceneRendererConnector.Release();
            Renderer.Release(Scene.View.Content);
            Map.Release();
            #if BETA_RELEASE
            dtimeLog.Close();
            #endif

            Program.Instance.Content.Release();
            var mainCharSkinMesh = Program.Instance.Content.Acquire<SkinnedMesh>(
                new SkinnedMeshFromFile("Models/Units/MainCharacter1.x"));
            mainCharSkinMesh.RemoveMeshContainerByFrameName("sword1");
            mainCharSkinMesh.RemoveMeshContainerByFrameName("sword2");
            mainCharSkinMesh.RemoveMeshContainerByFrameName("rifle");

            musicChannel1 = ambienceChannel1 = null;
            Instance = null;
        }
 public override void Exit()
 {
     base.Exit();
     Program.Instance.Interface.ClearInterface();
     if (MainMenuMusic != null)
         MainMenuMusic.Stop();
     MainMenuMusic = null;
 }
示例#16
0
        protected override void OnMoved()
        {
            base.OnMoved();

            if (Running && stomp == null)
            {
                stomp = Program.Instance.SoundManager.GetSFX(Sound.SFX.BullStomp1).Play(new Sound.PlayArgs
                    {
                        GetPosition = () => { return Position; },
                        GetVelocity = () => { if (MotionUnit != null) return MotionUnit.Velocity; else return Vector3.Zero; },
                        Looping = true
                    });
            }
        }
        protected override void OnRemovedFromScene()
        {
            base.OnRemovedFromScene();

            if (lowHealthChannel != null)
            {
                lowHealthChannel.Stop();
                lowHealthChannel = null;
            }
        }
 protected override void OnStateChanged(UnitState previousState)
 {
     if (State != UnitState.Alive)
     {
         if (lowHealthChannel != null)
         {
             lowHealthChannel.Stop();
             lowHealthChannel = null;
         }
     }
     base.OnStateChanged(previousState);
 }
示例#19
0
        protected override void StartPerform()
        {
            InitDelay = 2;
            base.StartPerform();
            var sm = Program.Instance.SoundManager;
            malariaSound = sm.GetSFX(Client.Sound.SFX.Malaria1).Play(
                new Sound.PlayArgs
            {
                Position = Game.Instance.Map.MainCharacter.Translation,
                Velocity = Vector3.Zero,
                Looping = true
            });
            /*Game.Instance.RendererSettingsController.ColorChannelPercentageIncrease.ClearKeys();
            Game.Instance.RendererSettingsController.ColorChannelPercentageIncrease.AddKey(
                new Common.LinearKey<Vector3>
                {
                    Time = 0.2f,
                    TimeType = Common.KeyTimeType.Relative,
                    Value = new Vector3(0, 1, 0)
                });*/
            Game.Instance.Scene.Add(mosquitos);
            runSpeedDec = Game.Instance.Map.MainCharacter.MaxRunSpeed * 0.35f;
            Game.Instance.Map.MainCharacter.MaxRunSpeed -= runSpeedDec;
            //mosquitoOpacity.SetTarget(1);

            Program.Instance.Profile.GetScriptVariable("MalariaIntroduced", (o) =>
            {
                if (o == null)
                {
                    Program.Instance.Profile.SetScriptVariable("MalariaIntroduced", true);
                    new DialogScript
                    {
                        Title = Locale.Resource.HUDMalariaWarningTitle,
                        Text = Locale.Resource.HUDMalariaWarning,
                    }.TryStartPerform();
                }
            });
            TickDamage = 40;
            TickPeriod = 2;

            //Game.Instance.Interface.AddChild(text = new Interface.WarningFlashText { Text = "M a l a r i a !" });
            Game.Instance.Interface.AddChild(malariaSign = new Interface.MalariaSign());
        }
        protected override void OnUpdate(UpdateEventArgs e)
        {
            base.OnUpdate(e);
            if (IsRemoved) return;

            Graphics.Renderer.Renderer.EntityAnimation ea;

            if(Scene.DesignMode)
                ea = Scene.View.Content.Peek<global::Graphics.Renderer.Renderer.EntityAnimation>(MetaEntityAnimation);
            else
                ea = Game.Instance.SceneRendererConnector.EntityAnimations[this];

            // Rotating the torso
            #if DEBUG_HARD
            if (float.IsNaN(TorsoDiffDir))
                throw new Exception("TorsoDiffDir: " + TorsoDiffDir);
            #endif
            float dir = TorsoDiffDir;
            #if DEBUG_HARD
            if (float.IsNaN(dir) || float.IsNaN(TorsoDiffDir))
                throw new Exception("dir: " + dir + ", TorsoDiffDir: " + TorsoDiffDir);
            #endif
            dir = Common.Math.Clamp(dir, -1, 1);
            dirSmooth = dirSmooth * 0.9f + dir * 0.1f;
            float lean = Common.Math.Clamp(TorsoLean*0.3f, -0.5f, 0.5f);
            #if DEBUG_HARD
            if (!float.IsNaN(lean) && !float.IsNaN(dirSmooth))
            {
            #endif
                var mat = Matrix.RotationZ(lean) * Matrix.RotationX(dirSmooth);
                ea.FrameCustomValues["joint2"] = mat;
            #if DEBUG_HARD
                var d1 = mat.Determinant();
                if (d1 == float.NaN) throw new Exception("Rotation matrix contains NaN");
                if (mat.M12 == float.NaN) throw new Exception("Rotation matrix contains NaN");
                if (mat.M22 == float.NaN) throw new Exception("Rotation matrix contains NaN");
                if (mat.M32 == float.NaN) throw new Exception("Rotation matrix contains NaN");

                var d2 = ea.FrameCustomValues["joint2"].Determinant();
                if (d2 == float.NaN) throw new Exception("Rotation matrix contains NaN");
                if (ea.FrameCustomValues["joint2"].M12 == float.NaN) throw new Exception("Rotation matrix contains NaN");
                if (ea.FrameCustomValues["joint2"].M22 == float.NaN) throw new Exception("Rotation matrix contains NaN");
                if (ea.FrameCustomValues["joint2"].M32 == float.NaN) throw new Exception("Rotation matrix contains NaN");
            }
            else
                throw new Exception("DirSmooth: " + dirSmooth + " Lean: " + lean);
            #endif
            // Attaching weapon
            if (SelectedWeapon == 0 && !isSlamming)
            {
                var hand = ea.GetFrame("sword1");
                if (hand != null)
                {
                    MeleeWeaponModel.WorldMatrix = ea.FrameTransformation[hand];
                    RangedWeaponModel.WorldMatrix = Matrix.Scaling(0.001f, 0.001f, 0.001f);
                }
                //No idea why this line was ever written
                //ea.FrameCustomValues["joint32"] = Matrix.Identity;
            }
            else if (SelectedWeapon == 1 && !isSlamming)
            {
                var hand = ea.GetFrame("rifle");
                if (hand != null)
                {
                    RangedWeaponModel.WorldMatrix = ea.FrameTransformation[hand];
                    MeleeWeaponModel.WorldMatrix = Matrix.Scaling(0.001f, 0.001f, 0.001f);
                }
                //Matrix m = ea.FrameCustomValues["joint32"];
                //var joint32 = ea.GetFrame("joint32");
                //ea.FrameTransformation[joint32] = ea.FrameTransformation[joint32] * Matrix.RotationX(-2);
                //offset += e.Dtime;
                //ea.FrameCustomValues["joint32"] = Matrix.RotationZ(0.2f);
            }
            else if(!isSlamming)
            {
                throw new NotImplementedException();
            }

            if (HitPoints < MaxHitPoints * 0.2f && !wasLowHealth && State == UnitState.Alive)
            {
                lowHealthChannel = Program.Instance.SoundManager.GetSFX(Sound.SFX.LowHealthBeat1).Play(new Sound.PlayArgs { Looping = true });
                wasLowHealth = true;
            }
            else if (HitPoints >= MaxHitPoints * 0.2f && wasLowHealth)
            {
                lowHealthChannel.Stop();
                lowHealthChannel = null;
                wasLowHealth = false;
            }

            if (RageLevel >= 4)
            {
                var back = ea.GetFrame("joint3");

                RageWings.WorldMatrix = ea.FrameTransformation[back];
                //Matrix.RotationZ(-(float)Math.PI / 4f) *
                //var ea1 = Scene.View.Content.Peek<global::Graphics.Renderer.Renderer.EntityAnimation>(MetaEntityAnimation);

                //var leftHand = ea.GetFrame("joint9");
                //var righthand = ea.GetFrame("joint32");

                //rageEffectLeftHand.WorldMatrix = Matrix.Scaling(10, 10, 10) * rageEffectLeftHand.WorldMatrix * leftHand.CombinedTransform;
            }
        }
示例#21
0
 protected override void EndPerform(bool aborted)
 {
     base.EndPerform(aborted);
     if (channel != null)
     {
         if (Loop)
             channel.Stop();
         channel = null;
     }
 }
        protected override void StartPerform()
        {
            EffectiveDuration = 0.2f + 0.3f / (0.3f * Performer.RageLevel + 1);
            Cooldown = 2f + 1f / (0.3f * Performer.RageLevel + 1);
            var d = (TargetPosition - Mediator.Position);
            Projectile.TimeToLive = d.Length() / Speed;
            ((GhostBulletProjectile)Projectile).TargetPosition = TargetPosition;
            Performer.PlayAnimation(UnitAnimations.FireRifle);

            Performer.MotionUnit.RunVelocity = Vector2.Zero;

            Performer.Scene.Add(new Effects.FireGunEffect
            {
                Translation = Performer.Translation +
                    Vector3.TransformCoordinate(new Vector3(1.4f * 0.7f, 0, 1.55f),
                    Matrix.RotationZ(Performer.LookatDir)),
                Direction = Common.Math.Vector3FromAngleXY(Performer.LookatDir)
            });
            var sm = Program.Instance.SoundManager;
            sm.GetSFX(Client.Sound.SFX.GhostBulletFire1).Play(new Sound.PlayArgs());
            ghostBullet = sm.GetSFX(Client.Sound.SFX.SilverShot1).Play(new Sound.PlayArgs
            {
                GetPosition = () => { return ((GhostBulletProjectile)Projectile).TargetPosition; },
                GetVelocity = () => { return ((GhostBulletProjectile)Projectile).Velocity; }
            });
            //sm.GetSoundResourceGroup(
            //     sm.GetSFX(global::Client.Sound.SFX.MetalMovement1),
            //     sm.GetSFX(global::Client.Sound.SFX.MetalMovement2),
            //     sm.GetSFX(global::Client.Sound.SFX.MetalMovement3),
            //     sm.GetSFX(global::Client.Sound.SFX.MetalMovement4)
            // ).Play(new Sound.PlayArgs());
            base.StartPerform();
            ResetCooldown();
        }
示例#23
0
        public override void Update(float dtime)
        {
            base.Update(dtime);
            float prevLeftTime = Time - (TimePassed - Game.Instance.GameDTime);

            if (!timeHasRunOut)
            {
                if (TimePassed > Time)
                {
                    Game.Instance.Map.MainCharacter.TurnIntoZombie();
                    new FinishScript
                    {
                        State = GameState.Lost,
                        Reason = Locale.Resource.HUDYouRanOutOfTime,
                        InitDelay = 1
                    }.TryStartPerform();
                    if (timeRunningOut != null)
                        timeRunningOut.Stop();
                    timeRunningOut = null;
                    timeHasRunOut = true;
                }

                float leftTime = Time - TimePassed;
                foreach (var v in timeWarnings)
                {
                    if (prevLeftTime > v.Time && leftTime <= v.Time)
                    {
                        Game.Instance.Interface.AddChild(new Interface.TimeLeftPopupText
                        {
                            Text = v.Text,
                            DisplayTime = v.DisplayTime
                        });
                        if (timeRunningOut == null && v.Time == 5)
                        {
                            timeRunningOut = Program.Instance.SoundManager.GetSFX(Client.Sound.SFX.TimeRunningOut1).Play(new Sound.PlayArgs { Looping = true });
                        }
                        else if (timeRunningOut == null && v.Time > 9)
                        {
                            timeRunningOut = Program.Instance.SoundManager.GetSFX(Client.Sound.SFX.TimeRunningOut1).Play(new Sound.PlayArgs());
                            timeRunningOut.PlaybackStopped += new EventHandler(timeRunningOut_PlaybackStopped);
                        }
                    }
                }
            }
        }
示例#24
0
 protected override void OnUpdate(UpdateEventArgs e)
 {
     if (Game.Instance != null)
     {
         if (Game.Instance.GameState != GameState.Playing)
         {
             if (piranhaSwimmingChannel != null)
             {
                 piranhaSwimmingChannel.Stop();
                 piranhaSwimmingChannel = null;
             }
         }
     }
     base.OnUpdate(e);
     if (DesignMode) return;
     UpdateHUDStats();
 }
示例#25
0
 void timeRunningOut_PlaybackStopped(object sender, EventArgs e)
 {
     timeRunningOut = null;
 }
 public override void Enter()
 {
     base.Enter();
     Program.Instance.Interface.AddChild(new MainMenuControl());
     if (MainMenuMusic == null)
         MainMenuMusic = Program.Instance.SoundManager.GetStream(Client.Sound.Stream.MainMenuMusic1).Play(new Sound.PlayArgs { Looping = true });
 }