Example #1
0
        protected void LoadCrystalSamples()
        {
            ContentManager forLevel = this.CMProvider.GetForLevel(this.LevelManager.Name);
            string         path1    = Path.Combine("Sounds", this.LevelManager.SequenceSamplesPath ?? "");

            foreach (TrileInstance index1 in Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.crystals.Keys, (Func <TrileInstance, bool>)(x => x.ActorSettings.SequenceSampleName != null)))
            {
                Sequencer.CrystalState crystalState  = this.crystals[index1];
                InstanceActorSettings  actorSettings = index1.ActorSettings;
                try
                {
                    crystalState.Sample = forLevel.Load <SoundEffect>(Path.Combine(path1, actorSettings.SequenceSampleName));
                    if (actorSettings.SequenceAlternateSampleName != null)
                    {
                        crystalState.AlternateSample = forLevel.Load <SoundEffect>(Path.Combine(path1, actorSettings.SequenceAlternateSampleName));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log("Sequencer", LogSeverity.Warning, string.Concat(new object[4]
                    {
                        (object)"Could not find crystal sample : ",
                        (object)crystalState.Sample,
                        (object)" or ",
                        (object)crystalState.AlternateSample
                    }));
                }
                bool flag1 = actorSettings.Sequence[15];
                bool flag2 = false;
                for (int index2 = 0; index2 < 16; ++index2)
                {
                    if (!flag1 && actorSettings.Sequence[index2])
                    {
                        crystalState.Alternate[index2] = flag2 && crystalState.AlternateSample != null;
                        flag2 = !flag2;
                    }
                    flag1 = actorSettings.Sequence[index2];
                }
            }
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            if (!this.Enabled || this.EngineState.Loading || (this.EngineState.Paused || this.EngineState.InMap))
            {
                return;
            }
            double num1 = FezMath.Frac((double)this.SoundManager.PlayPosition.Ticks / (double)this.measureLength.Ticks);

            this.step = (int)Math.Floor(num1 * 16.0);
            double num2   = FezMath.Frac(num1 * 16.0);
            int    index1 = (this.step + 1) % 16;
            bool   flag   = false;

            foreach (TrileInstance index2 in this.crystals.Keys)
            {
                if (index2.ActorSettings.Sequence != null)
                {
                    Sequencer.CrystalState crystalState = this.crystals[index2];
                    bool enabled = index2.Enabled;
                    index2.Enabled = index2.ActorSettings.Sequence.Length > this.step && index2.ActorSettings.Sequence[this.step];
                    if (!enabled && index2.Enabled)
                    {
                        this.LevelManager.RestoreTrile(index2);
                        index2.Hidden  = false;
                        index2.Enabled = true;
                        if (index2.InstanceId == -1)
                        {
                            this.LevelMaterializer.CullInstanceIn(index2);
                        }
                        if (crystalState.Sample != null)
                        {
                            Vector3 position = index2.Position + new Vector3(0.5f);
                            SoundEffectExtensions.EmitAt(crystalState.Alternate[this.step] ? crystalState.AlternateSample : crystalState.Sample, position);
                        }
                        flag = true;
                    }
                    else if (enabled && !index2.Enabled)
                    {
                        this.LevelMaterializer.UnregisterViewedInstance(index2);
                        this.LevelMaterializer.CullInstanceOut(index2, true);
                        this.LevelManager.ClearTrile(index2, true);
                        this.OnDisappear(index2);
                        flag = true;
                    }
                    else if (num2 > 0.449999988079071 && index2.Enabled && (index2.ActorSettings.Sequence.Length > index1 && !index2.ActorSettings.Sequence[index1]))
                    {
                        if ((int)Math.Round((num2 - 0.449999988079071) / 0.550000011920929 * 6.0) % 3 == 0)
                        {
                            if (!index2.Hidden)
                            {
                                index2.Hidden = true;
                                this.LevelMaterializer.UnregisterViewedInstance(index2);
                                this.LevelMaterializer.CullInstanceOut(index2, true);
                                flag = true;
                            }
                        }
                        else if (index2.Hidden)
                        {
                            index2.Hidden = false;
                            if (index2.InstanceId == -1)
                            {
                                this.LevelMaterializer.CullInstanceIn(index2);
                                flag = true;
                            }
                        }
                    }
                }
            }
            if (!flag)
            {
                return;
            }
            this.LevelMaterializer.CommitBatchesIfNeeded();
        }