Exemple #1
0
    void FixedUpdate()
    {
        if (wsm.state == "State02" && na.hasPath == false && na.velocity == Vector3.zero)
        {
            if (isPause)
            {
                return;
            }
            cur += 1;
            if (cur == state02limit + 1)
            {
                wsm.changeState(new State03(wsm));
                wsm.state = "State03";
                return;
            }
            na.speed = speed;
            na.SetDestination(points[cur].transform.position);
        }
        if (!isphone && cur == 3)
        {
            isphone = true;
            Vector3 pos = new Vector3(-409.1f, -238.9f, -139.1f);
            phone.transform.position = pos;
        }
        if (isphone && cur == 5)
        {
            isphone = false;
            Destroy(phone);
        }

        if (wsm.state == "State03" && na.hasPath == false && na.velocity == Vector3.zero)
        {
            if (isPause)
            {
                return;
            }
            cur      = Random.Range(state02limit + 1, state03limit + 1);
            na.speed = speed;
            na.SetDestination(points[cur].transform.position);
        }

        target = this.transform.TransformDirection(Vector3.forward);
        ray    = new Ray(transform.position, target);
        RaycastHit hit;

        if (Physics.Raycast(transform.position, target, out hit, 100f))
        {
            if (hit.collider.tag == "Player" && !player.GetComponent <PlayerMovement>().isHide)
            {
                Debug.Log("hit");
                gc.barPercent += 0.05f;
            }
        }
        Debug.DrawRay(ray.origin, ray.direction.normalized * 100f, Color.red);
    }
    void Update()
    {
        if (Dia01)
        {
            instruction01.GetComponent <DialogueTrigger>().TriggerDialogue();
            Dia01 = false;
        }

        if (!Dia01 && !Dia02 && !FindObjectOfType <DialogueManager>().open&& wsm.state != "State02" && wsm.state != "State03")
        {
            Debug.Log("test01");
            wsm.changeState(new State02(wsm));
            wsm.state = "State02";
            if (!Dia02wait)
            {
                StartCoroutine(WaitDia02(2f));
            }
        }

        if (Dia02)
        {
            Wang.GetComponent <npcWang02>().pause();
            instruction02.GetComponent <DialogueTrigger>().TriggerDialogue();
            Dia02     = false;
            Dia02over = true;
        }

        if (Dia02over && !FindObjectOfType <DialogueManager>().open)
        {
            Dia02over = false;
            Wang.GetComponent <npcWang02>().resume();
            Dia03 = true;
        }

        if (Dia03 && player.transform.position.z < GameObject.Find("limit01").transform.position.z)
        {
            instruction03.GetComponent <DialogueTrigger>().TriggerDialogue();
            Wang.GetComponent <npcWang02>().pause();
            Dia03     = false;
            Dia03over = true;
        }

        if (Dia03over && !FindObjectOfType <DialogueManager>().open)
        {
            Dia03over = false;
            Wang.GetComponent <npcWang02>().resume();
            Dia04 = true;
        }
    }