Ejemplo n.º 1
0
        public override void Init()
        {
            base.Init();

            Width  = 4;
            Height = 4;

            Setup("ui", "dialog_");
            triangle = CommonAse.Ui.GetSlice("dialog_tri");

            Str = new UiString(Font.Small);
            Area.Add(Str);

            Depth             = 2;
            Str.Paused        = true;
            Str.Depth         = Depth + 1;
            Str.WidthLimit    = 172;
            Str.Visible       = false;
            Str.AlwaysVisible = false;

            if (!Owner.HasComponent <AudioEmitterComponent>())
            {
                Owner.AddComponent(new AudioEmitterComponent());
            }

            var id = 0;

            Str.FinishedTyping += s => {
                DoneSaying = true;
                id         = 0;
            };

            Str.CharTyped += (s, i, c) => {
                if (!char.IsLetter(c))
                {
                    return;
                }

                if (id++ % 2 == 1)
                {
                    return;
                }

                var sf = (int)char.ToLower(c);
                var v  = (sf % 26) / 26f;

                if (Owner is entity.creature.bk.BurningKnight)
                {
                    Audio.PlaySfx($"mob_bk_syllable_{sf % 5 + 1}", 1f, v - 0.5f);
                }
                else
                {
                    Owner.GetComponent <AudioEmitterComponent>().Emit($"npc_voice_{Voice}", 1f - Audio.Db3, v + 0.5f);
                }
            };

            Tint.A = 0;
        }
Ejemplo n.º 2
0
        public static void Init()
        {
            Load();
            LoadCurrent();

            str = new UiString(Font.Small);
            Engine.Instance.State.Ui.Add(str);
            str.Position = new Vector2(5);
        }
Ejemplo n.º 3
0
 public virtual int GetWidth(UiString str)
 {
     return(0);
 }
Ejemplo n.º 4
0
 public override void Fire(UiString str, Glyph g)
 {
     str.Speed = Speed;
 }
Ejemplo n.º 5
0
 public override void Fire(UiString str, Glyph g)
 {
     str.Delay += Delay;
 }
Ejemplo n.º 6
0
 public virtual void Fire(UiString str, Glyph g)
 {
 }
Ejemplo n.º 7
0
        public override void Init()
        {
            base.Init();

            pixel = new TextureRegion(Textures.FastLoad("Content/pixel.png"));

            Ui.Add(logoCard = new PhotoCard {
                Region   = new TextureRegion(Textures.FastLoad("Content/logo.png")),
                Url      = "https://twitter.com/rexcellentgames",
                Name     = "Rexcellent Games",
                Position = new Vector2(240, Display.UiHeight + 60),
                Target   = new Vector2(240, 115),
                Scale    = 1
            });

            Ui.Add(tipLabel = new UiString(Font.Small));

            GenerateNewTip();

            logoCard.Start.Y = -90;
            progress         = 0;

            var thread = new Thread(() => {
                var sw = Stopwatch.StartNew();

                Log.Info("Starting asset loading thread");

                LoadSection(() => SaveManager.Load(gameArea, SaveType.Global), "Global saves");

                checkFullscreen = true;

                if (Assets.LoadMusic)
                {
                    LoadSection(() => Audio.ThreadLoad("Void"), "Audio");
                }
                else
                {
                    progress++;
                }

                LoadSection(() => Assets.Load(ref progress), "Assets");

                if (Assets.LoadMusic)
                {
                    LoadSection(() => Audio.ThreadLoad("Menu", false), "More audio");
                }
                else
                {
                    progress++;
                }

                LoadSection(Dialogs.Load, "Dialogs");

                CommonAse.Load();
                progress++;

                try {
                    ImGuiHelper.BindTextures();
                } catch (Exception e) {
                    Log.Error(e);
                }

                progress++;

                LoadSection(Shaders.Load, "Shaders");
                LoadSection(Prefabs.Load, "Prefabs");
                LoadSection(Items.Load, "Items");
                LoadSection(LootTables.Load, "Loot tables");
                LoadSection(Mods.Load, "Mods");

                Log.Info("Done loading assets! Loading level now.");

                LoadSection(() => {
                    Lights.Init();
                    Physics.Init();
                }, "Lights & physics");

                gameArea  = new Area();
                Run.Level = null;

                LoadSection(Tilesets.Load, "Tilesets");
                LoadSection(Achievements.Load, "Achievements");

                LoadSection(() => {
                    SaveManager.Load(gameArea, SaveType.Game);
                }, "Game saves");

                Rnd.Seed = $"{Run.Seed}_{Run.Depth}";

                LoadSection(() => {
                    SaveManager.Load(gameArea, SaveType.Level);
                }, "Level saves");

                LoadSection(() => {
                    if (Run.Depth > 0)
                    {
                        SaveManager.Load(gameArea, SaveType.Player);
                    }
                    else
                    {
                        SaveManager.Generate(gameArea, SaveType.Player);
                    }
                }, "Player saves");

                Log.Info($"Done loading level in {sw.ElapsedMilliseconds} ms! Going to menu.");

                ready = true;
            });

            thread.Start();
        }
Ejemplo n.º 8
0
        public override void Init()
        {
            base.Init();

            description = new UiString(Font.Small);
            ((InGameState)Engine.Instance.State).TopUi.Add(description);
            ((InGameState)Engine.Instance.State).TopUi.Add(new RenderTrigger(RenderTop, 10));
            description.DisableRender = true;

            Area.Add(activeSlot);

            if (weaponSlot != null)
            {
                Area.Add(weaponSlot);
            }

            Area.Add(activeWeaponSlot);

            var anim = Animations.Get("ui");

            ItemSlot = anim.GetSlice("item_slot");
            UseSlot  = new TextureRegion();
            UseSlot.Set(ItemSlot);

            question    = anim.GetSlice("question");
            bomb        = anim.GetSlice("bomb");
            key         = anim.GetSlice("key");
            coin        = anim.GetSlice("coin");
            pointer     = anim.GetSlice("pointer");
            exitPointer = anim.GetSlice("exit_pointer");

            Heart                      = anim.GetSlice("heart");
            HalfHeart                  = anim.GetSlice("half_heart");
            HeartBackground            = anim.GetSlice("heart_bg");
            changedHeartBackground     = anim.GetSlice("heart_hurt_bg");
            halfHeartBackground        = anim.GetSlice("half_heart_bg");
            changedHalfHeartBackground = anim.GetSlice("half_heart_hurt");

            veganHeart                      = anim.GetSlice("vegan");
            veganHalfHeart                  = anim.GetSlice("half_vegan");
            veganHeartBackground            = anim.GetSlice("vegan_bg");
            veganchangedHeartBackground     = anim.GetSlice("vegan_hurt_bg");
            veganhalfHeartBackground        = anim.GetSlice("half_vegan_bg");
            veganchangedHalfHeartBackground = anim.GetSlice("half_vegan_hurt_bg");

            Bomb          = anim.GetSlice("bmb");
            BombBg        = anim.GetSlice("bmb_bg");
            ChangedBombBg = anim.GetSlice("bmb_hurt");

            Mana                  = anim.GetSlice("mana");
            HalfMana              = anim.GetSlice("half_mana");
            ManaBackground        = anim.GetSlice("mana_bg");
            ChangedManaBackground = anim.GetSlice("mana_hurt_bg");

            ShieldBackground            = anim.GetSlice("shield_bg");
            changedShieldBackground     = anim.GetSlice("shield_hurt");
            halfShieldBackground        = anim.GetSlice("half_shield_bg");
            changedHalfShieldBackground = anim.GetSlice("half_shield_hurt");

            if (Player != null)
            {
                var component = Player.GetComponent <ConsumablesComponent>();

                coins = component.Coins;
                keys  = component.Keys;
                bombs = component.Bombs;

                var area = Player.Area;

                Subscribe <ConsumableAddedEvent>(area);
                Subscribe <ConsumableRemovedEvent>(area);
                Subscribe <ItemUsedEvent>(area);
                Subscribe <ItemAddedEvent>(area);
                Subscribe <ItemRemovedEvent>(area);
                Subscribe <RerollItemsOnPlayerUse.RerolledEvent>(area);

                more      = new UiButton();
                more.Font = Font.Small;

                more.Click = (b) => {
                    var state = (InGameState)Engine.Instance.State;
                    state.OnPauseCallback = state.GoToInventory;
                    state.Paused          = true;
                };

                more.Enabled = false;
                Area.Add(more);
                more.Right  = Display.UiWidth - 8;
                more.Bottom = Display.UiHeight - 5;

                var inventory = Player.GetComponent <InventoryComponent>();

                foreach (var item in inventory.Items)
                {
                    AddArtifact(item);
                }
            }
        }
Ejemplo n.º 9
0
 public override void Fire(UiString str, Glyph g)
 {
     str.EventFired?.Invoke(str, Id);
 }