コード例 #1
0
ファイル: Snake.cs プロジェクト: RandomByteFF/Logic-games
 private void GameEnd()
 {
     timer.Stop();
     SqlConnectionHandler.RunNonQuery($"INSERT INTO snake (score) VALUES({score})");
     panel.Location = new Point((Width / 2) - (panel.Size.Width / 2), (Height / 2) - (panel.Size.Height / 2));
     panel.Visible  = true;
 }
コード例 #2
0
 private void statisticsButton_Click(object sender, EventArgs e)
 {
     if (SqlConnectionHandler.InitialSetup() == 0)
     {
         this.Visible = false;
         Statistics statisticsWindow = new Statistics();
         statisticsWindow.Show();
         statisticsWindow.FormClosed += new FormClosedEventHandler(this.WindowReopen);
     }
 }
コード例 #3
0
        private int BattleshipWins()
        {
            List <List <string> > sum = SqlConnectionHandler.Query($"SELECT sum(score) FROM battleship WHERE score = 1");

            if (sum[0][0] != "")
            {
                return(int.Parse(sum[0][0]));
            }
            else
            {
                return(0);
            }
        }
コード例 #4
0
        private int Attempts(string table)
        {
            List <List <string> > result = SqlConnectionHandler.Query($"SELECT COUNT(id) FROM {table}");

            if (result.Count > 0)
            {
                return(int.Parse(result[0][0]));
            }
            else
            {
                return(0);
            }
        }
コード例 #5
0
        private void PlayTime()
        {
            List <List <string> > result = SqlConnectionHandler.Query("SELECT timeSpent FROM times");
            int seconds = 0;

            foreach (List <string> item in result)
            {
                string[] toTime = item[0].Split(':');
                seconds += int.Parse(toTime[0]) * 3600 + int.Parse(toTime[1]) * 60 + int.Parse(toTime[2]);
            }
            TimeSpan t = TimeSpan.FromSeconds(seconds);

            playTimeLabel.Text = "Play time:" + t.ToString("c");
        }
コード例 #6
0
ファイル: Snake.cs プロジェクト: RandomByteFF/Logic-games
        private void StartGame()
        {
            var highScore = SqlConnectionHandler.Query("SELECT MAX(score) FROM snake");

            if (highScore.Count != 0 && highScore[0][0] != "")
            {
                recordText.Text = highScore[0][0];
            }
            else
            {
                recordText.Text = "0";
            }
            SnakeSpawn();

            timer.Interval = Tick;

            CreateSprite(Properties.Resources.apple, new Vector2(), -2);
            NewApplePosition();
            headColor = false;
            tailColor = true;

            timer.Start();
        }
コード例 #7
0
        //DISPLAY WIN
        private void OnWinSingle(BattleshipPlayer winner)
        {
            ChangeView(menu, win);
            winnerLb.Text = winner.name + " WON!";
            List <List <string> > sum = new List <List <string> >();

            //INSERTING DATA TO THE TABLE
            try
            {
                if (SqlConnectionHandler.InitialSetup() == 0)
                {
                    if (winner.name != "BOT")
                    {
                        SqlConnectionHandler.RunNonQuery($"INSERT INTO battleship(score) VALUES(1)");
                    }
                    else
                    {
                        SqlConnectionHandler.RunNonQuery($"INSERT INTO battleship(score) VALUES(-1)");
                    }
                }
                //GETTING STATS
                sum = SqlConnectionHandler.Query($"SELECT sum(score) FROM battleship WHERE score = 1");
                if (sum.Count > 0)
                {
                    string ammount = Convert.ToString(sum[0][0]);
                    winStatisticsLabel.Text = "Wins against bot: " + ammount;
                }
                else
                {
                    winStatisticsLabel.Hide();
                }
            }
            catch
            {
                winStatisticsLabel.Hide();
            }
        }
コード例 #8
0
 //Reopening menu window on the close of one of the games
 private void WindowReopen(object sender, EventArgs e)
 {
     timeSpan = DateTime.Now - date1;
     SqlConnectionHandler.RunNonQuery($"INSERT INTO times (timeSpent) VALUES('{timeSpan.ToString("c")}')");
     this.Visible = true;
 }
コード例 #9
0
        public LogicGames()
        {
            int returnValue = SqlConnectionHandler.InitialSetup();

            InitializeComponent();
        }