private void Refresh(int phase, MenuLayer layer)
        {
            switch (phase)
            {
            case 1:
                ScoreBox.SetText(GamestateManager.Instance.Points.ToString());
                break;

            case 2:
                Layers[MenuLayer.Scores].FindAll(actor => !ScoreActors.Contains(actor)).ForEach(actor => { actor.Dispose(); Layers[MenuLayer.Scores].Remove(actor); });

                int i = 0;

                ScoreManager.GetScores(10, ScoresOffset).ForEach(score =>
                {
                    Layers[MenuLayer.Scores].AddRange(new List <Actor>
                    {
                        new MenuTextBox(new Vector2f(100, 210 + i * 50), new Vector2f(300, 50), score.Item1, 20),
                        new MenuTextBox(new Vector2f(400, 210 + i++ *50), new Vector2f(300, 50), score.Item2, 20)
                    });
                });
                if (layer != MenuLayer.Scores)
                {
                    Layers[MenuLayer.Scores].ForEach(actor => actor.Visible = false);
                }
                break;

            case 3:
                QuitNoSaveButton.Visible = layer == MenuLayer.Main && GamestateManager.Instance.GamePhase != GamePhase.NotStarted && GamestateManager.Instance.GamePhase != GamePhase.Ending;
                ScoresPrev.Visible       = layer == MenuLayer.Scores && ScoresOffset > 0;
                ScoresNext.Visible       = layer == MenuLayer.Scores && ScoresOffset + 10 < ScoreManager.GetScoresCount();
                break;
            }
        }
예제 #2
0
 public MenuView(IGuiServices guiServices,
                 MenuLayer menuLayer) : base(guiServices)
 {
     _layers = new List <Layer> {
         menuLayer
     };
 }
예제 #3
0
        public static void Update()
        {
            if (ControlInput.IsKeyPressed(Keys.Enter) && menuLayer == MenuLayer.Tiles && menuLayer == lastMenuLayer)
            {
                menuLayer = MenuLayer.Editor;
            }

            if (enabled)
            {
                Input();
                Layer();
                Selection();
            }

            if (ControlInput.IsKeyPressed(Keys.Escape) && menuLayer == MenuLayer.Game)
            {
                enabled = !enabled;

                if (enabled)
                {
                    gameState = GameState.Pause;
                }
                else if (!enabled)
                {
                    gameState = GameState.Play;
                }
            }

            if (ControlInput.IsKeyPressed(Keys.Escape) && menuLayer == MenuLayer.Editor || ControlInput.IsKeyPressed(Keys.Escape) && menuLayer == MenuLayer.Tiles)
            {
                menuLayer = MenuLayer.Editor;
                enabled   = !enabled;
            }
        }
        private void ShowLayer(MenuLayer layer)
        {
            Refresh(1, layer);

            Hide();
            MenuBackground.Visible = true;

            Refresh(2, layer);

            Layers[layer].ForEach(renderable => renderable.Visible = true);

            Refresh(3, layer);
        }
예제 #5
0
        public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
        {
            application.ContentRootDirectory = "Content";
            application.PreferMultiSampling  = false;
            CCSize winSize       = mainWindow.WindowSizeInPixels;
            float  desiredWidth  = 640.0f;
            float  desiredHeight = 960.0f;

            CCScene.SetDefaultDesignResolution(desiredWidth, desiredHeight, CCSceneResolutionPolicy.ExactFit);

            CCScene scene = MenuLayer.GameStartLayerScene(mainWindow);

            mainWindow.RunWithScene(scene);
        }
예제 #6
0
        static Menu()
        {
            menuLayer    = MenuLayer.Menu;
            title        = Setup.ContentDevice.Load <Texture2D>("Sprites/title");
            background   = Setup.ContentDevice.Load <Texture2D>("Sprites/area04_bkg0");
            editor_title = Setup.ContentDevice.Load <Texture2D>("Sprites/editor");


            copyright = new GUI("A Game by Memorix101");
            copyright.Load("Fonts\\Pixel_12");
            copyright.Position = new Vector2(Screen.width / 2 - copyright.Size.X / 2, Screen.height - copyright.Size.Y - 5);
            copyright.Color    = Color.White;

            pauseText = new GUI("PAUSE");
            pauseText.Load("Fonts\\Pixel_20");
            pauseText.Position = new Vector2(Screen.width / 2 - copyright.Size.X / 2 + 50, Screen.height / 2 - copyright.Size.Y);
            pauseText.Color    = Color.OrangeRed;


            MenuItems = new List <GUI>();
            Layer();
        }
예제 #7
0
        private static void Input()
        {
            if (ControlInput.IsKeyPressed(Keys.Up))
            {
                currentItem--;
            }

            else if (ControlInput.IsKeyPressed(Keys.Down))
            {
                currentItem++;
            }

            else if (ControlInput.IsKeyPressed(Keys.Enter) && menuLayer == lastMenuLayer)
            {
                ItemSelect();
            }

            if (lastMenuLayer != menuLayer)
            {
                currentItem = 0;
            }

            lastMenuLayer = menuLayer;
        }
예제 #8
0
 void Update()
 {
     // Back up a menu level if the user hits escape
     if (MenuLayer.MainMenu != currentMenuLayer && Input.GetKeyDown(KeyCode.Escape))
     {
         currentMenuLayer = MenuLayer.MainMenu;
     }
 }
예제 #9
0
    /// <summary>
    /// Renders the options menu.
    /// </summary>
    void RenderOptionsMenu()
    {
        // Player name
        GUILayout.BeginHorizontal();
        GUILayout.Label("Name", menuOptionsStyle, GUILayout.Width(100));
        PlayerDirector.Name = GUILayout.TextField(PlayerDirector.Name, GUILayout.Width(300));
        GUILayout.EndHorizontal();

        GUILayout.Space(20);

        // Player color
        GUILayout.BeginHorizontal();
        GUI.color = PlayerDirector.PlayerColor;
        GUILayout.Label("Color", GUILayout.Width(100));
        PlayerDirector.Hue = GUILayout.HorizontalSlider(PlayerDirector.Hue, 0, 1, GUILayout.Width(300));
        GUILayout.EndHorizontal();
        GUI.color = new Color(0,0,0,1);

        GUILayout.Space(20);

        // SFX volume
        GUILayout.BeginHorizontal();
        GUILayout.Label("SFX Volume", menuOptionsStyle, GUILayout.Width(100));
        AudioDirector.SFXVolume = ConfigurationDirector.Audio.SFXVolume = GUILayout.HorizontalSlider(ConfigurationDirector.Audio.SFXVolume, 0, 1, GUILayout.Width(300));
        GUILayout.Label( "   " + Mathf.CeilToInt(ConfigurationDirector.Audio.SFXVolume * 100.0f).ToString() + "%" );
        GUILayout.EndHorizontal();

        GUILayout.Space(20);

        // Music volume
        GUILayout.BeginHorizontal();
        GUILayout.Label("Music Volume", menuOptionsStyle, GUILayout.Width(100));
        ConfigurationDirector.Audio.MusicVolume = GUILayout.HorizontalSlider(ConfigurationDirector.Audio.MusicVolume, 0, 1, GUILayout.Width(300));
        AudioDirector.MusicVolume = ConfigurationDirector.Audio.MusicVolume;
        GUILayout.Label( "   " + Mathf.CeilToInt(ConfigurationDirector.Audio.MusicVolume * 100.0f).ToString() + "%" );
        GUILayout.EndHorizontal();

        GUILayout.Space(50);

        if (GUILayout.Button("Back", menuButtonStyle, GUILayout.Height(60), GUILayout.Width(800)))
        {
            currentMenuLayer = MenuLayer.MainMenu;
        }
        GUILayout.Space(10);

        GUILayout.EndArea();

        // Render the instructions
        float size = 300;
        float h = size * (float)instructionTexture.height / (float)instructionTexture.width;
        Rect instructionsRect = new Rect(Screen.width - size,Screen.height - h,size,h);
        GUI.color = Color.white;
        GUI.DrawTexture(instructionsRect, instructionTexture);
    }
예제 #10
0
    /// <summary>
    /// Renders the main menu.
    /// </summary>
    void RenderMainMenu()
    {
        if (GUILayout.Button("Join Online Game", menuButtonStyle, GUILayout.Height(60), GUILayout.Width(800)))
        {
            currentMenuLayer = MenuLayer.GameSearch;
        }
        GUILayout.Space(10);

        if (GUILayout.Button("Start New Online Game", menuButtonStyle, GUILayout.Height(60), GUILayout.Width(800)))
        {
            currentMenuLayer = MenuLayer.HostGameMenu;
        }
        GUILayout.Space(10);

        if (GUILayout.Button("Options", menuButtonStyle, GUILayout.Height(60), GUILayout.Width(800)))
        {
            currentMenuLayer = MenuLayer.OptionsMenu;
        }
        GUILayout.Space(10);

        GUILayout.EndArea();
    }
예제 #11
0
    /// <summary>
    /// Renders the 'host game' menu.
    /// </summary>
    void RenderHostGameMenu()
    {
        // Player count
        GUILayout.BeginHorizontal();
        GUILayout.Label("Players", menuOptionsStyle, GUILayout.Width(300));
        ConfigurationDirector.Host.MaxPlayers = (int)GUILayout.HorizontalSlider(ConfigurationDirector.Host.MaxPlayers, 1, 8, GUILayout.Width(300));
        GUILayout.Label( "   " + ConfigurationDirector.Host.MaxPlayers.ToString() );
        GUILayout.EndHorizontal();

        // Room name
        GUILayout.Space(10);
        GUI.color = Color.white;
        GUILayout.BeginHorizontal();
        GUILayout.Label("Game Name", menuOptionsStyle, GUILayout.Width(300));
        ConfigurationDirector.Host.RoomName = GUILayout.TextField(ConfigurationDirector.Host.RoomName, GUILayout.Width(300));
        GUILayout.EndHorizontal();
        GUI.color = Color.black;

        // Buttons
        GUILayout.Space(30);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Back", menuButtonStyle, GUILayout.Height(60)))
        {
            currentMenuLayer = MenuLayer.MainMenu;
        }

        if (GUILayout.Button("Start!", menuButtonStyle, GUILayout.Height(60)))
        {
            PlayerDirector.PopulateCustomPlayerProperties();
            NetworkLevelLoader.ResetLevelPrefix();
            // Now start the server
            NetworkDirector.InitializeServer(string.IsNullOrEmpty(ConfigurationDirector.Host.RoomName) ? PlayerDirector.Name : ConfigurationDirector.Host.RoomName, ConfigurationDirector.Host.MaxPlayers, NetworkDirector.defaultPort);
        }
        GUILayout.EndHorizontal();

        GUILayout.EndArea();
    }
예제 #12
0
    /// <summary>
    /// Renders the game search menu.
    /// </summary>
    void RenderGameSearchMenu()
    {
        if (GUILayout.Button("Back", menuButtonStyle, GUILayout.Height(60), GUILayout.Width(800)))
        {
            currentMenuLayer = MenuLayer.MainMenu;
        }
        GUILayout.Space(10);

        GUILayout.EndArea();
        GUILayout.Space(220);

        GUI.color = Color.black;
        GUILayout.BeginHorizontal();
        GUILayout.Label("Manual join: IP");
        GUILayout.Space(10);
        GUI.color = Color.white;
        ConfigurationDirector.ClientConnectionSettings.DefaultIP = GUILayout.TextField(ConfigurationDirector.ClientConnectionSettings.DefaultIP, GUILayout.Width(200));
        GUILayout.Space(20);
        GUI.color = Color.black;
        GUILayout.Label("Port");
        GUI.color = Color.white;
        ConfigurationDirector.ClientConnectionSettings.DefaultPort = GUILayout.TextField(ConfigurationDirector.ClientConnectionSettings.DefaultPort, GUILayout.Width(75));
        GUILayout.Space(20);
        GUI.color = Color.black;
        if (GUILayout.Button("Join"))
        {
            GameDirector.IsOnline = true;
            PlayerDirector.PopulateCustomPlayerProperties();
            NetworkLevelLoader.ResetLevelPrefix();
            NetworkDirector.Connect(ConfigurationDirector.ClientConnectionSettings.DefaultIP, System.Convert.ToInt32(ConfigurationDirector.ClientConnectionSettings.DefaultPort));
        }
        GUILayout.EndHorizontal();

        GUI.color = Color.black;

        if (NetworkDirector.PollHostList().Length == 0)
        {
            GUILayout.Label("Currently no known games are available.");
            GUILayout.Label("Games will be listed here, when they become available.");
        }
        else
        {
            GUILayout.Label("Games are currently available. Join either:");

            if (GUILayout.Button("Join Random Game"))
            {
                HostData[] hosts = NetworkDirector.PollHostList();
                if (hosts.Length > 0)
                {
                    int gameIndex = Random.Range(0, hosts.Length-1);
                    int ipIndex = Random.Range(0, hosts[gameIndex].ip.Length - 1);
                    GameDirector.IsOnline = true;
                    PlayerDirector.PopulateCustomPlayerProperties();
                    NetworkLevelLoader.ResetLevelPrefix();
                    NetworkDirector.Connect(hosts[gameIndex].ip[ipIndex], hosts[gameIndex].port);
                }
            }
            GUILayout.Space(20);

            // Room listing: simply call GetRoomList: no need to fetch/poll whatever!
            this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
            foreach (HostData host in NetworkDirector.PollHostList())
            {
                for (int i=0; i < host.ip.Length; i++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(" " + host.ip[i] + ":" + host.port.ToString() + host.gameName + " " + host.connectedPlayers + "/" + host.playerLimit);
                    if (GUILayout.Button("Join"))
                    {
                        GameDirector.IsOnline = true;
                        PlayerDirector.PopulateCustomPlayerProperties();
                        NetworkLevelLoader.ResetLevelPrefix();
                        NetworkDirector.Connect(host.ip[i], host.port);
                    }

                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.EndScrollView();
        }
    }
예제 #13
0
 public void AddToStack(MenuLayer layer)
 {
     menuStack.Add(layer);
 }
예제 #14
0
 protected override void AddedToScene()
 {
     base.AddedToScene();
     this.AddChild(menuLayer = new MenuLayer(this));
 }
        void ReleaseDesignerOutlets()
        {
            if (ActionBar != null)
            {
                ActionBar.Dispose();
                ActionBar = null;
            }

            if (AddressOK != null)
            {
                AddressOK.Dispose();
                AddressOK = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (BottomSeparator != null)
            {
                BottomSeparator.Dispose();
                BottomSeparator = null;
            }

            if (DistanceFilters != null)
            {
                DistanceFilters.Dispose();
                DistanceFilters = null;
            }

            if (DistanceFiltersOpenClose != null)
            {
                DistanceFiltersOpenClose.Dispose();
                DistanceFiltersOpenClose = null;
            }

            if (DistanceLimit != null)
            {
                DistanceLimit.Dispose();
                DistanceLimit = null;
            }

            if (DistanceLimitInput != null)
            {
                DistanceLimitInput.Dispose();
                DistanceLimitInput = null;
            }

            if (DistanceSourceAddress != null)
            {
                DistanceSourceAddress.Dispose();
                DistanceSourceAddress = null;
            }

            if (DistanceSourceAddressLabel != null)
            {
                DistanceSourceAddressLabel.Dispose();
                DistanceSourceAddressLabel = null;
            }

            if (DistanceSourceAddressText != null)
            {
                DistanceSourceAddressText.Dispose();
                DistanceSourceAddressText = null;
            }

            if (DistanceSourceCurrent != null)
            {
                DistanceSourceCurrent.Dispose();
                DistanceSourceCurrent = null;
            }

            if (DistanceSourceCurrentLabel != null)
            {
                DistanceSourceCurrentLabel.Dispose();
                DistanceSourceCurrentLabel = null;
            }

            if (DistanceUnitText != null)
            {
                DistanceUnitText.Dispose();
                DistanceUnitText = null;
            }

            if (FilterLayout != null)
            {
                FilterLayout.Dispose();
                FilterLayout = null;
            }

            if (ListType != null)
            {
                ListType.Dispose();
                ListType = null;
            }

            if (ListView != null)
            {
                ListView.Dispose();
                ListView = null;
            }

            if (ListViewMap != null)
            {
                ListViewMap.Dispose();
                ListViewMap = null;
            }

            if (LoaderCircle != null)
            {
                LoaderCircle.Dispose();
                LoaderCircle = null;
            }

            if (LoaderCircleLeftConstraint != null)
            {
                LoaderCircleLeftConstraint.Dispose();
                LoaderCircleLeftConstraint = null;
            }

            if (LoadNext != null)
            {
                LoadNext.Dispose();
                LoadNext = null;
            }

            if (LoadPrevious != null)
            {
                LoadPrevious.Dispose();
                LoadPrevious = null;
            }

            if (MapSatellite != null)
            {
                MapSatellite.Dispose();
                MapSatellite = null;
            }

            if (MapStreet != null)
            {
                MapStreet.Dispose();
                MapStreet = null;
            }

            if (MapView != null)
            {
                MapView.Dispose();
                MapView = null;
            }

            if (MenuAbout != null)
            {
                MenuAbout.Dispose();
                MenuAbout = null;
            }

            if (MenuChatList != null)
            {
                MenuChatList.Dispose();
                MenuChatList = null;
            }

            if (MenuChatListBg != null)
            {
                MenuChatListBg.Dispose();
                MenuChatListBg = null;
            }

            if (MenuChatListBgCorner != null)
            {
                MenuChatListBgCorner.Dispose();
                MenuChatListBgCorner = null;
            }

            if (MenuContainer != null)
            {
                MenuContainer.Dispose();
                MenuContainer = null;
            }

            if (MenuHelpCenter != null)
            {
                MenuHelpCenter.Dispose();
                MenuHelpCenter = null;
            }

            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (MenuLayer != null)
            {
                MenuLayer.Dispose();
                MenuLayer = null;
            }

            if (MenuLocation != null)
            {
                MenuLocation.Dispose();
                MenuLocation = null;
            }

            if (MenuLogIn != null)
            {
                MenuLogIn.Dispose();
                MenuLogIn = null;
            }

            if (MenuLogOut != null)
            {
                MenuLogOut.Dispose();
                MenuLogOut = null;
            }

            if (MenuRegister != null)
            {
                MenuRegister.Dispose();
                MenuRegister = null;
            }

            if (MenuSettings != null)
            {
                MenuSettings.Dispose();
                MenuSettings = null;
            }

            if (NoResult != null)
            {
                NoResult.Dispose();
                NoResult = null;
            }

            if (OpenFilters != null)
            {
                OpenFilters.Dispose();
                OpenFilters = null;
            }

            if (OpenSearch != null)
            {
                OpenSearch.Dispose();
                OpenSearch = null;
            }

            if (OrderBy != null)
            {
                OrderBy.Dispose();
                OrderBy = null;
            }

            if (RefreshDistance != null)
            {
                RefreshDistance.Dispose();
                RefreshDistance = null;
            }

            if (ResultSet != null)
            {
                ResultSet.Dispose();
                ResultSet = null;
            }

            if (RippleMain != null)
            {
                RippleMain.Dispose();
                RippleMain = null;
            }

            if (RippleRefreshDistance != null)
            {
                RippleRefreshDistance.Dispose();
                RippleRefreshDistance = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (SearchIn != null)
            {
                SearchIn.Dispose();
                SearchIn = null;
            }

            if (SearchLayout != null)
            {
                SearchLayout.Dispose();
                SearchLayout = null;
            }

            if (SearchTerm != null)
            {
                SearchTerm.Dispose();
                SearchTerm = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (SortBy_LastActiveDate != null)
            {
                SortBy_LastActiveDate.Dispose();
                SortBy_LastActiveDate = null;
            }

            if (SortBy_RegisterDate != null)
            {
                SortBy_RegisterDate.Dispose();
                SortBy_RegisterDate = null;
            }

            if (SortBy_ResponseRate != null)
            {
                SortBy_ResponseRate.Dispose();
                SortBy_ResponseRate = null;
            }

            if (SortByCaption != null)
            {
                SortByCaption.Dispose();
                SortByCaption = null;
            }

            if (StatusBar != null)
            {
                StatusBar.Dispose();
                StatusBar = null;
            }

            if (StatusImage != null)
            {
                StatusImage.Dispose();
                StatusImage = null;
            }

            if (StatusText != null)
            {
                StatusText.Dispose();
                StatusText = null;
            }

            if (UseGeoContainer != null)
            {
                UseGeoContainer.Dispose();
                UseGeoContainer = null;
            }

            if (UseGeoNo != null)
            {
                UseGeoNo.Dispose();
                UseGeoNo = null;
            }

            if (UseGeoNoLabel != null)
            {
                UseGeoNoLabel.Dispose();
                UseGeoNoLabel = null;
            }

            if (UseGeoYes != null)
            {
                UseGeoYes.Dispose();
                UseGeoYes = null;
            }

            if (UseGeoYesLabel != null)
            {
                UseGeoYesLabel.Dispose();
                UseGeoYesLabel = null;
            }

            if (UserSearchList != null)
            {
                UserSearchList.Dispose();
                UserSearchList = null;
            }
        }
예제 #16
0
    void OnGUI()
    {
        GUI.color = Color.black;

        // Render the version
        GUI.Label(new Rect(4,Screen.height-24,200,20), "Version " + GameDirector.GameVersion);

        GUILayout.BeginArea(new Rect((Screen.width/2)-400, 20, 800, Screen.height));

        // Render the title
        GUILayout.Label("Paper Cowboys", titleStyle, GUILayout.Height(60), GUILayout.Width(800));

        // Render the subtitle
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("A somewhat functional game programmed in 48 total hours!");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(30);

        // If we're not connected to the master photon network, then render nothing except our
        // status to it because nothing else matters.
        if (!PhotonNetwork.connected)
        {
            GUILayout.EndArea();
            GUILayout.Space(250);

            if (PhotonNetwork.connectionState == ConnectionState.Connecting)
            {
                GUILayout.Label("Connecting " + PhotonNetwork.networkingPeer.ServerAddress);
                GUILayout.Label(Time.time.ToString());
            }
            else
            {
                GUILayout.Label("Not connected.");
                if (GUILayout.Button("Reconnect", GUILayout.Width(100)))
                {
                    currentMenuLayer = MenuLayer.MainMenu;
                    this.connectFailed = false;
                    PhotonNetwork.ConnectUsingSettings(GameDirector.GameVersion);
                }
            }

            if (this.connectFailed)
            {
                GUILayout.Label("Connection failed. Check setup and use Setup Wizard to fix configuration.");
                GUILayout.Label(string.Format("Server: {0}:{1}", new object[] {PhotonNetwork.PhotonServerSettings.ServerAddress, PhotonNetwork.PhotonServerSettings.ServerPort}));
                GUILayout.Label("AppId: " + PhotonNetwork.PhotonServerSettings.AppID);

                if (GUILayout.Button("Try Again", GUILayout.Width(100)))
                {
                    currentMenuLayer = MenuLayer.MainMenu;
                    this.connectFailed = false;
                    PhotonNetwork.ConnectUsingSettings(GameDirector.GameVersion);
                }
            }
        }
        // If we are connected to the Photon master network, render the active menu
        else
        {
            switch (currentMenuLayer)
            {
            case MenuLayer.MainMenu:
                RenderMainMenu();
                break;
            case MenuLayer.OptionsMenu:
                RenderOptionsMenu();
                break;
            case MenuLayer.HostGameMenu:
                RenderHostGameMenu();
                break;
            case MenuLayer.GameSearch:
                RenderGameSearchMenu();
                break;
            }
        }

        RenderSocialLinks();
    }
예제 #17
0
    /// <summary>
    /// Renders the game search menu.
    /// </summary>
    void RenderGameSearchMenu()
    {
        if (GUILayout.Button("Back", menuButtonStyle, GUILayout.Height(60), GUILayout.Width(800)))
        {
            currentMenuLayer = MenuLayer.MainMenu;
        }
        GUILayout.Space(10);

        GUILayout.EndArea();
        GUILayout.Space(175);

        GUI.color = Color.black;
        if (PhotonNetwork.GetRoomList().Length == 0)
        {
            GUILayout.Label("Currently no games are available.");
            GUILayout.Label("Rooms will be listed here, when they become available.");
        }
        else
        {
            GUILayout.Label(PhotonNetwork.GetRoomList() + " currently available. Join either:");

            if (GUILayout.Button("Join Random Game"))
            {
                GameDirector.IsOnline = true;
                PlayerDirector.SetPhotonCustomPlayerProperties();
                NetworkLevelLoader.EnsureGroup();
                NetworkLevelLoader.ResetLevelPrefix();
                PhotonNetwork.JoinRandomRoom();
            }
            GUILayout.Space(20);

            // Room listing: simply call GetRoomList: no need to fetch/poll whatever!
            this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
            foreach (RoomInfo roomInfo in PhotonNetwork.GetRoomList())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(roomInfo.name + " " + roomInfo.playerCount + "/" + roomInfo.maxPlayers);
                if (GUILayout.Button("Join"))
                {
                    GameDirector.IsOnline = true;
                    PlayerDirector.SetPhotonCustomPlayerProperties();
                    NetworkLevelLoader.EnsureGroup();
                    NetworkLevelLoader.ResetLevelPrefix();
                    PhotonNetwork.JoinRoom(roomInfo.name);
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }
    }
예제 #18
0
        static void ItemSelect()
        {
            if (menuLayer == MenuLayer.Menu)
            {
                switch (currentItem)
                {
                case 0:
                    LevelIO.Load();
                    menuLayer      = MenuLayer.Game;
                    Menu.gameState = GameState.Play;
                    enabled        = false;
                    break;

                case 1:
                    menuLayer      = MenuLayer.Editor;
                    Menu.gameState = GameState.Pause;
                    Scene.Dispose();
                    break;

                case 2:
                    System.Environment.Exit(1);
                    break;
                }
            }
            else if (menuLayer == MenuLayer.Editor)
            {
                switch (currentItem)
                {
                case 0:
                    menuLayer = MenuLayer.Tiles;
                    enabled   = false;
                    break;

                case 1:
                    LevelIO.Load();
                    break;

                case 2:
                    LevelIO.Save();
                    break;

                case 3:
                    Scene.Dispose();
                    break;

                case 4:
                    menuLayer = MenuLayer.Menu;
                    Scene.Dispose();
                    break;
                }
            }
            else if (menuLayer == MenuLayer.Game)
            {
                switch (currentItem)
                {
                case 0:
                    enabled   = false;
                    gameState = GameState.Play;
                    break;

                case 1:
                    Scene.Dispose();
                    menuLayer = MenuLayer.Menu;
                    gameState = GameState.Play;
                    break;
                }
            }
        }
예제 #19
0
    void RefreshInteractables(GameObject target = null, bool includeChildren = true)
    {
        // Start at root object if haven't started yet
        if (!target || target.GetInstanceID() == gameObject.GetInstanceID())
        {
            target        = gameObject;
            interactables = new List <UIElement>();
        }
        List <GameObject> viableChildren = GetChildren(target);

        for (int i = 0; i < viableChildren.Count; i++)
        {
            MenuLayer menuLayer = viableChildren[i].GetComponent <MenuLayer>();
            if (!menuLayer)
            {
                Slider slider = viableChildren[i].GetComponent <Slider>();
                Button button = viableChildren[i].GetComponent <Button>();
                Toggle toggle = viableChildren[i].GetComponent <Toggle>();
                if (slider)
                {
                    UIElement element = new UIElement()
                    {
                        obj         = viableChildren[i],
                        elementType = ElementType.Slider
                    };
                    interactables.Add(element);
                }
                else if (button)
                {
                    UIElement element = new UIElement()
                    {
                        obj         = viableChildren[i],
                        elementType = ElementType.Button
                    };
                    interactables.Add(element);
                }
                else if (toggle)
                {
                    UIElement element = new UIElement()
                    {
                        obj         = viableChildren[i],
                        elementType = ElementType.Toggle
                    };
                    interactables.Add(element);
                }
            }
            else
            {
                viableChildren.RemoveAt(i);
                i--;
            }
            if (viableChildren[i].transform.childCount <= 0)
            {
                viableChildren.RemoveAt(i);
                i--;
            }
        }

        if (includeChildren)
        {
            for (int i = 0; i < viableChildren.Count; i++)
            {
                RefreshInteractables(viableChildren[i].gameObject);
            }
        }
    }
예제 #20
0
        void ReleaseDesignerOutlets()
        {
            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (ChatEditMessage != null)
            {
                ChatEditMessage.Dispose();
                ChatEditMessage = null;
            }

            if (ChatEditMessageContainer != null)
            {
                ChatEditMessageContainer.Dispose();
                ChatEditMessageContainer = null;
            }

            if (ChatMessageWindow != null)
            {
                ChatMessageWindow.Dispose();
                ChatMessageWindow = null;
            }

            if (ChatOneBack != null)
            {
                ChatOneBack.Dispose();
                ChatOneBack = null;
            }

            if (ChatOneLeftConstraint != null)
            {
                ChatOneLeftConstraint.Dispose();
                ChatOneLeftConstraint = null;
            }

            if (ChatOneRightConstraint != null)
            {
                ChatOneRightConstraint.Dispose();
                ChatOneRightConstraint = null;
            }

            if (ChatSendMessage != null)
            {
                ChatSendMessage.Dispose();
                ChatSendMessage = null;
            }

            if (ChatTargetImage != null)
            {
                ChatTargetImage.Dispose();
                ChatTargetImage = null;
            }

            if (ChatViewProfile != null)
            {
                ChatViewProfile.Dispose();
                ChatViewProfile = null;
            }

            if (MatchDate != null)
            {
                MatchDate.Dispose();
                MatchDate = null;
            }

            if (MenuBlock != null)
            {
                MenuBlock.Dispose();
                MenuBlock = null;
            }

            if (MenuContainer != null)
            {
                MenuContainer.Dispose();
                MenuContainer = null;
            }

            if (MenuFriend != null)
            {
                MenuFriend.Dispose();
                MenuFriend = null;
            }

            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (MenuLayer != null)
            {
                MenuLayer.Dispose();
                MenuLayer = null;
            }

            if (MenuLocationUpdates != null)
            {
                MenuLocationUpdates.Dispose();
                MenuLocationUpdates = null;
            }

            if (MenuReport != null)
            {
                MenuReport.Dispose();
                MenuReport = null;
            }

            if (MenuUnmatch != null)
            {
                MenuUnmatch.Dispose();
                MenuUnmatch = null;
            }

            if (NoMessages != null)
            {
                NoMessages.Dispose();
                NoMessages = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (TargetName != null)
            {
                TargetName.Dispose();
                TargetName = null;
            }

            if (UnmatchDate != null)
            {
                UnmatchDate.Dispose();
                UnmatchDate = null;
            }
        }
예제 #21
0
        void ReleaseDesignerOutlets()
        {
            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (DistanceText != null)
            {
                DistanceText.Dispose();
                DistanceText = null;
            }

            if (EditSelf != null)
            {
                EditSelf.Dispose();
                EditSelf = null;
            }

            if (EditSelfBack != null)
            {
                EditSelfBack.Dispose();
                EditSelfBack = null;
            }

            if (EditSelfHeader != null)
            {
                EditSelfHeader.Dispose();
                EditSelfHeader = null;
            }

            if (EditSpacer != null)
            {
                EditSpacer.Dispose();
                EditSpacer = null;
            }

            if (HeaderBackground != null)
            {
                HeaderBackground.Dispose();
                HeaderBackground = null;
            }

            if (HideButton != null)
            {
                HideButton.Dispose();
                HideButton = null;
            }

            if (LastActiveDate != null)
            {
                LastActiveDate.Dispose();
                LastActiveDate = null;
            }

            if (LikeButton != null)
            {
                LikeButton.Dispose();
                LikeButton = null;
            }

            if (LocationTime != null)
            {
                LocationTime.Dispose();
                LocationTime = null;
            }

            if (MapBottomSeparator != null)
            {
                MapBottomSeparator.Dispose();
                MapBottomSeparator = null;
            }

            if (MapSatellite != null)
            {
                MapSatellite.Dispose();
                MapSatellite = null;
            }

            if (MapStreet != null)
            {
                MapStreet.Dispose();
                MapStreet = null;
            }

            if (MapTopSeparator != null)
            {
                MapTopSeparator.Dispose();
                MapTopSeparator = null;
            }

            if (MenuBlock != null)
            {
                MenuBlock.Dispose();
                MenuBlock = null;
            }

            if (MenuContainer != null)
            {
                MenuContainer.Dispose();
                MenuContainer = null;
            }

            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (MenuLayer != null)
            {
                MenuLayer.Dispose();
                MenuLayer = null;
            }

            if (MenuReport != null)
            {
                MenuReport.Dispose();
                MenuReport = null;
            }

            if (Name != null)
            {
                Name.Dispose();
                Name = null;
            }

            if (NavigationSpacer != null)
            {
                NavigationSpacer.Dispose();
                NavigationSpacer = null;
            }

            if (NextButton != null)
            {
                NextButton.Dispose();
                NextButton = null;
            }

            if (PercentProgress != null)
            {
                PercentProgress.Dispose();
                PercentProgress = null;
            }

            if (PreviousButton != null)
            {
                PreviousButton.Dispose();
                PreviousButton = null;
            }

            if (ProfileImageContainer != null)
            {
                ProfileImageContainer.Dispose();
                ProfileImageContainer = null;
            }

            if (ProfileImageScroll != null)
            {
                ProfileImageScroll.Dispose();
                ProfileImageScroll = null;
            }

            if (ProfileViewDescription != null)
            {
                ProfileViewDescription.Dispose();
                ProfileViewDescription = null;
            }

            if (ProfileViewMap != null)
            {
                ProfileViewMap.Dispose();
                ProfileViewMap = null;
            }

            if (ProfileViewScroll != null)
            {
                ProfileViewScroll.Dispose();
                ProfileViewScroll = null;
            }

            if (RegisterDate != null)
            {
                RegisterDate.Dispose();
                RegisterDate = null;
            }

            if (ResponseRate != null)
            {
                ResponseRate.Dispose();
                ResponseRate = null;
            }

            if (RippleImageNext != null)
            {
                RippleImageNext.Dispose();
                RippleImageNext = null;
            }

            if (RippleImagePrev != null)
            {
                RippleImagePrev.Dispose();
                RippleImagePrev = null;
            }

            if (RippleProfileView != null)
            {
                RippleProfileView.Dispose();
                RippleProfileView = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (ScrollBottomConstraint != null)
            {
                ScrollBottomConstraint.Dispose();
                ScrollBottomConstraint = null;
            }

            if (SendLocation != null)
            {
                SendLocation.Dispose();
                SendLocation = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (Username != null)
            {
                Username.Dispose();
                Username = null;
            }

            if (ViewportConstraint != null)
            {
                ViewportConstraint.Dispose();
                ViewportConstraint = null;
            }
        }