예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (anim.waitforanim)
        {
            if (!agentPaused)
            {
                pause();
            }
            return;
        }
        if (agentPaused)
        {
            resume();
        }

        if (!agent.pathPending)
        {
            if (agent.enabled && agent.remainingDistance <= agent.stoppingDistance)
            {
                if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f)
                {
                    disableMoveIndicator();
                }
            }
        }


        if (pickingup)
        {
            if (target != null)
            {
                if (arrivedToDestination(50.0f))
                {
                    if (interaction.RotateTowards(target.transform))
                    {
                        anim.pickup();
                        //TODO, actually pickup something
                        disableTarget();
                    }
                }
            }
        }

        /* If target is double clicked, walk to it and at destination do what ever needs to be done*/
        if (movingToTarget)
        {
            if (arrivedToDestination(10.0f) && target != null)
            {
                if (target.tag == "MedCabinet")
                {
                    GameObject.Find("Minigame1").GetComponent <Minigame1>().startMinigame();
                    disableTarget();
                    movingToTarget = false;
                }
                else if (target.tag == "Computer")
                {
                    target.GetComponent <Computer>().StartComputer();
                    disableTarget();
                    movingToTarget = false;
                }
                else if (target.tag == "TrashCan")
                {
                    movingToTarget = false;
                }
                else if (target.tag == "CoffeeMachine")
                {
                    Instantiate(TimeSkipPrefab);
                    movingToTarget = false;
                    disableTarget();
                }
            }
        }

        if (sitting)
        {
            if (arrivedToDestination(10.0f))
            {
                if (target != null)
                {
                    if (interaction.RotateAwayFrom(target.transform))
                    {
                        if (target.tag == "Chair2")
                        {
                            if (agent.enabled)
                            {
                                anim.sitwithrotation();
                            }
                        }
                        else
                        {
                            if (agent.enabled)
                            {
                                anim.sit();
                            }
                        }
                    }
                }
                else
                {
                    sitting = false;
                    objManager.unbookObject(target);
                }
            }
        }

        if (sleeping)
        {
            if (arrivedToDestination(10.0f))
            {
                if (target != null || target.tag == "Bed")
                {
                    if (interaction.RotateAwayFrom(target.transform))
                    {
                        if (!anim.sleeping)
                        {
                            anim.sleep();
                        }
                    }
                }
                else
                {
                    sleeping = false;
                    objManager.unbookObject(interaction.getBed());
                }
            }
        }
        if (followNpc)
        {
            if (target != null)
            {
                disableMoveIndicator();
                if (arrivedToDestination(20.0f))
                {
                    if (agent.hasPath)
                    {
                        agent.ResetPath();
                    }
                    interaction.RotateTowards(target.transform);
                }
                else
                {
                    walkToTarget();
                }
            }
        }

        handleInput();
    }