Ejemplo n.º 1
0
    void OnGUI()
    {
        // Schedule notifications GUI
        GUI.Box(new Rect(10, 10, 340, 300), "ELAN Demo");

        if (GUI.Button(new Rect(20, 40, 120, 40), "Send"))
        {
            long d;
            if (long.TryParse(delay, out d))
            {
                long r;
                if (long.TryParse(rep, out r))
                {
                    if (r <= 0)
                    {
                        ELANManager.SendNotification(title, message, d);
                    }
                    else
                    {
                        ELANManager.ScheduleRepeatingNotification(title, message, d, r);
                    }
                    error = "";
                }
                else
                {
                    error = "Repetition must be an integer!";
                }
            }
            else
            {
                error = "Delay must be an integer!";
            }
        }
        title   = GUI.TextField(new Rect(20, 90, 120, 40), title, 15);
        message = GUI.TextField(new Rect(20, 140, 120, 40), message, 15);
        GUI.Label(new Rect(20, 190, 120, 40), "Delay");
        delay = GUI.TextField(new Rect(120, 190, 120, 40), delay, 15);
        GUI.Label(new Rect(20, 240, 120, 40), "Repetition");
        rep = GUI.TextField(new Rect(120, 240, 120, 40), rep, 15);
        if (GUI.Button(new Rect(20, 320, 120, 40), "Exit"))
        {
            Application.Quit();
        }

        GUI.Label(new Rect(20, 380, 300, 40), error);

        // Cancel scheduled notification GUI
        GUI.Box(new Rect(410, 10, 300, 150), "Cancel notifications");

        if (GUI.Button(new Rect(420, 40, 140, 40), "Cancel repeating"))
        {
            ELANManager.CancelRepeatingNotification();
        }
        if (GUI.Button(new Rect(420, 90, 140, 40), "Cancel ALL"))
        {
            ELANManager.CancelAllNotifications();
        }
    }
Ejemplo n.º 2
0
    void OnGUI()
    {
        GUI.skin = configurationSkin;

        //Background box Rect(x,y,width,height)
        //Main Menu
        Color32 colorAux = GUI.backgroundColor;

        GUI.Box(new Rect(0, 0, Screen.width * 4 / 5 + 10, Screen.height), "", configurationSkin.GetStyle("PanelContent"));

        GUI.Box(new Rect(Screen.width - Screen.width / 5, 0, Screen.width / 5, Screen.height), "", configurationSkin.GetStyle("PanelLeft"));

        //Creating Buttons
        mainMenuX = Screen.width - Screen.width / 5;
        mainMenuY = 0;
        menuOpW   = Screen.width / 5;
        menuOpH   = Screen.height / 4;

        Color32 color = new Color(0, 0, 0, 0);

        GUI.backgroundColor = color;

        if (bVisiblePlant)
        {
            if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iPlanta))
            {
                ApplicationModel.currentLevel = 1;
                Application.LoadLevel("InitialMainMenu");
            }
        }

        mainMenuY += Screen.height / 4;
        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iLogros))
        {
            Application.LoadLevel("AchievementsMenu");
        }

        mainMenuY += Screen.height / 4;
        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iFoto))
        {
            Application.LoadLevel("FacebookMenu");
        }

        mainMenuY += Screen.height / 4;
        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iConfig))
        {
            Application.LoadLevel("ConfigurationMenu");
        }

        /*
         *
         * Panel Configuration
         *
         * */

        int auxX = 0;
        int auxY = 0;

        GUI.backgroundColor = colorAux;

        GUI.Box(new Rect(Screen.width * 4 / 5 * 1 / 38, Screen.height * 1 / 27, Screen.width * 4 / 5 * 36 / 38, Screen.height * 25 / 27), "", configurationSkin.GetStyle("PanelCenter"));

        //Creating Buttons 3 iconos , 4 espaces
        mainMenuX = (Screen.width * 4 / 5) * 1 / 8;
        auxX      = mainMenuX;
        mainMenuY = (Screen.height / 3) * 1 / 2;
        menuOpW   = (Screen.width * 4 / 5) * 1 / 6;
        menuOpH   = Screen.height / 3 * 3 / 4;
        auxY      = Screen.height / 3 + Screen.height / 3 * 1 / 4;

        GUI.backgroundColor = color;

        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iAlertas))
        {
            optionMenu = 1;
        }
        GUI.Label(new Rect(mainMenuX + menuOpW * 1 / 4, mainMenuY + menuOpH, menuOpW, menuOpH), "Alertas");

        mainMenuX += auxX + menuOpW;

        GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iFB);
        GUI.Label(new Rect(mainMenuX + menuOpW * 1 / 5, mainMenuY + menuOpH, menuOpW, menuOpH), "Cuenta de Facebook");

        mainMenuX += auxX + menuOpW;

        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iAcerca))
        {
            optionMenu = 3;
        }
        GUI.Label(new Rect(mainMenuX + menuOpW * 1 / 4, mainMenuY + menuOpH, menuOpW, menuOpH), "A Cerca De");


        mainMenuX  = auxX;
        mainMenuY += auxY;

        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iHistorial))
        {
            optionMenu = 4;
        }

        GUI.Label(new Rect(mainMenuX + menuOpW * 1 / 4, mainMenuY + menuOpH, menuOpW, menuOpH), "Cambiar Nombre a Planta");

        mainMenuX += auxX + menuOpW;

        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iMensajes))
        {
            optionMenu = 5;
        }
        GUI.Label(new Rect(mainMenuX + menuOpW * 1 / 5, mainMenuY + menuOpH, menuOpW, menuOpH), "Cambiar Nombre Jugador");

        mainMenuX += auxX + menuOpW;

        if (GUI.Button(new Rect(mainMenuX, mainMenuY, menuOpW, menuOpH), iSonidos))
        {
            optionMenu = 6;
        }
        GUI.Label(new Rect(mainMenuX + menuOpW * 1 / 4, mainMenuY + menuOpH, menuOpW, menuOpH), "Reiniciar");


        /**
         * Creating Options
         * */

        GUI.backgroundColor = colorAux;

        mainMenuX = (Screen.width * 4 / 5) * 1 / 8;
        auxX      = mainMenuX;
        mainMenuY = (Screen.height / 3) * 1 / 2;
        menuOpW   = (Screen.width * 4 / 5) * 1 / 6;
        menuOpH   = Screen.height / 3 * 3 / 4;
        auxY      = Screen.height / 3 + Screen.height / 3 * 1 / 4;

        if (optionMenu > 0)
        {
            GUI.Box(new Rect(mainMenuX, mainMenuY, menuOpW * 5, menuOpH * 3), "");
        }

        switch (optionMenu)
        {
        case 1:
            buttonSaveX = mainMenuX + menuOpW * 5 / 2 - menuOpW / 2;
            buttonSaveY = mainMenuY + menuOpH * 3 / 2 - menuOpH / 4;

            notificationOn = GUI.Toggle(new Rect(buttonSaveX, buttonSaveY, 150, 15), notificationOn, "Activar/Desactivar");

            Debug.Log("Toggle " + notificationOn);
            if (GUI.Button(new Rect(buttonSaveX, buttonSaveY + 30, menuOpW, menuOpH / 2), "Guardar"))
            {
                ELANManager.CancelRepeatingNotification();
                if (notificationOn)
                {
                    myConfiguration.notificationOn = true;
                    ELANManager.ScheduleRepeatingNotification("PlantAR", ":'( Agua", 0, 10);
                    Debug.Log("Notification ON");
                }
                else
                {
                    myConfiguration.notificationOn = false;
                    Debug.Log("Notification OFF");
                }

                SaveConfiguration();
                optionMenu = 0;
            }
            break;

        case 2:
            break;

        case 3:
            buttonSaveX = mainMenuX + menuOpW * 5 / 2 - menuOpW / 2;
            buttonSaveY = mainMenuY + menuOpH * 2;
            string about = "PlantAR @Copyrights";
            GUI.Label(new Rect(mainMenuX + menuOpW, buttonSaveY - menuOpH * 3 / 2, menuOpW * 3, menuOpH * 2), about, configurationSkin.GetStyle("TextAbout"));

            if (GUI.Button(new Rect(buttonSaveX, buttonSaveY + 30, menuOpW, menuOpH / 4), "Aceptar"))
            {
                optionMenu = 0;
            }
            break;

        case 4:
            buttonSaveX = mainMenuX + menuOpW * 5 / 2 - menuOpW / 2;
            buttonSaveY = mainMenuY + menuOpH * 2;
            plantName   = GUI.TextField(new Rect(buttonSaveX - 50, buttonSaveY - menuOpH, 200, 25), plantName, 25);
            //playerName = GUI.TextField(new Rect(dialogDivX*2,dialogDivY+dialogDivH*4/10,200,25), playerName ,25);
            if (GUI.Button(new Rect(buttonSaveX, buttonSaveY + 30, menuOpW, menuOpH / 4), "Guardar"))
            {
                myConfiguration.plantName = plantName;
                optionMenu = 0;
                SaveConfiguration();
            }
            break;

        case 5:
            buttonSaveX = mainMenuX + menuOpW * 5 / 2 - menuOpW / 2;
            buttonSaveY = mainMenuY + menuOpH * 2;
            playerName  = GUI.TextField(new Rect(buttonSaveX - 50, buttonSaveY - menuOpH, 200, 25), playerName, 25);
            //playerName = GUI.TextField(new Rect(dialogDivX*2,dialogDivY+dialogDivH*4/10,200,25), playerName ,25);
            if (GUI.Button(new Rect(buttonSaveX, buttonSaveY + 30, menuOpW, menuOpH / 4), "Guardar"))
            {
                myConfiguration.playerName = playerName;
                SaveConfiguration();
                optionMenu = 0;
            }
            break;

        case 6:
            buttonSaveX = mainMenuX + menuOpW * 5 / 2 - menuOpW / 2;
            buttonSaveY = mainMenuY + menuOpH * 2;
            //playerName = GUI.TextField(new Rect(dialogDivX*2,dialogDivY+dialogDivH*4/10,200,25), playerName ,25);
            if (GUI.Button(new Rect(buttonSaveX, buttonSaveY + 30, menuOpW, menuOpH / 4), "Reiniciar"))
            {
                myConfiguration = new PlantARData();
                myAchievements  = new AchievementsData();
                CreateConfiguration();
                CreateAchievements();
                ApplicationModel.initialTime = 0;
                optionMenu = 0;
            }
            break;
        }
    }