Exemplo n.º 1
0
 public Input(
     int deviceNum,
     InControl.InputDevice device)
 {
     this.deviceNum = deviceNum;
     this.device    = device;
 }
        private static IEnumerator HandleCharacterChange()
        {
            //Pixelator.Instance.FadeToBlack(0.5f, false);
            InputDevice lastActiveDevice = GameManager.Instance.LastUsedInputDeviceForConversation;

            Vector3 position = GameManager.Instance.SecondaryPlayer.transform.position;

            //Destroy Player 2
            if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER)
            {
                GameManager.Instance.SecondaryPlayer.SetInputOverride("getting deleted");
                GameManager.Instance.ClearSecondaryPlayer();

                if (GameManager.Instance.PrimaryPlayer)
                {
                    GameManager.Instance.PrimaryPlayer.ReinitializeMovementRestrictors();
                }
                yield return(null);
            }

            //Build new Player 2
            GameManager.Instance.CurrentGameType = GameManager.GameType.COOP_2_PLAYER;
            if (GameManager.Instance.PrimaryPlayer)
            {
                GameManager.Instance.PrimaryPlayer.ReinitializeMovementRestrictors();
            }
            PlayerController newPlayer = GeneratePlayer(position);

            yield return(null);

            GameUIRoot.Instance.ConvertCoreUIToCoopMode();
            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(newPlayer.specRigidbody, null, false);
            GameManager.Instance.MainCameraController.ClearPlayerCache();
            BraveInput.ReassignAllControllers(lastActiveDevice);
            if (Foyer.Instance)
            {
                Foyer.Instance.ProcessPlayerEnteredFoyer(newPlayer);
                Foyer.Instance.OnCoopModeChanged?.Invoke();
            }

            GameManager.Instance.SecondaryPlayer.PlayerIDX         = 1;
            GameManager.Instance.SecondaryPlayer.characterIdentity = PlayableCharacters.CoopCultist;

            //Reset
            GameManager.Instance.RefreshAllPlayers();
            Tools.Print("Character swapped", "FFFFFF", true);
            yield break;
        }