Created
November 22, 2022 15:37
-
-
Save kristiandelay/04363a36badc780221546f488bd4686a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using Photon.Pun; | |
| using MoreMountains.TopDownEngine; | |
| public class CharacterMovementPhoton : CharacterMovement | |
| { | |
| private PhotonView view; | |
| protected override void Start() | |
| { | |
| base.Start(); | |
| view = GetComponent<PhotonView>(); | |
| } | |
| protected override void HandleInput() | |
| { | |
| if (view.IsMine) | |
| { | |
| base.HandleInput(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| using Photon.Pun; | |
| using MoreMountains.TopDownEngine; | |
| public class CharacterPhoton : Character | |
| { | |
| [HideInInspector] public PhotonView view; | |
| // Use this for initialization | |
| void Start() | |
| { | |
| view = GetComponent<PhotonView>(); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using Photon.Pun; | |
| using MoreMountains.TopDownEngine; | |
| using System.Linq; | |
| using Unity.VisualScripting; | |
| public class LevelManagerPhoton : LevelManager | |
| { | |
| protected override void InstantiatePlayableCharacters() | |
| { | |
| Players = new List<Character>(); | |
| if (GameManager.Instance.PersistentCharacter != null) | |
| { | |
| Players.Add(GameManager.Instance.PersistentCharacter); | |
| return; | |
| } | |
| // we check if there's a stored character in the game manager we should instantiate | |
| if (GameManager.Instance.StoredCharacter != null) | |
| { | |
| //Character newPlayer = (Character)Instantiate(GameManager.Instance.StoredCharacter, _initialSpawnPointPosition, Quaternion.identity); | |
| GameObject newPlayer = PhotonNetwork.Instantiate(GameManager.Instance.StoredCharacter.name, _initialSpawnPointPosition, Quaternion.identity); | |
| newPlayer.name = GameManager.Instance.StoredCharacter.name; | |
| Players.Add(newPlayer.GetComponent<CharacterPhoton>()); | |
| return; | |
| } | |
| if ((SceneCharacters != null) && (SceneCharacters.Count > 0)) | |
| { | |
| foreach (Character character in SceneCharacters) | |
| { | |
| Players.Add(character); | |
| } | |
| return; | |
| } | |
| if (PlayerPrefabs == null) { return; } | |
| // player instantiation | |
| if (PlayerPrefabs.Count() != 0) | |
| { | |
| foreach (Character playerPrefab in PlayerPrefabs) | |
| { | |
| GameObject newPlayer = PhotonNetwork.Instantiate(playerPrefab.name, _initialSpawnPointPosition, Quaternion.identity); | |
| //Character newPlayer = (Character)Instantiate(playerPrefab, _initialSpawnPointPosition, Quaternion.identity); | |
| newPlayer.name = playerPrefab.name; | |
| Players.Add(newPlayer.GetComponent<CharacterPhoton>()); | |
| if (playerPrefab.CharacterType != Character.CharacterTypes.Player) | |
| { | |
| Debug.LogWarning("LevelManager : The Character you've set in the LevelManager isn't a Player, which means it's probably not going to move. You can change that in the Character component of your prefab."); | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment