Exemple #1
0
        public override void Interact()
        {
            if (playGamePhase.clientSkeld.playGamePhaseUserInterface.minimapButton.IsMinimapShown)
            {
                return;
            }

            if (isTransitionGoing)
            {
                Logger.LogNotice(SharedLoggerSection.Interactions, "Unable to interact with security panel, because fade animation is still going");
                return;
            }

            isControlledPlayerViewing = !isControlledPlayerViewing;

            if (isControlledPlayerViewing)
            {
                playersLockable.Add(playersManager.controlledClientPlayer.basePlayer.information.id);
                Logger.LogEvent(SharedLoggerSection.Interactions, "Has started viewing security panel");
            }
            else
            {
                playersLockable.Remove(playersManager.controlledClientPlayer.basePlayer.information.id);
                Logger.LogEvent(SharedLoggerSection.Interactions, "Has stopped viewing security panel");
            }

            isTransitionGoing = true;
            isFirstTransition = true;
            StartCoroutine(BlinkFade());
        }
Exemple #2
0
        public void TryToScheduleGameStart(int calledPlayerId)
        {
            if (!PlayersManager.IsLobbyHost(calledPlayerId))
            {
                Logger.LogNotice(SharedLoggerSection.GameStart, $"Player {calledPlayerId} tries to schedule game start, but he's not the host");
                return;
            }

            if (playersManager.clients.Count < GameConfiguration.MinRequiredPlayersAmountForGame)
            {
                Logger.LogError(SharedLoggerSection.GameStart, "Attempt to start a game with too few players in it");
                return;
            }

            if (GameStarts)
            {
                Logger.LogError(SharedLoggerSection.GameStart, "Attempt to start a game which is already starting");
                return;
            }

            GameStarts = true;
            metaMonoBehaviours.coroutines.StartCoroutine(StartGame());

            Logger.LogEvent(SharedLoggerSection.GameStart, "Game starts");
        }
        private void ProcessWelcomeReceivedPacket(int playerId, Packet packet)
        {
            int    packetPlayerId = packet.ReadInt();
            string userName       = packet.ReadString();
            string userApiVersion = packet.ReadString();

            if (userApiVersion != GameConfiguration.ApiVersion)
            {
                playersManager.clients.Remove(playerId);
                Logger.LogError(LoggerSection.Connection, $"Unable to add a client with old version ({userApiVersion}) to the game");
                return;
            }

            if (playerId != packetPlayerId)
            {
                throw new Exception($"Bad playerId {playerId} received");
            }

            if (userName.Equals(""))
            {
                Logger.LogError(LoggerSection.Connection, $"Bad user name passed from player {playerId}");
                return;
            }

            Logger.LogEvent(LoggerSection.Connection, $"{playersManager.clients[playerId].GetTcpEndPoint()} connected successfully and is now a player {playerId}");

            lobbyGamePhase.ConnectPlayer(playerId, userName);
        }
Exemple #4
0
        /**
         * Callback that is getting called when player presses interaction key near interactable
         */
        public override void Interact(int playerId)
        {
            PlayerColor newPlayerColor = PlayerColors.SwitchToRandomColor(playerId);

            playersManager.clients[playerId].basePlayer.colorable.ChangeColor(newPlayerColor);

            Logger.LogEvent(SharedLoggerSection.PlayerColors, $"Changed player {playerId} color to {Helpers.GetEnumName(newPlayerColor)}");
        }
        public void ProcessPacket(int playerId, int packetTypeId, Packet packet, bool isTcp)
        {
            string packetTypeName = Helpers.GetEnumName((ClientPacketType)packetTypeId);
            string protocolName   = isTcp ? "TCP" : "UDP";

            Logger.LogEvent(LoggerSection.Network, $"Received «{packetTypeName}» {protocolName} packet from the client {playerId}");

            packetHandlers[packetTypeId](playerId, packet);
        }
        public void RequestGameStart()
        {
            if (!HasEnoughPlayersForGame())
            {
                return;
            }

            playersManager.controlledClientPlayer.clientControllable.OnStartGame();
            Logger.LogEvent(SharedLoggerSection.GameStart, "Requested game start");
        }
Exemple #7
0
        public void DisableSecurityCameras()
        {
            foreach (SecurityCamera camera in cameras)
            {
                camera.Disable();
            }

            CamerasEnabled = false;

            Logger.LogEvent(SharedLoggerSection.Interactions, "Enabled security cameras");
        }
        public void InitiateGameStart()
        {
            gameStarts = true;

            secondsBeforeGameStartsLeft = LobbyGamePhase.SecondsForGameLaunch;
            gameStartsInLabel.text      = GetGameStartsInLabelText();
            gameStartsInLabel.gameObject.SetActive(true);
            StartCoroutine(ProcessGameStartTick());

            Logger.LogEvent(SharedLoggerSection.GameStart, "Starting the game");
        }
Exemple #9
0
        public void Start()
        {
            Logger.Initialize(new[] { LoggerSection.Network, LoggerSection.GameSnapshots }, true);
            Logger.LogEvent(LoggerSection.Initialization, "Started client initialization");

            metaMonoBehaviours.Initialize();
            scenesManager.Initialize(InitializeScene);
            Logger.LogEvent(LoggerSection.Initialization, "Initialized global environment");

            scenesManager.LoadScene(Scene.MainMenu);
        }
Exemple #10
0
        private IEnumerator StartGame()
        {
            yield return(new WaitForSeconds(SecondsForGameLaunch));

            int[] impostorPlayerIds = GetImpostorPlayerIds();
            foreach (int impostorPlayerId in impostorPlayerIds)
            {
                playersManager.clients[impostorPlayerId].basePlayer.impostorable.isImpostor = true;
            }

            scenesManager.LoadScene(Scene.Skeld);

            Logger.LogEvent(SharedLoggerSection.GameStart, $"Game has started. Impostors: {string.Join(", ", impostorPlayerIds)}");
        }
        public override void Interact()
        {
            if (playGamePhase.clientSkeld.playGamePhaseUserInterface.minimapButton.IsMinimapShown)
            {
                return;
            }

            isControlledPlayerViewing = !isControlledPlayerViewing;

            if (isControlledPlayerViewing)
            {
                adminPanelMinimap.SetActive(true);
                playersLockable.Add(playersManager.controlledClientPlayer.basePlayer.information.id);
                Logger.LogEvent(SharedLoggerSection.Interactions, "Started viewing admin panel");
            }
            else
            {
                adminPanelMinimap.SetActive(false);
                playersLockable.Remove(playersManager.controlledClientPlayer.basePlayer.information.id);
                Logger.LogEvent(SharedLoggerSection.Interactions, "Stopped viewing admin panel");
            }

            onInteraction?.Invoke();
        }
 public void UnloadScene(string sceneName)
 {
     SceneManager.UnloadSceneAsync(sceneName);
     Logger.LogEvent(SharedLoggerSection.ScenesManager, $"Unloaded scene {sceneName}");
 }
 public void LoadScene(string sceneName)
 {
     SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
     Logger.LogEvent(SharedLoggerSection.ScenesManager, $"Loaded scene {sceneName}");
 }
Exemple #14
0
 public override void Interact()
 {
     Logger.LogEvent(SharedLoggerSection.PlayerColors, "Interacted with lobby computer");
 }