コード例 #1
0
        public void DoPlayerConnected(SimPlayer player)
        {
            if (!Simulator.EditorMode)
                return; 
            
            var editorPlayer = new EditorPlayer(Simulator)
            {
                SimPlayer = player,
                GeneralMenu = GeneralMenu
            };


            editorPlayer.Initialize();

            Players.Add(player, editorPlayer);

            NotifyPlayerConnected(editorPlayer);
        }
コード例 #2
0
 private void NotifyPlayerChanged(EditorPlayer player)
 {
     if (PlayerChanged != null)
         PlayerChanged(player);
 }
コード例 #3
0
 private void NotifyPlayerDisconnected(EditorPlayer player)
 {
     if (PlayerDisconnected != null)
         PlayerDisconnected(player);
 }
コード例 #4
0
        public void DoSelectAction(SimPlayer p)
        {
            if (!Simulator.EditorMode)
                return;

            var player = Players[p];

            player.DoSelectAction();

            if (player.ActualSelection.GeneralMenuChoice != EditorGeneralMenuChoice.None)
            {
                var menu = GeneralMenu.SubMenus[player.ActualSelection.GeneralMenuChoice];
                var choice = menu.GetChoice(player.ActualSelection.GeneralMenuSubMenuIndex);

                EditorCommand command = GetCommand(choice);

                command.Owner = player;

                ExecuteCommand(command);

                return;
            }


            if (OpenedPanel != EditorPanel.None)
            {
                var panel = Panels[OpenedPanel];

                CurrentOpenedPanelPlayer = player;

                panel.DoClick(player.Circle);

                return;
            }

            if (Simulator.EditorState == EditorState.Playtest)
                return;

            if (player.SimPlayer.ActualSelection.CelestialBody != null)
            {
                var choice = EditorGUIPlayers[player].CelestialBodyMenu.Menu.GetCurrentChoice();
                var command = GetCommand(choice);

                command.Owner = player;

                if (player.SimPlayer.ActualSelection.EditingState != EditorEditingState.None)
                    ExecuteCommand(new EditorCelestialBodyCommand("ShowPathPreview") { Owner = player });

                ExecuteCommand(command);

                return;
            }
        }
コード例 #5
0
        public void DoPlayerConnected(EditorPlayer p)
        {
            EditorGUIPlayer player = new EditorGUIPlayer(Simulator, p.Color);

            player.GeneralMenu = GeneralMenu;

            Players.Add(p, player);
        }
コード例 #6
0
        public void DoPlayerChanged(EditorPlayer p)
        {
            var player = Players[p];

            // Change general menu
            if (PlayerBrowsingGeneralMenu == null || (player == PlayerBrowsingGeneralMenu &&
                player.SelectedGeneralMenu != p.ActualSelection.GeneralMenuChoice))
            {
                if (PlayerBrowsingGeneralMenu == null)
                    PlayerBrowsingGeneralMenu = player;

                if (player == PlayerBrowsingGeneralMenu)
                    GeneralMenu.DoMenuChanged(player.SelectedGeneralMenu, p.ActualSelection.GeneralMenuChoice, p.Color);

                if (player == PlayerBrowsingGeneralMenu && p.ActualSelection.GeneralMenuChoice == EditorGeneralMenuChoice.None)
                    PlayerBrowsingGeneralMenu = null;
            }

            // update actual selection
            player.SelectedGeneralMenu = p.ActualSelection.GeneralMenuChoice;
            player.GeneralMenuSubMenuIndex = p.ActualSelection.GeneralMenuSubMenuIndex;
            player.CelestialBodyMenu.Menu.SelectedIndex = p.ActualSelection.CelestialBodyChoice;

            if (p.SimPlayer.ActualSelection.TurretToPlace != null)
                return;

            // synchronize celestial body menu
            if (p.SimPlayer.ActualSelection.CelestialBody != null && player.CelestialBodyMenu.CelestialBody != p.SimPlayer.ActualSelection.CelestialBody)
            {
                player.CelestialBodyMenu.CelestialBody = p.SimPlayer.ActualSelection.CelestialBody;
                player.CelestialBodyMenu.SyncData();
                player.CelestialBodyMenu.Visible = true;
            }

            else if (p.SimPlayer.ActualSelection.CelestialBody == null)
            {
                player.CelestialBodyMenu.CelestialBody = null;
                player.CelestialBodyMenu.Visible = false;
            }

            player.CelestialBodyMenu.Visible = p.SimPlayer.ActualSelection.EditingState == EditorEditingState.None;
        }
コード例 #7
0
 public void DoPlayerDisconnected(EditorPlayer p)
 {
     Players.Remove(p);
 }