Ejemplo n.º 1
0
        public static int[,] LoadGame(string name, int[,] ground)
        {
            Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/Saves");
            name = Directory.GetCurrentDirectory() + "/Saves/" + name;
            using (fileStream = new FileStream(name, FileMode.OpenOrCreate))
            {
                if (fileStream.Length != 0)
                {
                    ground = (int[, ])binaryFormatter.Deserialize(fileStream);
                }
                else
                {
                    ground = SetStartGround(ground);
                }
            }

            Form1.isActiveGround = !ClassAI.HasWinner(ref ground);

            return(ground);
        }
Ejemplo n.º 2
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (isActiveGround)
            {
                if (PlayerDoneTurn(e.X, e.Y))
                {
                    if (ClassAI.HasWinner(ref ground))
                    {
                        ShowWin(-3);
                        return;
                    }

                    ground = ClassAI.DoMachineTurn(ground);

                    if (ClassAI.HasWinner(ref ground))
                    {
                        ShowWin(-4);
                        return;
                    }

                    if (ClassAI.IsDraw(ground))
                    {
                        for (i = 0; i < 6; i++)
                        {
                            for (j = 0; j < 6; j++)
                            {
                                ground[i, j] -= 2;
                            }
                        }
                        isActiveGround = false;
                    }

                    Invalidate();
                }
            }
        }