Ejemplo n.º 1
0
        public override void Update(bool isPlayerIn)
        {
            bool isAnyOutriggerMoving = false;

            float delta = Game.FrameTime;

            for (int i = 0; i < outriggers.Length; i++)
            {
                Outrigger r = outriggers[i];
                r.Update(delta);
                isAnyOutriggerMoving = r.State == OutriggersState.Deploying || r.State == OutriggersState.Undeploying || r.VerticalState != UpDownState.None;
            }

            if (sound != null)
            {
                if (isAnyOutriggerMoving)
                {
                    sound.Play();
                }
                else
                {
                    sound.Stop();
                }

                sound.Update();
            }

            if (isPlayerIn && Game.IsKeyDown(Keys.O))
            {
                if (outriggers.All(o => o.State == OutriggersState.Undeployed))
                {
                    foreach (Outrigger o in outriggers)
                    {
                        o.State = OutriggersState.Deploying;
                    }
                }
                else if (outriggers.All(o => o.State == OutriggersState.Deployed))
                {
                    foreach (Outrigger o in outriggers)
                    {
                        o.State         = OutriggersState.Undeploying;
                        o.VerticalState = UpDownState.Up;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Outriggers(Vehicle vehicle, VehicleGadgetEntry dataEntry) : base(vehicle, dataEntry)
        {
            outriggersDataEntry = (OutriggersEntry)dataEntry;

            outriggers = new Outrigger[outriggersDataEntry.Outriggers.Length];

            for (int i = 0; i < outriggersDataEntry.Outriggers.Length; i++)
            {
                outriggers[i] = new Outrigger(vehicle, outriggersDataEntry.Outriggers[i]);
            }

            if (outriggersDataEntry.HasSoundsSet)
            {
                Sound begin = null, loop = null, end = null;

                begin = outriggersDataEntry.SoundsSet.HasBegin ?
                        outriggersDataEntry.SoundsSet.IsDefaultBegin ?
                        null :
                        new Sound(false, outriggersDataEntry.SoundsSet.NormalizedVolume, () => outriggersDataEntry.SoundsSet.BeginSoundFilePath) :
                        null;

                loop = outriggersDataEntry.SoundsSet.HasLoop ?
                       outriggersDataEntry.SoundsSet.IsDefaultLoop ?
                       new Sound(true, outriggersDataEntry.SoundsSet.NormalizedVolume, () => Properties.Resources.default_outriggers_loop) :
                       new Sound(true, outriggersDataEntry.SoundsSet.NormalizedVolume, () => outriggersDataEntry.SoundsSet.LoopSoundFilePath) :
                       null;

                end = outriggersDataEntry.SoundsSet.HasEnd ?
                      outriggersDataEntry.SoundsSet.IsDefaultEnd ?
                      null :
                      new Sound(false, outriggersDataEntry.SoundsSet.NormalizedVolume, () => outriggersDataEntry.SoundsSet.EndSoundFilePath) :
                      null;

                sound = new SoundEffect(begin, loop, end);
            }
        }