示例#1
0
    /* NavMeshProvider() function is for leading player to an assigned destination. this destination
     * parameter is passed by the one who call this function. a position(not direction) is requaired in this function.
     * by now, it is not calling locomote function in order to make movement going the right way.
     */

    public void NavMeshProvider(Vector3 destination)
    {
        //agent.velocity = locomotionCtl.controller.velocity;
        agent.velocity = rigidb.velocity;
        agent.Warp(this.transform.position);

        agent.SetDestination(destination);

        this.transform.position += Vector3.Normalize(agent.steeringTarget - this.transform.position) * 0.1f;

        if (Vector3.Distance(this.transform.position, destination) > 0.1f)
        {
            locomotionCtl.Locomote(Vector3.Normalize(agent.steeringTarget - this.transform.position));
        }
    }
示例#2
0
    /* FixedUpdate() function is for standalone testing navmesh function. Hit mouse left button(MLB) to set
     * up a destination for navmesh agent. if you want to test, uncomment
     * "locomotionCtl.Locomote(Vector3.Normalize(agent.steeringTarget - this.transform.position), false)"
     *  and comment the line blew. by now, it is not calling locomote function in order to make movement
     *  going the right way. -Feb 22th
     *
     *  March 16th on friday, Locomotion and navmesh works well together,this is the newest update of navmesh script
     */


    void FixedUpdate()
    {
        agent.velocity = rigidb.velocity;


        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = cam.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                agent.SetDestination(hit.point);
                destination = hit.point;
            }
        }

        //if (Input.GetMouseButtonDown(0)) {

        //    Ray ray = cam.ScreenPointToRay(Input.mousePosition);

        //    RaycastHit hit;

        //    if (Physics.Raycast(ray, out hit))
        //    {
        //        agent.SetDestination(hit.point);
        //        destination = hit.point;

        //    }
        //}

        if (Vector3.Distance(this.transform.position, destination) > 0.1f)
        {
            locomotionCtl.Locomote(Vector3.Normalize(agent.steeringTarget - this.transform.position));
        }

        //  this.transform.position += Vector3.Normalize(agent.steeringTarget - this.transform.position) * 0.1f;
    }
示例#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();
        }

        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
    }
示例#4
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
    }
示例#5
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
    }