Exemplo n.º 1
0
    void Update()
    {
        var xInput = Input.GetAxis("Horizontal");
        var yInput = Input.GetAxis("Vertical");

        ConveyorBeltBehaviour next = null;

        if (xInput > 0)
        {
            next = currentConveyorBelt.GetAdjacent(Direction.Right);
        }
        else if (xInput < 0)
        {
            next = currentConveyorBelt.GetAdjacent(Direction.Left);
        }

        if (yInput > 0)
        {
            next = currentConveyorBelt.GetAdjacent(Direction.Up);
        }
        else if (yInput < 0)
        {
            next = currentConveyorBelt.GetAdjacent(Direction.Down);
        }

        if (next && next != currentConveyorBelt)
        {
            GameManager.instance.musicManager.PlayToggleSound();
        }

        currentConveyorBelt = next ?? currentConveyorBelt;
        var cpos = currentConveyorBelt.transform.position + highlightOffset;

        cpos.z = highlightZ;

        highlightTransform.position = Vector3.Lerp(
            highlightTransform.position,
            cpos,
            1f - Mathf.Exp(-highlightSmoothing * Time.deltaTime)
            );

        if (Input.GetButtonDown("Jump"))
        {
            if (currentConveyorBelt.TryPickPart(out var part))
            {
                if (part.TryGetComponent <CameraFocusTransform>(out var cameraFocusTransform))
                {
                    cameraBehaviour.target = cameraFocusTransform;
                    this.enabled           = false;
                    GameManager.instance.musicManager.PlaySelectSound();
                }
                else
                {
                    // do pick fail animation/sound
                }
            }
        }
    }
Exemplo n.º 2
0
 void Start()
 {
     currentConveyorBelt = startConveyorBelt;
 }