Exemplo n.º 1
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);
    }
Exemplo n.º 2
0
 private void HandlePlayerDiedEvent(PlayerDiedEvent diedEvent)
 {
     CustomCoroutine.WaitOneFrameThenExecute(() => {
         EventManager.TriggerEvent(new GameOverEvent());
         Time.timeScale = 0.5f;
     });
 }
Exemplo n.º 3
0
 private void Attack()
 {
     Anim.Play("attack", 0, 0f);
     releasedAttack = true;
     CustomCoroutine.WaitThenExecute(0.05f, () => AttackConnect());
     attackCooldownCoroutine = StartCoroutine(AttackCooldown());
 }
Exemplo n.º 4
0
    public void NewGame()
    {
        Progress.Reset();
        ScreenEffects.FadeOut(1.2f);

        CustomCoroutine.WaitThenExecute(1.2f, () => { SceneManager.LoadScene("Treehouse"); });
    }
Exemplo n.º 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());
        }
                                     ));
    }
Exemplo n.º 6
0
    IEnumerator FadeOutAnimation()
    {
        fadeAnim.Play("FadeOut");
        yield return(StartCoroutine(CustomCoroutine.WaitForRealSeconds(1)));

        fadeCanvas.SetActive(false);
    }
Exemplo n.º 7
0
    /// <summary>
    /// Creates the coroutine and start it immediately
    /// Usage:
    /// Task t = this.StartCustomCoroutine( CoroutineA() )
    /// yield return t.untilDone;		// will wait until all coroutine is done
    /// </summary>
    /// <returns>The task.</returns>
    /// <param name="taskOwner">Task owner.</param>
    /// <param name="coroutine">Coroutine.</param>
    public static CustomCoroutine StartCustomCoroutine(this MonoBehaviour taskOwner, IEnumerator coroutine)
    {
        CustomCoroutine coroutineObject = new CustomCoroutine(taskOwner);

        coroutineObject.StartInternalRoutine(coroutine);
        return(coroutineObject);
    }
Exemplo n.º 8
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));
        }
    }
Exemplo n.º 9
0
 private static void TryCreateInstance()
 {
     if (instance == null)
     {
         instance = (new GameObject("CustomCoroutineRunner")).AddComponent <CustomCoroutine>();
     }
 }
Exemplo n.º 10
0
    public void UpdateDisplay(bool flicker = true)
    {
        text.SetText("x" + RunState.coal.ToString());

        text.color = default;
        CustomCoroutine.WaitThenExecute(0.1f, () => text.color = textColor);
    }
Exemplo n.º 11
0
    IEnumerator FadeInAnimation(string levelName)
    {
        fadeCanvas.SetActive(true);
        fadeAnim.Play("FadeIn");
        yield return(StartCoroutine(CustomCoroutine.WaitForRealSeconds(.7f)));

        Application.LoadLevel(levelName);
        FadeOut();
    }
        public void SimplifyImmidiate(HLODBuildInfo buildInfo)
        {
            IEnumerator     routine   = Simplify(buildInfo);
            CustomCoroutine coroutine = new CustomCoroutine(routine);

            while (coroutine.MoveNext())
            {
            }
        }
Exemplo n.º 13
0
    public void OnStartButtonClick()
    {
        GameMaster.Find().StartGame();

        BackgroundAlpha.IntendedAlpha = 0.0f;

        CustomCoroutine.WaitThenExecute(0.1f, () => {
            gameObject.SetActive(false);
        });
    }
Exemplo n.º 14
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();
    }
Exemplo n.º 15
0
    protected override void OnRepair()
    {
        base.OnRepair();

        _scrapEffect.SetActive(false);

        CustomCoroutine.WaitOneFrameThenExecute(() => {
            Attacker.enabled = true;
        });

        _sprite.material = Faction.UnitMat;
    }
Exemplo n.º 16
0
        public IEnumerator SendReportRoutine(TrelloCard card, List <Texture2D> screenshots)
        {
            // Shows the "in progress" text
            inProgressUI.SetActive(true);

            // We upload the card with an async custom coroutine that will return the card ID
            // Once it has been uploaded.
            CustomCoroutine cC = new CustomCoroutine(this, trello.UploadCardRoutine(card));

            yield return(cC.coroutine);

            // The uploaded card ID
            string cardID = (string)cC.result;

            int i = 0;

            foreach (Texture2D screenshot in screenshots)
            {
                i++;
                // We can now attach the screenshot to the card given its ID.
                yield return(trello.SetUpAttachmentInCardRoutine(cardID, "ScreenShot" + i + ".png", screenshot));
            }

#if UNITY_STANDALONE
            // We make sure the log exists before trying to retrieve it.
            if (System.IO.File.Exists(logPath))
            {
                // We make a copy of the log since the original is being used by Unity.
                System.IO.File.Copy(logPath, logPathCopy, true);

                // We attach the Unity log file to the card.
                yield return(trello.SetUpAttachmentInCardFromFileRoutine(cardID, "output_log.txt", logPathCopy));
            }
#endif
            // this one is meant to be replaced with relevant data about your game
            string relevantData = GetSettings() + GetSystemInfo();
            yield return(trello.SetUpAttachmentInCardRoutine(cardID, "SystemInfo.txt", relevantData));

            /**
             *
             *   Attach more convenient data to the card here
             *
             **/

            // Wait for one extra second to let the player read that his isssue is being processed
            yield return(new WaitForSeconds(1));

            // Since we are done we can deactivate the in progress canvas
            inProgressUI.SetActive(false);

            // Now we show the success text to let the user know the action has been completed
            StartCoroutine(SetActiveForSecondsRoutine(successUI, 2));
        }
Exemplo n.º 17
0
 public void TriggerTransition()
 {
     if (fadeObject != null)
     {
         fadeObject.SetActive(true);
         CustomCoroutine.WaitThenExecute(0.25f, LoadScene);
     }
     else
     {
         LoadScene();
     }
 }
Exemplo n.º 18
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);
         }
     }
 }
Exemplo n.º 19
0
    private IEnumerator PrintAll()
    {
        m_coroutineTest = this.CreateCustomCoroutine(PrintA());
        m_coroutineTest.AddCoroutine(PrintB());
        m_coroutineTest.AddCoroutine(PrintD());

        m_coroutineTest.Start();

        yield return(m_coroutineTest.UntilDone);

        Debug.Log("::: Wait for 1 second. :::");
        yield return(new WaitForSeconds(1));

        Debug.Log("::: PrintAll() completes its execution :::");
    }
Exemplo n.º 20
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);
    }
Exemplo n.º 21
0
    public void PlayMessage(string message)
    {
        shadow.gameObject.SetActive(!string.IsNullOrEmpty(message));

        if (sequentialText.PlayingMessage)
        {
            sequentialText.SkipToEnd();
        }

        currentCoroutines++;
        CustomCoroutine.WaitOnConditionThenExecute(() => !sequentialText.PlayingMessage, () =>
        {
            currentCoroutines--;
            sequentialText.PlayMessage(message.ToUpper());
        });
    }
Exemplo n.º 22
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;
    }
Exemplo n.º 23
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);
        });
    }
Exemplo n.º 24
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);
        }
    }
Exemplo n.º 25
0
 public void OnPlayerKilled()
 {
     fullScreenBlock.SetActive(true);
     CustomCoroutine.WaitThenExecute(0f, () => SceneManager.LoadScene("GameOver"));
 }
Exemplo n.º 26
0
    /// <summary>
    /// Creates the coroutine. But not yet started
    /// Usage:
    /// CustomCoroutine t = this.CreateCustomCoroutine( CoroutineA() );
    /// t.AddTask( CoroutineB() );
    /// t.Start();
    /// </summary>
    /// <returns>The task.</returns>
    /// <param name="taskOwner">Task owner.</param>
    /// <param name="coroutine">Coroutine.</param>
    public static CustomCoroutine CreateCustomCoroutine(this MonoBehaviour taskOwner, IEnumerator coroutine)
    {
        CustomCoroutine coroutineObject = new CustomCoroutine(taskOwner, coroutine);

        return(coroutineObject);
    }
Exemplo n.º 27
0
 public void Quit()
 {
     ScreenEffects.FadeOut(0.7f);
     CustomCoroutine.WaitThenExecute(0.7f, () => { Application.Quit(); });
 }