Ejemplo n.º 1
0
    void Update()
    {
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (HexGameController.myTurn && !myUnit.isTraveling)
            {
                DoPathfinding();
                if (Input.GetMouseButtonDown(1))
                {
                    DoMove();
                }
            }
            else
            {
                currentCell = null;
            }
        }

        if (Input.GetKeyDown("space"))
        {
            myUnit.Jump();
            photonView.RPC("GetJump", RpcTarget.Others, true);
        }

        // center camera to myUnit position
        if (Input.GetKeyDown(KeyCode.C))
        {
            HexMapCamera.SetPosition(myUnit.Location);
        }

        // toggle camera following
        if (Input.GetKeyDown(KeyCode.V))
        {
            following = !following;
            if (following)
            {
                HexMapCamera.SetPosition(myUnit.Location);
                switchToFollowing = true;
            }
        }

        // move camera
        if (switchToFollowing)
        {
            if (HexMapCamera.GetLocalPosition() == myUnit.transform.localPosition)
            {
                switchToFollowing = false;
            }
        }
        else if (following)
        {
            HexMapCamera.SetPosition(myUnit.transform.localPosition, true);
        }
        else
        {
            HexMapCamera.Move();
        }

        // networking
        if (otherUnit)
        {
            if (UnitInfo.newPath)
            {
                DoMove(UnitInfo.Path);
                UnitInfo.newPath = false;
            }

            if (UnitInfo.Jump)
            {
                otherUnit.Jump();
                UnitInfo.Jump = false;
            }
        }
    }