Exemplo n.º 1
0
    public AudioSource PlaySFX(string sfx, bool loop = false)
    {
        AudioSource audioSource = gameObject.AddComponent <AudioSource>();
        AudioClip   audioClip   = Resources.Load <AudioClip>("Audio/SFX/" + sfx);

        audioSource.clip = audioClip;
        audioSource.loop = loop;
        audioSource.Play();
        MHS.RunUntil(() => { return(audioSource == null || audioSource.isPlaying == false); }, () => {
        }, () => {
            StopAudioSource(audioSource);
        });
        return(audioSource);
    }
Exemplo n.º 2
0
    public static void MoveEntitySmooth(Transform go, Vector2 targetEndMarker, float totalTime, Action callback = null)
    {
        Vector2 targetStartMarker = go.transform.position;

        float t         = totalTime;
        float startTime = Time.time;

        MHS.RunUntil(() => { return(t <= 0); }, () => {
            t          -= Time.deltaTime;
            go.position = Vector2.Lerp(targetStartMarker, targetEndMarker, (Time.time - startTime) / totalTime);
        }, () => {
            go.position = targetEndMarker;
            if (callback != null)
            {
                callback();
            }
        });
    }
Exemplo n.º 3
0
    void Start()
    {
        player = Global.GetPlayer().gameObject;

        // If intro sequence is false
        if (!Global.gameData.forestIntroSequence)
        {
            MHSFader.instance.preventAutomaticFadeIn = true;
            player.GetComponent <Player>().playerGraphic.SetActive(false);
            player.GetComponent <PlayerMovement>().movementMode = PlayerMovement.MovementModes.None;
            CineTarget.instance.cineMode = CineTarget.CineModes.Position;
            targetStartMarker            = CineTarget.instance.transform.position;
            ProCamera2D.Instance.CenterOnTargets();

            MHSFader.FadeOut(0);

            MHS.WaitRun(3, () => {
                MHSFader.FadeIn(3);
                Vector2 targetEndMarker = new Vector2(0, 3);
                MHS.WaitRun(4, () => {
                    MHSTools.MoveEntitySmooth(CineTarget.instance.transform, new Vector2(0, 4), 6, () => {
                        MHS.WaitRun(2, () => {
                            MessageBoxController.BuildMessages(
                                "Huh, I don't remember sleeping here..."
                                ).Next(() => {
                                player.GetComponent <PlayerMovement>().movementMode = PlayerMovement.MovementModes.NoPlayerInteraction;
                                player.GetComponent <Player>().playerGraphic.SetActive(true);
                                player.transform.position = new Vector2(0, 6.5f);

                                MHS.RunUntil(() => player.GetComponent <Prime31.CharacterController2D>().isGrounded, null, () => {
                                    GameObject.Instantiate(smokeBurstUp, player.transform.position + new Vector3(0, -0.4f), Quaternion.identity);
                                    AudioManager.instance.PlaySFX("Thump");
                                    player.GetComponent <Player>().playerGraphic.GetComponent <Animator>().SetTrigger("FallFlat");
                                    ProCamera2D.Instance.GetComponent <ProCamera2DShake>().Shake(1f, new Vector2(5f, 5f), 10, 0.1f, -1, new Vector3(5, 5, 10), 0.5f, false);

                                    MHS.WaitRun(2, () => {
                                        MessageBoxController.BuildMessages(
                                            "... OUCH"
                                            ).Next(() => {
                                            MHS.WaitRun(0.5f, () => {
                                                AudioManager.instance.PlayMusic(Global.instance.defaultMusic);
                                                MessageBoxController.BuildMessages(
                                                    new MessageBoxParams {
                                                    Text = "I better take a look around..."
                                                }
                                                    ).Next(() => {
                                                    player.GetComponent <Player>().playerGraphic.GetComponent <Animator>().SetTrigger("StandUpDizzy");

                                                    MHS.WaitRun(4f, () => {
                                                        player.GetComponent <PlayerMovement>().movementMode = PlayerMovement.MovementModes.Normal;
                                                        CineTarget.instance.cineMode = CineTarget.CineModes.Target;
                                                        CineTarget.instance.target   = player.transform;

                                                        // Save
                                                        Global.gameData.forestIntroSequence = true;
                                                        Global.Save();
                                                    });
                                                });
                                            });
                                        });
                                    });
                                });
                            });
                        });
                    });
                });
            });
        }
        // If intro sequence is true
        else
        {
        }
    }