Example #1
0
 //при клике на какую-нибудь улицу
 void MouseOver_Street(GameObject ourHitObject)
 {
     if (ourHitObject.GetComponent <StreetPath>() != null)
     {
         if (Input.GetMouseButton(0) && canMove && _dBwork.GetPlayerbyId(1).GetCurrentStep() && Cameras.mode != 1)
         {
             canMove = false;
             _dBwork.GetPlayerbyId(1).move(ourHitObject.GetComponent <StreetPath>());
         }
         else if (Input.GetMouseButton(0) && canMove && _dBwork.GetPlayerbyId(1).GetCurrentStep() &&
                  Cameras.mode == 1)
         {
             if (_dBwork.GetWay(_dBwork.GetPlayerbyId(1).CurrentStreetPath.GetIdStreetPath(),
                                ourHitObject.GetComponent <StreetPath>().GetIdStreetPath()).Count == 1)
             {
                 canMove = false;
                 _dBwork.GetPlayerbyId(1).move(ourHitObject.GetComponent <StreetPath>());
             }
         }
         else if (Input.GetMouseButton(1) && Cameras.mode != 1)
         {
             // показать информацию о улице
             selectedStreetPath = ourHitObject.GetComponent <StreetPath>();
         }
         else if (!Input.GetMouseButton(0))
         {
             canMove = true;
         }
     }
     else
     {
         if (Input.GetMouseButton(0) && canMove && _networkDBwork.GetPlayer().GetCurrentStep() && Cameras.mode != 1)
         {
             canMove = false;
             _networkDBwork.GetPlayer().move(ourHitObject.GetComponent <NetworkStreetPath>());
         }
         else if (Input.GetMouseButton(0) && canMove && _networkDBwork.GetPlayer().GetCurrentStep() &&
                  Cameras.mode == 1)
         {
             if (_networkDBwork.GetWay(_networkDBwork.GetPlayer().CurrentStreetPath.GetIdStreetPath(),
                                       ourHitObject.GetComponent <NetworkStreetPath>().GetIdStreetPath()).Count == 1)
             {
                 canMove = false;
                 _networkDBwork.GetPlayer().move(ourHitObject.GetComponent <NetworkStreetPath>());
             }
         }
         else if (Input.GetMouseButton(1) && Cameras.mode != 1)
         {
             // показать информацию о улице
             //selectedStreetPath = ourHitObject.GetComponent<StreetPath>();
         }
         else if (!Input.GetMouseButton(0))
         {
             canMove = true;
         }
     }
 }
    //сброс истории, обновление ссылки на дбворк, бросок кубиков первого игрока
    void Start()
    {
        aboutPlayer = "";
        _dBwork     = Camera.main.GetComponent <NetworkDBwork>();
        _gameCanvas = gameObject.GetComponent <NetworkGameCanvas>();

        posFirstDice  = firstDice.transform.position;
        posSecondDice = secondDice.transform.position;
        CurrentPlayer = _dBwork.GetPlayer();
        if (PhotonNetwork.isMasterClient && CurrentPlayer != null)
        {
            CurrentPlayer.NextStep();
        }
        else
        {
            StartCoroutine(WaitForChanges());
        }
    }
    IEnumerator WaitForChanges()
    {
        while (CurrentPlayer == null && !_dBwork.ready)
        {
            yield return(new WaitForSeconds(1f));

            Debug.Log("Trying to get Current in Controller...");
            CurrentPlayer = _dBwork.GetPlayer();
        }

        if (PhotonNetwork.isMasterClient)
        {
            CurrentPlayer.NextStep();
        }
    }