// Update is called once per frame
    void Update()
    {
        if (TimeoutFramecounter == 0)
        {
            // Mic Stuff
            //get mic volume samples
            int     dec         = 64;
            float[] waveData    = new float[dec];
            int     micPosition = Microphone.GetPosition(null) - (dec + 1); // null means the first microphone
            microphoneInput.GetData(waveData, micPosition);

            // Getting a peak on the samples
            float levelMax = 0;
            for (int i = 0; i < dec; i++)
            {
                float wavePeak = waveData[i] * waveData[i];
                if (levelMax < wavePeak)
                {
                    levelMax = wavePeak;
                }
            }
            // Normalise the input to a nice 0-1ish level number
            float level = Mathf.Sqrt(Mathf.Sqrt(levelMax));

            if (level > sensitivity / 100)
            {
                CountdownTimer  countdownTimer = theTime.GetComponent <CountdownTimer>();
                Congratulations congrats       = runner.GetComponent <Congratulations>();
                Debug.Log(congrats.gameRunning);
                if (countdownTimer.timeLeft > 0 && congrats.gameRunning)
                {
                    GameObject shootingBullet = objectPooler.GetPooledObject();
                    shootingBullet.SetActive(true);
                    shootingBullet.transform.rotation = objectPooler.objectToPool.transform.rotation;
                    shootingBullet.transform.position = objectPooler.objectToPool.transform.position;
                    Rigidbody shootingBulletRigidbody = shootingBullet.GetComponent <Rigidbody>();

                    shootingBulletRigidbody.AddForce(Camera.main.transform.forward * speed);
                    // Don't shoot again until the TimeoutFrameCounter is reaced.
                    TimeoutFramecounter = 1;
                }
            }

            // Increment to continue the timeout
        }
        else if (TimeoutFramecounter > 0)
        {
            TimeoutFramecounter++;
        }

        // If we've reached our timeout, go ahead and run on the next frame
        if (TimeoutFramecounter > timeoutFrames)
        {
            TimeoutFramecounter = 0;
        }
    }
 private void Collider2D_Tick(object sender, EventArgs e)
 {
     //Bricks collider
     if (GameData.gameInitiated)
     {
         int xAxis = 10;
         int yAxis = 4;
         for (int j = yAxis - 1; j >= 0; j--)
         {
             for (int i = 0; i < xAxis; i++)
             {
                 if (bricksMatrix[i, j] != null)
                 {
                     if (mario.Bounds.IntersectsWith(bricksMatrix[i, j].Bounds))
                     {
                         bricksMatrix[i, j].hits--;
                         if (bricksMatrix[i, j].hits == 1)
                         {
                             bricksMatrix[i, j].BackgroundImage = Image.FromFile("../../Resources/Bricks/brokenBrick.png");
                             player.score = Convert.ToString($"Score: {Convert.ToInt32(player.score.Substring(6)) + 100}");
                         }
                         else
                         {
                             Controls.Remove(bricksMatrix[i, j]);
                             bricksMatrix[i, j] = null;
                             player.score       = Convert.ToString($"Score: {Convert.ToInt32(player.score.Substring(6)) + 100}");
                             number_of_bricks--;
                             if (number_of_bricks == 0)
                             {
                                 StaticAttributes.finished = true;
                                 var NewScore = (Convert.ToInt32(player.time.Substring(5)) + Convert.ToInt32(player.score.Substring(6))) * (Convert.ToInt32(player.lives.Substring(1)) + 1);
                                 if (!StaticAttributes.nicknameRepeated)
                                 {
                                     ControllerPlayer.AddNickname(player.nickname);
                                 }
                                 ControllerPlayer.AddScore(player.nickname, NewScore);
                                 Congratulations congratulations = new Congratulations(player);
                                 congratulations.Show();
                                 Hide();
                             }
                         }
                         GameData.dirY *= -1;
                         return;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public MainWindowVM()
        {
            game = new Game3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 24);
            //game = Game.FromCsv("C:/Users/Админ/Desktop/Puzzle15IITLab/Taken15/FieldFile.csv");
            GameBlockClickCommand = new RelayCommand(x =>
            {
                game.GameBlockClick((int)x);
                if (!game.IsOver)
                {
                    return;
                }

                var congratulations = new Congratulations();
                congratulations.Show();
            });
            GameBackCommand    = new RelayCommand(x => game.Back());
            GameForwardCommand = new RelayCommand(x => game.Forward());
        }