Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         musicManager.AirActivated();
     }
     if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         musicManager.WaterActivated();
     }
     if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         musicManager.EarthActivated();
     }
     if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         musicManager.FireActivated();
     }
 }
Exemplo n.º 2
0
    private void Update()
    {
        //element switch
        if (Input.GetKeyDown("q") && !down)
        {
            element = (Element)(((int)element + 5) % 4);
            switch (element)
            {
            case Element.WATER:
                musicManager.WaterActivated();
                break;

            case Element.FIRE:
                musicManager.FireActivated();
                break;

            case Element.EARTH:
                musicManager.EarthActivated();
                break;

            case Element.AIR:
                musicManager.AirActivated();
                break;
            }

            iconChanger.SwitchTo(element);
        }
        else if (Input.GetKeyDown("e") && !down)
        {
            element = (Element)(((int)element + 3) % 4);
            switch (element)
            {
            case Element.WATER:
                musicManager.WaterActivated();
                break;

            case Element.FIRE:
                musicManager.FireActivated();
                break;

            case Element.EARTH:
                musicManager.EarthActivated();
                break;

            case Element.AIR:
                musicManager.AirActivated();
                break;
            }

            iconChanger.SwitchTo(element);
        }

        //air
        if (element == Element.AIR && airU)
        {
            if (down && !cmp)
            {
                cmp = !cmp;
                air.MouseDown();
            }

            if (!down && cmp)
            {
                cmp = !cmp;
                air.MouseUp();
            }
        }


        movement.x = Input.GetAxisRaw("Mouse X");
        movement.y = Input.GetAxisRaw("Mouse Y");

        if (Input.GetMouseButtonDown(0))
        {
            down = true;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            down = false;
        }

        transform.position += new Vector3(movement.x, movement.y, 0) * speed / 10;

        //constraints
        viewport = Camera.main.WorldToViewportPoint(transform.position);
        //Top
        if (viewport.y > 1)
        {
            transform.position = _camera.ViewportToWorldPoint(new Vector3(viewport.x, 1, viewport.z));
        }
        //Bottom
        else if (viewport.y < 0)
        {
            transform.position = _camera.ViewportToWorldPoint(new Vector3(viewport.x, 0, viewport.z));
        }

        //Right
        if (viewport.x > 1)
        {
            transform.position = _camera.ViewportToWorldPoint(new Vector3(1, viewport.y, viewport.z));
        }

        //Left
        if (viewport.x < 0)
        {
            transform.position = _camera.ViewportToWorldPoint(new Vector3(0, viewport.y, viewport.z));
        }
    }