Exemplo n.º 1
0
 public void Construct(IMovable movement, IRotatable rotatable, IWave wave, IKillable killable)
 {
     this.killable  = killable;
     this.movement  = movement;
     this.rotatable = rotatable;
     this.wave      = wave;
 }
Exemplo n.º 2
0
        private void openAnalogGraph()
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string[] linesRead = File.ReadAllLines(openFileDialog1.FileName);

            m_currentWave = new Wave();

            double highPeak = 0;
            double lowPeak  = 0;
            double x        = 0;

            for (int i = 0; i < linesRead.Length; i++)
            {
                double y = Convert.ToDouble(linesRead[i]);
                m_currentWave.PointsList.Add(x, y);

                x       += m_SamplingPeriod;
                highPeak = Math.Max(highPeak, y);
                lowPeak  = Math.Min(lowPeak, y);
            }

            // Set graph viewable area
            m_GraphAxisYMax   = Math.Round(highPeak + highPeak / 4, 2);
            m_GraphAxisYMin   = Math.Round(lowPeak + lowPeak / 4, 2);
            m_GraphXAxisRange = (int)x;
        }
Exemplo n.º 3
0
 public AmplitudeWaveTransformer(IWave baseWave, double multiplier, double horizontalOffset, double verticalOffset)
 {
     _baseWave         = baseWave;
     _multiplier       = multiplier;
     _horizontalOffset = horizontalOffset;
     _verticalOffset   = verticalOffset;
 }
Exemplo n.º 4
0
    public GameObject[] ShortWaves;                      // array of waves prefab objects
    #endregion
    // Use this for initialization
    void Start()
    {
        isWaveLoaded  = false;
        numberOfWaves = waves.Length;
        if (numberOfWaves == 0)
        {
            return;
        }

        if (!GameSettings.Instance.IsGameLong)
        {
            ShortWaves[0].GetComponent <WaveStandard>().WavetimeinSeconds = (waves[0].GetComponent <WaveStandard>().WavetimeinSeconds / 2);
            ShortWaves[1].GetComponent <WaveStandard>().WavetimeinSeconds = (waves[1].GetComponent <WaveStandard>().WavetimeinSeconds / 2);
            ShortWaves[2].GetComponent <WaveStandard>().WavetimeinSeconds = (waves[2].GetComponent <WaveStandard>().WavetimeinSeconds / 2);


            currentWave  = Instantiate(ShortWaves[waveNum]);
            wave         = currentWave.GetComponent <IWave>();
            isWaveLoaded = true;
            WS           = GetCurrWave();
        }
        else
        {
            currentWave  = Instantiate(waves[waveNum]);
            wave         = currentWave.GetComponent <IWave>();
            isWaveLoaded = true;
            WS           = GetCurrWave();
        }
    }
Exemplo n.º 5
0
 public double GetLength(IWave<IEnumerable<Point>> wave, Point point)
 {
     var chain = wave.Peak.ToList();
     var min = chain.First().DistanceTo(point);
     var max = chain.Length();
     return min + Weight*(max - min);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Create wave map
        /// </summary>
        /// <param name="random">random number generator</param>
        public WaveMap(Random random)
        {
            WaveBuilder wavePackBuilder = new WaveBuilder();

            waveX = wavePackBuilder.Build(3, random);
            waveY = wavePackBuilder.Build(3, random);
        }
Exemplo n.º 7
0
        public WavePlayer(IWave wave, int sampleRate = 48000)
        {
            _waveProvider = new WaveProvider(sampleRate, new[] { wave });
            _wavePlayer   = new WaveOutEvent();

            _wavePlayer.Init(_waveProvider);
        }
Exemplo n.º 8
0
        private void openDigitalGraph()
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string[] linesRead = File.ReadAllLines(openFileDialog1.FileName);

            m_currentWave = new Wave();

            double highPeak = 0;
            double lowPeak  = 0;
            double x        = 0;

            for (int i = 0; i < linesRead.Length; i++)
            {
                int digitalValue = int.Parse(linesRead[i]);

                double y = (digitalValue * (m_ADVoltageHigh - m_ADVoltageLow) / Math.Pow(2, m_ADBits)) + m_ADVoltageLow;

                m_currentWave.PointsList.Add(x, y);

                x       += m_SamplingPeriod;
                highPeak = Math.Max(highPeak, y);
                lowPeak  = Math.Min(lowPeak, y);
            }

            // Set graph viewable area
            m_GraphAxisYMax   = Math.Round(highPeak + highPeak / 4, 2);
            m_GraphAxisYMin   = Math.Round(lowPeak + lowPeak / 4, 2);
            m_GraphXAxisRange = (int)x;
        }
Exemplo n.º 9
0
        private void DrawSquareWave()
        {
            // Set the x axis range to be the period of the wave.
            m_GraphXAxisRange = double.Parse(textBox_Period.Text);

            // Get the amplitude of the wave from the user
            double amplitude = Convert.ToDouble(textBox_Amplitude.Text);

            // Get the phase of the wave from the user
            double phase = Convert.ToDouble(textBox_Phase.Text);

            // Create the square wave
            //m_SquareWave = new SquareWave(amplitude,
            //                              m_GraphXAxisRange,
            //                              phase,
            //                              m_SamplingPeriod);

            m_SquareWave = new SquareWave(amplitude,
                                          m_GraphXAxisRange,
                                          (int)phase,
                                          m_SamplingPeriod);

            // Set the graph y axis limits
            m_GraphAxisYMax = Math.Round(amplitude + (amplitude / 4), 2);
            m_GraphAxisYMin = -1 * m_GraphAxisYMax;


            // Set the current wave
            m_currentWave = m_SquareWave;
        }
Exemplo n.º 10
0
        public ColorMapCache(IWave waveX, IWave waveY, int width, int height, double precision)
        {
            this.precision = precision;

            int intWidth  = (int)Math.Ceiling(width / precision);
            int intHeight = (int)Math.Ceiling(height / precision);

            internalData = new double[intWidth, intHeight];

            double value;

            for (int x = 0; x < intWidth; x++)
            {
                for (int y = 0; y < intHeight; y++)
                {
                    value = waveX[x / 100.0] + waveY[y / 100.0];

                    while (value > 1.0)
                    {
                        value -= 1.0;
                    }

                    while (value < 0)
                    {
                        value += 1.0;
                    }

                    internalData[x, y] = (value + 1.0) / 2.0;
                }
            }
        }
Exemplo n.º 11
0
        public IWave AddChild(IWave childWave)
        {
            childWave.ParentWaveId = WaveId;

            ChildWaves.Add(childWave);

            return(this);
        }
Exemplo n.º 12
0
        public void PlayWave(IWave wave)
        {
            var player = new WavePlayer(wave);

            player.Play();

            _tracks.AddTrack(player);
        }
Exemplo n.º 13
0
        private void LoadVoices(BinaryReaderEx reader)
        {
            if (this.SscfHeader.NumWaves <= 0)
            {
                return;
            }

            reader.BaseStream.Position = this.SscfHeader.OffsetB;
            this.VoiceOffsets          = new List <int>(this.SscfHeader.NumWaves);
            this.Children = new List <INavigable>(this.SscfHeader.NumWaves);

            for (var i = 0; i < this.SscfHeader.NumWaves; i++)
            {
                this.VoiceOffsets.Add(reader.ReadInt32());
            }

            foreach (int offset in this.VoiceOffsets)
            {
                reader.BaseStream.Position = offset;
                WaveHeader waveHeader = ReadWaveHeader(reader);
                IWave      voice      = null;
                switch (waveHeader.Format)
                {
                case WaveCompressionFormat.PCM:
                    voice = new PcmWave()
                    {
                        Parent = this, WaveHeader = waveHeader
                    };
                    break;

                case WaveCompressionFormat.Vorbis:
                    voice = new VorbisWave()
                    {
                        Parent = this, WaveHeader = waveHeader
                    };
                    break;

                case WaveCompressionFormat.ADPCM:
                    voice = new AdpcmWave()
                    {
                        Parent = this, WaveHeader = waveHeader
                    };
                    break;

                case WaveCompressionFormat.ATRAC3:
                case WaveCompressionFormat.ATRAC3_Too:
                case WaveCompressionFormat.XMA:
                    throw new InvalidOperationException("Unsupported Wave Format: " + waveHeader.Format);

                default:
                    throw new InvalidOperationException("Unknown Wave Format: 0x" + ((int)waveHeader.Format).ToString("X"));
                }

                this.Children.Add(voice);
                voice.LoadData(reader);
            }
        }
Exemplo n.º 14
0
 public AddWave(IWave wave1, IWave wave2)
 {
     this.wave1        = wave1;
     this.wave2        = wave2;
     this.period1      = wave1.Period;
     this.period2      = wave2.Period;
     this.mean_voltage = wave1.MeanVoltage + wave2.MeanVoltage;
     this.period       = GetLeastCommonMultiple(wave1.Period, wave2.Period);
 }
Exemplo n.º 15
0
        public void Trigger()
        {
            ++this.count;
            this.timeLeft = TimeInSecondsBetweenTwoWaves;

            IWave wave = this.CreateWave();

            wave.SpawnIn(this.world);
            this.Launched(this, wave);
        }
Exemplo n.º 16
0
        public override WaveBuilderTrendStatus Execute(IMove move)
        {
            IWave childWave = Wave.Open(IdProvider.CurrentId, ParentId, move);

            Item.Wave.AddChild(childWave);

            Item.State = WaveBuilderState.S1;

            return(WaveBuilderTrendStatus.Continue);
        }
Exemplo n.º 17
0
        public ColorMap(Random random, int width, int height)
        {
            WaveBuilder waveBuilder = new WaveBuilder();

            wavePackRedX   = waveBuilder.Build(3, random);
            wavePackGreenX = waveBuilder.Build(3, random);
            wavePackBlueX  = waveBuilder.Build(3, random);

            wavePackRedY   = waveBuilder.Build(3, random);
            wavePackGreenY = waveBuilder.Build(3, random);
            wavePackBlueY  = waveBuilder.Build(3, random);

            colorMapCacheRed   = new ColorMapCache(wavePackRedX, wavePackRedY, width, height, precision);
            colorMapCacheGreen = new ColorMapCache(wavePackGreenX, wavePackGreenY, width, height, precision);
            colorMapCacheBlue  = new ColorMapCache(wavePackBlueX, wavePackBlueY, width, height, precision);
        }
Exemplo n.º 18
0
        private void LateUpdate()
        {
            if (_waves == null)
            {
                _waves = FindObjectOfType <EnemySpawner>().Waves;
            }

            coinLabel.text = _playerState.Coin.ToString();
            lifeLabel.text = _playerState.Health.ToString();
            if (_playerState.Health < 0)
            {
                lifeLabel.text = "0";
            }

            waveLabel.text = $"{_waves.NumberOfStartedWaves()} / {_waves.NumberOfTotalWaves()}";
        }
Exemplo n.º 19
0
        public void Insert(IMove move)
        {
            var item = Stack.Top();

            if (item.State == WaveBuilderState.S0)
            {
                IWave wave = Wave.Open(CurrentId, 0, move);

                item.Wave = wave;

                item.Update(this, move);
            }
            else
            {
                var status = item.Update(this, move);
            }
        }
Exemplo n.º 20
0
        private void DrawGaussianPulse()
        {
            m_GraphXAxisRange = gaussian_b * 2;

            double a = double.Parse(textBox_Amplitude.Text);
            double b = double.Parse(textBox_Period.Text);
            double c = double.Parse(textBox_Phase.Text);

            m_GaussianWave = new GaussianCurve(a,
                                               b,
                                               c,
                                               m_GraphXAxisRange,
                                               m_SamplingPeriod);

            m_GraphAxisYMax = Math.Round(m_GaussianWave.Peak + m_GaussianWave.Peak / 4, 2);
            m_GraphAxisYMin = 0;

            m_currentWave = m_GaussianWave;
        }
Exemplo n.º 21
0
        public static double CalculateMeanVoltage(IWave wave, int calculate_times = 1000)
        {
            double delta_phase = 1.0 / (double)calculate_times;
            double little_sum  = 0;
            double mean        = 0;
            double phase       = 0;

            for (int i = 0; i < calculate_times; i++)
            {
                little_sum += wave.Voltage(phase);
                phase      += delta_phase;
                if ((i & 0xf) == 0)
                {
                    mean      += little_sum / calculate_times;
                    little_sum = 0;
                }
            }
            mean += little_sum / calculate_times;
            return(mean);
        }
Exemplo n.º 22
0
    public void WaveCompleted_soPopANewOne()
    {
        Destroy(currentWave);  //12345
        waveNum++;

        if (!GameSettings.Instance.IsGameLong)
        {
            if (currentWave != null)
            {
                currentWave  = Instantiate(ShortWaves[waveNum]);
                wave         = currentWave.GetComponent <IWave>();
                isWaveLoaded = true;
                BeginNextWave(GameSettings.Instance.NextBuffer);
            }
        }
        else
        {
            currentWave  = Instantiate(waves[waveNum]);
            wave         = currentWave.GetComponent <IWave>();
            isWaveLoaded = true;
            BeginNextWave(GameSettings.Instance.NextBuffer);
        }
    }
Exemplo n.º 23
0
    public void KeepPlaying()
    {
        GameIsNotOver_IcanmakeZombies = true;
        currentWave.GetComponent <WaveStandard>().ResetSpawnStates();
        isWaveLoaded = false;
        Destroy(currentWave);

        StemKitMNGR.CALL_ResetGunAndMeter();
        if (!GameSettings.Instance.IsGameLong)
        {
            currentWave  = Instantiate(ShortWaves[waveNum]);
            wave         = currentWave.GetComponent <IWave>();
            WS           = GetCurrWave();
            isWaveLoaded = true;

            TimerBehavior t = gameObject.AddComponent <TimerBehavior>();
            t.StartTimer(GameSettings.Instance.StartResetWaveIn, ResetWave);


            t = gameObject.AddComponent <TimerBehavior>();
            t.StartTimer(GameSettings.Instance.StartWaveAgain, WMStartWave);
        }
        else
        {
            currentWave  = Instantiate(waves[waveNum]);
            wave         = currentWave.GetComponent <IWave>();
            WS           = GetCurrWave();
            isWaveLoaded = true;

            TimerBehavior t = gameObject.AddComponent <TimerBehavior>();
            t.StartTimer(GameSettings.Instance.StartResetWaveIn, ResetWave);


            t = gameObject.AddComponent <TimerBehavior>();
            t.StartTimer(GameSettings.Instance.StartWaveAgain, WMStartWave);
        }
    }
Exemplo n.º 24
0
        private void ResetGame()
        {
            _obstacles.Clear();

            _nextTopSlot  = -500;
            _nextBotSlot  = -500;
            _forceTopLong = false;
            _forceBotLong = false;
            _deathTimer   = 0;
            for (int i = 0; i < 3; i++)
            {
                PlaceTop(true);
                PlaceBot(true);
            }

            _player = new Player(new Vector(0, 0));

            _waves = new ExpandedWave(new ScaledWave(new CompositeWave(
                                                         new ScaledWave(new MovingWave(new SinWave(200), 100), 0.1),
                                                         new ScaledWave(new MovingWave(new SinWave(100), -25), 0.05),
                                                         new MovingWave(new ScaledWave(new SimulatedWave(), 0.1), 100),
                                                         new SmoothedWave(new MovingWave(new Microwave(), 350), 30)
                                                         ), 100), 2);
        }
Exemplo n.º 25
0
 private void clear_graph_button_Click(object sender, EventArgs e)
 {
     m_currentWave = null;
     refresh_graph();
 }
Exemplo n.º 26
0
 public void AddWave(IWave wave)
 {
     waves.Add(wave);
 }
Exemplo n.º 27
0
 public void RemoveWave(IWave wave)
 {
     toRemove.Add(wave);
 }
 public ResourceWavelengthExchange(IWave wave, IResource <int> resource)
 {
     this.wave     = wave;
     this.resource = resource;
 }
Exemplo n.º 29
0
 public void Construct(IWave wave, Settings settings)
 {
     this.wave     = wave;
     this.settings = settings;
 }
Exemplo n.º 30
0
 private void DetermineColor(IWave wave)
 {
     settings.Renderer.material.color = GetColor(wave.Wavelength);
 }
Exemplo n.º 31
0
 public PowerWaveFilter(IWave baseWave, double power)
 {
     _baseWave = baseWave;
     _power    = power;
 }