Ejemplo n.º 1
0
    //player actions
    private void PlayerActions()
    {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        RigidBodyController controller = GetComponentInParent <RigidBodyController>();

        controller.Locomote(new Vector3(horizontal, 0, vertical));
        controller.Rotate();


        if (Input.GetKeyDown(KeyCode.Space))
        {
            controller.Jump();
        }

        if (Input.GetMouseButtonDown(0))
        {
            //become other player on left click
            CreateRay();
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            if (CamMode == 1)
            {
                CamMode = 0;
            }
            else
            {
                CamMode++;
            }
            StartCoroutine(CamChange());
        }
        if (Input.GetKeyDown(KeyCode.U))
        {
            if (actionPickup && actionPickup.IsHoldingObject())
            {
                Usable usable = actionPickup.HeldObject().GetComponent <Usable>();
                if (usable)
                {
                    usable.Use();
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.I))
        {
            //checks for the actionpickup script and if it is holding an object
            if (actionPickup && actionPickup.IsHoldingObject())
            {
                //check if the picked up item has a spawner script
                //get the spawner script in the children component of pickupper script
                actionSpawn = actionPickup.GetComponentInChildren <Spawner>();
                //call spawn function
                actionSpawn.Spawn();
            }
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            //call pickup function
            actionPickup = GetComponentInParent <Pickupper>();
            actionPickup.PickUp();
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            dropItem = GetComponentInParent <DropItem>();
            dropItem.DropHeldObject();
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            //call eat function
            actionEat = GetComponentInParent <Eat>();
            actionEat.EatFood();
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            /*
             *  actionThrow = GetComponentInParent<Throw>();
             *  actionThrow.ThrowObject();
             */
        }
        //... more actions
    }