コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (adjacentProp != null)
        {
            adjacentProp.useDirection = GetComponent <ThePlayer>().getCurrentDirection();


            if (!pickedUpProp)
            {
                if (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("NES BUTTON A"))
                {
                    adjacentProp.PickUpProp(transform);
                    pickedUpProp = true;
                }
            }
            else
            {
                if (!usingProp && adjacentProp.canUse && (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("NES BUTTON A")))
                {
                    Debug.Log("down");
                    adjacentProp.UseProp();
                    usingProp = true;
                }
                else if (usingProp && (Input.GetKeyUp(KeyCode.Space) || Input.GetButtonUp("NES BUTTON A")))
                {
                    Debug.Log("up");
                    adjacentProp.StopPropUse();
                    usingProp = false;
                }
            }



            //adjacentProp.useDirection = direction;
            ////Debug.Log(adjacentProp.useDirection);

            //if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetButtonDown("NES BUTTON B"))
            //{
            //    if (!pickedUpProp)
            //    {
            //        adjacentProp.PickUpProp(transform);
            //        pickedUpProp = true;
            //    }
            //    else
            //    {
            //        Debug.Log("Throw Prop");
            //        pickedUpProp = false;
            //        //If player is not moving then throw is set to a default direction
            //        adjacentProp.ThrowProp( throwSpeed);

            //    }
            //}
            //else if (HasProp())
            //{
            //    if (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("NES BUTTON A"))
            //    {
            //        adjacentProp.UseProp();
            //    }
            //    else if (Input.GetKeyUp(KeyCode.Space) || Input.GetButtonUp("NES BUTTON A"))
            //    {
            //        adjacentProp.StopPropUse();
            //    }
        }
    }