Exemplo n.º 1
0
        public WDTLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary <string, MiniYaml> logicArgs)
        {
            this.modData = modData;
            this.world   = world;
            var wdtDataReader = new WDTDataReader("wdt_data.yaml");

            wdtData = wdtDataReader.Read(modData);

            currentSprites = null;
            currentFrame   = 0;
            currentPalette = null;
            isVideoLoaded  = false;
            isLoadError    = false;

            panel = widget;

            var spriteWidget = panel.GetOrNull <SpriteWidget>("SPRITE");

            if (spriteWidget != null)
            {
                spriteWidget.GetSprite  = () => currentSprites != null ? currentSprites[currentFrame] : null;
                currentPalette          = spriteWidget.Palette;
                spriteWidget.GetPalette = () => currentPalette;
                spriteWidget.IsVisible  = () => !isVideoLoaded && !isLoadError;
            }

            var startButton = panel.GetOrNull <ButtonWidget>("START_BUTTON");

            if (startButton != null)
            {
                startButton.OnClick = () =>
                {
                    //Generate a random map by using the wdt data
                    //Hosting a multiplayer server and go into the lobby ui
                    //Then start game like the regular multiplayer
                }
            }
            ;

            var closeButton = panel.GetOrNull <ButtonWidget>("CLOSE_BUTTON");

            if (startButton != null)
            {
                startButton.OnClick = () =>
                {
                    Ui.CloseWindow();
                    onExit();
                }
            }
            ;
        }
    }
}
Exemplo n.º 2
0
        public WDTLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary <string, MiniYaml> logicArgs)
        {
            this.modData = modData;
            this.world   = world;
            var wdtDataReader = new WDTDataReader("wdt_data.yaml");

            wdtData = wdtDataReader.Read(modData);

            currentSprites = null;
            currentFrame   = 0;
            currentPalette = null;
            isVideoLoaded  = false;
            isLoadError    = false;

            panel = widget;

            var spriteWidget = panel.GetOrNull <SpriteWidget>("SPRITE");

            if (spriteWidget != null)
            {
                spriteWidget.GetSprite  = () => currentSprites != null ? currentSprites[currentFrame] : null;
                currentPalette          = spriteWidget.Palette;
                spriteWidget.GetPalette = () => currentPalette;
                spriteWidget.IsVisible  = () => !isVideoLoaded && !isLoadError;
            }

            var closeButton = panel.GetOrNull <ButtonWidget>("BACK_BUTTON");

            if (closeButton != null)
            {
                closeButton.OnClick = () =>
                {
                    Ui.CloseWindow();
                    onExit();
                }
            }
            ;

            loadDefaultWDTData();
        }