Ejemplo n.º 1
0
        public LobbyAvatarPlaceLighting GetConnectedPlayerPlace(IConnectedPlayer player)
        {
            int     sortIndex = _lobbyStateDataModel.localPlayer.sortIndex;
            float   outerCirclePositionAngleForPlayer = MultiplayerPlayerPlacement.GetOuterCirclePositionAngleForPlayer(player.sortIndex, sortIndex, angleBetweenPlayersWithEvenAdjustment);
            Vector3 playerWorldPosition = MultiplayerPlayerPlacement.GetPlayerWorldPosition(outerCircleRadius, outerCirclePositionAngleForPlayer, MultiplayerPlayerLayout.Circle);

            return(Array.Find(avatarPlaces, place => place.transform.position == playerWorldPosition && place.isActiveAndEnabled));
        }
        public MultiplayerLobbyAvatarPlace GetConnectedPlayerPlace(IConnectedPlayer player)
        {
            float innerCircleRadius    = _placeManager.GetField <float, MultiplayerLobbyAvatarPlaceManager>("_innerCircleRadius");
            float minOuterCircleRadius = _placeManager.GetField <float, MultiplayerLobbyAvatarPlaceManager>("_minOuterCircleRadius");

            float angleBetweenPlayersWithEvenAdjustment = MultiplayerPlayerPlacement.GetAngleBetweenPlayersWithEvenAdjustment(_lobbyStateDataModel.maxPartySize, MultiplayerPlayerLayout.Circle);
            float outerCircleRadius = Mathf.Max(MultiplayerPlayerPlacement.GetOuterCircleRadius(angleBetweenPlayersWithEvenAdjustment, innerCircleRadius), minOuterCircleRadius);
            int   sortIndex         = _lobbyStateDataModel.localPlayer.sortIndex;

            float   outerCirclePositionAngleForPlayer = MultiplayerPlayerPlacement.GetOuterCirclePositionAngleForPlayer(player.sortIndex, sortIndex, angleBetweenPlayersWithEvenAdjustment);
            Vector3 playerWorldPosition = MultiplayerPlayerPlacement.GetPlayerWorldPosition(outerCircleRadius, outerCirclePositionAngleForPlayer, MultiplayerPlayerLayout.Circle);

            MultiplayerLobbyAvatarPlace[] places      = Resources.FindObjectsOfTypeAll <MultiplayerLobbyAvatarPlace>();
            MultiplayerLobbyAvatarPlace   playerPlace = Array.Find(places, place => place.transform.position == playerWorldPosition && place.isActiveAndEnabled);

            return(playerPlace);
        }
        public void SetCenterScreenScale()
        {
            float innerCircleRadius    = _placeManager.GetField <float, MultiplayerLobbyAvatarPlaceManager>("_innerCircleRadius");
            float minOuterCircleRadius = _placeManager.GetField <float, MultiplayerLobbyAvatarPlaceManager>("_minOuterCircleRadius");
            float angleBetweenPlayersWithEvenAdjustment = MultiplayerPlayerPlacement.GetAngleBetweenPlayersWithEvenAdjustment(_lobbyStateDataModel.maxPartySize, MultiplayerPlayerLayout.Circle);
            float outerCircleRadius = Mathf.Max(MultiplayerPlayerPlacement.GetOuterCircleRadius(angleBetweenPlayersWithEvenAdjustment, innerCircleRadius), minOuterCircleRadius);
            float scaleRatio        = outerCircleRadius / minOuterCircleRadius;

            MultiplayerLobbyCenterStageManager[] centerscreens = Resources.FindObjectsOfTypeAll <MultiplayerLobbyCenterStageManager>();
            if (centerscreens.Length == 0)
            {
                return;
            }
            MultiplayerLobbyCenterStageManager centerscreen = centerscreens.First();

            centerscreen.transform.localScale = new Vector3(scaleRatio, scaleRatio, scaleRatio);
        }
        private void HandleLobbyEnvironmentLoaded(object sender, System.EventArgs e)
        {
            var nativeAvatarPlaces = Resources.FindObjectsOfTypeAll <MultiplayerLobbyAvatarPlace>();

            avatarPlaces = new LobbyAvatarPlaceLighting[nativeAvatarPlaces.Length];
            for (var i = 0; i < nativeAvatarPlaces.Length; i++)
            {
                var nativeAvatarPlace = nativeAvatarPlaces[i];

                var avatarPlace = nativeAvatarPlace.GetComponent <LobbyAvatarPlaceLighting>();
                if (avatarPlace == null)
                {
                    avatarPlace = nativeAvatarPlace.gameObject.AddComponent <LobbyAvatarPlaceLighting>();
                }

                avatarPlaces[i] = avatarPlace;
            }

            innerCircleRadius    = _placeManager.GetField <float, MultiplayerLobbyAvatarPlaceManager>("_innerCircleRadius");
            minOuterCircleRadius = _placeManager.GetField <float, MultiplayerLobbyAvatarPlaceManager>("_minOuterCircleRadius");
            angleBetweenPlayersWithEvenAdjustment = MultiplayerPlayerPlacement.GetAngleBetweenPlayersWithEvenAdjustment(_lobbyStateDataModel.maxPartySize, MultiplayerPlayerLayout.Circle);
            outerCircleRadius = Mathf.Max(MultiplayerPlayerPlacement.GetOuterCircleRadius(angleBetweenPlayersWithEvenAdjustment, innerCircleRadius), minOuterCircleRadius);

            bool buildingsEnabled = _sessionManager.maxPlayerCount <= 18;

            _menuEnvironmentManager.transform.Find("Construction")?.gameObject?.SetActive(buildingsEnabled);
            _menuEnvironmentManager.transform.Find("Construction (1)")?.gameObject?.SetActive(buildingsEnabled);

            float centerScreenScale = outerCircleRadius / minOuterCircleRadius;

            _stageManager.transform.localScale = new Vector3(centerScreenScale, centerScreenScale, centerScreenScale);

            SetAllPlayerPlaceColors(Color.black, true);
            SetPlayerPlaceColor(_sessionManager.localPlayer, ExtendedPlayerManager.localColor);
            foreach (ExtendedPlayer player in _playerManager.players.Values)
            {
                SetPlayerPlaceColor(player, player.playerColor);
            }
        }