Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (cooldownTimer > 0.0f)
        {
            cooldownTimer -= Time.deltaTime * ((timeScaler) ? (timeScaler.timeScale) : (1.0f));
        }

        if (enableControls)
        {
            if ((Input.GetButtonDown(fire)) || (Input.GetAxis("Shoot") != 0))
            {
                if ((cooldownTimer <= 0.0f) && (buttonsReleased))
                {
                    anim.SetTrigger("Attack");

                    if (muzzleFlash)
                    {
                        Instantiate(muzzleFlash, shootPosition.position - Vector3.forward * 0.1f, shootPosition.rotation);
                    }

                    Shot shot = Instantiate(shotPrefab, shootPosition.position, shootPosition.rotation);
                    shot.damage  = damage;
                    shot.speed   = speed;
                    shot.color   = color;
                    shot.faction = faction;

                    cooldownTimer   = cooldown;
                    buttonsReleased = false;

                    if (shakeEnable)
                    {
                        CameraShake2d.Shake(shakeStrength, shakeTime);
                    }
                }
            }
            else
            {
                buttonsReleased = true;
            }
        }
    }
Exemple #2
0
    IEnumerator RunCutsceneCR()
    {
        PlayerController pc = FindObjectOfType <PlayerController>();

        commander.SetBool("Grounded", true);
        pc.enableControls = false;

        yield return(new WaitForSeconds(1.0f));

        pc.enabled = false;

        Animator playerAnim = pc.GetComponent <Animator>();

        playerAnim.SetFloat("AbsSpeedX", pc.moveSpeed);

        Destroy(pc.GetComponent <HealthSystem>());

        while (playerAnim.transform.position.x < targetPos.position.x)
        {
            playerAnim.transform.position = Vector3.MoveTowards(playerAnim.transform.position, targetPos.position, pc.moveSpeed * Time.deltaTime);

            yield return(null);
        }

        playerAnim.SetFloat("AbsSpeedX", 0.0f);

        yield return(new WaitForSeconds(1.0f));

        commander.SetTrigger("Celebrate");
        commander.speed = 0.1f;

        levelManager.DisplayText("Congratulation, agent!");
        while (levelManager.textEnabled)
        {
            yield return(null);
        }

        levelManager.DisplayText("You are ready to join these men and women in the field, fighting for our Universe's salvation!");
        while (levelManager.textEnabled)
        {
            yield return(null);
        }

        levelManager.DisplayText("Now, just let me...");
        while (levelManager.textEnabled)
        {
            yield return(null);
        }

        StartCoroutine(AlarmCR());
        alarmSound.Play();
        crowdSound.Stop();

        yield return(new WaitForSeconds(1.0f));

        levelManager.DisplayText("What's this? An alarm? Impossible!");
        while (levelManager.textEnabled)
        {
            yield return(null);
        }

        for (int i = 0; i < 3; i++)
        {
            CameraShake2d.Shake(1.0f * (i + 1), 0.5f);
            explosionSound.volume = 0.2f * (i + 1);
            explosionSound.Play();

            yield return(new WaitForSeconds(0.75f));
        }

        levelManager.DisplayText("What...");
        while (levelManager.textEnabled)
        {
            yield return(null);
        }

        for (int i = 0; i < explosionPoints.Length; i++)
        {
            yield return(new WaitForSeconds(0.5f));

            CameraShake2d.Shake(2.0f, 0.5f);
            explosionSound.volume = 0.8f;
            explosionSound.Play();

            Instantiate(explosionPrefab, explosionPoints[i].position, explosionPoints[i].rotation);
        }

        FullscreenFader.FadeOut(0.6f, Color.white);

        yield return(new WaitForSeconds(3.0f));

        SceneManager.LoadScene("RealGame");
    }