コード例 #1
0
        private void GenerateNewTip()
        {
            exitTweenDone = false;

            // TODO: Increase tip chance when more tips are added.
            var tip = new Random().NextDouble() > 0.2 ? LoadScreenJokes.Generate() : LoadScreenTips.Generate();

            Tween.To(Display.UiWidth + 150, tipLabel.CenterX, x => tipLabel.CenterX = x, 1.5f, Ease.QuadIn).OnEnd += () => {
                tipLabel.Label = tip;
                tipLabel.FinishTyping();
                tipLabel.Center = new Vector2(-150, Display.UiHeight - 55);

                var t = Tween.To(Display.UiWidth / 2f, tipLabel.CenterX, x => tipLabel.CenterX = x, 1.5f, Ease.QuadOut);
                t.OnEnd = () => exitTweenDone = true;
            };
        }
コード例 #2
0
        public override void Init()
        {
            base.Init();

            Shaders.Ui.Parameters["black"].SetValue(1f);

            animation        = Animations.Create("loading");
            animation.Paused = false;

            nice = Rnd.Chance(4.2f);

            if (SaveManager.ExistsAndValid(SaveType.Game) &&
                SaveManager.ExistsAndValid(SaveType.Level) &&
                SaveManager.ExistsAndValid(SaveType.Player))
            {
                loading = true;
            }

            prefix = Locale.Get(loading || Run.Depth < 1 ? Locale.Get("loading") : Locale.Get("generating"));
            title  = new Random().NextDouble() > 0.3 ? LoadScreenJokes.Generate() : BiomeTitles.Generate(BiomeRegistry.GenerateForDepth(Run.Depth).Id);

            Lights.Init();
            Physics.Init();
            gameArea = new Area();

            Run.Level = null;
            progress  = 0;

            var thread = new Thread(() => {
                Tilesets.Load();

                SaveManager.Load(gameArea, SaveType.Game, Path);
                progress++;

                SaveManager.Load(gameArea, SaveType.Level, Path);
                progress++;

                Run.Luck = 0;
                Run.ResetScourge();

                if (Run.Depth > 0)
                {
                    SaveManager.Load(gameArea, SaveType.Player, Path);
                }
                else
                {
                    SaveManager.Generate(gameArea, SaveType.Player);
                }

                GC.Collect();
                progress++;
                Engine.AssetsLoaded?.Invoke();
                ready = true;
            });

            thread.Priority     = ThreadPriority.Lowest;
            thread.IsBackground = true;
            thread.Start();

            titleX = Font.Small.MeasureString(title).Width * -0.5f;
        }