Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (alive)
        {
            if (Vector3.Distance(transform.position, GetComponent <NavMeshAgent>().destination) > 10)
            {
                GetComponent <NavMeshAgent>().speed = startSpeed * 2;
            }
            else
            {
                GetComponent <NavMeshAgent>().speed = startSpeed;
            }

            GetComponent <NavMeshAgent>().destination    = FindObjectOfType <FirstPersonCharacterController>().gameObject.transform.position;
            GetComponent <NavMeshAgent>().updateRotation = false;
            if (blackout.IsOnBlack())
            {
                GetComponent <NavMeshAgent>().updatePosition = true;
            }
            else
            {
                GetComponent <NavMeshAgent>().updatePosition = false;
                InstantlyTurn(GetComponent <NavMeshAgent>().destination);
                screenStaticUI.alpha = 0.01f + Mathf.Max(0, (0.2f - Vector3.Distance(transform.position, GetComponent <NavMeshAgent>().destination) / 20));
            }
            //GetComponent<NavMeshAgent>().speed = 3f;
            //lights.SetActive(true);
        }
        else
        {
            screenStaticUI.alpha = 0f;
            blackout.StopFlashing();
        }

        switch (stepNum)
        {
        case 0:
            if (powerSwitch.isOn)
            {
                stepNum = 1;
            }
            break;

        case 1:
            if (IsVisibleToCamera(transform))
            {
                shockSource = AudioManager.PlaySound(shockSound, true);
                stepNum     = 2;
            }
            break;

        case 2:
            startPos             = transform.position;
            startRot             = transform.rotation;
            transform.localScale = new Vector3(0, 0, 0);
            if (emergencyButton.hasBeenPressed)
            {
                shockSource.Stop();
                StartCoroutine(StartHit());
                stepNum = 3;
                powerSwitch.SetLights(false);
            }
            break;

        case 3:

            break;

        case 4:
            powerSwitch.SetLights(true);
            transform.position   = startPos;
            transform.rotation   = Quaternion.Euler(startRot.eulerAngles.x, startRot.eulerAngles.y + 180, startRot.eulerAngles.z);
            transform.localScale = startScale;
            GetComponentInChildren <Animator>().Play("Idle", 0, 0);
            StartCoroutine(StartAttack());
            stepNum = 5;
            break;

        case 5:

            break;

        case 6:
            alive   = true;
            stepNum = 7;
            break;

        case 7:

            break;
        }
    }