Пример #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            Time.timeScale = (Time.timeScale == 1) ? .2f : 1;
        }

        if (currentGhost != null)
        {
            if (Input.GetKeyDown(KeyCode.Z) && !capturing)
            {
                currentGhost.Stun();
                light.GetComponent <Renderer>().material.DOFloat(3, "Opacity", .06f).OnComplete(() =>
                                                                                                light.GetComponent <Renderer>().material.DOFloat(.15f, "Opacity", .2f));

                light.GetComponentInChildren <Light>().DOIntensity(105, .06f).OnComplete(() =>
                                                                                         light.GetComponentInChildren <Light>().DOIntensity(7, .25f));
            }

            if (Input.GetKeyDown(KeyCode.X) && currentGhost.stunned)
            {
                currentGhost.ActivateEscapeRig();
                GetComponent <MovementInput>().enabled = false;
                CaptureState(true);
            }
        }

        if (!capturing)
        {
            return;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        axis = new Vector3(-x, 0, -z);
        float angle = Vector3.Angle(transform.forward, axis);

        c.Move(transform.forward * speed * Time.deltaTime);

        if (angle > 130)
        {
            c.Move(axis * (speed / 2) * Time.deltaTime);

            if (currentGhost.energy > 0)
            {
                currentGhost.Damage(angle, axis);
            }
            else
            {
                Capture();
            }
        }

        amount = (angle > 130) ? (-10 * Mathf.Abs(axis.magnitude)) : 10;
        controller.localEulerAngles = new Vector3(Mathf.LerpAngle(controller.localEulerAngles.x, amount, .35f),
                                                  0, Mathf.LerpAngle(controller.localEulerAngles.z, amount, .3f));
    }