コード例 #1
0
ファイル: Client.cs プロジェクト: johnnypernik/PropHuntV
		public Client() {
			if( ActiveInstance != null ) return; // Only instantiate once

			Game = new GameController( this );
			Player = new PlayerController( this );
			World = new WorldController( this );
			Ipl = new IplController( this );
			Time = new TimeController( this );
			Sessions = new SessionManager( this );
			PropHunt = new PropHunt( this );

			ActiveInstance = this;
		}
コード例 #2
0
        public LobbyHandler(PropHunt ctx, Client client) : base(client)
        {
            PropHunt = ctx;
            Client.RegisterNuiEventHandler("Lobby.Quit", OnQuit);
            Client.RegisterNuiEventHandler("Lobby.Close", OnClose);
            Client.RegisterNuiEventHandler("Lobby.SwitchCamera", SwitchCameras);
            Client.RegisterNuiEventHandler("Lobby.Purchase", OnPurchase);
            Client.RegisterNuiEventHandler("Lobby.SwitchModel", SwitchModel);
            Client.RegisterEventHandler("Lobby.ShowNotification", new Action <string, int>(ShowNotification));
            Client.RegisterEventHandler("Session.Loaded", new Action(async() => {
                API.DoScreenFadeOut(50);
                API.ShutdownLoadingScreen();
                await ToggleLobby(true);
            }));
            Client.RegisterEventHandler("PropHunt.UserData", new Action <string>(OnDataSet));
            Client.RegisterEventHandler("PropHunt.End", new Action <int>(OnRoundEnd));

            Client.RegisterTickHandler(OnTick);
        }
コード例 #3
0
        private async void OnGameStateUpdate(string data)
        {
            try {
                GameState = JsonConvert.DeserializeObject <GameDataModel>(data);

                var map = CurrentMap;
                if (map == null)
                {
                    Log.Warn("Map is null when it shouldn't be");
                    return;
                }
                Client.Time.Hour     = map.Hour;
                Client.Time.Freeze   = true;
                Client.World.Weather = (WeatherType)map.Weather;

                _currentBounds = map.Bounds.Any() ? new Area(map.Bounds, map.MinZ, map.MaxZ) : null;

                var player = GameState.Players.FirstOrDefault(p => p.NetId == Client.Player.ServerId);
                if (player == null)
                {
                    return;
                }
                LastTeam = player.Team;

                foreach (WeaponHash weapon in Enum.GetValues(typeof(WeaponHash)))
                {
                    CitizenFX.Core.Game.PlayerPed.Weapons.Remove(weapon);
                }

                var spawnPoint = new Vector3(map.SpawnPoint);
                if (GameState.IsHiding)
                {
                    if (player.Team == Team.Hunter)
                    {
                        spawnPoint += new Vector3(0f, 0f, -5f);
                        PropHunt.LobbyHandler.ShowNotification(
                            @"You are the <span style=""color: #FF0000AD; font-weight: bold"">Hunter</span>.<br><br>
							When the screen fades in, <span style=""color: #FF0000AD; font-weight: bold"">Kill</span> the props which are hiding."                            , 8);
                    }
                    else
                    {
                        PropHunt.LobbyHandler.ShowNotification(
                            @"You are the <span style=""color: #52CEFFAD; font-weight: bold"">Prop</span>.<br><br>
							You can disguise yourself as a prop with <span style=""color: #52CEFFAD; font-weight: bold"">Right-Click</span>."                            , 8);
                    }

                    PropHunt.LobbyHandler.SetCountdown("Hunters Release", PropHunt.Config.HideTime);
                    await PropHunt.SafeTeleport(spawnPoint, doFadeIn : player.Team != Team.Hunter);

                    return;
                }

                PropHunt.LobbyHandler.SetCountdown("Round Ends", GameState.TimeLeft - PropHunt.Config.HideTime);
                if (player.Team == Team.Hunter)
                {
                    await PropHunt.SafeTeleport(spawnPoint);

                    PropHunt.GiveAllWeapons(PropHunt.Config.HuntWeapons);
                }
            }
            catch (Exception ex) {
                Log.Error(ex);
            }
        }
コード例 #4
0
 protected internal MapHandler(PropHunt ctx, Client client) : base(client)
 {
     PropHunt = ctx;
     client.RegisterEventHandler("PropHunt.GameState", new Action <string>(OnGameStateUpdate));
     client.RegisterEventHandler("PropHunt.Died", new Action <int, string>(OnDeath));
 }