protected override Personaje handleRequest(string request)
        {
            Fantasma fantasma = new Fantasma("Fantasma " + this.diferenciador);

            this.diferenciador += 1;
            return(fantasma);
        }
    static void Main()
    {
        Sprite s = new Sprite();

        s.Mover();
        Pac p = new Pac(8, 10);

        p.Mostrar();
        p.Mover();
        Fantasma f1 = new Fantasma(15, 12);

        f1.Mostrar();
        f1.Mover();
        Fantasma f2 = new Fantasma(17, 14);

        f2.Mostrar();
        f2.Mover();
        Fantasma f3 = new Fantasma(19, 16);

        f3.Mostrar();
        f3.Mover();
        Fantasma f4 = new Fantasma(21, 18);

        f4.Mostrar();
        f4.Mover();
    }
Exemple #3
0
    void Start()
    {
        Pressed = false;
        GameObject pacmanObject   = FindObjectsOfType <GameObject>().First(x => x.name == "PacMan_1");
        GameObject fantasmaObject = FindObjectsOfType <GameObject>().First(x => x.name == "Fantasma");
        GameObject comidaObject   = FindObjectsOfType <GameObject>().First(x => x.name == "comida");

        pacman   = new Pacman(pacmanObject, 1, 3);
        fantasma = new Fantasma(fantasmaObject, 3, 2);
        comida   = new Comida(comidaObject, 3, 4);

        //StartCoroutine(TesteMovimento());
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        DetectLocation.Instance.atualiza();
        float distancia = DetectLocation.Instance.distance;
        var   direcao   = Acelerometro.Instance.getDirecao();

        //Debug.Log(distancia);

        if (distancia > 0.00001f || Pressed)
        {
            fantasma.MoverBaixo();
            comida.MoverBaixo();
            Thread.Sleep(0500);
            Pressed = false;
        }
        else
        {
            switch (direcao)
            {
            case 1:
                pacman.MoverEsquerda();
                Thread.Sleep(100);
                break;

            case 2:
                pacman.MoverDireita();
                Thread.Sleep(100);
                break;

            default:
                break;
            }
        }

        if (pacman.PacmanObject.IsColided(fantasma.GhostObject))
        {
            fantasma          = new Fantasma(fantasma.GhostObject);
            pacman.Pontuacao += +5;
        }
        if (pacman.PacmanObject.IsColided(comida.FoodObject))
        {
            comida            = new Comida(comida.FoodObject);
            pacman.Pontuacao -= 10;
        }
    }
Exemple #5
0
    static void Main()
    {
        Pac p = new Pac(13, 10);

        p.Mostrar();
        p.Mover();
        Fantasma[] fantasmas = new Fantasma[4];
        fantasmas[0] = new FantasmaRojo(15, 11);
        fantasmas[1] = new FantasmaNaranja(17, 12);
        fantasmas[2] = new FantasmaRosa(19, 13);
        fantasmas[3] = new FantasmaAzul(21, 14);

        for (int i = 0; i < fantasmas.Length; i++)
        {
            fantasmas[i].Mostrar();
            fantasmas[i].Mover();
        }
    }
Exemple #6
0
    static void Main()
    {
        Pac p = new Pac(8, 10);

        p.Mostrar();
        Fantasma f1 = new Fantasma(15, 10);

        f1.Mostrar();
        Fantasma f2 = new Fantasma(17, 10);

        f2.Mostrar();
        Fantasma f3 = new Fantasma(19, 10);

        f3.Mostrar();
        Fantasma f4 = new Fantasma(21, 10);

        f4.Mostrar();
    }
    static void Main()
    {
        bool salir = false;

        Pac p = new Pac(13, 10);

        p.Mostrar();
        p.Mover();
        Fantasma[] fantasmas = new Fantasma[4];
        fantasmas[0] = new FantasmaRojo(15, 11);
        fantasmas[1] = new FantasmaNaranja(17, 12);
        fantasmas[2] = new FantasmaRosa(19, 13);
        fantasmas[3] = new FantasmaAzul(21, 14);

        do
        {
            p.Mostrar();

            for (int i = 0; i < fantasmas.Length; i++)
            {
                fantasmas[i].Mostrar();
            }

            ConsoleKeyInfo tecla = Console.ReadKey();

            switch (tecla.Key)
            {
            case ConsoleKey.Escape:
                salir = true;
                break;

            case ConsoleKey.LeftArrow:
                p.X--;
                break;

            case ConsoleKey.RightArrow:
                p.X++;
                break;

            case ConsoleKey.UpArrow:
                p.Y--;
                break;

            case ConsoleKey.DownArrow:
                p.Y++;
                break;

            default:
                break;
            }
            foreach (Fantasma f in fantasmas)
            {
                f.Mover();
            }

            Console.Clear();

            foreach (Fantasma f in fantasmas)
            {
                f.Mostrar();
            }

            p.Mostrar();
        }while (!salir);
    }
Exemple #8
0
    static void Main()
    {
        bool  salir = false;
        Nivel n     = new Nivel();

        n.CrearLaberinto();
        n.Mostrar();
        n.MostrarMarcador();

        Pac p = new Pac(7, 5);

        p.Mostrar();
        p.Mover();
        Fantasma[] fantasmas = new Fantasma[4];
        fantasmas[0] = new FantasmaRojo(2, 1);
        fantasmas[1] = new FantasmaNaranja(10, 8);
        fantasmas[2] = new FantasmaRosa(11, 1);
        fantasmas[3] = new FantasmaAzul(13, 7);
        do
        {
            n.Mostrar();
            n.MostrarMarcador();
            p.Mostrar();

            for (int i = 0; i < fantasmas.Length; i++)
            {
                fantasmas[i].Mostrar();
            }

            ConsoleKeyInfo tecla = Console.ReadKey();

            switch (tecla.Key)
            {
            case ConsoleKey.Escape:
                salir = true;
                break;

            case ConsoleKey.LeftArrow:
                if (n.EsPosibleMoverA(p.X - 1, p.Y))
                {
                    p.X--;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            case ConsoleKey.RightArrow:
                if (n.EsPosibleMoverA(p.X + 1, p.Y))
                {
                    p.X++;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            case ConsoleKey.UpArrow:
                if (n.EsPosibleMoverA(p.X, p.Y - 1))
                {
                    p.Y--;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            case ConsoleKey.DownArrow:
                if (n.EsPosibleMoverA(p.X, p.Y + 1))
                {
                    p.Y++;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            default:
                break;
            }

            for (int i = 0; i < fantasmas.Length; i++)
            {//Falta depurar movimiento de fantasmas
                if (n.EsPosibleMoverA(fantasmas[i].X, fantasmas[i].Y + 1))
                {
                    fantasmas[i].MoverAbajo();
                }
                else if (n.EsPosibleMoverA(fantasmas[i].X, fantasmas[i].Y - 1))
                {
                    fantasmas[i].MoverArriba();
                }
                else if (n.EsPosibleMoverA(fantasmas[i].X + 1, fantasmas[i].Y))
                {
                    fantasmas[i].MoverIzquierda();
                }
                else if (n.EsPosibleMoverA(fantasmas[i].X - 1, fantasmas[i].Y))
                {
                    fantasmas[i].MoverDerecha();
                }
            }
            Console.Clear();

            foreach (Fantasma f in fantasmas)
            {
                f.Mostrar();
            }

            n.Mostrar();
            p.Mostrar();

            for (int i = 0; i < fantasmas.Length; i++)
            {
                if (p.X == fantasmas[i].X && p.Y == fantasmas[i].Y)
                {
                    salir = true;
                }
            }

            if (salir)
            {
                Console.WriteLine("TE HA COMIDO EL FANTASMA!");
            }
        }while (!salir);
        Console.SetCursorPosition(5, 12);
        Console.WriteLine("FIN DE LA PARTIDA!");
    }