private static void Main()
        {
            Watchdog.Watchdog watchdog          = new Watchdog.Watchdog();
            CancellationToken cancellationToken = new CancellationToken();

            watchdog.Input(cancellationToken);
        }
Ejemplo n.º 2
0
        private void Initialise()
        {
            Watchdog.Watchdog watchdog = new Watchdog.Watchdog();

            searchActivity.cancelationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = searchActivity.cancelationTokenSource.Token;

            tcpServerTask = new Task(() => watchdog.Input(cancellationToken), searchActivity.cancelationTokenSource.Token, TaskCreationOptions.LongRunning);

            heartbeatTask = new Task(() => Heartbeat(cancellationToken), searchActivity.cancelationTokenSource.Token, TaskCreationOptions.LongRunning);

            UDPServer.UDPServer udpServer = new UDPServer.UDPServer();

            udpServerTask = new Task(() => udpServer.Input(cancellationToken), searchActivity.cancelationTokenSource.Token, TaskCreationOptions.LongRunning);

            clientTask = new Task(() => Client(cancellationToken), searchActivity.cancelationTokenSource.Token, TaskCreationOptions.LongRunning);
        }
        private void Initialise()
        {
            gameType = Intent.GetStringExtra("gameType");

            latLngToKM = 105.65F;

            utilities = new Utilities(this);

            cancelationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = cancelationTokenSource.Token;

            finishTask = new Task(() => FinishCheck(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);
            scoreTask  = new Task(() => EndConditions(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);
            hazardTask = new Task(() => RunHazards(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);
            cameraTask = new Task(() => MoveCamera(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);

            areaTextView      = (TextView)FindViewById(Resource.Id.Area);
            scoreTextView     = (TextView)FindViewById(Resource.Id.Score);
            area              = 100;
            areaTextView.Text = "Area: " + area.ToString();
            finishBool        = false;

            gameMap = new GameMap(this);

            gamePlayArea          = new GamePlayArea();
            gamePlayArea.vertices = new LinkedList <LatLng>();

            GetVertices();

            gamePlayArea.polygons          = new LinkedList <Polygon>();
            gamePlayArea.playAreaDrawnBool = false;

            gamePosition = new GamePosition(this);

            cameraInitiallySet = false;

            if (gameType == "Single Player")
            {
                numberOfPlayers = 1;

                playerArray = new Player[numberOfPlayers];

                playerPosition = numberOfPlayers - 1;
            }
            else
            {
                if (gameType == "Host")
                {
                    numberOfPlayers = int.Parse(Intent.GetStringExtra("numberOfPlayers"));

                    playerArray = new Player[numberOfPlayers];

                    playerPosition = int.Parse(Intent.GetStringExtra("playerPosition")) - 1;

                    Watchdog.Watchdog watchdog = new Watchdog.Watchdog();

                    serverTask = new Task(() => watchdog.Input(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);

                    heartbeatTask = new Task(() => Heartbeat(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);

                    clientTask = new Task(() => HostClient(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);
                }
                else
                {
                    if (gameType == "Join")
                    {
                        numberOfPlayers = int.Parse(Intent.GetStringExtra("numberOfPlayers"));

                        playerArray = new Player[numberOfPlayers];

                        playerPosition = int.Parse(Intent.GetStringExtra("playerPosition")) - 1;

                        ip = Intent.GetStringExtra("ip");

                        clientTask = new Task(() => JoinClient(cancellationToken), cancelationTokenSource.Token, TaskCreationOptions.LongRunning);
                    }
                }
            }

            for (int i = 0; i < numberOfPlayers; i++)
            {
                playerArray[i] = new Player();

                playerArray[i].score = 0;

                playerArray[i].currentPosition = new LatLng(0, 0);
                playerArray[i].vertices        = new LinkedList <LatLng>();
                playerArray[i].drawingBool     = false;
                playerArray[i].positionBool    = true;
                playerArray[i].deathBool       = false;
            }

            scoreTextView.Text = "Score: " + playerArray[playerPosition].score.ToString();

            rotation    = new Rotation(this);
            gravity     = new float[3];
            geoMagnetic = new float[3];
            azimuth     = 0;

            hazards = new Hazards(this);
        }