コード例 #1
0
    public void OnPlayerJoined(PlayerController player)
    {
        if (_playerList == null)
        {
            _playerList = _playerListFactory.Create();
        }

        _playerList.AddPlayer(player);
    }
コード例 #2
0
        /// <summary>
        /// These initizaltion will happen after the player object been instantiated or
        /// the scene reloaded and befer the character object's own Start() method;
        /// </summary>
        public void Init()
        {
            // Used in Room manager we keep track of the localPlayer instance to prevent instanciation when levels are synchronized
            if (photonView.isMine)
            {
                // Double check
                LocalPlayer = this;

                // Use photon.
                PhotonNetwork.player.SetScore(0);

                // Change the name of the object so makes easier for debugging.
                this.gameObject.name = "Local player";

                // Change the tag to localPlayer as it won't be taged as "Target" and receive damage from itself.
                this.gameObject.tag = "LocalPlayer";

                // Set itself's layer to "player" as that the raycast will ignore this object's collider.
                this.gameObject.layer = LayerMask.NameToLayer("Player");

                // Set the canvas render mode
                if (MainCamera)
                {
                    UIframework.UIManager.Instance.ResetUnderBlurCanvasRenderCamera(MainCamera);
                }
            }

            // Apply the default value.
            // Reset the team info.
            Team = CustomRoomOptions.Team.OneManArmy;

            // Reset health
            MaximunHealth = (int)PhotonNetwork.room.customProperties[RoomProperties.HealthLimit];
            CurrentHealth = MaximunHealth;

            // Hide it untill respawn
            IsVisiable = false;

            Helper.GetCachedComponent <CharacterControl>(this.gameObject, ref m_Control);
            // That is werid, the CharacterController is not a part of MonoBehaviour's compoment.
            m_Controller = GetComponent <CharacterController>();
            Helper.GetCachedComponent <WeaponManager>(this.gameObject, ref m_WeaponManager);
            m_DamageHandler = GetComponentInChildren <DamageHandler>();
            m_PlayerHUD     = GetPlayerHUD;

            // Initlize the weapon manager
            m_WeaponManager.Init();

            // Don't show the player HUD UI at the beginning.
            //if (photonView.isMine)
            //    UIframework.UIManager.Instance.hide(UIframework.UIManager.SceneUIs.PlayerHUDUI);

            // Enable the character contorl
            EnableCharacterControl(false);

            // Enable the unity3d controller compoment, without this the player character can't even move.
            m_Controller.enabled = false;

            HideCharacterModel(true);

            // Hide the player model and disable its contol for now until the game started.
            HideCharacterModel(photonView.isMine);
        }