Пример #1
0
    /* This draws the gui and attaches the buttons to the appropriate functions */
    void OnGUI()
    {
        GUI.skin = this.myGUISkin;

        //		// Old fetch status button
        //		if (GUI.Button (new Rect (45, 45, Screen.width/2 - 90, 95), "Fetch Status")) {
        //			myNetworkHelper.refreshGameState(worldName,worldPassword,playerName,playerPassword,refreshGameStateInGUI);
        //		}

        // This turns the gyro on and off.  You can set it as you see fit
        Input.gyro.enabled = true;

        // TODO: Implement the rest of the GUI
        // Fetch Status
        if (GUI.Button(new Rect(0, 0, boxWidth, boxHeight), "Fetch Status"))
        {
            myNetworkHelper.refreshGameState(worldName, worldPassword, playerName, playerPassword, refreshGameStateInGUI);
        }

        //// Toggle
        // Expand
        expandGUI = GUI.Toggle(new Rect(boxWidth, 0, boxWidth, boxHeight), expandGUI, "Expand");

        if (expandGUI)
        {
            //// GUI.Label inside GUI.Box
            // Current Location
            GUI.Label(new Rect(0, boxHeight, Screen.width, boxHeight), "Current Location: (" + lastLat + ", " + lastLng + ", " + lastAlt + ")");



            // Tower Location
            if (myNetworkHelper.isTowerSet())
            {
                GUI.Label(new Rect(0, 2 * boxHeight, Screen.width, boxHeight), "Tower Location: (" + myNetworkHelper.getTowerLat() + ", " + myNetworkHelper.getTowerLng() + ", " + myNetworkHelper.getTowerAlt() + ")");
            }
            else
            {
                GUI.Label(new Rect(0, 2 * boxHeight, Screen.width, boxHeight), "Tower Location:");
            }


            // Bomb Location
            if (myNetworkHelper.isBombSet())
            {
                GUI.Label(new Rect(0, 3 * boxHeight, Screen.width, boxHeight), "Bomb Location: (" + myNetworkHelper.getBombLat() + ", " + myNetworkHelper.getBombLng() + ", " + myNetworkHelper.getBombAlt() + ")");
            }
            else
            {
                GUI.Label(new Rect(0, 3 * boxHeight, Screen.width, boxHeight), "Bomb Location: ");
            }



            //// Text fields

            // World Name
            GUI.Label(new Rect(0, 4 * boxHeight, Screen.width, boxHeight / 2), "World Name");
            worldName = GUI.TextField(new Rect(0, 4 * boxHeight, boxWidth, boxHeight), worldName);

            // World Password
            GUI.Label(new Rect(0, 5 * boxHeight, Screen.width, boxHeight / 2), "World Password");
            worldPassword = GUI.TextField(new Rect(0, 5 * boxHeight, boxWidth, boxHeight), worldPassword);

            // Player Name
            GUI.Label(new Rect(0, 6 * boxHeight, Screen.width, boxHeight / 2), "Player Name");
            playerName = GUI.TextField(new Rect(0, 6 * boxHeight, boxWidth, boxHeight), playerName);

            // Player Password
            GUI.Label(new Rect(0, 7 * boxHeight, Screen.width, boxHeight / 2), "Player Password");
            playerPassword = GUI.TextField(new Rect(0, 7 * boxHeight, boxWidth, boxHeight), playerPassword);

            // Code
            GUI.Label(new Rect(0, 8 * boxHeight, Screen.width, boxHeight / 2), "Secret Code");
            secretcode = GUI.TextField(new Rect(0, 8 * boxHeight, boxWidth, boxHeight), secretcode);


            // Buttons



            // Place Tower
            if (GUI.Button(new Rect(boxWidth, 4 * boxHeight, boxWidth, boxHeight), "Place Tower"))
            {
                myNetworkHelper.buildTowerPoint(lastLat, lastLng, lastAlt);
            }

            // Upload Tower
            if (GUI.Button(new Rect(boxWidth, 5 * boxHeight, boxWidth, boxHeight), "Upload Tower"))
            {
                myNetworkHelper.uploadTowerPoint(worldName, worldPassword, playerName, playerPassword, refreshGameStateInGUI);
            }
            // Place Bomb
            if (GUI.Button(new Rect(boxWidth, 6 * boxHeight, boxWidth, boxHeight), "Place Bomb"))
            {
                myNetworkHelper.dropBombPoint(lastLat, lastLng, lastAlt);
            }

            // Upload Bomb
            if (GUI.Button(new Rect(boxWidth, 7 * boxHeight, boxWidth, boxHeight), "Upload Bomb"))
            {
                myNetworkHelper.uploadBombPoint(worldName, worldPassword, playerName, playerPassword, refreshGameStateInGUI);
            }

            // Upload Code
            if (GUI.Button(new Rect(boxWidth, 8 * boxHeight, boxWidth, boxHeight), "Upload Code"))
            {
                myNetworkHelper.uploadCode(worldName, worldPassword, playerName, playerPassword, secretcode, refreshGameStateInGUI);
            }

            // Leader Board
            if (GUI.Button(new Rect(boxWidth, 9 * boxHeight, boxWidth, boxHeight), "Leader Board"))
            {
                myNetworkHelper.requestLeaderBoard(worldName, worldPassword, leaderBoardCallback);
                leaders = null;
            }
        }
        else
        {
            GUI.Label(new Rect(boxWidth, boxHeight, boxWidth, 8 * boxHeight), leaders);
        }
    }
Пример #2
0
    /* This draws the gui and attaches the buttons to the appropriate functions */
    void OnGUI()
    {
        GUI.skin = this.myGUISkin;

        if (GUI.Button(new Rect(0, 0, Screen.width / 2, 150), "Fetch Status"))
        {
            myNetworkHelper.refreshGameState(worldName, worldPassword, playerName, playerPassword, refreshGameStateInGUI);
        }

        // This turns the gyro on and off.  You can set it as you see fit
        Input.gyro.enabled = true;

        // TODO: Implement the rest of the GUI
        expandGUI = GUI.Toggle(new Rect(Screen.width / 2, 0, Screen.width / 2, 150), expandGUI, "Expand");
        if (expandGUI)
        {
            worldName      = GUI.TextField(new Rect(0, 600, Screen.width / 2, 150), worldName);
            worldPassword  = GUI.TextField(new Rect(0, 750, Screen.width / 2, 150), worldPassword);
            playerName     = GUI.TextField(new Rect(0, 900, Screen.width / 2, 150), playerName);
            playerPassword = GUI.TextField(new Rect(0, 1050, Screen.width / 2, 150), playerPassword);
            secretcode     = GUI.TextField(new Rect(0, 1200, Screen.width / 2, 150), secretcode);

            GUI.Label(new Rect(0, 150, Screen.width, 150), "Current Location\n(" + Input.location.lastData.latitude + " "
                      + Input.location.lastData.longitude + ") " + Input.location.lastData.altitude);

            if (myNetworkHelper.isTowerSet())
            {
                GUI.Label(new Rect(0, 300, Screen.width, 150), "Current Tower\n(" + myNetworkHelper.getTowerLat() + " "
                          + myNetworkHelper.getTowerLng() + ") " + myNetworkHelper.getTowerAlt());
            }

            if (myNetworkHelper.isBombSet())
            {
                GUI.Label(new Rect(0, 450, Screen.width, 150), "Current Bomb\n(" + myNetworkHelper.getBombLat() + " "
                          + myNetworkHelper.getBombLng() + ") " + myNetworkHelper.getBombAlt());
            }
            if (GUI.Button(new Rect(Screen.width / 2, 600, Screen.width / 2, 150), "PlaceTower"))
            {
                myNetworkHelper.buildTowerPoint(myLocation.getLat(), myLocation.getLng(), myLocation.getAlt());
            }
            if (GUI.Button(new Rect(Screen.width / 2, 750, Screen.width / 2, 150), "UploadTower"))
            {
                myNetworkHelper.uploadTowerPoint(worldName, worldPassword, playerName, playerPassword, genericCallback);
            }
            if (GUI.Button(new Rect(Screen.width / 2, 900, Screen.width / 2, 150), "PlaceBomb"))
            {
                myNetworkHelper.dropBombPoint(myLocation.getLat(), myLocation.getLng(), myLocation.getAlt());
            }
            if (GUI.Button(new Rect(Screen.width / 2, 1050, Screen.width / 2, 150), "UploadBomb"))
            {
                myNetworkHelper.uploadBombPoint(worldName, worldPassword, playerName, playerPassword, genericCallback);
            }
            if (GUI.Button(new Rect(Screen.width / 2, 1200, Screen.width / 2, 150), "UploadCode"))
            {
                //myNetworkHelper.uploadCode(worldName, worldPassword, playerName, playerPassword, refreshGameStateInGUI);
                myNetworkHelper.uploadCode(worldName, worldPassword, playerName, playerPassword, secretcode, genericCallback);
            }
            if (GUI.Button(new Rect(0, 1350, Screen.width, 150), "LeederBored"))
            {
            }

            GUI.Label(new Rect(0, 1500, Screen.width, 150), destination.ToString());

            foreach (string d in errors)
            {
                GUI.Label(new Rect(0, 1650, Screen.width, 150), d.ToString());
            }

            while (errors.Count > 1)
            {
                errors.RemoveAt(0);
            }
        }
    }
Пример #3
0
	/* This draws the gui and attaches the buttons to the appropriate functions */
	void OnGUI ()
	{
		GUI.skin = this.myGUISkin;

		show_UI = GUI.Toggle(new Rect(Screen.width/2, 0, Screen.width/2, 50), show_UI, "Show UI");

		if(show_UI)
		{
			if (GUI.Button (new Rect (0, 0, Screen.width/2 - 90, 50), "Fetch Status")) 
			{
				myNetworkHelper.refreshGameState(worldName,worldPassword,playerName,playerPassword,refreshGameStateInGUI);
			}

			// This turns the gyro on and off. You can set it as you see fit
			Input.gyro.enabled = true;
			
			// TODO: Implement the rest of the GUI
			GUI.Label(new Rect(0, 50, Screen.width, 50), "Current Location: (" + lastLat + ", " + lastLng + ") " + lastAlt);
			if(towerPlaced)
			{
				GUI.Label(new Rect(0, 100, Screen.width, 50), "Tower Location: (" + myNetworkHelper.getTowerLat() 
			          					+ ", " + myNetworkHelper.getTowerLng() + ") " + myNetworkHelper.getTowerAlt());
			}
			else
				GUI.Label(new Rect(0, 100, Screen.width, 50), "Tower Location");
			if(bombPlaced)
			{
				GUI.Label(new Rect(0, 150, Screen.width, 50), "Bomb Location: (" + myNetworkHelper.getBombLat() 
			          	+ ", " + myNetworkHelper.getBombLng() + ") " + myNetworkHelper.getBombAlt());
			}
			else
				GUI.Label(new Rect(0, 150, Screen.width, 50), "Bomb Location");

			//All the text fields for the information we need to put into the game
			worldName = GUI.TextField(new Rect(0, 200, Screen.width/2, 50), worldName);
			worldPassword = GUI.TextField(new Rect(0, 250, Screen.width/2, 50), worldPassword);
			playerName = GUI.TextField(new Rect(0, 300, Screen.width/2, 50), playerName);
			playerPassword = GUI.TextField(new Rect(0, 350, Screen.width/2, 50), playerPassword);
			secretcode = GUI.TextField(new Rect(0, 400, Screen.width/2, 50), secretcode);

			//Upload and place buttons 
			if(GUI.Button(new Rect(Screen.width/2, 200, Screen.width/2, 50), "Place Tower")) 
			{
				//save current position with tower specific object, overwrite this data if already present
				//first we update our current location
				myNetworkHelper.buildTowerPoint(lastLat, lastLng, lastAlt);
				towerPlaced = true;
		
			}
			if(GUI.Button(new Rect(Screen.width/2, 250, Screen.width/2, 50), "Upload Tower")) 
			{
				myNetworkHelper.uploadTowerPoint(worldName, worldPassword, playerName, playerPassword, genericCallback);
				towerPlaced = false;
			}
			if(GUI.Button(new Rect(Screen.width/2, 300, Screen.width/2, 50), "Place Bomb")) 
			{
				//save current position with bomb specific object, overwrite this data if already present
				//first we update our current location
				myNetworkHelper.dropBombPoint(lastLat, lastLng, lastAlt);
				bombPlaced = true;
			}
			if(GUI.Button(new Rect(Screen.width/2, 350, Screen.width/2, 50), "Upload Bomb")) 
			{
				myNetworkHelper.uploadBombPoint(worldName, worldPassword, playerName, playerPassword, genericCallback);
				bombPlaced = false;
			}
			if(GUI.Button(new Rect(Screen.width/2, 400, Screen.width/2, 50), "Upload Code"))
			{
				myNetworkHelper.uploadCode(worldName, worldPassword, playerName, playerPassword, secretcode, genericCallback);
			}
			if(GUI.Button(new Rect(Screen.width/2, 450, Screen.width/2, 50), "Leader Board")) 
			{
				myNetworkHelper.requestLeaderBoard(worldName, worldPassword, leaderBoardCallback);
			}
		}
		
	}
Пример #4
0
    /* This draws the gui and attaches the buttons to the appropriate functions */
    void OnGUI()
    {
        GUI.skin = this.myGUISkin;

        if (GUI.Button(new Rect(0, 0, Screen.width / 2, Screen.height / 10), "Fetch Status"))
        {
            myNetworkHelper.refreshGameState(worldName, worldPassword, playerName, playerPassword, refreshGameStateInGUI);
        }
        if (GUI.Button(new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height / 10), "Show/Hide UI"))
        {
            expandGUI = !expandGUI;
        }

        Input.gyro.enabled = true;

        if (!expandGUI)
        {
            return;
        }

        GUI.Box(new Rect(0, Screen.height / 10, Screen.width, Screen.height / 10), "Current Location");
        GUI.Label(new Rect(0, Screen.height / 10, Screen.width, Screen.height / 10), "(" + lastLng + ", " + lastLat + ") " + lastAlt);

        GUI.Box(new Rect(0, Screen.height / 10 * 2, Screen.width, Screen.height / 10), "Tower Location");
        if (myNetworkHelper.isTowerSet())
        {
            GUI.Label(new Rect(0, Screen.height / 10 * 2, Screen.width, Screen.height / 10), "(" + myNetworkHelper.getTowerLng() + ", " + myNetworkHelper.getTowerLat() + ") " + myNetworkHelper.getTowerAlt());
        }
        else
        {
            GUI.Label(new Rect(0, Screen.height / 10 * 2, Screen.width, Screen.height / 10), "");
        }

        GUI.Box(new Rect(0, Screen.height / 10 * 3, Screen.width, Screen.height / 10), "Bomb Location");
        if (myNetworkHelper.isBombSet())
        {
            GUI.Label(new Rect(0, Screen.height / 10 * 3, Screen.width, Screen.height / 10), "(" + myNetworkHelper.getBombLng() + ", " + myNetworkHelper.getBombLat() + ") " + myNetworkHelper.getBombAlt());
        }
        else
        {
            GUI.Label(new Rect(0, Screen.height / 10 * 3, Screen.width, Screen.height / 10), "");
        }


        /* Left column */

        GUI.Box(new Rect(0, Screen.height / 10 * 4, Screen.width / 2, Screen.height / 10), "World Name");
        worldName = GUI.TextField(new Rect(0, Screen.height / 10 * 4 + 10, Screen.width / 2, Screen.height / 10), worldName);

        GUI.Box(new Rect(0, Screen.height / 10 * 5, Screen.width / 2, Screen.height / 10), "World Password");
        worldPassword = GUI.TextField(new Rect(0, Screen.height / 10 * 5 + 10, Screen.width / 2, Screen.height / 10), worldPassword);

        GUI.Box(new Rect(0, Screen.height / 10 * 6, Screen.width / 2, Screen.height / 10), "Player Name");
        playerName = GUI.TextField(new Rect(0, Screen.height / 10 * 6 + 10, Screen.width / 2, Screen.height / 10), playerName);

        GUI.Box(new Rect(0, Screen.height / 10 * 7, Screen.width / 2, Screen.height / 10), "Player Password");
        playerPassword = GUI.TextField(new Rect(0, Screen.height / 10 * 7 + 10, Screen.width / 2, Screen.height / 10), playerPassword);

        GUI.Box(new Rect(0, Screen.height / 10 * 8, Screen.width / 2, Screen.height / 10), "Secret Code");
        secretcode = GUI.TextField(new Rect(0, Screen.height / 10 * 8 + 10, Screen.width / 2, Screen.height / 10), secretcode);

        /* Right column */

        if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 10 * 4, Screen.width / 2, Screen.height / 10), "Place Tower"))
        {
            myNetworkHelper.buildTowerPoint(lastLat, lastLng, lastAlt);
        }

        if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 10 * 5, Screen.width / 2, Screen.height / 10), "Upload Tower"))
        {
            myNetworkHelper.uploadTowerPoint(worldName, worldPassword, playerName, playerPassword, genericCallback);
        }

        if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 10 * 6, Screen.width / 2, Screen.height / 10), "Place Bomb"))
        {
            myNetworkHelper.dropBombPoint(lastLat, lastLng, lastAlt);
        }

        if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 10 * 7, Screen.width / 2, Screen.height / 10), "Upload Bomb"))
        {
            myNetworkHelper.uploadBombPoint(worldName, worldPassword, playerName, playerPassword, genericCallback);
        }

        if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 10 * 8, Screen.width / 2, Screen.height / 10), "Upload Code"))
        {
            myNetworkHelper.uploadCode(worldName, worldPassword, playerName, playerPassword, secretcode, genericCallback);
        }
    }