示例#1
0
 void Start()
 {
     NPCAnimator  = GetComponent <Animator>();
     SelenitState = NPCState.Work;
     selenit1     = new CurveMotion(this.gameObject, wayPoints);
     selenit1.MoveSetup(speed, forward: true, cycled: true);
     selenit1.RotateToPoint(workPoint);
     currentTime     = Time.time;
     playerObjects   = GameObject.Find("Player").GetComponent <PlayerObjects>();
     playerEquipment = GameObject.Find("Player").GetComponent <PlayerEquipment>();
     npcSFX          = GetComponent <AudioSource>();
 }
示例#2
0
    void Update()
    {
        if (true) //not game over
        {
            switch (SelenitState)
            {
            case NPCState.Walk:
            {
                bool result = selenit1.Move(workPoint);
                if (result)
                {
                    SelenitState = NPCState.Work;
                    selenit1.RotateToPoint(workPoint);
                    NPCAnimator.SetBool("Walk", false);
                    NPCAnimator.SetBool(workAnim, true);
                    currentTime = Time.time;
                }
            }
            break;

            case NPCState.Work:
            {
                if (Time.time - currentTime > pauseTime)
                {
                    NPCAnimator.SetBool(workAnim, false);
                    NPCAnimator.SetBool("Walk", true);
                    SelenitState = NPCState.Walk;
                }
            }
            break;

            case NPCState.Idle:
            {
                if (Time.time - currentTime > pauseTime)
                {
                    NPCAnimator.SetBool("Walk", true);
                    NPCAnimator.SetBool(workAnim, false);
                    SelenitState = NPCState.Walk;
                }
            }
            break;

            case NPCState.Talk:
            {
                if (Input.GetKeyDown(KeyCode.Y))
                {
                    if (playerObjects.Change(objectName, changeAmount))
                    {
                        if (gameObjectOff != null)
                        {
                            gameObjectOff.SetActive(false);
                        }
                        if (gameObjectOn != null)
                        {
                            gameObjectOn.SetActive(true);
                            gameObjectOn.transform.position = new Vector3(transform.position.x,
                                                                          gameObjectOn.transform.position.y,
                                                                          transform.position.z);
                        }
                        questCompleted = true;
                    }
                    Destroy(dialog);
                    SelenitState = NPCState.Walk;
                    NPCAnimator.SetBool("Walk", true);
                    NPCAnimator.SetBool(workAnim, false);
                }
                else if (Input.GetKeyDown(KeyCode.N))
                {
                    Destroy(dialog);
                    SelenitState = NPCState.Walk;
                    NPCAnimator.SetBool("Walk", true);
                    NPCAnimator.SetBool(workAnim, false);
                }
            }
            break;

            case NPCState.Panic:
            {
                if (!isPanic)
                {
                    npcSFX.PlayOneShot(panicSound, 0.1f);
                    isPanic = true;
                }

                bool result = panicWay.Move(panicPoint);
                if (result)
                {
                    gameObject.SetActive(false);
                    Time.timeScale = 0;
                    gameOverPanel.transform.GetChild(0).gameObject.GetComponent <Text>().text = "You were discovered! Panic arose. Mission failed";
                    gameOverPanel.SetActive(true);
                }
            }
            break;

            default: break;
            }
        }
    }