Esempio n. 1
0
        public PacBze getPacBze()
        {
            // Suche Pacman auf dem Feld
            PacBze x = null;

            foreach (object o in this._gamefieldcontent)
            {
                switch (o.GetType().ToString())
                {
                case "PACBZE.classes.PacBze":
                    x = (PacBze)o;
                    return(x);
                }
            }
            return(x);
        }
Esempio n. 2
0
        private void set_Figur(Direction dir)
        {
            // Suche aktuellen PacMan
            PacBze pac = this._gameField.getPacBze();
            byte   x   = pac.x;
            byte   y   = pac.y;

            switch (dir)
            {
            case Direction.down:
                pac.y += 1;
                break;

            case Direction.up:
                pac.y -= 1;
                break;

            case Direction.left:
                pac.x -= 1;
                break;

            case Direction.right:
                pac.x += 1;
                break;
            }

            List <object> Figuren = _gameField.getFieldInfo(pac.x, pac.y);

            foreach (var o in Figuren)
            {
                switch (o.GetType().ToString())
                {
                case "PACBZE.classes.Wall":
                    pac.x = x;
                    pac.y = y;

                    break;
                }
            }
        }
Esempio n. 3
0
        private void check_rules(ref GameStatus status)
        {
            // Prüfen ob Coin gefressen
            PacBze pac = _gameField.getPacBze();

            List <object> Figuren = _gameField.getFieldInfo(pac.x, pac.y);

            foreach (var o in Figuren)
            {
                switch (o.GetType().ToString())
                {
                case "PACBZE.classes.Coin":

                    pac.SaveCoins.Add((Coin)o);
                    _gameField.GameFieldContent.Remove(o);
                    Console.Beep();
                    if (_gameField.getCoinCount() == 0)
                    {
                        _currenGamer.Score = _currenGamer.Score + pac.SaveCoins.Count;
                        _highScore.Add(_currenGamer);
                        status = GameStatus.succesful;
                    }


                    break;

                case "PACBZE.classes.Monster":
                    pac.Life--;
                    if (pac.Life < 1)
                    {
                        status = GameStatus.gameover;
                    }



                    break;
                }
            }
        }
Esempio n. 4
0
        static public GameField createGamefield()
        {
            GameField gamef = new GameField();

            gamef.FieldName        = "Testspielfeld";
            gamef.GameFieldContent = new System.Collections.Generic.List <object>();

            Wall w = new Wall();

            w.x = 1;
            w.y = 1;



            Coin co = new Coin();

            co.x = 10;
            co.y = 10;

            Coin co1 = new Coin();

            co1.x = 3;
            co1.y = 10;
            Coin co2 = new Coin();

            co2.x = 10;
            co2.y = 3;

            Monster mo = new Monster();

            mo.x = 13;
            mo.y = 13;

            Monster mo1 = new Monster();

            mo1.x = 15;
            mo1.y = 10;



            gamef.GameFieldContent.Add(co);  // Coin zum Spielfeld
            gamef.GameFieldContent.Add(co1); // Coin zum Spielfeld
            gamef.GameFieldContent.Add(co2); // Coin zum Spielfeld
            gamef.GameFieldContent.Add(mo);  // Monster zum Spielfeld
            gamef.GameFieldContent.Add(mo1); // Monster zum Spielfeld


            byte maxX = 20;
            byte maxY = 15;

            // Rahmen zeichnen
            for (byte i = 1; i <= maxX; i++)
            {
                for (byte y = 1; y <= maxY; y++)
                {
                    if ((i == 1 || i == maxX) || (y == 1 || y == maxY))
                    {
                        Wall t = new Wall();
                        t.x = i;
                        t.y = y;
                        gamef.GameFieldContent.Add(t);
                    }
                }
            }
            PacBze pac = new PacBze();

            pac.x    = 5;
            pac.y    = 5;
            pac.Life = 3;

            gamef.GameFieldContent.Add(pac);// Pacman zum Spielfeld
            return(gamef);
        }