Beispiel #1
0
        private bool allowedDir(Labyrinthe laby, string dir)
        {
            switch (dir)
            {
            case "top": return(laby.allowToGo(x - 1, y));

            case "bottom": return(laby.allowToGo(x + 1, y));

            case "right": { if (x == 10 && y == 18)
                            {
                                return(true);
                            }
                            else
                            {
                                return(laby.allowToGo(x, y + 1));
                            } }

            case "left": { if (x == 10 && y == 0)
                           {
                               return(true);
                           }
                           else
                           {
                               return(laby.allowToGo(x, y - 1));
                           } }

            default: return(false);
            }
        }
Beispiel #2
0
        public virtual void move(ConsoleKey key, Labyrinthe laby)
        {
            switch (key)
            {
            case ConsoleKey.UpArrow:
            {
                if (laby.allowToGo(x - 1, y))
                {
                    x--;
                }
            }
            break;

            case ConsoleKey.DownArrow:
            {
                if (laby.allowToGo(x + 1, y))
                {
                    x++;
                }
            }
            break;

            case ConsoleKey.RightArrow:
            {
                if (x == 10 && y == 18)
                {
                    y = 0;
                    laby.laby[10, 18].setStatement("eated");
                }
                else if (laby.allowToGo(x, y + 1))
                {
                    y++;
                }
            }
            break;

            case ConsoleKey.LeftArrow:
            {
                if (x == 10 && y == 0)
                {
                    y = 18;
                    laby.laby[10, 0].setStatement("eated");
                }
                else if (laby.allowToGo(x, y - 1))
                {
                    y--;
                }
            }
            break;

            default: { } break;
            }

            setPlace(laby);
        }
Beispiel #3
0
        public override void move(ConsoleKey key, Labyrinthe laby)
        {
            if (super)
            {
                super_time--;
            }

            if (super_time == 0)
            {
                super = false;
            }

            switch (key)
            {
            case ConsoleKey.UpArrow:
            {
                if (laby.allowToGo(x - 1, y))
                {
                    x--;

                    if (laby.toEat(x, y))
                    {
                        points += 100;
                        laby.nbGums--;
                        if (laby.laby[x, y].getStatement().CompareTo("supercandy") == 0)
                        {
                            super      = true;
                            super_time = 15;
                        }
                    }
                    laby.eatGum(x + 1, y);
                }
            }
            break;

            case ConsoleKey.DownArrow:
            {
                if (laby.allowToGo(x + 1, y))
                {
                    x++;

                    if (laby.toEat(x, y))
                    {
                        points += 100;
                        laby.nbGums--;
                        if (laby.laby[x, y].getStatement().CompareTo("supercandy") == 0)
                        {
                            super      = true;
                            super_time = 15;
                        }
                    }
                    laby.eatGum(x - 1, y);
                }
            }
            break;

            case ConsoleKey.RightArrow:
            {
                if (x == 10 && y == 18)
                {
                    y = 0;
                    laby.laby[10, 18].setStatement("eated");
                }
                else if (laby.allowToGo(x, y + 1))
                {
                    y++;

                    if (laby.toEat(x, y))
                    {
                        points += 100;
                        laby.nbGums--;
                        if (laby.laby[x, y].getStatement().CompareTo("supercandy") == 0)
                        {
                            super      = true;
                            super_time = 15;
                        }
                    }
                    laby.eatGum(x, y - 1);
                }
            }
            break;

            case ConsoleKey.LeftArrow:
            {
                if (x == 10 && y == 0)
                {
                    y = 18;
                    laby.laby[10, 0].setStatement("eated");
                }
                else if (laby.allowToGo(x, y - 1))
                {
                    y--;

                    if (laby.toEat(x, y))
                    {
                        points += 100;
                        laby.nbGums--;
                        if (laby.laby[x, y].getStatement().CompareTo("supercandy") == 0)
                        {
                            super      = true;
                            super_time = 15;
                        }
                    }
                    laby.eatGum(x, y + 1);
                }
            }
            break;

            default: { } break;
            }

            if (laby.nbGums == 0)
            {
                laby.endGame();
            }

            setPlace(laby);
        }