Exemplo n.º 1
0
 public static void OpenDropInventory()
 {
     if (CookInterface.IsOpen)
     {
         CookInterface.CloseCookInventory();
     }
     InventoryAction.CurrentInventoryAction = InventoryDropAction.instance;
     //Instance.Owner = new InventoryData(new Vector2Int(5, 1));
     Instance.gameObject.SetActive(true);
     IsOpen = true;
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        velocity = Vector3.zero;

        if (Input.GetKey(KeyCode.W))
        {
            velocity.x += -1f;
            velocity.z += 1f;
        }

        if (Input.GetKey(KeyCode.S))
        {
            velocity.x += 1f;
            velocity.z += -1f;
        }

        if (Input.GetKey(KeyCode.A))
        {
            velocity.x += -1f;
            velocity.z += -1f;
        }

        if (Input.GetKey(KeyCode.D))
        {
            velocity.x += 1f;
            velocity.z += 1f;
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            CookInterface.ToggleCookInventory();
        }

        if (Input.GetKey(KeyCode.Mouse0) &&
            !EventSystem.current.IsPointerOverGameObject() &&
            !MouseInventory.Instance.IsDrag)
        {
            isAttack = true;
        }
        else
        {
            //애니메이션 결과 반영후 작업
            isAttack = false;
        }

        velocity.Normalize();

        if (!isAttack && velocity.magnitude > 0.1f)
        {
            Quaternion destLook = Quaternion.LookRotation(velocity, Vector3.up);
            transform.rotation = Quaternion.Slerp(transform.rotation, destLook, 7f * Time.deltaTime);

            body.MovePosition(transform.position + 3f * Time.deltaTime * velocity);
            transform.position += 3f * Time.deltaTime * velocity;
            GetComponentInChildren <Animator>().SetBool("IsMove", true);
            GetComponentInChildren <Animator>().SetBool("IsAttack", false);
        }
        else if (isAttack)
        {
            Quaternion destLook = Quaternion.LookRotation(velocity.magnitude > 0.01f ? velocity : transform.forward, Vector3.up);
            transform.rotation = Quaternion.Slerp(transform.rotation, destLook, 7f * Time.deltaTime);
            GetComponentInChildren <Animator>().SetBool("IsAttack", true);
            GetComponentInChildren <Animator>().SetBool("IsMove", false);
        }
        else
        {
            GetComponentInChildren <Animator>().SetBool("IsAttack", false);
            GetComponentInChildren <Animator>().SetBool("IsMove", false);
        }

        Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, transform.position + cameraOffset, 5f * Time.deltaTime);
    }