Example #1
0
        private void Bottone3(object sender, RoutedEventArgs e)
        {
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = new TimeSpan(0, 0, 0, 0, 300);
            timer.Tick    += new EventHandler(DiventaOpaco3);

            Button3.Opacity = opac;
            Titolo.Text     = "Livello " + livello;
            SuonoBottone3.Play();
            timer.Start();


            sequenza++;
            if (ControllaGiusto(3))
            {
                if (sequenza == livello)
                {
                    ProssimoLivello();
                }
            }
            else
            {
                PhoneApplicationService.Current.State["ris"] = livello - 1;
                NavigationService.Navigate(new Uri("/FineGioco.xaml", UriKind.Relative));
            }
        }
Example #2
0
        async void IniziaGioco()
        {
            if (livello == 0)
            {
                await Task.Delay(2000);
            }
            else
            {
                await Task.Delay(1000);
            }

            for (int i = 0; i < livello; i++)
            {
                switch (tasti[i])
                {
                case 1:
                    DispatcherTimer timer = new DispatcherTimer();
                    timer.Interval  = new TimeSpan(0, 0, 0, 0, 300);
                    timer.Tick     += new EventHandler(DiventaOpaco1);
                    Button1.Opacity = opac;
                    SuonoBottone1.Play();
                    timer.Start();
                    //timer5.Start();
                    break;

                case 2:
                    DispatcherTimer timer2 = new DispatcherTimer();
                    timer2.Interval = new TimeSpan(0, 0, 0, 0, 300);
                    timer2.Tick    += new EventHandler(DiventaOpaco2);
                    Button2.Opacity = opac;
                    SuonoBottone2.Play();
                    timer2.Start();
                    //timer5.Start();
                    break;

                case 3:
                    DispatcherTimer timer3 = new DispatcherTimer();
                    timer3.Interval = new TimeSpan(0, 0, 0, 0, 300);
                    timer3.Tick    += new EventHandler(DiventaOpaco3);
                    Button3.Opacity = opac;
                    SuonoBottone3.Play();
                    timer3.Start();
                    //timer5.Start();
                    break;

                case 4:
                    DispatcherTimer timer4 = new DispatcherTimer();
                    timer4.Interval = new TimeSpan(0, 0, 0, 0, 300);
                    timer4.Tick    += new EventHandler(DiventaOpaco4);
                    Button4.Opacity = opac;
                    SuonoBottone4.Play();
                    timer4.Start();

                    break;
                }

                if (livello < 4)
                {
                    await Task.Delay(1000);
                }
                else if (livello > 3 && livello < 9)
                {
                    await Task.Delay(900);
                }
                else if (livello > 8 && livello < 16)
                {
                    await Task.Delay(750);
                }
                else
                {
                    await Task.Delay(600);
                }
            }
        }