Example #1
0
    private void ShowEndMenu(int[] pkt)
    {
        endMenuPanel = guiScr.CreatePanel(menuCanvas, "EndMenuPanel", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                          new Vector2(400, 400), new Vector2(0, 0), spr, new Color32(255, 255, 255, 125));
        endMenuButt  = guiScr.FillWithButtons(endMenuPanel, 2, 1, 200, 100, spr, new Color32(255, 255, 255, 255));
        endMenuTex   = guiScr.SetMenuText(endMenuButt, endMenuNames);
        endMenuScore = guiScr.CreateTextField(endMenuPanel, "Score");

        string scor = "";

        if (PlayersNumber > 1)
        {
            scor += ("RED : " + pkt[0].ToString() + "\n");
            scor += ("GREEN : " + pkt[1].ToString() + "\n");
            if (playersNumber >= 3)
            {
                scor += ("BLUE : " + pkt[2].ToString() + "\n");
            }
            if (playersNumber >= 4)
            {
                scor += ("YELLOW : " + pkt[3].ToString() + "\n");
            }
        }
        else
        {
            scor += ("PLAYER : " + pkt[0].ToString() + "\n");
            scor += ("AI : " + pkt[1].ToString() + "\n");
        }
        endMenuScore.GetComponent <Text>().text = scor;

        endMenuButt[0, 0].GetComponent <Button>().onClick.AddListener(delegate
                                                                      { SceneManager.LoadScene(SceneManager.GetActiveScene().name); });
        endMenuButt[1, 0].GetComponent <Button>().onClick.AddListener(delegate
                                                                      { Application.Quit(); });
    }
Example #2
0
    public void SetUp(GameObject parent, float panelX, float panelY, int colsCount, int rowsCount, Sprite panelImage, Sprite boardImage,
                      float buttonSize, Sprite retryImage, Sprite menuImage, Sprite soundImage, Sprite circleImage, Sprite henImage)
    {
        guiScript = gameObject.AddComponent <GuiScript>();
        eggs      = new GameObject[colsCount, rowsCount];

        gamePanel = guiScript.CreatePanel(parent, "GamePanel", new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0),
                                          new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(panelX, panelY), new Vector2(0, 0), panelImage,
                                          new Color32(255, 255, 255, 100));

        float sizeX = panelX / (float)colsCount;
        float sizeY = panelY / (float)rowsCount;

        hens = new GameObject[colsCount];
        for (int i = 0; i < colsCount; i++)
        {
            Vector2 pos = new Vector2((i + 0.5f) * sizeX, sizeY + panelY);
            hens[i] = guiScript.CreateImage(gamePanel, "Hen", new Vector2(0, 0), new Vector2(0, 0),
                                            new Vector2(0.5f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(3.5f * sizeX, 3.5f * sizeY),
                                            new Vector2(pos.x, pos.y + 1.5f * sizeY), henImage, new Color32(255, 255, 255, 255));
            hens[i].SetActive(false);
        }

        holes   = guiScript.FillWithImages(gamePanel, colsCount, rowsCount, boardImage, new Color32(130, 85, 30, 255));
        buttons = guiScript.FillWithButtons(gamePanel, colsCount, 1, panelImage, new Color32(0, 0, 0, 0));

        menuPanel = guiScript.CreatePanel(parent, "MenuPanel", new Vector2(0, 1), new Vector2(0, 1),
                                          new Vector2(0, 1), new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(3 * buttonSize, buttonSize),
                                          new Vector2(0, 0), panelImage, new Color32(255, 255, 255, 0));
        menuButtons = guiScript.FillWithButtons(menuPanel, 3, 1, panelImage, new Color32(255, 255, 255, 255));

        menuButtons[0, 0].GetComponent <Image>().sprite = menuImage;
        menuButtons[1, 0].GetComponent <Image>().sprite = retryImage;
        menuButtons[2, 0].GetComponent <Image>().sprite = soundImage;

        menuButtons[0, 0].GetComponent <Button>().onClick.AddListener(delegate
        {
            Destroy(SettingsScript.instance.gameObject);
            SceneManager.LoadScene("MenuScene");
        });
        menuButtons[1, 0].GetComponent <Button>().onClick.AddListener(delegate { SceneManager.LoadScene(SceneManager.GetActiveScene().name); });

        playerPointer = guiScript.CreateImage(parent, "PlayerPointer", new Vector2(1, 1), new Vector2(1, 1), new Vector2(1, 1),
                                              new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(buttonSize, buttonSize), new Vector2(0, 0),
                                              circleImage, new Color32(255, 255, 255, 255));
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        guiScr    = new GuiScript();
        modelScr  = new ModelScript(CELL_COUNT);
        gamePanel = guiScr.CreatePanel(gameObject, "GamePanel", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                       new Vector2(400, 400), new Vector2(0, 0), spr, new Color32(0, 150, 120, 255));
        menuPanel = guiScr.CreatePanel(gameObject, "MenuPanel", new Vector2(1, 1), new Vector2(1, 1), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                       new Vector2(100, 200), new Vector2(-60, -110), spr, new Color32(255, 255, 255, 0));
        tab      = guiScr.FillWithButtons(gamePanel, 4, 4, 100, 100, spr, new Color32(255, 255, 255, 255));
        menuButt = guiScr.FillWithButtons(menuPanel, 1, 2, 100, 100, spr, new Color32(255, 255, 255, 255));
        tex      = guiScr.SetText(modelScr.Table, CELL_COUNT, tab);
        menuTex  = guiScr.SetMenuText(menuButt);

        onClick = new action(Execute);

        guiScr.SetAction(tab, onClick);

        menuButt[0, 0].GetComponent <Button>().onClick.AddListener(delegate
                                                                   { SceneManager.LoadScene(SceneManager.GetActiveScene().name); });
        menuButt[0, 1].GetComponent <Button>().onClick.AddListener(delegate
                                                                   { Application.Quit(); });
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        guiScr    = new GuiScript();
        menuPanel = guiScr.CreatePanel(menuCanvas, "MenuPanel", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                       new Vector2(200, 400), new Vector2(0, 0), spr, new Color32(255, 255, 255, 0));
        menuButt = guiScr.FillWithButtons(menuPanel, 1, 5, 200, 80, spr, new Color32(255, 255, 255, 255));
        menuTex  = guiScr.SetMenuText(menuButt, menuNames);

        onClick = new action(SetUpGame);

        for (int i = 0; i < menuButt.GetLength(1) - 1; i++)
        {
            int x = i;
            guiScr.SetAction(menuButt[0, x], (x + 1), onClick);
        }

        menuButt[0, menuButt.GetLength(1) - 1].GetComponent <Button>().onClick.AddListener(delegate
                                                                                           { Application.Quit(); });

        ChangeState(new IPlayerTurn());
    }
Example #5
0
    public void ShowEndMenu(GameObject parent, float panelX, float panelY, Sprite panelImage, float buttonSize, float offset,
                            Sprite retryImage, Sprite menuImage)
    {
        endMenuPanel = guiScript.CreatePanel(parent, "EndMenuPanel", new Vector2(0.5f, 1), new Vector2(0.5f, 1),
                                             new Vector2(0.5f, 1), new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(panelX, panelY),
                                             new Vector2(0, -offset), panelImage, new Color32(255, 255, 255, 0));
        guiScript.CreateText(endMenuPanel, "EndText", new Vector2(0.5f, 1), new Vector2(0.5f, 1), new Vector2(0.5f, 1),
                             new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(panelX, panelY * 0.5f), new Vector2(0, 0), "GAME OVER",
                             new Color32(0, 0, 0, 255));
        endMenuButton = guiScript.CreateButton(endMenuPanel, "MenuButton", new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0),
                                               new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(buttonSize, buttonSize),
                                               new Vector2(-0.55f * buttonSize, 0.1f * buttonSize), menuImage, new Color32(255, 255, 255, 255));
        endRetryButton = guiScript.CreateButton(endMenuPanel, "RetryButton", new Vector2(0.5f, 0), new Vector2(0.5f, 0),
                                                new Vector2(0.5f, 0), new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector2(buttonSize, buttonSize),
                                                new Vector2(0.55f * buttonSize, 0.1f * buttonSize), retryImage, new Color32(255, 255, 255, 255));

        endMenuButton.GetComponent <Button>().onClick.AddListener(delegate
        {
            Destroy(SettingsScript.instance.gameObject);
            SceneManager.LoadScene("MenuScene");
        });
        endRetryButton.GetComponent <Button>().onClick.AddListener(delegate { SceneManager.LoadScene(SceneManager.GetActiveScene().name); });
    }