示例#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
    }
示例#2
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))
        {
            //call spawn function
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            //call pickup function
            actionPickup = GetComponentInParent <Pickupper2>();
            actionPickup.PickUp();
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            //call eat function
            actionEat = GetComponentInParent <Eat>();
            actionEat.EatFood();
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            if (actionPickup && actionThrow && actionPickup.IsHoldingObject())
            {
                actionThrow.ThrowObject();
            }
        }
        //... more actions
    }
示例#3
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();
        }

        // KeyCode for Marie-Eve and Audrey's milestone
//        if (Input.GetKeyDown(KeyCode.M))
//        {
//            if(actionShield.collectedShield()) {
//            if (!shieldActivated){
//            shieldActivated = true;
//            actionPickup.dropIt();
//            } else {
//            shieldActivated = false;
//                }
//            } else return;
//
//        }

        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.P))
        {
//            if (!actionEat.isSmall()) {
            //call pickup function

            if (!actionShield.shieldIsOn())
            {
                actionPickup.PickUp();
            }

            //}
        }
//
//                if (Input.GetKeyDown(KeyCode.F))
//        {
//
//           if(actionPickup.IsHoldingKey()) {
//               open.openDoor();
//           }
//
//        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            //call eat function

            actionEat.EatFood();
        }
//        if (Input.GetKeyDown(KeyCode.T))
//        {
//            if (actionPickup.IsHoldingObject())
//            {
//                print("throw");
//                actionThrow.ThrowObject();
//            }
//        }
        //... more actions
    }