Exemplo n.º 1
0
        void CacheMap(int id, string name, string gamemodes, Vector3 pos, Vector3 size, dynamic spawns)
        {
            ClientMap map = new ClientMap(id, name, gamemodes.Split(',').ToList(), pos, size, false);

            map.SpawnsFromSendable(spawns);

            ClientGlobals.Maps[id] = map;
        }
Exemplo n.º 2
0
        public static void SendMap(ClientMap map)
        {
            string gamemode = "";

            if (map.Gamemodes != null)
            {
                gamemode = string.Join(",", map.Gamemodes);
            }

            var spawns = map.SpawnsAsSendable();

            TriggerServerEvent("saltyMap:netUpdate", new Dictionary <string, dynamic> {
                { "id", map.ID },
                { "name", map.Name },
                { "gamemode", gamemode },
                { "position", map.Position },
                { "size", map.Size },
                { "spawns", spawns },
                { "create", map.JustCreated }
            });
        }
        // Protected implementation of Dispose pattern.
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                // Free any other managed objects here.
                //
            }

            HUD.Dispose();
            Map = null;

            // Free any unmanaged objects here.
            //

            disposed = true;
        }
Exemplo n.º 4
0
        public void EditMapMenu(Menu parent, ClientMap map)
        {
            Menu deleteMapMenu = AddSubMenu(parent, "Delete " + map.Name + "?");

            deleteMapMenu.AddMenuItem(new MenuItem("Yes", ""));
            deleteMapMenu.AddMenuItem(new MenuItem("No", ""));
            deleteMapMenu.OnItemSelect += (_menu, _item, _index) => {
                if (_item.Text == "Yes")
                {
                }
                if (_item.Text == "No")
                {
                    deleteMapMenu.CloseMenu();
                }
            };


            parent.AddMenuItem(new MenuItem("Show/Hide"));
            parent.AddMenuItem(new MenuItem("Teleport to"));
            parent.AddMenuItem(new MenuItem("Set Map Name"));
            parent.AddMenuItem(new MenuItem("Set Gamemodes"));


            parent.OnItemSelect += (_menu, _item, _index) => {
                if (_item.Text == "Show/Hide")
                {
                }
                if (_item.Text == "Teleport to")
                {
                }
                if (_item.Text == "Set Map Name")
                {
                    ClientGlobals.SendNUIMessage("enable", "mapName");
                }
                if (_item.Text == "Set Gamemodes")
                {
                    ClientGlobals.SendNUIMessage("enable", "mapGamemode");
                }
                if (_item.Text == "Save")
                {
                    ClientGlobals.SendMap(map);
                    parent.CloseMenu();
                    TriggerServerEvent("salty:netOpenMapGUI");
                }
            };



            Vector2 dimensions = new Vector2(100, 100);

            MenuSliderItem sliderOffset = new MenuSliderItem("Offset: 1", -25, 25, 1, false);
            MenuSliderItem sliderX      = new MenuSliderItem("Centre X: ", -999999, 999999, (int)dimensions.X, false);
            MenuSliderItem sliderY      = new MenuSliderItem("Centre Y: ", -999999, 999999, (int)dimensions.Y, false);
            MenuSliderItem sliderWidth  = new MenuSliderItem("Width: ", -9999, 9999, (int)dimensions.X, false);
            MenuSliderItem sliderLength = new MenuSliderItem("Length: ", -9999, 9999, (int)dimensions.Y, false);

            parent.AddMenuItem(sliderOffset);
            parent.AddMenuItem(sliderX);
            parent.AddMenuItem(sliderY);
            parent.AddMenuItem(sliderWidth);
            parent.AddMenuItem(sliderLength);

            MenuItem deleteMapItem = AddMenuItem(parent, deleteMapMenu, "Delete Map", "Delete entire map", "", true);



            parent.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => {
                if (_sliderItem == sliderOffset)
                {
                    _sliderItem.Text = "Offset: " + _newPosition;
                }
                if (_sliderItem == sliderX)
                {
                    map.Position.X  += (_newPosition - _oldPosition) * sliderOffset.Position;
                    _sliderItem.Text = "Centre X: " + map.Position.X;
                }
                if (_sliderItem == sliderY)
                {
                    map.Position.Y  += (_newPosition - _oldPosition) * sliderOffset.Position;
                    _sliderItem.Text = "Centre Y: " + map.Position.Y;
                }
                if (_sliderItem == sliderWidth)
                {
                    map.Size.X      += (_newPosition - _oldPosition) * sliderOffset.Position;
                    _sliderItem.Text = "Width: " + map.Size.X;
                }
                if (_sliderItem == sliderLength)
                {
                    map.Size.Y      += (_newPosition - _oldPosition) * sliderOffset.Position;
                    _sliderItem.Text = "Length: " + map.Size.Y;
                }
            };

            parent.OnMenuOpen += (_) => {
                ClientGlobals.LastSelectedMap = map;
                if (map.JustCreated)
                {
                    map.Position = LocalPlayer.Character.Position;
                    map.Size     = new Vector3(0, 0, 0);
                    map.Name     = "unnamed" + Game.GameTime;
                }
                sliderX.Text      = "Centre X: " + map.Position.X;
                sliderY.Text      = "Centre Y: " + map.Position.Y;
                sliderWidth.Text  = "Width: " + map.Size.X;
                sliderLength.Text = "Length: " + map.Size.Y;
            };

            parent.OnMenuClose += (_) => {
            };



            Menu playerSpawnMenu = AddSubMenu(parent, "Edit " + map.Name + " player spawns");

            playerSpawnMenu.AddMenuItem(new MenuItem("Save"));
            MenuItem playerSpawnItem = AddMenuItem(parent, playerSpawnMenu, "Player Spawns", "Modify player spawn points", "", true);



            Menu addSpawnMenu = EditSpawnMenu(playerSpawnMenu, map, new Spawn(-3, LocalPlayer.Character.Position, 0, "player", 0));


            foreach (var spawn in map.Spawns)
            {
                Menu editSpawnMenu = EditSpawnMenu(playerSpawnMenu, map, spawn);
            }

            playerSpawnMenu.OnItemSelect += (_menu, _item, _index) => {
                if (_item.Text == "Save")
                {
                    ClientGlobals.SendMap(map);
                    playerSpawnMenu.CloseMenu();
                    TriggerServerEvent("salty:netOpenMapGUI");
                }
            };

            parent.AddMenuItem(new MenuItem("Save", "Saves new position and size"));
        }