Ejemplo n.º 1
0
    //Update Method
    void Update()
    {
        if (GameController.game.isPlaying && !GameController.game.isPaused)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(ray, out hit))
                {
                    if (hit.transform.tag == "Cask" || hit.transform.tag == "Glass" || hit.transform.tag == "GlassSupport")
                    {
                        MoveCharacter(hit.transform.position, hit);
                    }
                }
            }

            if (!agent.pathPending)
            {
                if (agent.remainingDistance <= agent.stoppingDistance)
                {
                    if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f)
                    {
                        if (hasPath)
                        {
                            hasPath = false;
                            ManageGlass(hit);
                            anim.ChangeAnimation(false);
                        }
                    }
                }
            }

            DisplayMugs();
        }
    }
Ejemplo n.º 2
0
    //FixedUpdate Method
    void FixedUpdate()
    {
        if (GameController.game.isPlaying && !GameController.game.isPaused)
        {
            //Movement
            if (!isSlipping)
            {
                transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * Time.fixedDeltaTime * speed, 0, Input.GetAxisRaw("Vertical") * Time.fixedDeltaTime * speed));

                //Animation control
                if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0)
                {
                    Vector3 direction = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
                    model.transform.rotation = Quaternion.LookRotation(direction);

                    if (!isWalking)
                    {
                        changedAnimation = true;
                    }
                    isWalking = true;
                }
                else
                {
                    if (isWalking)
                    {
                        changedAnimation = true;
                    }
                    isWalking = false;
                }

                if (changedAnimation)
                {
                    changedAnimation = false;
                    anim.ChangeAnimation(isWalking);
                }

                //Checks player input
                if (Input.GetKeyDown(KeyCode.Q) && slot[0] != -1)                   //Left slot

                {
                    Collider coll = CheckClients();

                    if (coll != null)
                    {
                        if (!coll.GetComponent <Client>().isLeaving)
                        {
                            coll.GetComponent <Client> ().GetOrder(slot [0]);
                            slot [0] = -1;
                        }
                    }
                }

                if (Input.GetKeyDown(KeyCode.E) && slot[1] != -1)                   //Right slot

                {
                    Collider coll = CheckClients();

                    if (coll != null)
                    {
                        if (!coll.GetComponent <Client>().isLeaving)
                        {
                            coll.GetComponent <Client> ().GetOrder(slot [1]);
                            slot [1] = -1;
                        }
                    }
                }
            }

            //Displays mugs
            DisplayMugs();
        }
    }