Ejemplo n.º 1
0
        public static void menu()
        {
            char chon; int x = 2;

            do
            {
                Console.Clear();
                Console.WriteLine("\t\t\t   Huong Dan");
                Console.WriteLine("\n\t\t\tLuat choi");
                Console.WriteLine("\t\t\tCach choi");
                Console.WriteLine("\t\t\tChe do Classic");
                Console.WriteLine("\t\t\tChe do Survivor");
                Console.WriteLine("\t\t\tBang xep hang");
                Console.WriteLine("\t\t\tTro lai menu chinh");
                GIAOTHUC.gotoxy(x, 22);
                Console.Write("→");
                chon = GIAOTHUC.getch();
                if (chon == 'w' || chon == 'W')
                {
                    if (x > 2)
                    {
                        x--;
                    }
                }
                if (chon == 's' || chon == 'S')
                {
                    if (x < 7)
                    {
                        x++;
                    }
                }
                if (chon == 13)
                {
                    if (x == 2)
                    {
                        luatchoi();
                    }
                    if (x == 3)
                    {
                        cachchoi();
                    }
                    if (x == 4)
                    {
                        chedoclassic();
                    }
                    if (x == 5)
                    {
                        chedosurvive();
                    }
                    if (x == 6)
                    {
                        BXH();
                    }
                    if (x == 7)
                    {
                        break;
                    }
                }
            } while (chon != 27);
        }
Ejemplo n.º 2
0
 protected bool notemty()
 {
     if (s[x, y] != ' ')
     {
         GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
         GIAOTHUC.textcolor(ConsoleColor.Red); Console.WriteLine("Vi tri nay da thao tac"); GIAOTHUC.colordefault();
         GIAOTHUC.gotoxy(x, y + 16); return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
 public void xuat()
 {
     GIAOTHUC.textcolor(ConsoleColor.Red);
     Console.WriteLine("\n\t\t    »»»»» CHE DO SURVIVOR «««««\n");
     GIAOTHUC.colordefault();
     for (int i = 0; i < ng.Length; i++)
     {
         Console.Write("\t\t\t    {0}.   ", i + 1);
         ng[i].xuat();
     }
 }
Ejemplo n.º 4
0
 public static void gioithieu()
 {
     GIAOTHUC.textcolor(ConsoleColor.Red);
     Console.WriteLine("\t\t\t  ======================");
     Console.WriteLine("\t\t\t | DO AN MON OOP NHOM 7 |");
     Console.WriteLine("\t\t\t  ======================");
     GIAOTHUC.textcolor(ConsoleColor.Green);
     Console.WriteLine("\n\t\t\t»»»»»GAME TIM KHO BAU«««««");
     GIAOTHUC.textcolor(ConsoleColor.Magenta);
     Console.WriteLine("THANH VIEN :"); GIAOTHUC.textcolor(ConsoleColor.Yellow);
     Console.WriteLine("\n NGUYEN MANH CUONG \n\n CAO TRAN MINH HIEN \n\n NGUYEN XUAN BINH \n\n PHAM QUACH HOANG GIANG");
     GIAOTHUC.textcolor(ConsoleColor.White);
     Console.ReadKey();
 }
Ejemplo n.º 5
0
        protected void endgame(int x)
        {
            GIAOTHUC.gotoxy(m + 3, n / 2 + 10); //canh toa do xuat KQ

            if (x == 0)
            {
                GIAOTHUC.textcolor(ConsoleColor.Blue); GIAOTHUC.backgroundcolor(ConsoleColor.White);
                Console.WriteLine("RAT TIEC! TRO CHOI KET THUC T-T ");
                GIAOTHUC.colordefault(); Console.ReadKey(true);
            }
            if (x == 1)
            {
                GIAOTHUC.textcolor(ConsoleColor.Red); GIAOTHUC.backgroundcolor(ConsoleColor.Yellow);
                Console.Write("CHUC MUNG BAN DA DANH DAU DU SO KHO BAU");
                GIAOTHUC.colordefault(); Console.ReadKey(true);
            }
        }
Ejemplo n.º 6
0
        static void luatchoi()
        {
            char ch;

            Console.Clear();
            do
            {
                Console.Clear();
                Console.WriteLine("Nhiem vu cua ban la danh dau tat ca so kho bau trong moi man choi.");
                Console.WriteLine("\nDe co thong tin ve vi tri kho bau ma ban can danh dau,ban can pha huy mot so ô.\nKhi ban pha huy 1 ô,ban se biet duoc so luong kho bau xung quanh no");
                Console.WriteLine("\nNeu ban pha huy vao nhung ô có kho bau hoac danh dau vao nhung ô KHONG có kho bau thi tro choi se ket thuc.");
                Console.WriteLine("\nDanh dau du so luong kho bau thi ban chien thang ");
                Console.WriteLine("\nBan da nam ro chua ?:(Y)");
                ch = GIAOTHUC.getch(); if (ch == 'y' || ch == 'Y')
                {
                    break;
                }
            } while (ch != 'y' || ch != 'Y');
        }
Ejemplo n.º 7
0
 protected void luamau()
 {
     if (s[x, y] == c)
     {
         GIAOTHUC.textcolor(ConsoleColor.Red);
     }
     if (s[x, y] == '4' || s[x, y] == '8' || s[x, y] == '0')
     {
         GIAOTHUC.textcolor(ConsoleColor.Yellow);
     }
     if (s[x, y] == '2' || s[x, y] == '5')
     {
         GIAOTHUC.textcolor(ConsoleColor.Cyan);
     }
     if (s[x, y] == '3' || s[x, y] == '6')
     {
         GIAOTHUC.textcolor(ConsoleColor.Magenta);
     }
     if (s[x, y] == '1' || s[x, y] == '7')
     {
         GIAOTHUC.textcolor(ConsoleColor.Green);
     }
 }
Ejemplo n.º 8
0
        virtual public void dichuyen()
        {
            GIAOTHUC.gotoxy(x, y + 16); Console.Write("*"); GIAOTHUC.gotoxy(x, y + 16);

            do
            {
                a = GIAOTHUC.getch();
                if (a == 32)//khoang trang
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) == -1)
                    {
                        endgame(0); win(); break;
                    }                                                      //khi sai thao tac
                    s[x, y] = (char)BANDO.kt(x, y); luamau(); Console.Write("{0}", s[x, y]);
                    GIAOTHUC.textcolor(ConsoleColor.White); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 13)//enter
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) != -1)
                    {
                        endgame(0); win(); break;
                    }                                                      //khi sai thao tac
                    s[x, y] = c; luamau(); Console.Write("{0}", s[x, y]); dem--;
                    GIAOTHUC.textcolor(ConsoleColor.White);
                    GIAOTHUC.gotoxy(x, y + 16);
                    if (dem == 0)
                    {
                        endgame(1); win(); break;
                    }
                }

                if (a == 'w' || a == 'W')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == 1)
                    {
                        x = m - 2;
                    }
                    else
                    {
                        x = x - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     ");
                    GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'a' || a == 'A')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == 1)
                    {
                        y = n - 2;
                    }
                    else
                    {
                        y = y - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 's' || a == 'S')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == m - 2)
                    {
                        x = 1;
                    }
                    else
                    {
                        x = x + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'd' || a == 'D')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == n - 2)
                    {
                        y = 1;
                    }
                    else
                    {
                        y = y + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }
            } while (a != 27);
        }
Ejemplo n.º 9
0
        public override void dichuyen()
        {
            GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
            GIAOTHUC.gotoxy(m / 2, n + 20); /*toa do xuat ra DIEM*/
            Console.Write("DIEM:{0} ", diem);
            GIAOTHUC.gotoxy(x, y + 16);     //dua con tro console ve vi tri con tro * tren man hinh
            do
            {
                a = GIAOTHUC.getch();
                if (a == 32)
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) == -1)
                    {
                        endgame(0); win(); break;
                    }                                                      //khi sai thao tac
                    s[x, y] = (char)BANDO.kt(x, y); luamau(); Console.Write("{0}", s[x, y]);
                    GIAOTHUC.textcolor(ConsoleColor.White); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 13)//enter
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) != -1)
                    {
                        endgame(0); win(); break;
                    }                                                       //khi sai thao tac
                    diem = diem + 100; s[x, y] = c; dem--;
                    luamau(); Console.Write("{0}", s[x, y]);
                    GIAOTHUC.textcolor(ConsoleColor.White);
                    GIAOTHUC.gotoxy(m / 2, n + 20); /*toa do xuat ra DIEM*/
                    Console.Write("DIEM:{0} ", diem);
                    GIAOTHUC.gotoxy(x, y + 16);     //dua con tro console ve vi tri con tro * tren man hinh
                    if (dem == 0)
                    {
                        endgame(1); win(); break;
                    }
                }

                if (a == 'w' || a == 'W')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == 1)
                    {
                        x = m - 2;
                    }
                    else
                    {
                        x = x - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     ");
                    GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'a' || a == 'A')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == 1)
                    {
                        y = n - 2;
                    }
                    else
                    {
                        y = y - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 's' || a == 'S')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == m - 2)
                    {
                        x = 1;
                    }
                    else
                    {
                        x = x + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'd' || a == 'D')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == n - 2)
                    {
                        y = 1;
                    }
                    else
                    {
                        y = y + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }
            } while (a != 27);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            int x = 2; char chon;

            OPEN.gioithieu();
            BANDO    map;
            GAMEPLAY game;

            do
            {
                Console.Clear();
                Console.Write("\t\t\t     MENU");
                Console.Write("\n\n\t\t\tChe do Classic");
                Console.Write("\n\t\t\tChe do Survivor");
                Console.Write("\n\t\t\tLuyen tap");
                Console.Write("\n\t\t\tHuong dan");
                Console.Write("\n\t\t\tBang xep hang");
                Console.Write("\n\t\t\tThoat");
                Console.Write("\n\nBam W,S,Enter de thuc hien su lua chon");
                GIAOTHUC.gotoxy(x, 22);
                Console.Write("→");
                DSCD1 ds1 = new DSCD1();
                DSCD2 ds2 = new DSCD2();
                chon = GIAOTHUC.getch();
                if (chon == 'w' || chon == 'W')
                {
                    if (x > 2)
                    {
                        x--;
                    }
                }
                if (chon == 's' || chon == 'S')
                {
                    if (x < 7)
                    {
                        x++;
                    }
                }
                if (chon == 13) //enter
                {
                    if (x == 2) //Classic
                    {
                        int m = 3, n = 3, r;
                        game = new CLASSIC();
                        do
                        {
                            r    = (m * n) / 3 - 2;
                            map  = new BANDO(m, n, r);
                            game = new CLASSIC(CLASSIC.Diem);
                            map.taobando();
                            game.vekhung(); game.xuatkhung(); //map.xuat();
                            game.dichuyen();
                            if (game.win() == false)          //khi thua
                            {
                                ds1.docfile(); if (ds1.sosanh(CLASSIC.Diem) && CLASSIC.Diem > 0)
                                {
                                    ds1.them();
                                }
                                ds1.sapxep(); ds1.ghifile(); break;
                            }
                            m = m + 1; n = n + 2;
                        } while (game.win() == true);
                    }
                    if (x == 3)//Survive
                    {
                        int m = 3, n = 3, r;
                        game = new SURVIVE();
                        do
                        {
                            r    = (m * n) / 3 - 2;
                            map  = new BANDO(m, n, r);
                            game = new SURVIVE(SURVIVE.Diem);
                            map.taobando();
                            game.vekhung(); game.xuatkhung(); //map.xuat();
                            game.dichuyen();
                            if (game.win() == false)
                            {
                                ds2.docfile(); if (ds2.sosanh(SURVIVE.Level) && SURVIVE.Level > 1)
                                {
                                    ds2.them();
                                }
                                ds2.sapxep(); ds2.ghifile(); break;
                            }
                            m = m + 1; n = n + 2;
                        } while (game.win() == true);
                    }
                    if (x == 4) //Luyen tap
                    {
                        Console.Clear();
                        int a, b, c;
                        Console.Write("Nhap chieu cao:"); a = int.Parse(Console.ReadLine());
                        while (a > 25)
                        {
                            Console.Write("Chieu cao khong the lon hon 25.\nHay nhap lai chieu cao : ");
                            a = int.Parse(Console.ReadLine());
                        }
                        Console.Write("\nNhap chieu dai: "); b = int.Parse(Console.ReadLine());
                        while (b > 25)
                        {
                            Console.Write("Chieu dai khong the lon hon 25\nHay nhap lai chieu dai : ");
                            b = int.Parse(Console.ReadLine());
                        }
                        Console.Write("\nNhap so luong kho bau:"); c = int.Parse(Console.ReadLine());
                        while (c > a * b - (a + b - 1))
                        {
                            Console.Write("So luong kho bau chi co the <={0}.Hay nhap lai sl:", a * b - (a + b - 1));
                            c = int.Parse(Console.ReadLine());
                        }
                        map = new BANDO(a, b, c); map.taobando(); game = new GAMEPLAY(); game.vekhung(); game.xuatkhung(); //map.xuat();
                        game.dichuyen();
                    }
                    if (x == 5)
                    {
                        OPEN.menu();
                    }
                    if (x == 6)
                    {
                        Console.Clear();
                        ds1.docfile(); ds1.sapxep(); ds1.xuat();
                        ds2.docfile(); ds2.sapxep(); ds2.xuat();
                        Console.ReadKey(true);
                    }
                    if (x == 7)
                    {
                        break;
                    }
                }
            } while (chon != 27);
        }