Example #1
0
        public HUD(BaseGamemode gamemode)
        {
            ActiveGame = gamemode;
            HUDText    = new SaltyText(0.5f, 0.5f, 0, 0, 0.5f, "", 255, 255, 255, 255, false, true, 0, true);
            HealthText = new SaltyText(0.085f, 0.895f, 0, 0, 0.5f, "Health: ", 255, 255, 255, 255, false, true, 0, true);
            AmmoText   = new SaltyText(0.085f, 0.935f, 0, 0, 0.5f, "Ammo: ", 255, 255, 255, 255, false, true, 0, true);

            GameTimeText = new SaltyText(0.121f, 0.855f, 0, 0, 0.5f, "", 255, 255, 255, 255, false, true, 0, true);
            ScoreText    = new SaltyText(0.5f, 0.01f, 0, 0, 0.7f, "Score: 0", 255, 255, 255, 255, false, true, 0, true);
            AddScoreText = new SaltyText(0.5f + (ScoreText.Caption.Length), 0.025f, 0, 0, 0.3f, "", 255, 255, 255, 255, false, true, 0, true);
            BoundText    = new SaltyText(0.5f, 0.1f, 0, 0, 1, "", 255, 255, 255, 255, true, true, 0, true);

            GoalText = new SaltyText(0.5f, 0.1f, 0, 0, 1f, "", 255, 255, 255, 255, false, true, 0, true);
        }
        public void StartGame(int id, int team, double duration, Map map, Vector3 startPos, Dictionary <string, List <Vector3> > gunSpawns)
        {
            isInRoom = true;
            NetworkSetVoiceChannel(0);
            map.GunSpawns = gunSpawns;
            if (id == 1)    // Trouble in Terrorist Town
            {
                ActiveGame = new TTT(map, team);
            }
            if (id == 2)    // Drive or die
            {
                ActiveGame = new DriveOrDie(map, team);
            }
            if (id == 3)    // Murder
            {
                ActiveGame = new Murder(map, team);
            }
            if (id == 4)    // Ice Cream Man
            {
                ActiveGame = new IceCreamMan(map, team);
            }
            if (id == 5)    // TDM
            {
                ActiveGame = new TDM(map, team);
            }
            if (duration > 0)
            {
                ActiveGame.CreateGameTimer(duration);
            }
            ActiveGame.PlayerSpawn = startPos;
            ActiveGame.SetNoClip(false);
            Game.Player.Character.Position = startPos;
            Debug.WriteLine("Game started");

            ActiveGame.Start();
        }
Example #3
0
        public MapMenu(Init instance, string name, string subtitle, Dictionary <string, Map> Maps)
        {
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
            Menu mapMenu = new Menu(name, subtitle)
            {
                Visible = true
            };

            MenuController.AddMenu(mapMenu);

            foreach (var map in Maps.ToDictionary(x => x.Key, x => x.Value))
            {
                Vector3 selectedVector = map.Value.SpawnPoints.ElementAt(0).Value[0];
                int     selectedTeam   = map.Value.SpawnPoints.ElementAt(0).Key;

                Menu mapEditor = AddSubMenu(mapMenu, "Edit " + map.Key);


                MenuItem mapItem = AddMenuItem(mapMenu, mapEditor, map.Key, "Modify Map", ">>>", true);

                Menu playerSpawnMenu = AddSubMenu(mapEditor, "Edit " + map.Key + " player spawns");
                Menu deleteMapMenu   = AddSubMenu(mapEditor, "Delete " + map.Key + "?");
                deleteMapMenu.AddMenuItem(new MenuItem("Yes", ""));
                deleteMapMenu.AddMenuItem(new MenuItem("No", ""));
                deleteMapMenu.OnItemSelect += (_menu, _item, _index) => {
                    if (_item.Text == "Yes")
                    {
                        TriggerServerEvent("salty::netModifyMap", "delete", map.Key);
                        MenuController.CloseAllMenus();
                        TriggerServerEvent("salty::netSpawnPointGUI");
                    }
                    if (_item.Text == "No")
                    {
                        deleteMapMenu.CloseMenu();
                    }
                };
                mapEditor.AddMenuItem(new MenuItem("Show/Hide"));

                mapEditor.OnItemSelect += (_menu, _item, _index) => {
                    if (_item.Text == "Show/Hide")
                    {
                        if (instance.Maps[map.Key].isVisible)
                        {
                            instance.Maps[map.Key].ClearBlip();
                        }
                        else
                        {
                            instance.Maps[map.Key].CreateBlip();
                        }
                    }
                };

                Menu modifyPosMenu = AddSubMenu(playerSpawnMenu, "Edit position");

                MenuSliderItem sliderOffset = new MenuSliderItem("Offset", -25, 25, 0, false);
                MenuSliderItem sliderX      = new MenuSliderItem("Centre X", -999999, 999999, (int)map.Value.Position.X, false);
                MenuSliderItem sliderY      = new MenuSliderItem("Centre Y", -999999, 999999, (int)map.Value.Position.Y, false);
                MenuSliderItem sliderWidth  = new MenuSliderItem("Width", -9999, 9999, (int)map.Value.Size.X, false);
                MenuSliderItem sliderLength = new MenuSliderItem("Length", -9999, 9999, (int)map.Value.Size.Y, false);

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

                MenuItem playerSpawnItem = AddMenuItem(mapEditor, playerSpawnMenu, "Player Spawns", "Modify player spawn points", ">>", true);
                MenuItem deleteMapItem   = AddMenuItem(mapEditor, deleteMapMenu, "Delete Map", "Delete entire map", ">", true);

                modifyPosMenu.AddMenuItem(new MenuItem("Delete", "Deletes the selected position"));
                mapEditor.AddMenuItem(new MenuItem("Save", "Saves new position and size"));



                mapEditor.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => {
                    if (_sliderItem.Text == "Centre X")
                    {
                        map.Value.Position.X += (_newPosition - _oldPosition) * sliderOffset.Position;
                    }
                    if (_sliderItem.Text == "Centre Y")
                    {
                        map.Value.Position.Y += (_newPosition - _oldPosition) * sliderOffset.Position;
                    }
                    if (_sliderItem.Text == "Width")
                    {
                        map.Value.Size.X += (_newPosition - _oldPosition) * sliderOffset.Position;
                    }
                    if (_sliderItem.Text == "Length")
                    {
                        map.Value.Size.Y += (_newPosition - _oldPosition) * sliderOffset.Position;
                    }
                };

                mapEditor.OnItemSelect += (_menu, _item, _index) => {
                    if (_item.Text == "Save")
                    {
                        TriggerServerEvent("salty::netModifyMap", "edit", map.Key, 0, map.Value.Position, map.Value.Size);
                    }
                };

                modifyPosMenu.OnItemSelect += (_menu, _item, _index) => {
                    if (_item.Text == "Delete")
                    {
                        TriggerServerEvent("salty::netModifyMapPos", "delete", map.Key, selectedTeam, selectedVector);
                        MenuController.CloseAllMenus();
                        TriggerServerEvent("salty::netSpawnPointGUI");
                    }
                };

                foreach (var spawns in map.Value.SpawnPoints.ToDictionary(x => x.Key, x => x.Value))
                {
                    foreach (var spawn in spawns.Value)
                    {
                        MenuItem playerPositionItem = AddMenuItem(playerSpawnMenu, modifyPosMenu, string.Format("{0} | {1}", spawns.Key.ToString(), spawn.ToString()), "Modify player spawn point", ">", true);
                    }

                    playerSpawnMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => {
                        string[] vector = _newItem.Text.Split('|');
                        selectedTeam   = Convert.ToInt32(vector[0].Split(' ')[0]);
                        selectedVector = BaseGamemode.StringToVector3(vector[1].Substring(1));
                    };
                }


                mapMenu.OnMenuClose += (_menu) => {
                };

                mapMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => {
                };
            }
        }
Example #4
0
 public TTT_HUD(BaseGamemode gamemode) : base(gamemode)
 {
     ActiveTTT     = gamemode as TTT;
     TeamText      = new SaltyText(0.033f, 0.855f, 0, 0, 0.5f, "Spectator", 255, 255, 255, 255, false, false, 0, true);
     DisguisedText = new SaltyText(0f, 0f, 0, 0, 0.5f, "Disguise enabled", 200, 0, 0, 255, false, false, 0, true);
 }