Пример #1
0
    // Update is called once per frame
    void Update()
    {
        // Move Value PC + MOBLIE
        h = dmanager.isAction ? 0 : Input.GetAxisRaw("Horizontal") + right_Value + left_Value;
        v = dmanager.isAction ? 0 : Input.GetAxisRaw("Vertical") + up_Value + down_Value;

        // Check Button Down & Up
        bool hDown = dmanager.isAction ? false : Input.GetButtonDown("Horizontal") || right_Down || left_Down;
        bool vDown = dmanager.isAction ? false : Input.GetButtonDown("Vertical") || up_Down || down_Down;
        bool hUp   = dmanager.isAction ? false : Input.GetButtonUp("Horizontal") || right_Up || left_Up;
        bool vUp   = dmanager.isAction ? false : Input.GetButtonUp("Vertical") || up_Up || down_Up;

        // Check Horizontal Move
        if (hDown)
        {
            isHorizonMove = true;
        }
        else if (vDown)
        {
            isHorizonMove = false;
        }
        else if (hUp || vUp)
        {
            isHorizonMove = h != 0;
        }

        // Animation

        if (anim.GetInteger("hAxisRaw") != h)
        {
            anim.SetBool("isChange", true);
            anim.SetInteger("hAxisRaw", (int)h);
        }
        else if (anim.GetInteger("vAxisRaw") != v)
        {
            anim.SetBool("isChange", true);
            anim.SetInteger("vAxisRaw", (int)v);
        }
        else
        {
            anim.SetBool("isChange", false);
        }

        // Direction
        if (vDown && v == 1) // Up
        {
            dirVec = Vector3.up;
        }
        else if (vDown && v == -1) // Down
        {
            dirVec = Vector3.down;
        }
        else if (hDown && h == 1) // right
        {
            dirVec = Vector3.right;
        }
        else if (hDown && h == -1) // left
        {
            dirVec = Vector3.left;
        }

        // Scan Object
        if (Input.GetButtonDown("Jump") && scanObject != null)
        {
            dmanager.Action(scanObject);
        }

        // Mobile Var Init
        up_Down    = false;
        down_Down  = false;
        left_Down  = false;
        right_Down = false;
        up_Up      = false;
        down_Up    = false;
        left_Up    = false;
        right_Up   = false;
    }