ヨッピのC#言語教室

ヨッピのC#言語教室

C#言語教室

c言語の勉強を行うサイトです。


<pre class="line-numbers u-mb30">
<code class="language-csharp">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NAudio.Wave;
using System.Windows.Forms;
</code>
</pre>

C#言語とは

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NAudio.Wave;
using System.Windows.Forms;
namespace ルーレット
{
    public partial class Form1 : Form
    {
        int st1= 0;
        int st2= 0;
        int st3= 0;
        int ss = 0;
        int ss2 = 0;
        int js1 = 0;
        int js2 = 0;
        int js3 = 0;
        int js4 = 0;
       int ss3= 0;
       int jss1=0;
         int jss2=0;
        int jss3=0;
        public Form1()
        {
            InitializeComponent();
         
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (ss == 0)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「よぉーい…」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer1.Interval = 50;
                timer1.Enabled = true;
                button1.Text = "ストップ";
            }
            if (ss == 1)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「ドン!」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer1.Enabled = false;
                timer2.Interval = 50;
                timer2.Enabled = true;
                button1.Text = "ストップ";
            }
            if (ss == 2)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「ドン!」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer2.Enabled = false;
                timer3.Interval = 50;
                timer3.Enabled = true;
                button1.Text = "ストップ";
            }
            if (ss==3) {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「ドン!」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer3.Enabled = false;
                ss = -1;
                button1.Text = "スタート";
            }
            ss++;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (ss == 1) { 
            if (st1 == 0) label1.Text = "Aが";
            if (st1 == 1) label1.Text = "Bが";
            if (st1 == 2) label1.Text = "Cが";
            if (st1 == 3) label1.Text = "Dが";
            if (st1 == 4) label1.Text = "Eが";
            if (st1 == 5) label1.Text = "Fが";
            st1++;
            if (st1 == 6) st1 = 0;
        }
        }
        private void label1_Click(object sender, EventArgs e)
        {
        }
        private void label2_Click(object sender, EventArgs e)
        {
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (ss == 2)
            {
                if (st2 == 0) label2.Text = "Aで";
                if (st2 == 1) label2.Text = "Bで";
                if (st2 == 2) label2.Text = "Cが";
                if (st2 == 3) label2.Text = "Dで";
                if (st2 == 4) label2.Text = "Eで";
                if (st2 == 5) label2.Text = "Fで";
                st2++;
                if (st2 == 6) st2 = 0;
            }
        }
        private void timer3_Tick(object sender, EventArgs e)
        {
            if (ss == 3)
            {
                if (st3 == 0) label3.Text = "Aをやる";
                if (st3 == 1) label3.Text = "Bをやる";
                if (st3 == 2) label3.Text = "Cをやる";
                if (st3 == 3) label3.Text = "Dをやる";
                if (st3 == 4) label3.Text = "Eをやる";
                if (st3 == 5) label3.Text = "Fをやる";
                st3++;
                if (st3 == 6) st3 = 0;
            }
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            pictureBox1.ImageLocation = "go.png";
        }
        private void pictureBox2_Click(object sender, EventArgs e)
        {
        }
        private void pictureBox3_Click(object sender, EventArgs e)
        {
        }
        private void pictureBox4_Click(object sender, EventArgs e)
        {
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (ss2 == 0)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「よぉーい…」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer4.Interval = 100;
                timer5.Interval = 80;
                timer6.Interval = 50;
                timer7.Interval = 30;
                timer8.Interval = 1000;
                timer4.Enabled = true;
                timer5.Enabled=true;
                timer6.Enabled=true;
                timer7.Enabled=true;
                timer8.Enabled=true;
                button2.Enabled = false;
                button2.Text = "ストップ";
            }
            if (ss2 == 1)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「ドン!」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer8.Interval = 1000;
                timer8.Enabled = true;
                button2.Enabled = false;
                timer4.Enabled = false;
            }
            if (ss2 == 2)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「ドン!」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer5.Enabled = false;
                timer8.Interval = 1000;
                timer8.Enabled = true;
                button2.Enabled = false;
            }
            if (ss2 == 3)
            {
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("「ドン!」.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
                timer6.Enabled = false;
                timer8.Interval = 1000;
                timer8.Enabled = true;
                button2.Enabled = false;
            }
            if (ss2 == 4)
            {
                timer7.Enabled = false;
               
                    ss2 = -1;
                button2.Text = "スタート";
                if (js1 == js2 && js2 == js3 && js3 == js4)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("「大当たり~」.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                }
                else if (js1 == js2 && js2 == js3)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("「当ったり~」.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                }
                else if (js1 == js2)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("一連.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                }
                else if(js1 != js2)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("「はっずれ~」.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                }
            }
            ss2++;
        }
        private void timer4_Tick(object sender, EventArgs e)
        {
            if (js1 == 0)
            {
                pictureBox1.ImageLocation = "go.png";
            }
            if (js1 == 2)
            {
                pictureBox1.ImageLocation = "pa.png";
            }
            if (js1 == 3)
            {
                pictureBox1.ImageLocation = "tyo.png";
            }
            js1++;
            if (js1 == 4) js1 = 0;
        }
        private void timer5_Tick(object sender, EventArgs e)
        {
            if (js2 == 0)
            {
                pictureBox2.ImageLocation = "go.png";
            }
            if (js2 == 2)
            {
                pictureBox2.ImageLocation = "pa.png";
            }
            if (js2 == 3)
            {
                pictureBox2.ImageLocation = "tyo.png";
            }
            js2++;
            if (js2 == 4) js2= 0;
        }
        private void timer6_Tick(object sender, EventArgs e)
        {
            if (js3 == 0)
            {
                pictureBox3.ImageLocation = "go.png";
            }
            if (js3 == 2)
            {
                pictureBox3.ImageLocation = "pa.png";
            }
            if (js3 == 3)
            {
                pictureBox3.ImageLocation = "tyo.png";
            }
            js3++;
            if (js3 == 4) js3 = 0;
        }
        private void timer7_Tick(object sender, EventArgs e)
        {
            if (js4 == 0)
            {
                pictureBox4.ImageLocation = "go.png";
            }
            if (js4 == 2)
            {
                pictureBox4.ImageLocation = "pa.png";
            }
            if (js4 == 3)
            {
                pictureBox4.ImageLocation = "tyo.png";
            }
            js4++;
            if (js4 == 4) js4 = 0;
        }
        private void timer8_Tick(object sender, EventArgs e)
        {
            WaveOut waveOut = new WaveOut();
            AudioFileReader reader = new AudioFileReader("「ボタンをタッチしてね」.mp3");
            waveOut.Init(reader);
            //音声ファイルの再生
            waveOut.Play(); timer8.Enabled = false;
            button2.Enabled = true;
        }
        private void label4_Click(object sender, EventArgs e)
        {
        }
        private void label5_Click(object sender, EventArgs e)
        {
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (ss3 == 0)
            {
                timer9.Interval = 50;
                timer9.Enabled = true;
                button3.Text = "じゃんけんを出してね";
                WaveOut waveOut = new WaveOut();
                AudioFileReader reader = new AudioFileReader("じゃんけん.mp3");
                waveOut.Init(reader);
                //音声ファイルの再生
                waveOut.Play();
            }
            ss3++;
        }
        private void pictureBox5_Click(object sender, EventArgs e)
        {
            if (ss3 >= 1)
            {
                Random r = new Random();
                jss1 = r.Next(0, 3000) % 3;
                jss2 = 0;
                timer9.Enabled = false;
                button3.Text = "スタート";
                ss3 = 0;
                if (jss1 == 0)
                {
                    pictureBox8.ImageLocation = "go.png";
                }
                if (jss1 == 1)
                {
                    pictureBox8.ImageLocation = "tyo.png";
                }
                if (jss1 == 2)
                {
                    pictureBox8.ImageLocation = "pa.png";
                }
                if (jss1 == 0)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("aiko.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "あいこ";//aiko
                }
                if (jss1 == 1)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("kati.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "勝ち";//kati
                }
                if (jss1 == 2)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("make.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "負け";//make
                }
            }
        }
        private void pictureBox6_Click(object sender, EventArgs e)
        {
            if (ss3 >= 1)
            {
                jss2 = 1;
                Random r = new Random();
                jss1 = r.Next(0, 3000) % 3;
                jss2 = 0;
                timer9.Enabled = false;
                button3.Text = "スタート";
                ss3 = 0;
                if (jss1 == 0)
                {
                    pictureBox8.ImageLocation = "go.png";
                }
                if (jss1 == 1)
                {
                    pictureBox8.ImageLocation = "tyo.png";
                }
                if (jss1 == 2)
                {
                    pictureBox8.ImageLocation = "pa.png";
                }
                if (jss1 == 0)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("make.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "負け";//aiko
                }
                if (jss1 == 1)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("aiko.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "あいこ";//kati
                }
                if (jss1 == 2)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("kati.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "勝ち";//make
                }
            }
        }
        private void pictureBox7_Click(object sender, EventArgs e)
        {
            if (ss3 >= 1)
            {
                jss2 = 2;
                Random r = new Random();
                jss1 = r.Next(0, 3000) % 3;
                jss2 = 0;
                timer9.Enabled = false;
                button3.Text = "スタート";
                ss3 = 0;
                if (jss1 == 0)
                {
                    pictureBox8.ImageLocation = "go.png";
                }
                if (jss1 == 1)
                {
                    pictureBox8.ImageLocation = "tyo.png";
                }
                if (jss1 == 2)
                {
                    pictureBox8.ImageLocation = "pa.png";
                }
                if (jss1 == 0)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("kati.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "勝ち";//aiko
                }
                if (jss1 == 1)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("make.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "負け";//kati
                }
                if (jss1 == 2)
                {
                    WaveOut waveOut = new WaveOut();
                    AudioFileReader reader = new AudioFileReader("aiko.mp3");
                    waveOut.Init(reader);
                    //音声ファイルの再生
                    waveOut.Play();
                    label6.Text = "あいこ";//make
                }
            }
        }
        private void timer9_Tick(object sender, EventArgs e)
        {
            if (jss3 == 0)
            {
                pictureBox8.ImageLocation= "go.png";
            }
            if (jss3 == 1)
            {
                pictureBox8.ImageLocation = "tyo.png";
            }
            if (jss3 == 2)
            {
                pictureBox8.ImageLocation = "pa.png";
            }
            jss3++;
            if (jss3 == 3) jss3 = 0;
        }
        private void pictureBox8_Click(object sender, EventArgs e)
        {
        }
        private void label6_Click(object sender, EventArgs e)
        {
        }
    }
}