Beispiel #1
0
 //Method to add startpoint to screen
 public void AddStartPoint(StartPoint s, Canvas c)
 {
     //Add everything to the screen
     Canvas.SetTop(s.rect, s.Y);
     Canvas.SetLeft(s.rect, s.X);
     c.Children.Add(s.rect);
 }
Beispiel #2
0
        public Game(MainWindow mw, Canvas canvas, int aantalBoom, int aantalBom, int aantalMoving, int aantalCoin, int s, bool rl)
        {
            mainWindow        = mw;
            GameCanvas        = canvas;
            this.amountTree   = aantalBoom;
            this.amountBomb   = aantalBom;
            this.amountMoving = aantalMoving;
            this.amountCoin   = aantalCoin;
            Seconde           = s;
            randomLevel       = rl;

            playing    = true;
            StartPoint = new StartPoint();
            AddStartPoint(StartPoint, GameCanvas);

            obstacles = new Obstacles(aantalBoom, aantalBom, aantalMoving, aantalCoin, randomLevel);
            PlaceAllObstacles();

            Player = new Player();
            AddPlayer();
            Player.walkedOverBomb         += OnPlayerWalkedOverBomb;
            Player.collectCoin            += OnPlayerCollectCoin;
            Player.walkedOnMovingObstacle += OnDeadByMovingObstacle;
            GameTimer           = new Model.Timer(Seconde, this);
            GameTimer.timeIsUp += OnPlayerTimeIsUp;


            mw.escKeyIsPressed   += OnEscKeyIsPressed;
            mw.enterKeyIsPressed += OnEnterKeyIsPressed;
            activeEndPoint       += OnActivateEndpoint;
            foreach (Obstacle o in Obstacles.obstacles)
            {
                if (o.GetType().ToString() == "KBSGame.Model.MovingObstacle")
                {
                    MovingObstacle mo = (MovingObstacle)o;
                    mo.deadByMovingObstacle += OnDeadByMovingObstacle;
                }
            }

            CollectedCoins = 0;
        }