Exemple #1
0
        private void OnPauseMenuClosed()
        {
            Cursor.lockState = CursorLockMode.Locked;

            PlayerMovement    playerMovement    = GetComponent <PlayerMovement>();
            ThirdPersonCamera thirdPersonCamera = GetComponent <ThirdPersonCamera>();
            Spellcasting      spellcasting      = GetComponent <Spellcasting>();
            Dancing           dancing           = GetComponent <Dancing>();

            if (playerMovement != null && !networkGamePlayerMageBall.IsFrozen)
            {
                playerMovement.enabled = true;
            }

            if (dancing != null)
            {
                dancing.enabled = true;
            }

            if (thirdPersonCamera != null)
            {
                thirdPersonCamera.enabled = true;
            }

            if (spellcasting != null && !networkGamePlayerMageBall.IsFrozen)
            {
                spellcasting.CmdSetCanCastSpells(true);
            }
        }
        private IEnumerator ResetPlayer()
        {
            if (playerGameObject == null)
            {
                yield return(new WaitUntil(() => playerGameObject != null));
            }

            PlayerMovement playerMovement = playerGameObject.GetComponent <PlayerMovement>();

            playerMovement.ResetSpeed();
            playerMovement.enabled = false;
            CharacterControllerGravity gravity = playerGameObject.GetComponent <CharacterControllerGravity>();

            gravity.enabled = false;
            Spellcasting spellcasting = playerGameObject.GetComponent <Spellcasting>();

            spellcasting.ResetMana();
            spellcasting.CmdSetCanCastSpells(false);
            Animator animator = playerGameObject.GetComponent <Animator>();

            if (animator != null)
            {
                animator.SetFloat("Speed", 0);
                animator.SetBool("IsJumping", false);
            }
            playerGameObject.transform.position = spawnPosition;
            playerGameObject.transform.rotation = spawnRotation;
            StartCoroutine(EnablePlayerControls());
        }
        private IEnumerator EnablePlayerControls()
        {
            isFrozen = true;
            yield return(new WaitForSeconds(NetworkManager.WaitBeforeControlsEnableInSeconds));

            isFrozen = false;

            CharacterControllerGravity gravity = playerGameObject.GetComponent <CharacterControllerGravity>();

            gravity.enabled = true;

            PauseMenu pauseMenu = FindObjectOfType <PauseMenu>();

            if (pauseMenu != null && pauseMenu.IsOpen)
            {
                yield break;
            }

            PlayerMovement playerMovement = playerGameObject.GetComponent <PlayerMovement>();

            playerMovement.enabled = true;
            Spellcasting spellcasting = playerGameObject.GetComponent <Spellcasting>();

            spellcasting.CmdSetCanCastSpells(true);
        }
        public void OnServerReadied(NetworkConnection connection)
        {
            NetworkGamePlayerMageBall networkGamePlayer = connection.identity.gameObject.GetComponent <NetworkGamePlayerMageBall>();

            Transform spawnPoint;

            spawnPoint = (currentTeam == Team.Red) ? redSpawnPoints.ElementAtOrDefault(nextIndex) : blueSpawnPoints.ElementAtOrDefault(nextIndex);

            if (spawnPoint == null)
            {
                Debug.LogError($"There is no spawn point for player {nextIndex}!");
                return;
            }

            Vector3    position     = (currentTeam == Team.Red) ? redSpawnPoints[nextIndex].position : blueSpawnPoints[nextIndex].position;
            Quaternion rotation     = (currentTeam == Team.Red) ? redSpawnPoints[nextIndex].rotation : blueSpawnPoints[nextIndex].rotation;
            GameObject playerPrefab = GetPlayerPrefabFromLoadout(networkGamePlayer.PlayerLoadout);

            GameObject playerInstance = Instantiate(playerPrefab, position, rotation);

            NetworkServer.Spawn(playerInstance, connection);

            networkGamePlayer.SetPlayerGameObject(playerInstance, position, rotation);
            networkGamePlayer.TargetResetPlayerOwner();

            HUD hud = playerInstance.GetComponent <HUD>();

            hud.SetNetworkGamePlayerMageBall(networkGamePlayer);

            Spellcasting spellcasting = playerInstance.GetComponent <Spellcasting>();

            spellcasting.SetPlayerLoadout(networkGamePlayer.PlayerLoadout);

            PlayerMovement playerMovement = playerInstance.GetComponent <PlayerMovement>();

            playerMovement.SetPassiveFromLoadout(networkGamePlayer.PlayerLoadout);

            PlayerNameTag playerNameTag = playerInstance.GetComponent <PlayerNameTag>();

            playerNameTag.SetPlayerName(networkGamePlayer.DisplayName);

            if (currentTeam != firstTeam)
            {
                nextIndex++;
            }

            if (currentTeam == Team.Blue)
            {
                currentTeam = Team.Red;
            }
            else
            {
                currentTeam = Team.Blue;
            }
        }
Exemple #5
0
        private void OnTriggerEnter(Collider other)
        {
            if (!other.CompareTag(Tags.PlayerTag))
            {
                return;
            }

            Spellcasting spellcasting = other.gameObject.GetComponent <Spellcasting>();
            HUD          hud          = other.gameObject.GetComponent <HUD>();

            if (hasBeenPickedUp || spellcasting == null || hud == null)
            {
                return;
            }

            hasBeenPickedUp = true;
            NetworkServer.Destroy(gameObject);
            spellcasting.TargetEnablePowerUp(powerUpDuration);
            hud.TargetPowerUpManaBar(powerUpDuration);
        }
Exemple #6
0
        private void OnPauseMenuOpened()
        {
            Cursor.lockState = CursorLockMode.None;

            PlayerMovement    playerMovement    = GetComponent <PlayerMovement>();
            ThirdPersonCamera thirdPersonCamera = GetComponent <ThirdPersonCamera>();
            Spellcasting      spellcasting      = GetComponent <Spellcasting>();
            Animator          animator          = GetComponent <Animator>();
            Dancing           dancing           = GetComponent <Dancing>();

            if (animator != null)
            {
                animator.SetFloat("Speed", 0);
                animator.SetBool("IsJumping", false);
            }
            if (playerMovement != null)
            {
                playerMovement.ResetSpeed();
                playerMovement.enabled = false;
            }

            if (dancing != null)
            {
                dancing.enabled = false;
                dancing.StopDancing();
            }

            if (thirdPersonCamera != null)
            {
                thirdPersonCamera.enabled = false;
            }

            if (spellcasting != null)
            {
                spellcasting.CmdSetCanCastSpells(false);
            }
        }