Ejemplo n.º 1
0
        private void gameTick()
        {
            //move player
            for (int i = 0; i < players.Count; i++)
            {
                players[i].movePlayer();
            }

            //move ghosts
            redGhost.Move();
            yellowGhost.Move();
            pinkGhost.Move();

            updateRemoteGhosts();

            redGhost.IntersectsWith(wall1);
            redGhost.IntersectsWith(wall2);

            yellowGhost.IntersectsWith(wall3);
            yellowGhost.IntersectsWith(wall4);


            //moving ghosts and bumping with the walls end
            //for loop to check walls, ghosts and points
            for (int i = 0; i < players.Count; i++)
            {
                Player p = players[i];
                for (int j = 0; j < walls.Count; j++)
                {
                    if (p.IntersectsWith(walls[j].r))
                    {
                        p.GameOver();
                    }
                }

                if (p.IntersectsWith(redGhost.r) || p.IntersectsWith(yellowGhost.r) || p.IntersectsWith(pinkGhost.r))
                {
                    p.GameOver();
                }


                for (int j = 0; j < coins.Count; j++)
                {
                    if (p.IntersectsWith(coins[j].r))
                    {
                        coinsRemoved.Add(coins[j].getId());
                        coins.RemoveAt(j);
                        p.score++;
                    }
                }
            }
            if (coinsRemoved.Count > 0)
            {
                sendUpdateCoins();
            }



            pinkGhost.IntersectsWith(wall1);
            pinkGhost.IntersectsWith(wall2);
            pinkGhost.IntersectsWith(wall3);
            pinkGhost.IntersectsWith(wall4);
            pinkGhost.checkBoardX();
            pinkGhost.checkBoardY();

            if (coins.Count == 0)
            {
                calculateWinner();
                gameRunning = true;
                Thread.Sleep(10000);
                //TODO Close Game Clean Variables
            }
        }