Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        handler = GameObject.Find("VuMark").GetComponent <DefaultTrackableEventHandler>();

        float h = Input.GetAxis("Horizontal") * transformSpeedMod;
        float v = Input.GetAxis("Vertical") * transformSpeedMod;

        if (selection == null)
        {
            VuMarkTarget firstTarget = handler.GetVuMarkObj();
            if (firstTarget == null)
            {
                /* Nothing visible, so nothing to do
                 * Resets selection, and updates the text */
                SetVuMarkText();
                return;
            }
            else
            {
                selection = firstTarget;
                rm        = VuMarkRenderer(selection);
                tb        = VuMarkTransformer(selection);
                SetVuMarkText();
            }
        }


        //Debug.Log("BEFORE TRANSF: SELECT IS " + handler.FurnitureLookup(selection));
        //TransformManager tb = VuMarkTransformer(selection);
        //RendererManager rm = VuMarkRenderer(selection);

        if (Input.GetButton("Jump") && myTime > nextFire)
        {
            Debug.Log("Jumped");
            nextFire = myTime + fireDelta;
            ChangeSelection();
            SetVuMarkText();
            nextFire = nextFire - myTime;
            myTime   = 0.0f;
        }
        else if (Input.GetButton("Fire1") && myTime > nextFire)
        {
            Debug.Log("Moving");
            nextFire = myTime + fireDelta;

            tb.Move(v, h);
            nextFire = nextFire - myTime;
            myTime   = 0.0f;
        }
        else if (Input.GetButton("Fire2"))
        {
            Debug.Log("Rotating");
            tb.Rotate(v * rotationaSpeedMod);
        }
        else if (Input.GetButton("Fire3") && myTime > nextFire)
        {
            Debug.Log("Changing Color");
            nextFire = myTime + fireDelta;
            if (rm.GetColor() != Color.black)
            {
                rm.SetColor(Color.black);
            }
            else
            {
                rm.SetColor(Color.white);
            }
            nextFire = nextFire - myTime;
            myTime   = 0.0f;
        }
        else
        {
            Debug.Log("Trying to move " + handler.FurnitureLookup(selection));
            Debug.Log("Verify: Trying to move " + tb.GetName());
            tb.Move(v, h);
        }
        myTime = myTime + Time.deltaTime;
    }