Ejemplo n.º 1
0
        private void PlayerKilled([FromSource] Player ply, int killerID, ExpandoObject deathData)
        {
            int            killerType  = 0;
            List <dynamic> deathCoords = new List <dynamic>();

            foreach (var data in deathData)
            {
                if (data.Key == "killertype")
                {
                    killerType = (int)data.Value;
                }
                if (data.Key == "killerpos")
                {
                    deathCoords = data.Value as List <dynamic>;
                }
            }
            Vector3 coords = new Vector3((float)deathCoords[0], (float)deathCoords[1], (float)deathCoords[2]);

            PlayerDied(ply, killerType, deathCoords);
            BaseGamemode activeGame = Salty.GetGame(ply);

            if (activeGame != null)
            {
                activeGame.PlayerKilled(ply, killerID, coords);
            }
        }
Ejemplo n.º 2
0
        public void UpdatePlayerBool([FromSource] Player ply, string key)
        {
            BaseGamemode activeGame = Salty.GetGame(ply);

            if (activeGame != null)
            {
                activeGame.UpdatePlayerBoolean(ply, key);
            }
        }
        public BaseGamemode StartGame(int gamemode, Map map, List <Player> players)
        {
            BaseGamemode Game;

            switch ((Gamemodes)gamemode)
            {
            case Gamemodes.TTT:
                Game = new TTT((int)Gamemodes.TTT, map, players);
                Game.CreateGameTimer(10 * 60);
                Game.Start();
                break;

            case Gamemodes.Murder:
                Game = new Murder((int)Gamemodes.Murder, map, players);
                Game.CreateGameTimer(5 * 60);
                Game.Start();
                break;

            case Gamemodes.IceCreamMan:
                Game = new IceCreamMan((int)Gamemodes.IceCreamMan, map, players);
                Game.CreateGameTimer(8 * 60);
                Game.Start();
                break;

            case Gamemodes.DriveOrDie:
                Game = new DriveOrDie((int)Gamemodes.DriveOrDie, map, players);
                Game.CreateGameTimer(15 * 60);
                Game.Start();
                break;

            case Gamemodes.TDM:
                Game = new TDM((int)Gamemodes.TDM, map, players);
                Game.CreateGameTimer(15 * 60);
                Game.Start();
                break;

            default:
                Game = new BaseGamemode((int)Gamemodes.None, null, players);
                Game.CreateGameTimer(15 * 60);
                Game.Start();
                break;
            }
            InGamePlayers[gamemode] = players;
            return(Game);
        }
Ejemplo n.º 4
0
        public Init()
        {
            SQLConnection = new Database();
            MapManager    = new MapManager(SQLConnection.Load());
            Salty         = new SaltyTown(MapManager);

            ActiveGame = new BaseGamemode((int)Gamemodes.None, Map.None(), new PlayerList().ToList());

            EventHandlers["playerDropped"] += new Action <Player, string>(ActiveGame.PlayerDropped);

            EventHandlers["baseevents:onPlayerDied"]   += new Action <Player, int, List <dynamic> >(PlayerDied);
            EventHandlers["baseevents:onPlayerKilled"] += new Action <Player, int, ExpandoObject>(PlayerKilled);

            EventHandlers["salty::netStartGame"] += new Action(ActiveGame.Start);
            //EventHandlers[ "salty::netEndGame" ] += new Action(  );
            EventHandlers["salty::netSpawnPointGUI"]    += new Action <Player>(SpawnPointGUI);
            EventHandlers["salty::netModifyMapPos"]     += new Action <Player, string, string, int, Vector3>(ModifyMapPosition);
            EventHandlers["salty::netModifyWeaponPos"]  += new Action <Player, string, string, string, Vector3>(ModifyWeaponPosition);
            EventHandlers["salty::netModifyMap"]        += new Action <Player, string, string, int, Vector3, Vector3>(ModifyMap);
            EventHandlers["salty::netAddScore"]         += new Action <Player, int>(AddScoreToPlayer);
            EventHandlers["salty::netVoteMap"]          += new Action <Player, string>(PlayerVote);
            EventHandlers["salty::netJoined"]           += new Action <Player>(PlayerJoined);
            EventHandlers["salty::netUpdatePlayerBool"] += new Action <Player, string>(UpdatePlayerBool);
            EventHandlers["salty::netBodyDiscovered"]   += new Action <Player, int>(BodyDiscovered);
            EventHandlers["salty::netJoinRoom"]         += new Action <Player, string>(JoinRoom);

            EventHandlers["chatMessage"] += new Action <int, string, string>(ChatMessage);

            RegisterCommand("rooms", new Action <int, List <object>, string>((source, args, raw) => {
                // Show rooms GUI to client
                Salty.SendRoomsToClient(SourceToPlayer(source));
            }), false);

            RegisterCommand("leaveroom", new Action <int, List <object>, string>((source, args, raw) => {
                Salty.LeaveRoom(SourceToPlayer(source));
            }), false);

            RegisterCommand("startroom", new Action <int, List <object>, string>((source, args, raw) => {
                //if( source != 0 ) { return; }
                Salty.StartRoom(SourceToPlayer(source));
            }), false);

            /*
             * RegisterCommand( "endroom", new Action<int, List<object>, string>( ( source, args, raw ) => {
             *  if( source != 0 ) { return; }
             *  Salty.EndRoom( Convert.ToInt32( args[0] ) );
             * } ), false );
             *
             * RegisterCommand( "joinroom", new Action<int, List<object>, string>( ( source, args, raw ) => {
             *  Salty.JoinRoom( SourceToPlayer(source), Convert.ToInt32( args[0] ) );
             * } ), false );
             *
             * RegisterCommand( "vote", new Action<int, List<object>, string>( ( source, args, raw ) => {
             *  if( source == 0 ) {
             *      ActiveVote = new Vote( new Dictionary<string, string> { { "Trouble in Terrorist Town", "ttt" }, { "Murder", "mmm" }, { "Drive Or Die", "dod" }, { "Ice Cream Man", "icm" } }, GamemodeVoteOver );
             *      return;
             *  }
             *  GamemodeVoteCount++;
             *  int needed = (int)Math.Round( new PlayerList().ToList().Count * 0.7 );
             *  if( GamemodeVoteCount >= needed) {
             *      ActiveGame.WriteChat( "Salty Gamemodes", "Gamemode vote started", 230, 230, 0 );
             *      ActiveVote = new Vote( new Dictionary<string, string> { { "Trouble in Terrorist Town", "ttt" }, { "Murder", "mmm" }, { "Drive Or Die", "dod" }, { "Ice Cream Man", "icm" } }, GamemodeVoteOver );
             *      GamemodeVoteCount = 0;
             *  } else {
             *      ActiveGame.WriteChat( "Salty Gamemodes", needed + " more vote(s) needed to vote new gamemode.", 230, 230, 0 );
             *  }
             *
             * } ), false );
             *
             * RegisterCommand( "loadSQL", new Action<int, List<object>, string>( ( source, args, raw ) => {
             *  if( source != 0 ) { return; }
             *  SQLConnection.Load();
             * } ), false );
             *
             * RegisterCommand( "saveSQL", new Action<int, List<object>, string>( ( source, args, raw ) => {
             *  if( source != 0 ) { return; }
             *  SQLConnection.SaveAll(MapManager.Maps);
             * } ), false );
             */
            Tick += Init_Tick;
        }