예제 #1
0
    public void UpdateDisplay(bool flicker = true)
    {
        text.SetText("x" + RunState.coal.ToString());

        text.color = default;
        CustomCoroutine.WaitThenExecute(0.1f, () => text.color = textColor);
    }
예제 #2
0
 private void Attack()
 {
     Anim.Play("attack", 0, 0f);
     releasedAttack = true;
     CustomCoroutine.WaitThenExecute(0.05f, () => AttackConnect());
     attackCooldownCoroutine = StartCoroutine(AttackCooldown());
 }
예제 #3
0
    protected virtual void Attack()
    {
        target.TakeDamage(damage);
        Rigidbody enRigidbody = target.GetComponent <Rigidbody>();

        if (enRigidbody != null)
        {
            enRigidbody.AddForce((target.transform.position - transform.position).normalized * attackPushback, ForceMode.Impulse);
        }
        lastAttack = Time.time;
        following  = false;

        if (slashPref != null)
        {
            slash.SetActive(true);
            slash.transform.position = target.transform.position;
            CustomCoroutine.WaitThenExecute(1.0f, () => {
                if (slash != null)
                {
                    slash.SetActive(false);
                }
            }
                                            );
        }

        CustomCoroutine.WaitThenExecute(attackCooldown, () => following = true);
    }
예제 #4
0
    public void NewGame()
    {
        Progress.Reset();
        ScreenEffects.FadeOut(1.2f);

        CustomCoroutine.WaitThenExecute(1.2f, () => { SceneManager.LoadScene("Treehouse"); });
    }
예제 #5
0
    public void StartStage()
    {
        Progress.Save();

        GameObject player1 = Instantiate(kid1Pref, kidSpawns[0].position, Quaternion.identity);

        kids.Add(player1.GetComponent <Kid>());

        GameObject player2 = Instantiate(kid2Pref, kidSpawns[1].position, Quaternion.identity);

        kids.Add(player2.GetComponent <Kid>());

        dayText.gameObject.SetActive(true);
        dayText.transform.SetAsLastSibling();
        dayText.text = "Day " + (Progress.Day + 1);
        dayText.GetComponent <LerpAlpha>().SetAlpha(0.0f);
        dayText.GetComponent <LerpAlpha>().IntendedAlpha = 1.0f;
        CustomCoroutine.WaitThenExecute(3.0f, () => {
            dayText.GetComponent <LerpAlpha>().IntendedAlpha = 0.0f;
            dayText.transform.SetAsLastSibling();
        });

        sequencer.StartCoroutine(sequencer.OnStageStarted(
                                     () => {
            state = GameState.Playing;
            EventManager.QueueEvent(new StageStartedEvent());
        }
                                     ));
    }
예제 #6
0
    private IEnumerator SpawnNextWave()
    {
        AudioController.Instance.FadeOutLoop(0.6f);

        yield return(new WaitForSeconds(breakTimes / 4));

        string loopToPlay = string.IsNullOrEmpty(CurrentWave.songLoop) ? defaultWaveLoop : CurrentWave.songLoop;

        AudioController.Instance.SetLoop(loopToPlay);
        AudioController.Instance.SetLoopVolume(0.0f);
        AudioController.Instance.FadeInLoop(0.6f, 0.8f);

        yield return(new WaitForSeconds(breakTimes - breakTimes / 4));

        stage.WaveStarted(waveIndex);

        LerpAlpha textAplha = notifyText.GetComponent <LerpAlpha>();

        notifyText.text = "Wave " + (waveIndex + 1);
        notifyText.transform.SetAsLastSibling();
        textAplha.SetAlpha(0.0f);
        textAplha.IntendedAlpha = 0.8f;
        CustomCoroutine.WaitThenExecute(1.54f, () => {
            textAplha.IntendedAlpha = 0.0f;
        });

        foreach (var spawnGroup in CurrentWave.spawnGroups)
        {
            StartCoroutine(SpawnGroup(spawnGroup));
        }
    }
예제 #7
0
    private void ShootGun()
    {
        gunflare.SetActive(true);
        CustomCoroutine.WaitThenExecute(0.05f, () => gunflare.SetActive(false));
        AudioController.Instance.PlaySound2D("gunshot_2");
        RaiderSpawner.Instance.OnRaiderShot();

        RunState.bullets--;
        BulletsDisplay.Instance.UpdateDisplay();
    }
예제 #8
0
    public void OnStartButtonClick()
    {
        GameMaster.Find().StartGame();

        BackgroundAlpha.IntendedAlpha = 0.0f;

        CustomCoroutine.WaitThenExecute(0.1f, () => {
            gameObject.SetActive(false);
        });
    }
예제 #9
0
 public void TriggerTransition()
 {
     if (fadeObject != null)
     {
         fadeObject.SetActive(true);
         CustomCoroutine.WaitThenExecute(0.25f, LoadScene);
     }
     else
     {
         LoadScene();
     }
 }
예제 #10
0
 public void GainWeapon(Weapon weapon, bool immediate = true)
 {
     weapons.ForEach(x => x.SetActive(false));
     CurrentWeaponId = weapon;
     if (weapon != Weapon.None)
     {
         CurrentWeapon.SetActive(true);
         if (!immediate)
         {
             AudioController.Instance.PlaySound2D("misc_crunch_1");
             CurrentWeapon.GetComponent <SpriteRenderer>().material = flashWeaponMat;
             CustomCoroutine.WaitThenExecute(0.1f, () => CurrentWeapon.GetComponent <SpriteRenderer>().material = defaultWeaponMat);
         }
     }
 }
예제 #11
0
    private IEnumerator AttackCoroutine()
    {
        LastAttack = Time.time;
        Following  = false;

        animator.SetTrigger("Attack");

        if (waitForAnim)
        {
            yield return(new WaitForSeconds(0.65f));
        }

        LaunchProjectile();

        CustomCoroutine.WaitThenExecute(attackCooldown, () => Following = true);
    }
예제 #12
0
    protected override IEnumerator EventSequence()
    {
        if (campAudio != null)
        {
            CustomCoroutine.WaitThenExecute(2f, () =>
            {
                campAudio.SetActive(true);
                AudioController.Instance.FadeOutLoop(2f);
            });
        }
        if (skipHint != null && returned)
        {
            skipHint.SetActive(true);
        }

        PlayerController.Instance.enabled = false;
        yield return(new WaitForSeconds(0.2f));

        foreach (DialogueBubble b in dialogueBubbles)
        {
            b.gameObject.SetActive(true);
            yield return(b.PlayDialogue());

            yield return(new WaitForSeconds(0.1f));

            b.gameObject.SetActive(false);
        }

        if (liveComrade != null)
        {
            liveComrade.GetComponentInChildren <Animator>().SetTrigger("slide");
            Tween.Position(liveComrade, liveComrade.transform.position + (Vector3.right * 12f), 0.5f, 0f, Tween.EaseInOut);
            yield return(new WaitForSeconds(0.5f));

            liveComrade.gameObject.SetActive(false);
        }

        if (finale)
        {
            yield return(Finale());
        }
        else
        {
            PlayerController.Instance.enabled = true;
        }
        returned = true;
    }
예제 #13
0
    private void ProcessInput()
    {
        if (submitting)
        {
            PlayerManager.ActivePlayers[m_PlayerNum] = true;
        }

        if (cancelling)
        {
            PlayerManager.ActivePlayers[m_PlayerNum] = false;
        }

        if (starting && PlayerManager.ActivePlayers[m_PlayerNum] && PlayerManager.HasEnoughPlayers())
        {
            CustomCoroutine.WaitThenExecute(0.25f, () => SceneManager.LoadScene(2));
            fadeOut.SetActive(true);
        }
    }
예제 #14
0
    public void StageLost()
    {
        if (!Playing)
        {
            return;
        }

        state = GameState.Lost;

        Treehouse house = GameObject.FindGameObjectWithTag("Treehouse").GetComponent <Treehouse>();

        cameraControl.Focus(house.transform.position);

        CustomCoroutine.WaitThenExecute(END_GAME_DELAY, () => {
            gameOverScreen.transform.SetAsLastSibling();
            gameOverScreen.SetActive(true);
        });
    }
예제 #15
0
 public void Quit()
 {
     ScreenEffects.FadeOut(0.7f);
     CustomCoroutine.WaitThenExecute(0.7f, () => { Application.Quit(); });
 }
예제 #16
0
 public void OnPlayerKilled()
 {
     fullScreenBlock.SetActive(true);
     CustomCoroutine.WaitThenExecute(0f, () => SceneManager.LoadScene("GameOver"));
 }