Exemplo n.º 1
0
        public void Link(string dreamFilePath, Color color, bool playSound = true, string spawnName = "")
        {
            GameSettings.CanControlPlayer = false;
            _canLink = false;

            int  shouldChangeTextureSetChance = RandUtil.Int(100);
            bool shouldChangeTextureSet       = shouldChangeTextureSetChance < ChangeTextureSetChance;

            if (playSound)
            {
                _source.PlayOneShot(_linkSound);
            }
            Fader.FadeIn(color, 1F, () =>
            {
                DreamDirector.SwitchDreamLevel(dreamFilePath, spawnName);
                if (shouldChangeTextureSet)
                {
                    DreamDirector.RefreshTextureSet(false);
                }
                GameSettings.CanControlPlayer = true;
                Fader.FadeOut(color, 1F, () =>
                {
                    _canLink = true;
                });
            });
        }
Exemplo n.º 2
0
        void Start()
        {
            string[] titleScreenSongs = Directory.GetFiles(IOUtil.PathCombine(Application.streamingAssetsPath, "music", "title"), "*.ogg");
            int      songHandle       = RandUtil.Int(titleScreenSongs.Length);

            StartCoroutine(IOUtil.LoadOGGIntoSource(titleScreenSongs[songHandle], source, true, true));
        }
Exemplo n.º 3
0
    public static T RandomValue <T>(this T[] array)
    {
        if (array == null || array.Length == 0)
        {
            return(default(T));
        }

        return(array[RandUtil.Int(array.Length)]);
    }
Exemplo n.º 4
0
        public static void RefreshTextureSet(bool canUseCurrent)
        {
            TextureSet textureSet = (TextureSet)RandUtil.Int(1, 5);

            if (!canUseCurrent && textureSet == CurrentTextureSet)
            {
                RefreshTextureSet(false);
            }
            CurrentTextureSet = textureSet;
            Shader.SetGlobalInt("_TextureSet", (int)textureSet);
        }
Exemplo n.º 5
0
        void Start()
        {
            string[] titleScreenSongs =
                Directory.GetFiles(PathUtil.Combine(Application.streamingAssetsPath, "music", "title"), "*.ogg");
            int songHandle     = RandUtil.Int(titleScreenSongs.Length);
            var toriiAudioClip = ResourceManager.Load <ToriiAudioClip>(titleScreenSongs[songHandle], "global");

            source.clip = toriiAudioClip.Clip;
            source.loop = true;
            source.Play();
        }
Exemplo n.º 6
0
        private IEnumerator RollForGreyman()
        {
            while (true)
            {
                if (DreamDirector.CanSpawnGreyman)
                {
                    int chance = RandUtil.Int(GameSettings.CHANCE_FOR_GREYMAN);

                    Debug.Log(chance);
                    if (chance == 0)
                    {
                        SpawnGreyman();
                    }
                }

                yield return(new WaitForSeconds(RandUtil.Float(_minWaitTime, _maxWaitTime)));
            }
        }
Exemplo n.º 7
0
        public static void SwitchDreamLevel(string levelPath, string spawnPoint = "")
        {
            PostLoadEvent = null;

            if (_loadedDreamObject)
            {
                UnityEngine.Object.Destroy(_loadedDreamObject);
                ResourceManager.ClearLifespan(ResourceLifespan.LEVEL);
            }

            GameObject.FindGameObjectWithTag("EnvironmentController")
            .GetComponent <EnvironmentController>()
            .EnvironmentEntity = null;

            PlayerSpawns.Clear();
            PlayerSpawnForced = false;

            Target.Targets.Clear();
            ActionSequence.Sequences.Clear();

            TMAP t;

            _loadedDreamObject = IOUtil.LoadToriiMap(levelPath, ResourceLifespan.DREAM, out t);
            Payload.LevelsVisited.Add(t.Header.Name);

            if (PlayerSpawns.Count > 0)
            {
                int spawnPointHandle = 0;
                if (spawnPoint.Equals(string.Empty))                 // random spawn point
                {
                    spawnPointHandle = (PlayerSpawnForced || CurrentDay == 1)
                                                ? ForcedSpawnIndex
                                                : RandUtil.Int(0, PlayerSpawns.Count);
                }
                else
                {
                    // named spawn point
                    for (int i = 0; i < PlayerSpawns.Count; i++)
                    {
                        if (PlayerSpawns[i].Name.Equals(spawnPoint))
                        {
                            spawnPointHandle = i;
                        }
                    }
                }
                Vector3 spawnPos = SetPlayerSpawn(PlayerSpawns[spawnPointHandle].transform);

                Player.transform.position = spawnPos;
                Player.transform.rotation = Quaternion.Euler(0, PlayerSpawns[spawnPointHandle].transform.rotation.eulerAngles.y, 0);
            }
            else
            {
                Debug.LogError("There are no player_spawn entities in the level, cannot spawn player!");
            }

            if (PostLoadEvent != null)
            {
                PostLoadEvent.Invoke();
            }
            if (OnLevelFinishChange != null)
            {
                OnLevelFinishChange.Invoke();
            }
        }