void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
示例#2
0
    public void TogglePanel(bool active, MainMenuPanels panels)
    {
        panelOpen = active;
        switch (panels)
        {
        case MainMenuPanels.Options:
            OptionsPanel.SetActive(active);
            MenuOptions.GetComponent <MenuOptions>().enabled = !active;
            break;

        case MainMenuPanels.Highscore:
            HighscorePanel.SetActive(active);
            MenuOptions.GetComponent <MenuOptions>().enabled = !active;
            break;

        case MainMenuPanels.Credits:
            CreditsPanel.SetActive(active);
            MenuOptions.GetComponent <MenuOptions>().enabled = !active;
            break;
        }
    }
示例#3
0
    public void UpdateEndGameDisplay(int playerIndex, List <Highscore> scores)
    {
        HighscorePanel panel     = FindObjectOfType <HighscorePanel>(true);
        var            toDisplay = new List <Highscore>();

        if (playerIndex <= 3)
        {
            toDisplay = scores.GetRange(0, 4);
        }
        else
        {
            toDisplay = scores.GetRange(0, 3);
            toDisplay.Add(scores[playerIndex]);
        }

        if (panel != null)
        {
            panel.DisplayHighscores(toDisplay, playerIndex - 1);
        }
        else
        {
            Debug.Log("Highscore panel NOT FOUND!");
        }
    }
示例#4
0
    /// <summary>
    /// constructor
    /// </summary>
    /// <param name="_width">panel width</param>
    /// <param name="_height">panel height</param>
    public Menu(int _width, int _height) : base(_width, _height)
    {
        this.setBackground("assets/images/background_game.jpg");

        _startGameCommand = new NetworkCommand("G:START", (x) =>
        {
            this.Dispatcher.Invoke(() => { initNone(); lobbyManager.startGame(); });
        }, false, true);

        _onGengreChange = new NetworkCommand("G:GENCHANGE", (x) =>
        {
            this.Dispatcher.Invoke(() => { tb_lobbygenredisplay.Text = x[0]; });
        });

        // game background
        _backgroundGame = new PanelBase(MainWindow.SCREEN_WIDTH, MainWindow.SCREEN_HEIGHT);
        _backgroundGame.setBackground("assets/images/background_menu.png");
        this.Center(UIPlacerMode.center, 0, _backgroundGame);

        // notifications
        _notification = new NotificationHandler();
        this.addChild(_notification);

        // login pannel
        _loginPanel = new LoginPanel(300, 500);
        _loginPanel.setBackground("assets/images/background_panel.png");
        this.Center(UIPlacerMode.center, 0, _loginPanel);
        _loginPanel.rescale();

        _loginPanel.OnLogin += () =>
        {
            b_login.Content     = "Logout";
            tb_namemessage.Text = "You are logedin as " + Account.name;
            this.removeChild(_loginPanel);
        };

        string title = Account.isActivateAccount() ? "Logout" : "login";

        b_login = UIFactory.CreateButton(title, new Thickness(), new Point(100, 30), (x, y) =>
        {
            if (!MemoryDatabase.isConnected())
            {
                MemoryDatabase.reload();
                return;
            }

            if (Account.isActivateAccount())
            {
                Account.logout();
                b_login.Content     = "Login";
                tb_namemessage.Text = "You are logedin as " + Account.name;
                return;
            }

            if (this.Children.Contains(_loginPanel))
            {
                this.removeChild(_loginPanel);
            }
            else
            {
                this.addChild(_loginPanel);
            }
        });
        this.CenterLeft(UIPlacerMode.top, 5, b_login);

        b_highscore = UIFactory.CreateButton("Highscore's", new Thickness(), new Point(70, 30), (x, y) =>
        {
            if (this.Children.Contains(_highscorePanel))
            {
                this.removeChild(_highscorePanel);
            }
            else
            {
                this.addChild(_highscorePanel);
            }
        });
        this.CenterRigth(UIPlacerMode.top, 5, b_highscore);

        // main menu
        tb_namemessage = UIFactory.CreateTextBlock("You are loged in as " + Account.name, new Thickness(), new Point(400, 50), 20);

        tb_ip = UIFactory.CreateTextBox(new Thickness(), new Point(200, 30), 20);

        b_client = UIFactory.CreateButton("Connect To Game", new Thickness(), new Point(200, 50), (x, y) =>
        {
            startGame(false);
        });

        b_host = UIFactory.CreateButton("Host Game", new Thickness(), new Point(200, 50), (x, y) =>
        {
            startGame(true);
        });

        b_quit = UIFactory.CreateButton("Quit", new Thickness(), new Point(200, 50), (x, y) =>
        {
            System.Windows.Application.Current.Shutdown();
        });

        // lobby menu
        tb_lobbyname = UIFactory.CreateTextBlock(Account.name, new Thickness(), new Point(200, 30), 20);

        tb_lobbyscore = UIFactory.CreateTextBlock(string.Format("Wins: {0} / Losses: {1}", Account.score.wins, Account.score.losses), new Thickness(), new Point(200, 30), 20);

        tb_lobbygenredisplay = UIFactory.CreateTextBlock("Waiting for host", new Thickness(), new Point(200, 30), 20); // client only

        tb_lobbygenre = UIFactory.CreateTextBox(new Thickness(), new Point(200, 30), 20);                              // host only

        b_loggyconfirmgenre = UIFactory.CreateButton("Confirm Genre", new Thickness(), new Point(200, 50), (x, y) =>
        { // host only
            _onGengreChange.send(tb_lobbygenre.Text);
        });

        b_lobbyback = UIFactory.CreateButton("Return To Menu", new Thickness(), new Point(200, 50), (x, y) =>
        {
            initMenu();
        });

        b_lobbystartgame = UIFactory.CreateButton("Start Game", new Thickness(), new Point(200, 50), (x, y) =>
        {
            _startGameCommand.send("");
        });

        tb_lobbyplayerdisplay = UIFactory.CreateTextBlock(Account.name + "\n", new Thickness(), new Point(300, 400), 20, TextAlignment.Left);

        tb_lobbyplayerdisplay.Background = new ImageBrush()
        {
            ImageSource = new BitmapImage((new Uri("assets/images/background_panel.png", UriKind.RelativeOrAbsolute)))
        };

        // loading screen
        tb_loadingmessage = UIFactory.CreateTextBlock("connection to game", new Thickness(), new Point(400, 30), 20);

        b_loadingback = UIFactory.CreateButton("Return To Menu", new Thickness(), new Point(200, 50), (x, y) =>
        {
            terminateLobby();
        });
        this.Center(UIPlacerMode.center, 3, tb_loadingmessage, b_loadingback);

        initMenu();

        MemoryDatabase.init();
        Account.Load();

        // highscore panel
        _highscorePanel = new HighscorePanel(300, 300);
        _highscorePanel.setBackground("assets/images/background_panel.png");
        this.Center(UIPlacerMode.center, 0, _highscorePanel);
        _highscorePanel.rescale();

        tb_namemessage.Text = "You are loged in as " + Account.name;
    }