Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject gameManager = GameObject.Find("GameManager");

        sceneHistory = gameManager.GetComponent <SceneHistory>();
        sceneHistory.LoadScene(sceneToLoad);
    }
Ejemplo n.º 2
0
 protected override void Awake()
 {
     base.Awake();
     if (Application.isPlaying)
     {
         onClick.AddListener(() => SceneHistory.LoadScene(RythmGameSettings.GameMode.gameScene));
     }
 }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Awake()
    {
        Scene  currentScene = SceneManager.GetActiveScene();
        string sceneName    = currentScene.name;

        // Call the LevelManager and set the last level.
        SceneHistory.setLastLevel(sceneName);
    }
Ejemplo n.º 4
0
        public SceneHistoryDrawer() : base()
        {
            _history = new SceneHistory();
            _history.Load();

            _channel       = EditorPreferenceHandler.GetChannel(this, CLASS_NAME);
            _restoreOnStop = _channel.GetBool(RESTORE_VAR);
            _textCol1      = GUILayout.Width(100);
        }
Ejemplo n.º 5
0
 //! Handle the Singleton object
 void Awake()
 {
     if (scene_history == null)
     {
         DontDestroyOnLoad(gameObject);
         scene_history = this;
     }
     else if (scene_history != this)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 6
0
        public static void LoadPreviousScene()
        {
            if (SceneHistory.Count < 2)
            {
                Debug.LogWarning("No scene to return to");
                return;
            }

            CallSceneChanging();
            SceneHistory.Pop();
            SceneManager.LoadScene(CurrentScene);
        }
Ejemplo n.º 7
0
    private void Start()
    {
        DontDestroyOnLoad(gameObject);
        apps           = FindObjectOfType <AppMessage>();
        users          = FindObjectOfType <DB_User>();
        products       = FindObjectOfType <DB_Product>();
        countries      = FindObjectOfType <DB_Country>();
        product_groups = FindObjectOfType <DB_ProductGroup>();
        scene_history  = FindObjectOfType <SceneHistory>();

        scene = SceneManager.GetActiveScene();

        Initialized();
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Update the StoryBoard.
        /// </summary>
        /// <param name="dt">The delta time.</param>
        /// <param name="input">The input item if any.</param>
        public static bool Update(TimeSpan dt, GenericMessage message)
        {
            // The STORYBOARD should only response to Low Level Game Events like SceneSwitch
            if (message is Message_SceneSwitch)
            {
                if (null != CurrentScene.mp)
                {
                    CurrentScene.mp.Pause();
                    CurrentScene.mp.PlaybackSession.Position = TimeSpan.Zero;
                }

                Message_SceneSwitch mss = message as Message_SceneSwitch;

                // find the scene
                if (SceneDictionary.ContainsKey(mss.TargetScene))
                {
                    // push the scene on to the history
                    SceneHistory.Push(CurrentScene);

                    // switch and kill the message
                    CurrentScene = SceneDictionary[mss.TargetScene];
                    CurrentScene.Reset();

                    if (AudioManager.AudioDictionary.TryGetValue(mss.TargetScene, out CurrentScene.mp))
                    {
                        CurrentScene.mp.Play();
                    }
                }

                return(true);
            }
            else if (message is Message_GoBack)
            {
                // check to see if the history list is empty
                if (SceneHistory.Count == 0)
                {
                    //Do nothing
                }
                else
                {
                    // Pop the scene from the history list and set it as the current scene
                    CurrentScene = SceneHistory.Pop();
                    CurrentScene.Reset();
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 9
0
    private void Update()
    {
        if (voteIsRunning && Time.time > timeVoteStarted + defaultVoteTime)
        {
            voteIsRunning = false;
            TwitchClient.Instance.OnMessageReceived -= VoteHandler;

            int winnerID = 0;
            for (int i = 1; i < songVotes.Length; ++i)
            {
                if (songVotes[i] > songVotes[winnerID])
                {
                    winnerID = i;
                }
            }
            float winnerDifficulty = (float)difficultyCumulatedVotes / votesCount;

            TwitchClient.Instance.SendMessage("Vote has ended, thanks for your participation !");
            TwitchClient.Instance.SendMessage($"Song {choices[winnerID].Id} with difficulty {System.Math.Round(winnerDifficulty, 1)} have been choosen !");
            NotificationManager.Instance.PushNotification("Vote has ended", Color.white, Color.blue);

            RythmGameSettings.BeatmapToLoad = choices[winnerID].Song.BeatmapContainer;
            RythmGameSettings.Difficulty    = winnerDifficulty;
            SceneHistory.LoadScene("TwitchMode");
        }

        if (voteIsRunning)
        {
            for (int i = 0; i < choices.Length; ++i)
            {
                if (Input.GetKeyDown(KeyCode.A + i))
                {
                    songVotes[i]++;
                    difficultyCumulatedVotes += Random.Range(1, 5);
                    votesCount++;
                    Debug.Log(difficultyCumulatedVotes / (float)votesCount);
                }
            }

            if (votesCount != 0)
            {
                for (int i = 0; i < choices.Length; ++i)
                {
                    choices[i].Percentage = (float)songVotes[i] / votesCount;
                }
                DifficultyCursor.Difficulty = (float)difficultyCumulatedVotes / votesCount;
            }
        }
    }
Ejemplo n.º 10
0
 private void Awake()
 {
     if (instance != null)
     {
         if (instance == this)
         {
             Destroy(this);
         }
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
 }
Ejemplo n.º 11
0
        static void ShowMenu()
        {
            GenericMenu menu = new GenericMenu();

            var sceneGuids = SceneHistory.GetResentSceneGuids();

            foreach (var sceneGuid in sceneGuids)
            {
                var path     = AssetDatabase.GUIDToAssetPath(sceneGuid);
                var filename = Path.GetFileName(path);
                var content  = new GUIContent(filename);
                menu.AddItem(content, false, OpenScene, path);
            }

            menu.DropDown(new Rect(200, 200, 1, 1));
        }
Ejemplo n.º 12
0
        public static void Update()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var oldNodes = _nodes;

            var newScenes = ZetaDia.Scenes.Where(s => s.Mesh.Zone != null).ToList();

            int minEdgeLength  = (int)Math.Ceiling(newScenes.Min(s => Math.Min(s.Mesh.Zone.ZoneMax.X - s.Mesh.Zone.ZoneMin.X, s.Mesh.Zone.ZoneMax.Y - s.Mesh.Zone.ZoneMin.Y)));
            int halfEdgeLength = minEdgeLength / 2;

            var nodes        = new List <DungeonNode>();
            var cachedScenes = new List <CachedScene>();

            var completeScenes = new HashSet <int>(_scenes.Where(pair => pair.Value.IsExplored).Select(pair => pair.Key));

            // Iterate through scenes, find connecting scene names and create a dungeon node to navigate to the scene center
            newScenes.AsParallel().ForEach(scene =>
            {
                if (scene.Name.EndsWith("_Filler") || !scene.IsValid)
                {
                    return;
                }

                var zone      = scene.Mesh.Zone;
                var zoneMin   = zone.ZoneMin;
                var zoneMax   = zone.ZoneMax;
                var sceneHash = GetSceneHash(zone);

                if (completeScenes.Contains(sceneHash))
                {
                    return;
                }

                var cachedScene = new CachedScene
                {
                    Scene          = scene,
                    SceneHash      = sceneHash,
                    Name           = scene.Name,
                    Zone           = zone,
                    ZoneMax        = zoneMax,
                    ZoneMin        = zoneMin,
                    MinEdgeLength  = minEdgeLength,
                    HalfEdgeLength = halfEdgeLength
                };

                PopulateExitCodes(cachedScene);

                var baseNode         = new DungeonNode(zoneMin, zoneMax);
                cachedScene.BaseNode = baseNode;
                cachedScene.Nodes.Add(baseNode);
                if (nodes.All(node => node.WorldTopLeft != baseNode.WorldTopLeft))
                {
                    nodes.Add(baseNode);
                }

                cachedScene.Center          = new Vector3(zoneMax.X - (zoneMax.X - zoneMin.X) / 2, zoneMax.Y - (zoneMax.Y - zoneMin.Y) / 2, 0);
                cachedScene.NorthEdgeCenter = new Vector3(zoneMin.X, zoneMax.Y - (zoneMax.Y - zoneMin.Y) / 2, 0);
                cachedScene.SouthEdgeCenter = new Vector3(zoneMax.X, zoneMax.Y - (zoneMax.Y - zoneMin.Y) / 2, 0);
                cachedScene.EastEdgeCenter  = new Vector3(zoneMax.X - (zoneMax.X - zoneMin.X) / 2, zoneMax.Y, 0);
                cachedScene.WestEdgeCenter  = new Vector3(zoneMax.X - (zoneMax.X - zoneMin.X) / 2, zoneMin.Y, 0);

                // North
                var northNode         = (new DungeonNode(new Vector2(zoneMin.X - halfEdgeLength, zoneMin.Y), new Vector2(zoneMax.X - halfEdgeLength, zoneMin.Y)));
                cachedScene.NorthNode = northNode;
                cachedScene.Nodes.Add(northNode);
                if (nodes.All(node => node.WorldTopLeft != northNode.WorldTopLeft))
                {
                    nodes.Add(northNode);
                }

                // South
                var southNode         = (new DungeonNode(new Vector2(zoneMin.X + halfEdgeLength, zoneMin.Y), new Vector2(zoneMax.X + halfEdgeLength, zoneMin.Y)));
                cachedScene.SouthNode = southNode;
                cachedScene.Nodes.Add(southNode);
                if (nodes.All(node => node.WorldTopLeft != southNode.WorldTopLeft))
                {
                    nodes.Add(southNode);
                }

                // East
                var eastNode         = (new DungeonNode(new Vector2(zoneMin.X, zoneMin.Y - halfEdgeLength), new Vector2(zoneMax.X, zoneMin.Y - halfEdgeLength)));
                cachedScene.EastNode = eastNode;
                cachedScene.Nodes.Add(eastNode);
                if (nodes.All(node => node.WorldTopLeft != eastNode.WorldTopLeft))
                {
                    nodes.Add(eastNode);
                }

                // West
                var westNode         = (new DungeonNode(new Vector2(zoneMin.X, zoneMin.Y + halfEdgeLength), new Vector2(zoneMax.X, zoneMin.Y + halfEdgeLength)));
                cachedScene.WestNode = westNode;
                cachedScene.Nodes.Add(westNode);
                if (nodes.All(node => node.WorldTopLeft != westNode.WorldTopLeft))
                {
                    nodes.Add(westNode);
                }


                if (!_scenes.ContainsKey(cachedScene.SceneHash))
                {
                    _scenes.Add(cachedScene.SceneHash, cachedScene);
                }
                else
                {
                    _scenes[cachedScene.SceneHash] = cachedScene;
                }
            });

            _scenes.Values.ForEach(PopulateSceneConnections);

            if (oldNodes != null && oldNodes.Any())
            {
                nodes.AsParallel().ForEach(node =>
                {
                    var oldNode = oldNodes.FirstOrDefault(n => node.WorldTopLeft == n.WorldTopLeft);
                    if (oldNode != null && oldNode.Visited)
                    {
                        node.Visited = true;
                    }
                });

                oldNodes.AsParallel().ForEach(oldNode =>
                {
                    if (nodes.All(newNode => newNode.Center != oldNode.WorldTopLeft))
                    {
                        nodes.Add(oldNode);
                    }
                });
            }

            SceneHistory.UpdateSceneHistory();

            _nodes = new ConcurrentBag <DungeonNode>(nodes.Distinct());
            Logger.Debug("Updated SceneSegmentation {0} Scenes {1} nodes in {2:0}ms", _scenes.Count, _nodes.Count, stopwatch.ElapsedMilliseconds);
        }
Ejemplo n.º 13
0
 protected override void Awake()
 {
     base.Awake();
     onClick.AddListener(() => SceneHistory.LoadScene(ScenePath));
 }
Ejemplo n.º 14
0
    public IEnumerator Wait()
    {
        yield return(new WaitForSeconds(5));

        SceneHistory.changeToPreviousLvl();
    }
Ejemplo n.º 15
0
 public void start()
 {
     SceneHistory.changeToPreviousLvl();
     print("hi");
 }
 protected override void Awake()
 {
     base.Awake();
     onClick.AddListener(() => SceneHistory.LoadPreviousScene());
 }
Ejemplo n.º 17
0
 public void ExitBank()
 {
     SceneHistory.changeToPreviousLvl();
 }