Exemplo n.º 1
0
        static void CreateSkybox()
        {
            new Shader("assets/shaders/skybox/Skybox.vert", "assets/shaders/skybox/Skybox.frag");

            WObject      sky = new WObject("Skybox");
            MeshRenderer mr  = sky.AddModule <MeshRenderer>();

            sky.AddModule <DayNightCycle>();

            mr.Mesh    = Mesh.LoadFile("assets/models/Skysphere.obj", MeshFormats.Wavefront);
            mr.UseMask = false;

            mr.Material = new Material(Shader.Find("Skybox"));
            mr.Material.SetData <Vector4>("horizonColourDay", HorizonColourDay);
            mr.Material.SetData <Vector4>("horizonColourSunset", HorizonColourSunset);
            mr.Material.SetData <Vector4>("nightColour", NightColour);
            mr.Material.SetData <Vector4>("highAtmosphereColour", HighAtmosphereColour);
            mr.Material.SetData <Vector4>("groundAtmosphereColour", GroundAtmosphereColour);

            mr.Material.SetData <float>("sunSize", 0.1F);

            mr.Material.SetData <Vector4>("sunInnerColor", new Color256(1.0D, 1.0D, 1.0D, 1.0D));
            mr.Material.SetData <Vector4>("sunOuterColor", new Color256(245D / 255D, 234D / 255D, 181D / 255D, 1.0D));

            sky.Layer = 1L << 32;

            WObject sun = new WObject("Sun");

            sun.AddModule <DirectionalLight>();


            SkyboxCamera skycam = new WObject("Skybox Camera").AddModule <SkyboxCamera>();

            skycam.ReferenceCamera = Camera.Main;
        }
Exemplo n.º 2
0
        private static void CreateMenu()
        {
            MenuWobject    = new WObject("Main Menu");
            MenuCameraWobj = new WObject("Main Menu Camera Wobject")
            {
                Parent = MenuWobject
            };
            Camera MainMenuCamera = MenuCameraWobj.AddModule <Camera>();

            MenuBGWObject        = new WObject("Main Menu Background Object");
            MenuBGWObject.Parent = MenuWobject;
            MainMenuCamera.FOV   = 80.0D;
            MainMenuCamera.WObject.LocalRotation = new Quaternion(25, 0, 0);

            MenuBGWObject.AddModule <MenuBackgroundControler>();

            WObject bgPanel = new WObject("Background Panel")
            {
                Parent = MenuWobject
            };

            bgPanel.Parent = MenuWobject;

            LocalizedLabel lbVersion = bgPanel.AddModule <LocalizedLabel>();

            lbVersion.LocalizationArgs = new object[] { Winecrash.Version };
            lbVersion.Localization     = "#winecrash:ui.mainmenu.gameversion";
            lbVersion.Aligns           = TextAligns.Down | TextAligns.Left;
            lbVersion.AutoSize         = true;
            lbVersion.MinAnchor        = new Vector2F(0.0F, 0.0F);
            lbVersion.MaxAnchor        = new Vector2F(1.0F, 0.05F);
            lbVersion.Color            = Color256.White;
            lbVersion.Left             = 20.0D;

            Label lbCopyright = bgPanel.AddModule <Label>();

            lbCopyright.Text      = "Copyright Arekva 2020\nAll Rights Reserved";
            lbCopyright.Aligns    = TextAligns.Down | TextAligns.Right;
            lbCopyright.AutoSize  = true;
            lbCopyright.MinAnchor = new Vector2F(0.0F, 0.0F);
            lbCopyright.MaxAnchor = new Vector2F(1.0F, 0.1F);
            lbCopyright.Color     = Color256.White;
            lbCopyright.Right     = 20.0D;


            CreateMain();
            CreateOptions();
            CreateMultiplayer();
        }
Exemplo n.º 3
0
        private static WObject CreateItemRenderer(WObject parent, out Model model, out Label amount)
        {
            WObject itemRenderer = new WObject("Item")
            {
                Parent = parent,
                Layer  = (ulong)Layers.UI,
            };


            model = itemRenderer.AddModule <Model>();
            model.Renderer.Material = ItemCache.AtlasMaterial;
            model.KeepRatio         = true;

            WObject labelRender = new WObject("Amount")
            {
                Parent = itemRenderer,
                Layer  = (ulong)Layers.UI
            };

            amount           = labelRender.AddModule <Label>();
            amount.Text      = "";
            amount.AutoSize  = true;
            amount.Aligns    = TextAligns.Down | TextAligns.Right;
            amount.MinAnchor = new Vector2D(0.05, -0.3);
            amount.MaxAnchor = new Vector2D(1.0, 0.3);

            return(itemRenderer);
        }
Exemplo n.º 4
0
        protected override void Creation()
        {
            Instance       = this;
            this.FPSCamera = Camera.Main;
            this._Rb       = this.WObject.GetModule <RigidBody>();
            this._Bc       = this.WObject.GetModule <BoxCollider>();


            Cursor3D = new WObject("Block Cursor");
            MeshRenderer mr = Cursor3D.AddModule <MeshRenderer>();

            mr.Material = new Material(Shader.Find("Cursor"));
            mr.Material.SetData <Vector4>("color", new Color256(0.0D, 0.0D, 0.0D, 1.0D));
            mr.Material.SetData <float>("border", 0.1F);
            mr.Material.SetData <float>("opacity", 0.85F);
            mr.Mesh = Mesh.LoadFile("assets/models/Cube.obj", MeshFormats.Wavefront);
            //mr.Wireframe = true;
            Cursor3D.Scale *= 1.005F;

            /*HitSphere = new WObject("Debug hit sphere");
             * MeshRenderer hmr = HitSphere.AddModule<MeshRenderer>();
             * hmr.Material = new Material(Shader.Find("Unlit"));
             * hmr.Material.SetData<Vector4>("color", new Color256(0, 1, 0, 1));
             * hmr.Mesh = Mesh.LoadFile("assets/models/Skysphere.obj", MeshFormats.Wavefront);
             * hmr.Wireframe = true;
             * HitSphere.Scale *= 0.05F;*/

            Cursor3D.Enabled /*= HitSphere.Enabled*/ = false;

            for (int i = 0; i < 10; i++)
            {
                mr.Material.SetData <Texture>("albedo" + i, break_textures[i]);
            }
        }
Exemplo n.º 5
0
        public static Task DisplayScene()
        {
            return(Task.Run(() =>
            {
                Camera.Main.ClearColor = new Color256(1.0D, 1.0D, 1.0D, 1.0D);

                LoadScene = new WObject("LoadScene");
                LoadScene.Parent = Canvas.Main.WObject;
                Image bg = LoadScene.AddModule <Image>();
                Image logo = LoadScene.AddModule <Image>();
                logo.Picture = new Texture("assets/textures/logo.png");
                logo.KeepRatio = true;
                logo.MinAnchor = new Vector2F(0.3F, 0.6F);
                logo.MaxAnchor = new Vector2F(0.7F, 0.8F);
            }));
        }
Exemplo n.º 6
0
        public Entity Parse()
        {
            try
            {
                Entity entity = Entity.Get(this.GUID);

                if (entity != null)
                {
                    //Debug.Log($"Updating Entity [{entity.GetType().Name}] {GUID}");

                    entity.WObject.Position = Position;
                }
                else
                {
                    WObject ettWobj = new WObject("Entity " + GUID)
                    {
                        Position = Position,
                    };
                    entity            = (Entity)ettWobj.AddModule(this.EntityType);
                    entity.Identifier = GUID;

                    //Debug.Log($"Created Entity [{ent.GetType().Name}] {GUID}");
                }

                entity.Rotation           = Rotation;
                entity.RigidBody.Velocity = this.Velocity;

                return(entity);
            }
            catch (Exception e)
            {
                Debug.LogError("Error when trying to parse entity: " + e.Message);
                return(null);
            }
        }
Exemplo n.º 7
0
        protected override void FirstFrame()
        {
            base.FirstFrame();

            if (ModelWObject)
            {
                ModelWObject.Enabled = !(Player.LocalPlayer != null && Player.LocalPlayer.Entity == this);

                if (!ModelWObject.Enabled && PlayerHandWobject == null) // local player
                {
                    PlayerHandWobject               = new WObject("FPS Hand");
                    PlayerHandWobject.Parent        = Camera.Main.WObject;
                    PlayerHandWobject.LocalPosition =
                        Vector3D.Left * 0.4 + Vector3D.Forward * 0.4 + Vector3D.Down * 0.75;
                    PlayerHandWobject.LocalRotation  = new Quaternion(180 + 45, -20, 0);
                    PlayerHandWobject.LocalRotation *= new Quaternion(0, -25, 0);
                    MeshRenderer mr = PlayerHandWobject.AddModule <MeshRenderer>();
                    mr.UseDepth  = false;
                    mr.DrawOrder = 1000;

                    mr.Mesh     = PlayerRightArmMesh;
                    mr.Material = SkinMaterial;
                }
            }
        }
Exemplo n.º 8
0
        private void CreatePlayerInventory()
        {
            Inventory = new WObject("Player Inventory")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };

            Image img = Inventory.AddModule <Image>();

            img.KeepRatio = true;
            img.Picture   = new Texture("assets/textures/gui/inventory.png", "Player Inventory", true);
            img.MinAnchor = new Vector2D(0.33, 0.0);
            img.MaxAnchor = new Vector2D(0.66, 1.0);
            img.Depth     = -1;

            WObject wobj = new WObject("Crafting Label")
            {
                Parent = Inventory,
                Layer  = (ulong)Layers.UI
            };

            LocalizedLabel lb = wobj.AddModule <LocalizedLabel>();

            lb.Localization = "#winecrash:ui.inventory.crafting";
            lb.AutoSize     = true;
            lb.Aligns       = TextAligns.Left;
            lb.MinAnchor    = new Vector2D(0.5, 0.90);
            lb.MaxAnchor    = new Vector2D(0.95, 0.965);
            lb.Color        = new Color256(0.35, 0.35, 0.35, 1.0);
            lb.Shadows      = false;

            Inventory.Enabled = false;
        }
Exemplo n.º 9
0
        private static void Create()
        {
            _PanelWobject = new WObject("Main Loading Screen")
            {
                Parent = Canvas.Main.WObject
            };
            Image bg = _PanelWobject.AddModule <Image>();

            bg.Picture = Texture.GetOrCreate("assets/textures/icon.png");
            bg.Color   = Color256.White;
        }
Exemplo n.º 10
0
        private static void CreateMenu()
        {
            MenuWobject          = new WObject("Main Menu");
            MenuBGWObject        = new WObject("Main Menu Background Object");
            MenuBGWObject.Parent = MenuWobject;
            MenuBGWObject.AddModule <MenuBackgroundControler>();

            WObject bgPanel = new WObject("Background Panel")
            {
                Parent = MenuWobject
            };

            bgPanel.Parent = MenuWobject;

            Label lbVersion = bgPanel.AddModule <Label>();

            lbVersion.Text      = "Winecrash Alpha 0.0.1";
            lbVersion.Aligns    = TextAligns.Down | TextAligns.Left;
            lbVersion.AutoSize  = true;
            lbVersion.MinAnchor = new Vector2F(0.0F, 0.0F);
            lbVersion.MaxAnchor = new Vector2F(1.0F, 0.05F);
            lbVersion.Color     = Color256.White;
            lbVersion.Left      = 20.0D;

            Label lbCopyright = bgPanel.AddModule <Label>();

            lbCopyright.Text      = "Copyright Arekva 2020\nAll Rights Reserved";
            lbCopyright.Aligns    = TextAligns.Down | TextAligns.Right;
            lbCopyright.AutoSize  = true;
            lbCopyright.MinAnchor = new Vector2F(0.0F, 0.0F);
            lbCopyright.MaxAnchor = new Vector2F(1.0F, 0.1F);
            lbCopyright.Color     = Color256.White;
            lbCopyright.Right     = 20.0D;


            CreateMain();
            CreateOptions();
        }
Exemplo n.º 11
0
        protected internal override void Creation()
        {
            this.ParentGUI = this.WObject.Parent?.GetModule <GUIModule>();

            WObject bgWobj = new WObject("Image")
            {
                Parent = this.WObject
            };

            this.Background = bgWobj.AddModule <Image>();

            WObject lbWobj = new WObject("Label")
            {
                Parent = bgWobj
            };

            this.Label      = lbWobj.AddModule <Label>();
            this.Label.Text = "Button";

            this.Label.Color      = Color256.Black;
            this.Background.Color = IdleColor;

            this.OnHover += () =>
            {
                this.Background.Color = this.Locked ? this.LockedColor : this.HoverColor;
            };

            this.OnUnhover += () =>
            {
                this.Background.Color = this.Locked ? this.LockedColor : this.IdleColor;
            };

            this.OnLock += () =>
            {
                this.Background.Color = this.LockedColor;
            };

            this.OnUnlock += () =>
            {
                this.Background.Color = this.Hovered ? this.HoverColor : this.IdleColor;
            };

            this.OnColorChanged += () =>
            {
                this.Background.Color = this.Locked ? this._LockedColor : (this.Hovered ? this._HoverColor : this._IdleColor);
            };
        }
Exemplo n.º 12
0
        private void CreateInventoryRenders()
        {
            for (int i = 0; i < InventoryItemsRenders.Length; i++)
            {
                WObject itemRenderer = InventoryItemsRenders[i] = CreateItemRenderer(Inventory, out Model mod, out Label amount);
                itemRenderer.Name += " (Inventory)";
                UIBoxCollider collider = _colliders[i] = itemRenderer.AddModule <UIBoxCollider>();
                collider.GUIModule = mod;
                Vector2D scales = ItemSlotScale;
                collider.Extents        = new Vector3D(scales, 10000);
                mod.Depth               = -1000;
                amount.Depth            = -1000;
                InventoryItemsAmount[i] = amount;

                mod.MinAnchor = _ItemInventoryAnchors[i][0];
                mod.MaxAnchor = _ItemInventoryAnchors[i][1];
            }
        }
Exemplo n.º 13
0
        private void CreateInventoryFocus()
        {
            GlobalInventoryBackground = new WObject("Inventory Background")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };

            Image img = GlobalInventoryBackground.AddModule <Image>();

            //img.Material = MenuBackgroundMaterial;
            //img.SetupMaterial();
            img.Picture = Texture.Blank;
            img.Color   = new Color256(0.2, 0.2, 0.2, 0.75);
            //GlobalInventoryBackground.GetModule<ImageRenderer>().DrawOrder = 1;
            img.Depth = 0;
            GlobalInventoryBackground.Enabled = false;
        }
Exemplo n.º 14
0
        protected override void Creation()
        {
            Mesh     mesh     = Mesh.LoadFile("assets/models/Arrow.obj");
            Shader   shader   = Shader.Find("Unlit");
            Material material = new Material(shader);
            Texture  texture  = new Texture("assets/textures/arrow.png");

            material.SetData("color", Color256.White);
            material.SetData("albedo", texture);
            material.SetData("tiling", Vector2D.One);

            WObject arrow = _arrow = new WObject("Arrow")
            {
                Parent = WObject.Find("Player Camera"),
                Layer  = (ulong)Layers.Default, LocalPosition = Vector3D.Forward, LocalScale = Vector3D.One * 0.025
            };
            MeshRenderer meshRenderer = arrow.AddModule <MeshRenderer>();

            meshRenderer.Material = material;
            meshRenderer.Mesh     = mesh;
        }
Exemplo n.º 15
0
        protected override void Creation()
        {
            base.Creation();


            WObject bgImageW = new WObject("Background Image")
            {
                Parent = this.WObject, Layer = (ulong)Layers.UI
            };

            BackgroundImage       = bgImageW.AddModule <Image>();
            BackgroundImage.Color = new Color256(0.0, 0.0, 0.0, 0.95);

            WObject labelW = new WObject("Label")
            {
                Parent = bgImageW, Layer = (ulong)Layers.UI
            };

            Label          = labelW.AddModule <Label>();
            Label.Text     = "Nullref";
            Label.AutoSize = true;
            Label.Aligns   = TextAligns.Middle;
            Offset         = new Vector2D(-10, 10);
        }
Exemplo n.º 16
0
        public static void CreateMultiplayer()
        {
            WObject mainPanel = MultiPanel = new WObject("Multi UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject multiTitle = new WObject("Multi Main Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel mainLb = multiTitle.AddModule <LocalizedLabel>();

            mainLb.Localization = "#winecrash:ui.mutliplayer.title";
            mainLb.MinAnchor    = new Vector2F(0.0F, 1.0F);
            mainLb.MaxAnchor    = new Vector2F(1.0F, 1.1F);
            mainLb.AutoSize     = true;
            mainLb.Aligns       = TextAligns.Middle;

            WObject error = new WObject("Multi Error Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel errLb = MultiErrorLabel = error.AddModule <LocalizedLabel>();

            errLb.Localization = "#winecrash:error";
            errLb.MinAnchor    = new Vector2F(0.0F, 0.82F);
            errLb.MaxAnchor    = new Vector2F(1.0F, 0.88F);
            errLb.AutoSize     = true;
            errLb.Color        = Color256.Red;
            errLb.Enabled      = false;

            WObject addressTif = new WObject("Multi Address Input")
            {
                Parent = btnPanel
            };

            GUI.LargeTextField taddress = addressTif.AddModule <LargeTextField>();
            taddress.MinAnchor    = new Vector2F(0.0F, 0.7F);
            taddress.MaxAnchor    = new Vector2F(1.0F, 0.8F);
            taddress.Localization = "#winecrash:ui.multiplayer.address";
            taddress.Text         = Game.LastAddress;


            WObject back = new WObject("Multi Back")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnBack = back.AddModule <GUI.SmallButton>();
            btnBack.Button.MinAnchor   = new Vector2F(0.0F, 0.5F);
            btnBack.Button.MaxAnchor   = new Vector2F(0.45F, 0.6F);
            btnBack.Label.Localization = "#winecrash:ui.back";
            btnBack.Button.OnClick    += () =>
            {
                HideMulti();
                ShowMain();
            };

            WObject connect = new WObject("Multi Connect")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnConnect = connect.AddModule <GUI.SmallButton>();
            btnConnect.Button.MinAnchor   = new Vector2F(0.55F, 0.5F);
            btnConnect.Button.MaxAnchor   = new Vector2F(1.0F, 0.6F);
            btnConnect.Label.Localization = "#winecrash:ui.multiplayer.connect";

            void ShowConnectError(string reason)
            {
                errLb.LocalizationArgs = new[] { reason };
                errLb.Localization     = "#winecrash:error";
                errLb.Enabled          = true;
            }

            btnConnect.Button.OnClick += () =>
            {
                Task.Run(() =>
                {
                    errLb.LocalizationArgs = null;
                    errLb.Enabled          = false;

                    string address = "localhost";
                    int port       = Networking.DefaultPort;

                    string input     = taddress.Text;
                    Game.LastAddress = input;

                    if (string.IsNullOrEmpty(input) | string.IsNullOrWhiteSpace(input))
                    {
                        ShowConnectError(Game.Language.GetText("#winecrash:error.noaddress"));
                        return;
                    }

                    int separatorPos = input.IndexOf(':');
                    if (separatorPos > 0) // custom port
                    {
                        address = input.Substring(0, separatorPos);

                        if (int.TryParse(input.Substring(separatorPos + 1, input.Length - 1 - separatorPos), out port))
                        {
                            if (port < 0 || port > Networking.MaxPort)
                            {
                                ShowConnectError(Game.Language.GetText("#winecrash:error.invalidport"));
                                return;
                            }
                        }
                        else
                        {
                            ShowConnectError(Game.Language.GetText("#winecrash:error.invalidport"));
                            return;
                        }
                    }
                    else
                    {
                        address = input;
                    }

                    btnConnect.Button.Locked      = true;
                    btnBack.Button.Locked         = true;
                    taddress.Locked               = true;
                    btnConnect.Label.Localization = "#winecrash:ui.multiplayer.connecting";

                    try
                    {
                        Program.Client.Connect(address, port);
                        Game.InvokePartyJoined(PartyType.Multiplayer);
                        MainMenu.Hide();
                    }
                    catch (SocketException e)
                    {
                        switch (e.SocketErrorCode)
                        {
                        case SocketError.HostNotFound:
                            ShowConnectError(Game.Language.GetText("#winecrash:error.socket.hostnotfound"));
                            break;

                        case SocketError.ConnectionRefused:
                            ShowConnectError(Game.Language.GetText("#winecrash:error.socket.connectionrefused"));
                            break;

                        case SocketError.TryAgain:
                            ShowConnectError(Game.Language.GetText(("#winecrash:error.socket.tryagain")));
                            break;

                        default:
                            ShowConnectError(e.Message);
                            break;
                        }
                    }
                    finally
                    {
                        btnConnect.Button.Locked      = false;
                        btnBack.Button.Locked         = false;
                        taddress.Locked               = false;
                        btnConnect.Label.Localization = "#winecrash:ui.multiplayer.connect";
                    }
                });
            };
        }
Exemplo n.º 17
0
        public static void CreateOptions()
        {
            WObject panel = OptionPanel = new WObject("Main Menu Options")
            {
                Parent = MenuWobject
            };

            /*Image bgFullScreen = OptionPanel.AddModule<Image>();
             * bgFullScreen.Color = Color256.DarkGray * new Color256(1.0, 1.0, 1.0, 0.75);*/

            Image mainPanel = panel.AddModule <Image>();

            mainPanel.Color     = Color256.White * 0.0;//new Color256(1.0, 1.0, 1.0, 0.4);
            mainPanel.MinAnchor = new Vector2D(0.2, 0.05D);
            mainPanel.MaxAnchor = new Vector2D(0.8, 0.95D);
            mainPanel.MinSize   = new Vector3D(800.0D, 400.0D, double.NegativeInfinity);


            WObject tabsPanelWobj = new WObject("Options tab panel")
            {
                Parent = panel
            };
            Image tabsPanel = tabsPanelWobj.AddModule <Image>();

            tabsPanel.MinAnchor = new Vector2D(0.0, 0.85);
            tabsPanel.MaxAnchor = new Vector2D(1.0, 1.0);
            tabsPanel.Color     = new Color256(1.0, 1.0, 1.0, .0);

            WObject backOptions = new WObject("Back Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.TinyButton btnBack = backOptions.AddModule <GUI.TinyButton>();
            btnBack.Button.MinAnchor  = new Vector2D(0.0, 0.0);
            btnBack.Button.MaxAnchor  = new Vector2D(0.06, 1.0);
            btnBack.Button.Label.Text = "<";
            btnBack.Button.OnClick   += () => ShowMain();

            WObject gameOptions = new WObject("Game Options Panel")
            {
                Parent = panel
            };
            Image gameOptionsPanel = gameOptions.AddModule <Image>();

            gameOptionsPanel.MinAnchor = new Vector2D(0.0, 0.0);
            gameOptionsPanel.MaxAnchor = new Vector2D(1.0, 0.85);
            gameOptionsPanel.Color     = Color256.White;

            WObject gameOptionsTab = new WObject("Game Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.SmallButton btnGame = gameOptionsTab.AddModule <GUI.SmallButton>();
            btnGame.Button.MinAnchor  = new Vector2D(WMath.Remap(0.00, 0.0, 1.0, 0.1, 1.0), 0.0);
            btnGame.Button.MaxAnchor  = new Vector2D(WMath.Remap(0.30, 0.0, 1.0, 0.1, 1.0), 1.0);
            btnGame.Button.Label.Text = "#winecrash:ui.settings.game";
            btnGame.Button.OnClick   += () =>
            {
                gameOptions.Enabled = true;
            };



            WObject controlsOptionsTab = new WObject("Controls Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.SmallButton btnCtrls = controlsOptionsTab.AddModule <GUI.SmallButton>();
            btnCtrls.Button.MinAnchor  = new Vector2D(WMath.Remap(0.35, 0.0, 1.0, 0.1, 1.0), 0.0);
            btnCtrls.Button.MaxAnchor  = new Vector2D(WMath.Remap(0.65, 0.0, 1.0, 0.1, 1.0), 1.0);
            btnCtrls.Button.Label.Text = "#winecrash:ui.settings.inputs";

            WObject videoOptionsTab = new WObject("Controls Options Button")
            {
                Parent = tabsPanelWobj
            };

            GUI.SmallButton btnVideo = videoOptionsTab.AddModule <GUI.SmallButton>();
            btnVideo.Button.MinAnchor  = new Vector2D(WMath.Remap(0.70, 0.0, 1.0, 0.1, 1.0), 0.0);
            btnVideo.Button.MaxAnchor  = new Vector2D(WMath.Remap(1.00, 0.0, 1.0, 0.1, 1.0), 1.0);
            btnVideo.Button.Label.Text = "#winecrash:ui.settings.video";
        }
Exemplo n.º 18
0
        protected override void Creation()
        {
            Mesh   quad   = Mesh.LoadFile("assets/models/Quad.obj", MeshFormats.Wavefront);
            Shader shader = Shader.Find("Unlit");

            Task.Run(() =>
            {
                ForwardPlane               = new WObject("Menu BG Forward Plane");
                ForwardPlane.Parent        = this.WObject;
                ForwardPlane.LocalPosition = Vector3D.Forward * 0.5D;
                ForwardPlane.LocalRotation = new Quaternion(0, 90, 0);
                MeshRenderer mr            = ForwardPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/+z.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });

            Task.Run(() =>
            {
                BackwardPlane               = new WObject("Menu BG Backward Plane");
                BackwardPlane.Parent        = this.WObject;
                BackwardPlane.LocalPosition = Vector3D.Backward * 0.5D;
                BackwardPlane.LocalRotation = new Quaternion(0, -90, 0);
                MeshRenderer mr             = BackwardPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/-z.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });

            Task.Run(() =>
            {
                UpPlane               = new WObject("Menu BG Up Plane");
                UpPlane.Parent        = this.WObject;
                UpPlane.LocalPosition = Vector3D.Up * 0.5D;
                UpPlane.LocalRotation = new Quaternion(0, 90, -90);
                MeshRenderer mr       = UpPlane.AddModule <MeshRenderer>();
                mr.Mesh               = quad;
                mr.Material           = new Material(Shader.Find("Unlit"));
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/+y.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });
            Task.Run(() =>
            {
                DownPlane               = new WObject("Menu BG Down Plane");
                DownPlane.Parent        = this.WObject;
                DownPlane.LocalPosition = Vector3D.Down * 0.5D;
                DownPlane.LocalRotation = new Quaternion(180, -90, -90);
                MeshRenderer mr         = DownPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/-y.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });

            Task.Run(() =>
            {
                EastPlane               = new WObject("Menu BG East Plane");
                EastPlane.Parent        = this.WObject;
                EastPlane.LocalPosition = Vector3D.Left * 0.5D;
                EastPlane.LocalRotation = new Quaternion(0, 0, 0);
                MeshRenderer mr         = EastPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/+x.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });
            Task.Run(() =>
            {
                WestPlane               = new WObject("Menu BG West Plane");
                WestPlane.Parent        = this.WObject;
                WestPlane.LocalPosition = Vector3D.Right * 0.5D;
                WestPlane.LocalRotation = new Quaternion(0, 180, 0);
                MeshRenderer mr         = WestPlane.AddModule <MeshRenderer>();
                mr.Mesh     = quad;
                mr.Material = new Material(shader);
                mr.Material.SetData <Texture>("albedo", Texture.GetOrCreate("assets/textures/menu/-x.png", true));
                mr.Material.SetData <Color256>("color", Color256.White);
                mr.Material.SetData <Vector2D>("tiling", Vector2D.One);
            });
        }
Exemplo n.º 19
0
        private static void CreateMain()
        {
            WObject mainPanel = MainMenuPanel = new WObject("Main UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject logo = new WObject("Game Text Logo")
            {
                Parent = mainPanel
            };
            Image logoImage = logo.AddModule <Image>();

            logoImage.Picture   = new Texture("assets/textures/logo.png");
            logoImage.MinAnchor = new Vector2F(0.0F, 0.8F);
            logoImage.MaxAnchor = new Vector2F(1.0F, 1.0F);
            logoImage.KeepRatio = true;

            Label lbTip = mainPanel.AddModule <Label>();

            lbTip.ParentGUI = logoImage;
            lbTip.Text      = "Minecraft";
            lbTip.Color     = new Color256(1.0, 1.0, 0.0, 1.0);
            lbTip.Aligns    = TextAligns.Middle;
            lbTip.AutoSize  = true;
            lbTip.MinAnchor = new Vector2F(0.7F, 0.0F);
            lbTip.MaxAnchor = new Vector2F(1.1F, 0.4F);
            lbTip.Rotation  = -20.0D;


            MenuTip tip = MenuWobject.AddModule <MenuTip>();

            tip.ReferenceLabel = lbTip;
            lbTip.Text         = tip.SelectRandom();


            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject single = new WObject("Singleplayer Button")
            {
                Parent = btnPanel
            };

            UI.LargeButton btnSingle = single.AddModule <UI.LargeButton>();
            btnSingle.Button.MinAnchor  = new Vector2F(0.0F, 0.9F);
            btnSingle.Button.MaxAnchor  = new Vector2F(1.0F, 1.0F);
            btnSingle.Button.Label.Text = "Singleplayer";
            btnSingle.Button.OnClick   += () => { Graphics.Window.InvokeUpdate(() => Program.RunGameDebug()); };

            WObject mult = new WObject("Multiplayer Button")
            {
                Parent = btnPanel
            };

            UI.LargeButton btnMult = mult.AddModule <UI.LargeButton>();
            btnMult.Button.MinAnchor  = new Vector2F(0.0F, 0.7F);
            btnMult.Button.MaxAnchor  = new Vector2F(1.0F, 0.8F);
            btnMult.Button.Label.Text = "Multiplayer";
            btnMult.Button.Locked     = true;

            WObject mods = new WObject("Mods Button")
            {
                Parent = btnPanel
            };

            UI.LargeButton btnMods = mods.AddModule <UI.LargeButton>();
            btnMods.Button.MinAnchor  = new Vector2F(0.0F, 0.5F);
            btnMods.Button.MaxAnchor  = new Vector2F(1.0F, 0.6F);
            btnMods.Button.Label.Text = "Mods and Texture Packs";
            btnMods.Button.Locked     = true;

            WObject options = new WObject("Options Button")
            {
                Parent = btnPanel
            };

            UI.SmallButton btnOptions = options.AddModule <UI.SmallButton>();
            btnOptions.Button.MinAnchor  = new Vector2F(0.0F, 0.2F);
            btnOptions.Button.MaxAnchor  = new Vector2F(0.45F, 0.3F);
            btnOptions.Button.Label.Text = "Options...";

            WObject quit = new WObject("Quit Button")
            {
                Parent = btnPanel
            };

            UI.SmallButton btnQuit = quit.AddModule <UI.SmallButton>();
            btnQuit.Button.MinAnchor  = new Vector2F(0.55F, 0.2F);
            btnQuit.Button.MaxAnchor  = new Vector2F(1.0F, 0.3F);
            btnQuit.Button.Label.Text = "Quit Game";
            btnQuit.Button.OnClick   += () => WEngine.Stop();
        }
Exemplo n.º 20
0
        public void CreateModel()
        {
            ModelWObject = new WObject("Player Model")
            {
                Parent = this.WObject
            };
            ModelWObject.LocalPosition = Vector3D.Zero;

            PlayerHead = new WObject("Head")
            {
                Parent = this.ModelWObject
            };
            PlayerHead.LocalPosition = Vector3D.Up * 1.3875D;//1.62D;

            MeshRenderer mr = PlayerHead.AddModule <MeshRenderer>();

            mr.Mesh     = PlayerHeadMesh;
            mr.Material = SkinMaterial = new Material(Shader.Find("Player"));
            mr.Material.SetData("albedo", DefaultTexture);
            mr.Material.SetData("color", Color256.White);
            mr.Material.SetData("tiling", Vector2D.One);

            PlayerTorso = new WObject("Torso")
            {
                Parent = this.ModelWObject
            };
            PlayerTorso.LocalPosition = Vector3D.Up * 0.69375D;
            mr          = PlayerTorso.AddModule <MeshRenderer>();
            mr.Mesh     = PlayerTorsoMesh;
            mr.Material = SkinMaterial;

            PlayerRightArm = new WObject("Right Arm")
            {
                Parent = this.PlayerTorso
            };
            PlayerRightArm.LocalPosition = Vector3D.Up * 0.578125D + Vector3D.Left * (0.4625D - (0.4625D / 4.0D));
            mr          = PlayerRightArm.AddModule <MeshRenderer>();
            mr.Mesh     = PlayerRightArmMesh;
            mr.Material = SkinMaterial;

            PlayerLeftArm = new WObject("Left Arm")
            {
                Parent = this.PlayerTorso
            };
            PlayerLeftArm.LocalPosition = Vector3D.Up * 0.578125D - Vector3D.Left * (0.4625D - (0.4625D / 4.0D));
            mr          = PlayerLeftArm.AddModule <MeshRenderer>();
            mr.Mesh     = PlayerLeftArmMesh;
            mr.Material = SkinMaterial;

            PlayerRightLeg = new WObject("Right Leg")
            {
                Parent = this.PlayerTorso
            };
            PlayerRightLeg.LocalPosition = Vector3D.Left * (0.4625D / 4.0D);
            mr          = PlayerRightLeg.AddModule <MeshRenderer>();
            mr.Mesh     = PlayerRightLegMesh;
            mr.Material = SkinMaterial;

            PlayerLeftLeg = new WObject("Left Leg")
            {
                Parent = this.PlayerTorso
            };
            PlayerLeftLeg.LocalPosition = -Vector3D.Left * (0.4625D / 4.0D);
            mr          = PlayerLeftLeg.AddModule <MeshRenderer>();
            mr.Mesh     = PlayerLeftLegMesh;
            mr.Material = SkinMaterial;



            OnRotate += rotation =>
            {
                if (PlayerHead)
                {
                    PlayerHead.LocalRotation = rotation;
                }
            };
        }
Exemplo n.º 21
0
        public static void RunGameDebug()
        {
            MainMenu.Hide();

            Input.LockMode      = CursorLockModes.Lock;
            Input.CursorVisible = false;

            new Shader("assets/shaders/cursor/Cursor.vert", "assets/shaders/cursor/Cursor.frag");
            WObject   playerWobj = new WObject("Player");
            RigidBody rb         = playerWobj.AddModule <RigidBody>();

            rb.UseGravity = false;
            BoxCollider bc = playerWobj.AddModule <BoxCollider>();

            bc.Extents = new Vector3D(0.4F, 0.9F, 0.4F);

            playerWobj.AddModule <Player>();

            //FreeCam.FreeCTRL = true;

            Camera.Main.WObject.AddModule <FreeCam>();

            Camera.Main._FarClip = 1000.0F;
            Camera.Main.FOV      = 80.0F;

            playerWobj.Position = Vector3F.Up * 80F;

            Database db = Database.Load("assets/items/items.json");

            db.ParseItems();

            new Shader("assets/shaders/chunk/Chunk.vert", "assets/shaders/chunk/Chunk.frag");
            new Shader("assets/shaders/itemUnlit/ItemUnlit.vert", "assets/shaders/itemUnlit/ItemUnlit.frag");

            Chunk.ChunkTexture = ItemCache.BuildChunkTexture(out int xsize, out int ysize);
            Chunk.TexWidth     = xsize;
            Chunk.TexHeight    = ysize;
            CreateSkybox();

            WObject worldwobj = new WObject("World");

            worldwobj.AddModule <World>();


            new WObject("Debug").AddModule <DebugMenu>();
            new WObject("EscapeMenu").AddModule <EscapeMenu>();

            WObject crosshair = new WObject("Crosshair");

            crosshair.Parent = Engine.GUI.Canvas.Main.WObject;
            Engine.GUI.Image reticule = crosshair.AddModule <Engine.GUI.Image>();
            reticule.Picture   = new Texture("assets/textures/crosshair.png");
            reticule.KeepRatio = true;
            reticule.Material.SourceColorBlending = OpenTK.Graphics.OpenGL4.BlendingFactorSrc.OneMinusDstColor;
            reticule.MinAnchor = new Vector2F(0.48F, 0.48F);
            reticule.MaxAnchor = new Vector2F(0.52F, 0.52F);

            reticule.MaxSize = Vector3F.One * 30.0F;

            WObject itembar = new WObject("Item Bar");

            itembar.Parent = Canvas.Main.WObject;
            Image bar = itembar.AddModule <Image>();

            bar.Picture   = new Texture("assets/textures/itembar.png");
            bar.KeepRatio = true;
            bar.MinAnchor = new Vector2F(0.35F, 0.005F);
            bar.MaxAnchor = new Vector2F(0.65F, 0.08F);
            bar.Color     = new Color256(1.0, 1.0, 1.0, 0.8F);

            Mesh mesh = Mesh.LoadFile("assets/models/BlockCube.obj", MeshFormats.Wavefront);

            for (int i = 0; i < ItemCache.TotalItems; i++)
            {
                Cube item = ItemCache.Get <Cube>(i);

                if (!(item is Cube))
                {
                    continue;
                }

                WObject cube = new WObject("Cube");

                cube.Parent = itembar;
                Model    model = cube.AddModule <Model>();
                Material mat   = new Material(Shader.Find("ItemUnlit"));
                mat.SetData <Vector2>("offset", new Vector2D(0, (double)i / ItemCache.TotalItems));
                mat.SetData <Vector2>("tiling", new Vector2D(1.0, 1.0 / ItemCache.TotalItems));
                mat.SetData <Vector3>("lightDir", new Vector3D(0.8, 1.0, -0.6));
                mat.SetData <Vector4>("ambiant", new Color256(0.0, 0.0, 0.0, 1.0));
                mat.SetData <Vector4>("lightColor", new Color256(2.0, 2.0, 2.0, 1.0));
                mat.SetData <Texture>("albedo", Texture.Find("Cache"));
                mat.SetData <Vector4>("color", Color256.White);

                model.Renderer.Mesh     = mesh;
                model.Renderer.Material = mat;
                model.KeepRatio         = true;

                cube.Scale   *= 1.1F;
                cube.Rotation = new Engine.Quaternion(-21, 45, -20);

                float shift = i * 0.1093F;

                model.MinAnchor = new Vector2F(0.0175F + shift, 0.0F);
                model.MaxAnchor = new Vector2F(0.11F + shift, 1.0F);
            }

            WObject itemcursor = new WObject("Item Cursor");

            itemcursor.Parent = bar.WObject;
            Image itemcurs = itemcursor.AddModule <Image>();

            itemcurs.Picture   = new Texture("assets/textures/barcursor.png");
            itemcurs.Color     = new Color256(0.4, 0.4, 1.0, 1.0F);
            itemcurs.MinAnchor = new Vector2F(0.0F, 0.0F);
            itemcurs.MaxAnchor = new Vector2F(0.125F, 1.0F);
            itemcurs.KeepRatio = true;
        }
Exemplo n.º 22
0
        private Chunk CreateChunk()
        {
            //Debug.Log("Creating chunk " + this.Position);
            WObject chunkwobj = new WObject($"Chunk [{this.Position.X};{this.Position.Y}]");

            chunkwobj.AddModule <MeshRenderer>();
            Chunk chunk = chunkwobj.AddModule <Chunk>();

            chunk.Ticket = this;
            //chunk.Position = new Vector3I(Position, 0);
            chunkwobj.Parent = World.Instance.WObject;

            chunk.Group = (this.Position.X / 4) * 1000 + ((this.Position.Y / 4) * 1000);

            //chunk.RunAsync = true;

            Task.Run(() =>
            {
                //try
                //{
                chunk.Position         = new Vector3I(chunk.Ticket.Position.X, chunk.Ticket.Position.Y, 0);
                chunk.WObject.Position = new Vector3F(this.Position.X * Chunk.Width, 0, this.Position.Y * Chunk.Depth);
                Chunk.TriggerAnyChunkCreated(chunk);

                chunk.NorthNeighbor = Ticket.GetTicket(this.Position.XY + Vector2I.Up)?.Chunk;
                chunk.SouthNeighbor = Ticket.GetTicket(this.Position.XY + Vector2I.Down)?.Chunk;
                chunk.EastNeighbor  = Ticket.GetTicket(this.Position.XY + Vector2I.Right)?.Chunk;
                chunk.WestNeighbor  = Ticket.GetTicket(this.Position.XY + Vector2I.Left)?.Chunk;


                chunk._Blocks = Generator.GetChunk(this.Position.X, this.Position.Y, out bool generated);

/*#if !DEBUG
 *              if(generated)
 *              {
 *                  Save();
 *              }
 #endif*/
                chunk.BuiltOnce = true;

                //Task.Run(chunk.GenerateLights);

                chunk.ForceNextConstruct = true;
                chunk.BuildEndFrame      = true;
                //chunk.Construct();
                //chunk.BuildEndFrame = true;
                Chunk.TriggerAnyChunkFirstBuilt(chunk);

                /*}
                 * catch(Exception e)
                 * {
                 *  var st = new StackTrace(e, true);
                 *  // Get the top stack frame
                 *  var frame = st.GetFrame(0);
                 *
                 *
                 *  Engine.Debug.LogError("Error when building chunk " + this.Position + " : " + st);
                 * }*/
            });

            /*if (gen)
             * {
             *  Save(chunk, this.Position.X, this.Position.Y);
             * }*/
            return(chunk);
        }
Exemplo n.º 23
0
        protected override void Creation()
        {
            if (Instance)
            {
                this.Delete();
                return;
            }

            Instance = this;

            Crosshair = new WObject("Crosshair")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };
            Image img = Crosshair.AddModule <Image>();

            img.Picture   = new Texture("assets/textures/gui/crosshair.png");
            img.KeepRatio = true;
            img.MinAnchor = new Vector2D(0.49D, 0.49D);
            img.MaxAnchor = new Vector2D(0.51D, 0.51D);
            img.Material.SourceColorBlending = BlendingFactorSrc.OneMinusDstColor;


            Hotbar = new WObject("Hotbar")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };
            HotbarImage   = img = Hotbar.AddModule <Image>();
            img.Picture   = new Texture("assets/textures/gui/hotbar.png");
            img.KeepRatio = true;
            img.Depth     = 2000;
            img.Renderer.Material.RenderOrder = -10;

            HotbarSelector = new WObject("Hotbar Selector")
            {
                Parent = Hotbar,
                Layer  = (ulong)Layers.UI
            };
            HotbarSelectorImage = img = HotbarSelector.AddModule <Image>();
            img.Picture         = new Texture("assets/textures/gui/hotbar_selector.png");
            img.KeepRatio       = true;
            img.MinAnchor       = new Vector2D(-0.0055D, 0.01D);
            img.MaxAnchor       = new Vector2D(0.1265, 1.0725D);
            img.Depth           = 1999;

            DebugPanel = new WObject("Debug Panel")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };
            img       = DebugPanel.AddModule <Image>();
            img.Color = Color256.Transparent;

            WObject inamewobj = new WObject("Item Name Display")
            {
                Parent = Canvas.Main.WObject,
                Layer  = (ulong)Layers.UI
            };

            ItemNameLabel           = inamewobj.AddModule <LocalizedLabel>();
            ItemNameLabel.AutoSize  = true;
            ItemNameLabel.MinAnchor = new Vector2D(0.33, 0.15);
            ItemNameLabel.MaxAnchor = new Vector2D(0.66, 0.20);
            ItemNameLabel.Aligns    = TextAligns.Middle;
            ItemNameLabel.Enabled   = false;
            ItemNameLabel.Depth     = 1000;

            WObject positionTextObj = new WObject("Global Position")
            {
                Parent = DebugPanel
            };

            DebugPosition           = positionTextObj.AddModule <Label>();
            DebugPosition.MinAnchor = new Vector2D(0.3, 0.95);
            DebugPosition.MaxAnchor = new Vector2D(0.7, 1.0);
            DebugPosition.AutoSize  = true;
            DebugPosition.Aligns    = TextAligns.Up | TextAligns.Middle;
            DebugPosition.Color     = Color256.White;
            DebugPosition.Text      = "XYZ: ?/?/?";

            CreateInventoryFocus();
            CreatePlayerInventory();

            Player.LocalPlayer.OnHotbarUpdate         += UpdateHotbarItem;
            Player.LocalPlayer.OnHotbarSelectedChange += UpdateHotbarSelected;
            Player.LocalPlayer.OnContainerToggle      += TogglePlayerInventory;
            Player.LocalPlayer.OnContainerClose       += PlayerCloseInventory;
            Player.LocalPlayer.OnContainerOpen        += PlayerOpenInventory;
            Player.LocalPlayer.OnItemUpdate           += UpdateItem;

            Player.LocalPlayer.OnCraftUpdate += UpdateCraft;


            HoveredTooltipWObject = new WObject("Item Tooltip")
            {
                Parent  = Canvas.Main.WObject,
                Layer   = (ulong)Layers.UI,
                Enabled = false
            };
            HoveredTooltip           = HoveredTooltipWObject.AddModule <ToolTip>();
            HoveredTooltip.MinAnchor = new Vector2D(0);
            HoveredTooltip.MaxAnchor = new Vector2D(0.2, 0.05);

            CreateInventoryRenders();
        }
Exemplo n.º 24
0
        protected override void Creation()
        {
            if (Instance != null)
            {
                this.Delete();
                return;
            }

            Instance = this;

            this.WObject.Layer = (ulong)Layers.Sky;

            WObject camWobj = new WObject("Skybox Camera Wobject");

            Camera              = camWobj.AddModule <Camera>();
            Camera.Depth        = -100;
            Camera.RenderLayers = (ulong)Layers.Sky;
            Camera.Name         = "Skybox";

            Camera.Main.RenderLayers &= ~(ulong)Layers.Sky;

            SkyWobjet = new WObject("Sky")
            {
                Parent = this.WObject, Layer = (ulong)Layers.Sky
            };


            MainRenderer           = SkyWobjet.AddModule <MeshRenderer>();
            MainRenderer.UseDepth  = false;
            MainRenderer.DrawOrder = 10000;

            MainRenderer.Material = SkyboxMaterial;
            MainRenderer.Mesh     = SkyboxMesh;

            MainRenderer.Material.SetData("highColorDay", new Color32(122, 168, 255, 255));
            MainRenderer.Material.SetData("horizonColorDay", new Color32(201, 220, 244, 255));

            SunWobject = new WObject("Sun")
            {
                Parent        = SkyWobjet,
                Layer         = (ulong)Layers.Sky,
                LocalScale    = Vector3D.One / 2.0D,
                LocalPosition = Vector3D.Up,
                LocalRotation = new Quaternion(0, 0, 270)
            };

            MeshRenderer mr = SunWobject.AddModule <MeshRenderer>();

            mr.Material = new Material(Shader.Find("CelestialBody"));
            mr.Material.SetData("albedo", SunTexture);
            mr.Material.SetData("tiling", Vector2D.One);
            mr.Material.SetData("color", Color256.White);

            mr.Mesh      = Mesh.LoadFile("assets/models/Quad.obj", MeshFormats.Wavefront);
            mr.UseDepth  = false;
            mr.DrawOrder = 10001;


            MoonWobject = new WObject("Moon")
            {
                Parent        = SkyWobjet,
                Layer         = (ulong)Layers.Sky,
                LocalScale    = Vector3D.One / 2.0D,
                LocalPosition = Vector3D.Down,
                LocalRotation = new Quaternion(0, 0, 90)
            };
            mr          = MoonWobject.AddModule <MeshRenderer>();
            mr.Material = new Material(Shader.Find("CelestialBody"));
            mr.Material.SetData("albedo", MoonTexture);
            mr.Material.SetData("tiling", Vector2D.One);
            mr.Material.SetData("color", Color256.White);

            mr.Mesh      = Mesh.LoadFile("assets/models/Quad.obj", MeshFormats.Wavefront);
            mr.UseDepth  = false;
            mr.DrawOrder = 10001;



            base.Creation();
        }
Exemplo n.º 25
0
        public static void CreateDisconnection()
        {
            WObject mainPanel = MultiDisconnectionPanel = new WObject("Multi Disconnect UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject multiTitle = new WObject("Multi Main Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel mainLb = multiTitle.AddModule <LocalizedLabel>();

            mainLb.Localization = "#winecrash:ui.multiplayer.disconnected";
            mainLb.MinAnchor    = new Vector2F(0.0F, 1.0F);
            mainLb.MaxAnchor    = new Vector2F(1.0F, 1.1F);
            mainLb.AutoSize     = true;
            mainLb.Aligns       = TextAligns.Middle;

            WObject error = new WObject("Multi Disconnected Label")
            {
                Parent = btnPanel
            };
            LocalizedLabel reaLb = MultiDisconnectionReason = error.AddModule <LocalizedLabel>();

            reaLb.Localization = "#server_disconnection_unspecified";
            reaLb.MinAnchor    = new Vector2F(0.0F, 0.82F);
            reaLb.MaxAnchor    = new Vector2F(1.0F, 0.88F);
            reaLb.AutoSize     = true;
            reaLb.Aligns       = TextAligns.Up | TextAligns.Vertical;

            WObject back = new WObject("Multi Back")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnBack = back.AddModule <GUI.LargeButton>();
            btnBack.Button.MinAnchor   = new Vector2F(0.0F, 0.6F);
            btnBack.Button.MaxAnchor   = new Vector2F(1.0F, 0.7F);
            btnBack.Label.Localization = "#winecrash:ui.back";
            btnBack.Button.OnClick    += () =>
            {
                HideDisconnection();
                ShowMain();
            };
        }
Exemplo n.º 26
0
        private static void CreateMain()
        {
            WObject mainPanel = MainMenuPanel = new WObject("Main UI Panel")
            {
                Parent = MenuWobject
            };
            Image mainPanelImg = mainPanel.AddModule <Image>();

            mainPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            mainPanelImg.MinAnchor = new Vector2F(0.225F, 0.10F);
            mainPanelImg.MaxAnchor = new Vector2F(0.775F, 0.95F);
            mainPanelImg.MinSize   = new Vector3F(400.0F, 400.0F, Single.PositiveInfinity);
            mainPanelImg.MaxSize   = new Vector3F(800.0F, 800.0F, Single.PositiveInfinity);
            mainPanelImg.KeepRatio = true;

            WObject logo = new WObject("Game Text Logo")
            {
                Parent = mainPanel
            };
            Image logoImage = logo.AddModule <Image>();

            logoImage.Picture   = new Texture("assets/textures/logo.png");
            logoImage.MinAnchor = new Vector2F(0.0F, 0.8F);
            logoImage.MaxAnchor = new Vector2F(1.0F, 1.0F);
            logoImage.KeepRatio = true;

            Label lbTip = mainPanel.AddModule <Label>();

            lbTip.ParentGUI = logoImage;
            lbTip.Text      = "Minecraft";
            lbTip.Color     = new Color256(1.0, 1.0, 0.0, 1.0);
            lbTip.Aligns    = TextAligns.Middle;
            lbTip.AutoSize  = true;
            lbTip.MinAnchor = new Vector2F(0.7F, 0.0F);
            lbTip.MaxAnchor = new Vector2F(1.1F, 0.4F);
            lbTip.Rotation  = -20.0D;


            MenuTip tip = MenuWobject.AddModule <MenuTip>();

            tip.ReferenceLabel = lbTip;
            lbTip.Text         = tip.SelectRandom();


            WObject btnPanel = new WObject("Main UI Button Panel")
            {
                Parent = mainPanel
            };
            Image btnPanelImg = btnPanel.AddModule <Image>();

            btnPanelImg.Color     = new Color256(1.0, 0.0, 1.0, 0.0);
            btnPanelImg.MinAnchor = new Vector2F(0.075F, 0.0F);
            btnPanelImg.MaxAnchor = new Vector2F(0.925F, 0.6F);

            WObject single = new WObject("Singleplayer Button")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnSingle = single.AddModule <GUI.LargeButton>();
            btnSingle.Button.MinAnchor   = new Vector2F(0.0F, 0.9F);
            btnSingle.Button.MaxAnchor   = new Vector2F(1.0F, 1.0F);
            btnSingle.Label.Localization = "#winecrash:ui.mainmenu.singleplayer";
            btnSingle.Button.Locked      = false;
            //btnSingle.Button.OnClick += () => { Graphics.Window.InvokeUpdate(() => Program.RunGameDebug()); };
            btnSingle.Button.OnClick += () =>
            {
                Game.InvokePartyJoined(PartyType.Singleplayer);
                Task.Run(() =>
                {
                    //Parallel.ForEach()
                    //IntegratedServer server = IntegratedServer.CurrentIntegratedServer = new IntegratedServer(new Player("Arthur"));
                    //server.Run();
                });
            };

            WObject mult = new WObject("Multiplayer Button")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnMult = mult.AddModule <GUI.LargeButton>();
            btnMult.Button.MinAnchor   = new Vector2F(0.0F, 0.7F);
            btnMult.Button.MaxAnchor   = new Vector2F(1.0F, 0.8F);
            btnMult.Label.Localization = "#winecrash:ui.mainmenu.multiplayer";
            btnMult.Button.Locked      = true;
            btnMult.Button.OnClick    += () =>
            {
                ShowMulti();
            };

            WObject mods = new WObject("Mods Button")
            {
                Parent = btnPanel
            };

            GUI.LargeButton btnMods = mods.AddModule <GUI.LargeButton>();
            btnMods.Button.MinAnchor   = new Vector2F(0.0F, 0.5F);
            btnMods.Button.MaxAnchor   = new Vector2F(1.0F, 0.6F);
            btnMods.Label.Localization = "#winecrash:ui.mainmenu.addons";
            btnMods.Button.Locked      = true;

            WObject options = new WObject("Options Button")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnOptions = options.AddModule <GUI.SmallButton>();
            btnOptions.Button.MinAnchor   = new Vector2F(0.0F, 0.2F);
            btnOptions.Button.MaxAnchor   = new Vector2F(0.45F, 0.3F);
            btnOptions.Label.Localization = "#winecrash:ui.mainmenu.settings";
            btnOptions.Button.OnClick    += () => ShowOptions();
            btnOptions.Button.Locked      = false;

            WObject quit = new WObject("Quit Button")
            {
                Parent = btnPanel
            };

            GUI.SmallButton btnQuit = quit.AddModule <GUI.SmallButton>();
            btnQuit.Button.MinAnchor   = new Vector2F(0.55F, 0.2F);
            btnQuit.Button.MaxAnchor   = new Vector2F(1.0F, 0.3F);
            btnQuit.Label.Localization = "#winecrash:ui.mainmenu.quit";
            btnQuit.Button.OnClick    += () => Engine.Stop();
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            CreateDebugWindow();

            Engine.Run(true, args).Wait();

            Engine.OnStop += () => End.Set();

            Debug.Log("\n\n");

            Time.PhysicsRate = 128D;
            Vector3D soloPlayerSpawnpoint = /*new Vector3D(32_000_000D, 0, 32_000_000D);//*/
                                            new Vector3D(572, 66, 459);


            //MainLoadScreen.Show();

            new Sound(@"assets/sounds/button_click.mp3");
            //new Shader("assets/shaders/Debug/Volume/DebugVolume.vert", "assets/shaders/Debug/Volume/DebugVolume.frag");

            Tester = new WObject("tester").AddModule <ClientTester>();

            /* ego mode enabled */
            Player.LocalPlayer = new Player("Arthur_" + new Random().Next(1000, 10000));

            Camera.Main.WObject.Delete();
            Camera.Main = null;



            WObject localPlayerWobj = new WObject("Local Player");

            localPlayerWobj.Enabled = false;
            PlayerController pc = localPlayerWobj.AddModule <PlayerController>();

            WObject camW = new WObject("Player Camera");

            camW.Parent        = localPlayerWobj;
            camW.LocalPosition = Vector3D.Up * 1.62D;
            Camera main = Camera.Main = camW.AddModule <Camera>();

            main.FOV           = 80;
            main.NearClip      = 0.01D;
            main.FarClip       = 4096.0D;
            main.RenderLayers &= ~(ulong)Layers.UI;
            main.WObject.AddModule <PanoramicPhotographer>();

            Winecrash.RenderDistance = 5;

            GameApplication app = (GameApplication)Graphics.Window;

            app.VSync = VSyncMode.On;

            string title = $"Winecrash {Winecrash.Version} ({IntPtr.Size * 8}bits)";

#if DEBUG
            title += " <DEBUG BUILD>";
#endif

            app.Title = title;

            app.OnLoaded += () =>
            {
                new Shader("assets/shaders/player/Player.vert", "assets/shaders/player/Player.frag");
                new Shader("assets/shaders/Unlit/Unlit.vert", "assets/shaders/Unlit/Unlit.frag");
                new Shader("assets/shaders/chunk/Chunk.vert", "assets/shaders/chunk/Chunk.frag");
                new Shader("assets/shaders/skybox/Skybox.vert", "assets/shaders/skybox/Skybox.frag");
                new Shader("assets/shaders/celestialbody/CelestialBody.vert", "assets/shaders/celestialbody/CelestialBody.frag");
                new Shader("assets/shaders/item/Item.vert", "assets/shaders/item/Item.frag");
                //new Shader("assets/shaders/fun/Fun.vert", "assets/shaders/fun/Fun.frag");


                Package.Load("assets/winecrash.package");
                ItemCache.BuildChunkTexture(out int xsize, out int ysize);
                //Chunk.Texture.Save(Folders.UserData + "items_atlas.png");

                Winecrash.CurrentSave = new Save(Save.DefaultName, Save.Exists(Save.DefaultName));

                Canvas.Main.UICamera.NearClip = -8192.0D;
                Canvas.Main.UICamera.FarClip  = 8192.0D;

                EngineCore.Instance.WObject.AddModule <GameDebug>();

                GameUI gui = Canvas.Main.WObject.AddModule <GameUI>();
                gui.Enabled = false;

                Client = new GameClient();
                Client.OnDisconnected += client =>
                {
                    Game.InvokePartyLeft(PartyType.Multiplayer);
                };

                MainMenu.Show();
            };

            Game.OnPartyJoined += type =>
            {
                GameUI.Instance.Enabled = true;
                Input.LockMode          = CursorLockModes.Lock;
                Input.CursorVisible     = false;
                MainMenu.Hide();

                localPlayerWobj.Enabled = true;
                Player.LocalPlayer.CreateEntity(localPlayerWobj);

                localPlayerWobj.Position = new Vector3D(soloPlayerSpawnpoint.X, 0, soloPlayerSpawnpoint.Z) + Vector3D.Up * (World.GetSurface(soloPlayerSpawnpoint, "winecraft:dimension") + 1);

                if (SkyboxController.Instance)
                {
                    SkyboxController.Instance.Show();
                }
                else
                {
                    new WObject("Skybox").AddModule <SkyboxController>();
                }

                Player.LocalPlayer.Entity.OnRotate += rotation =>
                {
                    if (!PlayerController.CameraLocked)
                    {
                        Camera.Main.WObject.Rotation = rotation;
                    }
                };

                if (type == PartyType.Singleplayer)
                {
                    Player.LocalPlayer.CameraAngles = Vector2I.Zero;

                    //Player.LocalPlayer.Entity.WObject.AddModule<DebugArrow>();

                    Task.Run(() =>
                    {
                        World.GlobalToLocal(soloPlayerSpawnpoint, out Vector2I cpos, out _);

                        Parallel.ForEach(World.GetCoordsInRange(cpos, Winecrash.RenderDistance),
                                         vector => { World.GetOrCreateChunk(vector, "winecrash:overworld"); });
                    });
                }
            };
            Game.OnPartyLeft += type =>
            {
                GameUI.Instance.Enabled = false;
                Input.LockMode          = CursorLockModes.Free;
                Input.CursorVisible     = true;
                World.Unload();

                localPlayerWobj.Enabled = false;
                Player.LocalPlayer.Entity?.Delete();
                Player.LocalPlayer.Entity = null;

                if (SkyboxController.Instance)
                {
                    SkyboxController.Instance.Hide();
                }

                MainMenu.Show();

                if (type == PartyType.Multiplayer)
                {
                    MainMenu.HideMain();
                }

                //Camera.Main._FarClip = 4096;
                //Camera.Main.WObject.Position = Vector3D.Zero;
            };


            Task.Run(() => End.WaitOne()).Wait();
        }