Exemple #1
0
    void Update()
    {
        if (Time.timeScale <= 0)
        {
            return;
        }

        if (health <= 0)
        {
            Die(GameManager.player);
            return;
        }

        transform.position = bezierCurveManager.GetPositionAtTime(Time.time - startTime);

        foreach (Transform gun in gunTransforms)
        {
            Vector3 direction = Functions.Direction(gun.position, new Vector3(targetTransform.position.x, gun.position.y, targetTransform.position.z));
            gun.rotation = Quaternion.RotateTowards(gun.rotation, Quaternion.LookRotation(direction), turnSpeed * Time.deltaTime);

            string timerName = RandomName + "-" + gun.name;
            if (transform.position.z > targetTransform.position.z)
            {
                GameManager.timer.Add(timerName, 2f, true, true, GunSequence);
            }
            else
            {
                GameManager.timer.Remove(timerName);
            }
        }
    }
Exemple #2
0
    void Update()
    {
        if (GameManager.player == null || Time.timeScale <= 0)
        {
            return;
        }

        if (transform.GetComponent <Rigidbody>().useGravity)
        {
            float t = Mathf.Sin(Time.time * 0.5f);
            transform.rotation = Quaternion.Euler(t * -45, t * 360, 0);
        }

        if (health <= 0)
        {
            GameManager.timer.RemoveContaining(RandomName);
            transform.GetComponent <Rigidbody>().isKinematic = false;
            transform.GetComponent <Rigidbody>().useGravity  = true;
            return;
        }

        if (PlayerIsInRange())
        {
            GameManager.player.config.onRails = false;
            GameManager.player.sceneCamera.config.followPlayer = false;

            GameManager.timer.Add(RandomName + "_SequenceSwitcher", 5f, true, true, SequenceSwitcher);
        }
        else
        {
            GameManager.timer.Remove(RandomName + "_SequenceSwitcher");
        }

        if (health <= (spawnHealth / 100 * goingDownEffectsPrecentage))
        {
            goingDownEffects.SetActive(true);
        }

        followSequenceIndex = 0;
        if (followSequenceIndex == 0 && bezierCurveManager != null)
        {
            transform.position = Vector3.Lerp(transform.position, bezierCurveManager.GetPositionAtTime(Time.time), Time.deltaTime * smooth);
        }
        else if (followSequenceIndex == 1)
        {
            Vector3 simulatedPos = new Vector3(GameManager.player.transform.position.x, transform.position.y, transform.position.z);
            transform.position = Vector3.Lerp(transform.position, simulatedPos, Time.deltaTime * (smooth / 2));
        }

        if (health <= (spawnHealth / 100 * goingDownEffectsPrecentage))
        {
            if (GameManager.timer.Remove(RandomName + "_SequenceSwitcher"))
            {
                followSequenceIndex = 1;

                GameManager.timer.Remove(RandomName + "_Sequence0");
                GameManager.timer.Remove(RandomName + "_Sequence1");
                GameManager.timer.Remove(RandomName + "_Sequence2");

                GameManager.timer.Add(RandomName + "_Sequence0", 0.4f, true, false, Sequence0);
                GameManager.timer.Add(RandomName + "_Sequence2", 0.8f, true, false, Sequence2);
            }
        }
    }