/// <summary>
 ///
 /// </summary>
 /// <param name="_info"></param>
 public static void OnLogMsnEvent(bl_LogInfo _info)
 {
     if (OnLogWindow != null)
     {
         OnLogWindow(_info);
     }
 }
    /// <summary>
    ///
    /// </summary>
    void Awake()
    {
        //When start in this scene, but is not connect, return to lobby to connect
        if (!isConnected || PhotonNetwork.room == null)
        {
            bl_UtilityHelper.LoadLevel(0);
            return;
        }
        StartCoroutine(bl_UIManager.Instance.FadeIn(1.5f));
        //Available to receive messages from cloud.
        PhotonNetwork.isMessageQueueRunning = true;
        //Inform to Lobby information, that this scene is playing
        if (PhotonNetwork.isMasterClient)
        {
            PhotonNetwork.room.SendRoomState(true);
        }
        if (InstantSpawn)
        {
            Invoke("SpawnPlayer", 2);
        }
        else
        {
            bl_UIManager.Instance.StartWindow.SetActive(true);
        }
        //Send a new log information
        string     logText = LocalName + " joined to the game";
        bl_LogInfo inf     = new bl_LogInfo(logText, Color.green);

        bl_EventHandler.OnLogMsnEvent(inf);
    }
    /// <summary>
    ///
    /// </summary>
    public void SpawnPlayer()
    {
        if (PlayerPrefab == null)
        {
            Debug.Log("Player Prefabs I was not assigned yet!");
            return;
        }
        //Sure of hace just only player on room
        if (m_Player != null)
        {
            NetworkDestroy(m_Player);
        }

        Vector3    p = Vector3.zero;
        Quaternion r = Quaternion.identity;

        //Get Position and rotation from a spawnPoint
        GetSpawnPoint(out p, out r);

        m_Player = PhotonNetwork.Instantiate(PlayerPrefab.name, p, r, 0);
        m_ViewID = m_Player.GetViewID();
        if (RoomCamera != null)
        {
            RoomCamera.SetActive(false);
        }
        Cursor.lockState = CursorLockMode.Locked;
        //bl_CoopUtils.LockCursor(true);
        isPlaying = true;

        //Send a new log information
        string     logText = LocalName + " joined to game";
        bl_LogInfo inf     = new bl_LogInfo(logText, Color.green);

        bl_EventHandler.OnLogMsnEvent(inf);
    }
Exemple #4
0
 void RpcSyncMessage(string[] texts)
 {
     //Convert string / Hex color to color RGB.
     Color _color = bl_ColorHelper.HexToColor(texts[2]);
     //Create again the bl_LogInfo to create a new UI in Log window.
     bl_LogInfo _info = new bl_LogInfo(texts[0], texts[1],_color);
     AddNewLog(_info);
 }
    void RpcSyncMessage(string[] texts)
    {
        //Convert string / Hex color to color RGB.
        Color _color = bl_ColorHelper.HexToColor(texts[2]);
        //Create again the bl_LogInfo to create a new UI in Log window.
        bl_LogInfo _info = new bl_LogInfo(texts[0], texts[1], _color);

        AddNewLog(_info);
    }
Exemple #6
0
    /// <summary>
    /// Add a new message with info in Log Window list.
    /// </summary>
    public void AddNewLog(bl_LogInfo _info)
    {
        GameObject log = (GameObject)Instantiate(LogUIPrefab);
        float _isFade = (FadeMsnInTime) ? FadeTime : 0;
        log.GetComponent<bl_LogText>().GetInfo(_info,_isFade);
        cacheLogs.Add(log);
        UpdateMaxList();

        log.transform.SetParent(LogWindowPanel, false);
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="newMasterClient"></param>
    public override void OnMasterClientSwitched(PhotonPlayer newMasterClient)
    {
        base.OnMasterClientSwitched(newMasterClient);
        //Send a new log information
        string logText = "We have a new Master Client: " + newMasterClient.NickName;
        //Send this as local because this function is already call in other players in room.
        bl_LogInfo inf = new bl_LogInfo(logText, Color.yellow, true);

        bl_EventHandler.OnLogMsnEvent(inf);
    }
Exemple #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_info"></param>
 public void GetInfo(bl_LogInfo _info,float fade = 0f)
 {
     SenderText.text = "[" + _info.m_Sender + "]";
     SenderText.color = _info.m_Color;
     MsnText.text = _info.m_Message;
     //If use fade start corrutine
     if (fade > 0)
     {
         StartCoroutine(Fade(fade));
     }
 }
    /// <summary>
    /// Add a new message with info in Log Window list.
    /// </summary>
    public void AddNewLog(bl_LogInfo _info)
    {
        GameObject log     = (GameObject)Instantiate(LogUIPrefab);
        float      _isFade = (FadeMsnInTime) ? FadeTime : 0;

        log.GetComponent <bl_LogText>().GetInfo(_info, _isFade);
        cacheLogs.Add(log);
        UpdateMaxList();

        log.transform.SetParent(LogWindowPanel, false);
    }
Exemple #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_info"></param>
 public void GetInfo(bl_LogInfo _info, float fade = 0f)
 {
     SenderText.text  = "[" + _info.m_Sender + "]";
     SenderText.color = _info.m_Color;
     MsnText.text     = _info.m_Message;
     //If use fade start corrutine
     if (fade > 0)
     {
         StartCoroutine(Fade(fade));
     }
 }
    /// <summary>
    ///
    /// </summary>
    /// <param name="otherPlayer"></param>
    public override void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
    {
        base.OnPhotonPlayerDisconnected(otherPlayer);

        //Send a new log information
        string logText = otherPlayer.NickName + " Left of room";
        //Send this as local because this function is already call in other players in room.
        bl_LogInfo inf = new bl_LogInfo(logText, Color.red, true);

        bl_EventHandler.OnLogMsnEvent(inf);
        //Debug.Log(otherPlayer.name + " Left of room");
        if (PhotonNetwork.isMasterClient)
        {
            PhotonNetwork.DestroyPlayerObjects(otherPlayer);
        }
    }
Exemple #12
0
    /// <summary>
    /// Receive event info
    /// </summary>
    /// <param name="_info"></param>
    void OnLogMsnEvent(bl_LogInfo _info)
    {
        //If message local, just call function to add.
        if (_info.isLocalMessage || PhotonNetwork.offlineMode)
        {
            AddNewLog(_info);
        }
        else
        {
            //is sync message, add all info in a string array to serialized and send in a RPC call.
            string[] texts = new string[3];
            texts[0] = _info.m_Sender;
            texts[1] = _info.m_Message;
            //Convert color to string for serialized.
            texts[2] = bl_ColorHelper.ColorToHex(_info.m_Color);

            photonView.RPC("RpcSyncMessage", PhotonTargets.All, texts);
        }
    }
    /// <summary>
    /// Receive event info
    /// </summary>
    /// <param name="_info"></param>
    void OnLogMsnEvent(bl_LogInfo _info)
    {
        //If message local, just call function to add.
        if (_info.isLocalMessage || PhotonNetwork.offlineMode)
        {
            AddNewLog(_info);
        }
        else
        {
            //is sync message, add all info in a string array to serialized and send in a RPC call.
            string[] texts = new string[3];
            texts[0] = _info.m_Sender;
            texts[1] = _info.m_Message;
            //Convert color to string for serialized.
            texts[2] = bl_ColorHelper.ColorToHex(_info.m_Color);

            photonView.RPC("RpcSyncMessage", PhotonTargets.All, texts);
        }
    }
    /// <summary>
    ///
    /// </summary>
    void OnDeath()
    {
        if (isDeath)
        {
            return;
        }

        isDeath = true;
        GetComponent <CharacterController>().enabled = false;
        if (View.isMine)
        {
            bl_EventHandler.OnLocalPlayerDeath();
            bl_EventHandler.OnSmallImpactEvent();
            if (PlayerCar.isPlayerInsideVehicle)
            {
                if (PlayerCar.isInVehicle)
                {
                    PlayerCar.Vehicle.OnExit(true);
                }
                else
                {
                    PlayerCar.Passenger.ExitSeat(true);
                }
            }
            //Send a new log information
            string     logText = View.owner.NickName + " Die";
            bl_LogInfo inf     = new bl_LogInfo(logText, Color.yellow);
            bl_EventHandler.OnLogMsnEvent(inf);
            StartCoroutine(Respawn());
        }
        else
        {
            PlayerPhoton.RemoteObject.SetActive(true);
            PlayerPhoton.RemoteObject.transform.parent = null;
            PlayerAnim.OnRemoteDeath(RespawnTime);
            // Destroy(gameObject);
        }
    }
Exemple #15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_info"></param>
 public static void OnLogMsnEvent(bl_LogInfo _info)
 {
     if (OnLogWindow != null)
         OnLogWindow(_info);
 }
Exemple #16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="newMasterClient"></param>
 public override void OnMasterClientSwitched(PhotonPlayer newMasterClient)
 {
     base.OnMasterClientSwitched(newMasterClient);
     //Send a new log information
     string logText = "We have a new Master Client: " + newMasterClient.name;
     //Send this as local because this function is already call in other players in room.
     bl_LogInfo inf = new bl_LogInfo(logText, Color.yellow, true);
     bl_EventHandler.OnLogMsnEvent(inf);
 }
Exemple #17
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="otherPlayer"></param>
    public override void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
    {
        base.OnPhotonPlayerDisconnected(otherPlayer);

        //Send a new log information
        string logText = otherPlayer.name + " Left of room";
        //Send this as local because this function is already call in other players in room.
        bl_LogInfo inf = new bl_LogInfo(logText, Color.red,true);
        bl_EventHandler.OnLogMsnEvent(inf);
        //Debug.Log(otherPlayer.name + " Left of room");
        if (PhotonNetwork.isMasterClient)
        {
            PhotonNetwork.DestroyPlayerObjects(otherPlayer);
        }
    }
Exemple #18
0
    /// <summary>
    /// 
    /// </summary>
    public void SpawnPlayer()
    {
        if (PlayerPrefab == null)
        {
            Debug.Log("Player Prefabs I was not assigned yet!");
            return;
        }
        //Sure of hace just only player on room
        if (m_Player != null)
        {
            NetworkDestroy(m_Player);
        }

        Vector3 p = Vector3.zero;
        Quaternion r = Quaternion.identity;
        //Get Position and rotation from a spawnPoint
        GetSpawnPoint(out p, out r);

        m_Player = PhotonNetwork.Instantiate(PlayerPrefab.name,p,r, 0);
        m_ViewID = m_Player.GetViewID();
        if (RoomCamera != null)
        {
            RoomCamera.SetActive(false);
        }
        bl_CoopUtils.LockCursor(true);
        isPlaying = true;

        //Send a new log information
        string logText = LocalName + " joined to game";
        bl_LogInfo inf = new bl_LogInfo(logText, Color.green);
        bl_EventHandler.OnLogMsnEvent(inf);
    }