Пример #1
0
        protected override void OnLoad()
        {
            base.OnLoad();

            Layer = LayerUI;

            userData = MMW.GetAsset <UserData>();

            coin = userData.Coin;

            tex = new Texture2D(Resources.number);
            tex.Load();

            texCoin           = new Texture2D(Resources.mmw_icon_coin);
            texCoin.MagFilter = OpenTK.Graphics.OpenGL4.TextureMagFilter.Linear;
            texCoin.Load();

            texBack = new Texture2D(Resources.shadowline);
            texBack.Load();

            lerp = new Lerper(-100.0f);
            Show();

            sound = MMW.GetAsset <Sound>("coin");

            player = MMW.FindGameObject(g => g.Tags.Contains("player"));
        }
Пример #2
0
        protected override void OnLoad()
        {
            Layer = LayerUI + 2;

            var label = new Label(
                null,
                "Disconnected",
                new Font("Yu Gothic UI", 32.0f),
                new Vector2((MMW.Width - Drawer.MeasureString("DISCONNECTED", new Font("Yu Gothic UI", 32.0f)).X) / 2.0f, 100.0f));

            controls.Add(label);

            var sw   = Drawer.MeasureString("Can't connect to the world. Return to the Title Window.", ControlDrawer.fontSmallB).X;
            var text = new Label(null, "Can't connect to the world. Return to the Title Window.", new Vector2((MMW.Width - sw) * 0.5f, 200));

            text.Font = ControlDrawer.fontSmallB;
            controls.Add(text);

            var btnOK = new Button(null, "OK", new Vector2((MMW.Width - sw) * 0.5f, 240), "click");

            btnOK.Clicked += (s, e) =>
            {
                GameObject.SendMessage("close leave window");
                var ws = MMW.FindGameComponent <WalkerScript>();
                MMW.DestroyGameObject(ws.GameObject);

                var title = new GameObject("Title", Matrix4.Identity, "title");
                MMW.RegistGameObject(title);
                title.AddComponent <BackgroundScript>();
                title.AddComponent <TitleScript>();
                MMW.Window.CursorVisible = true;
            };
            controls.Add(btnOK);
        }
Пример #3
0
        public ToonShader() : base("Toon")
        {
            VertexCode   = Resources.Toon_vert;
            FragmentCode = Resources.Toon_frag;

            RegistShaderParam <Matrix4>("M", "Model");
            RegistShaderParam <Matrix4>("MIT", "ModelInverseTranspose");
            RegistShaderParam <Matrix4>("MVP", "ModelViewProjection");

            RegistShaderParam <Color4>("diffuse", "Diffuse");
            RegistShaderParam <Color4>("specular", "Specular");
            RegistShaderParam <float>("shininess", "Shininess");

            RegistShaderParam <Vector3>("wCamDir", "WorldCameraDir");
            RegistShaderParam <Vector3>("wCamPos", "WorldCameraPosition");

            RegistShaderParam <Vector3>("wDirLight.dir", "DirectionalLightDir");
            RegistShaderParam <Vector3>("wDirLight.color", "DirectionalLightColor");
            RegistShaderParam <Vector3>("wDirLight.intensity", "DirectionalLightIntensity");

            RegistShaderParam <Color4>("gAmbient", "GlobalAmbient");


            RegistShaderParam("albedoMap", "AlbedoMap", TextureUnit.Texture0);
            RegistShaderParam("toonMap", "ToonMap", TextureUnit.Texture1);

            whiteMap = MMW.GetAsset <Texture2D>("WhiteMap");
            //toonMap = MMW.GetAsset<Texture2D>("ToonMap");
            toonMap = new Texture2D(Resources.toon2);
            toonMap.Load();
        }
Пример #4
0
 public void SendMessage(string message, params object[] args)
 {
     if (obj != null)
     {
         MMW.SendMessage(obj, message, args);
     }
 }
Пример #5
0
        protected internal override void OnLoad()
        {
            base.OnLoad();

            renderTexture              = new RenderTexture(MMW.RenderResolution);
            renderTexture.MagFilter    = TextureMagFilter.Linear;
            renderTexture.MinFilter    = TextureMinFilter.Linear;
            renderTexture.WrapMode     = TextureWrapMode.MirroredRepeat;
            renderTexture.ColorFormat0 = MMW.Configuration.DefaultPixelFormat;
            renderTexture.Load();

            dofShader = (BokehDoFShader)MMW.GetAsset <Shader>("Bokeh DoF");
            if (dofShader == null)
            {
                dofShader = new BokehDoFShader();
                MMW.RegistAsset(dofShader);
            }

            if (GameObject != null)
            {
                Camera        = GameObject.GetComponent <Camera>();
                RenderTexture = Camera.TargetTexture;
            }

            orthoMatrix = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1);
        }
Пример #6
0
        protected internal override void OnLoad()
        {
            base.OnLoad();

            renderTexture              = new RenderTexture(MMW.RenderResolution);
            renderTexture.MagFilter    = TextureMagFilter.Linear;
            renderTexture.MinFilter    = TextureMinFilter.Linear;
            renderTexture.ColorFormat0 = MMW.Configuration.DefaultPixelFormat;
            renderTexture.Load();

            ccShader = (GLSLShader)MMW.GetAsset <Shader>("Color Collect");
            if (ccShader == null)
            {
                ccShader = new ColorCollectShader();
                MMW.RegistAsset(ccShader);
            }

            loc_con        = ccShader.GetUniformLocation("contrast");
            loc_sat        = ccShader.GetUniformLocation("saturation");
            loc_brt        = ccShader.GetUniformLocation("brightness");
            loc_resolution = ccShader.GetUniformLocation("resolutionInverse");
            loc_mvp        = ccShader.GetUniformLocation("MVP");

            if (GameObject != null)
            {
                Camera        = GameObject.GetComponent <Camera>();
                RenderTexture = Camera.TargetTexture;
            }

            orthoMatrix = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1);
        }
Пример #7
0
        protected override void Update(double deltaTime)
        {
            transition += (trans ? -1.0f : 1.0f) * (float)deltaTime * 5.0f;
            transition  = MMWMath.Saturate(transition);

            transit.Update(deltaTime);

            if (AcceptInput && !trans)
            {
                input.Update(deltaTime);
                controls.ForEach(c => c.Update(null, deltaTime));

                if (input.IsBack)
                {
                    MMW.GetAsset <Sound>("back").Play();
                    trans          = true;
                    transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                    GameObject.AddComponent <TitleScript>();
                }
            }

            if (trans && transition < 0.01f)
            {
                Destroy();
            }
        }
        protected override void OnLoad()
        {
            base.OnLoad();

            Layer  = LayerUI;
            server = MMW.GetAsset <Server>();
        }
        public DeferredPhysicalSkinShader(string name = "Deferred Physical Skin") : base(name)
        {
            VertexCode   = Resources.DeferredPhysicalSkin_vert;
            FragmentCode = Resources.DeferredPhysical_frag;

            RegistShaderParam <Matrix4>("M", "Model");
            RegistShaderParam <Matrix4>("MIT", "ModelInverseTranspose");
            RegistShaderParam <Matrix4>("MVP", "ModelViewProjection");
            RegistShaderParam <Matrix4>("OldMVP", "OldModelViewProjection");
            RegistShaderParam <Matrix4>("shadowMV1", "ShadowModelView1");
            RegistShaderParam <Matrix4>("shadowMV2", "ShadowModelView2");
            RegistShaderParam <Matrix4>("shadowMV3", "ShadowModelView3");

            RegistShaderParam <Color4>("albedo", "Albedo");
            RegistShaderParam <float>("metallic", "Metallic");
            RegistShaderParam <float>("roughness", "Roughness");
            RegistShaderParam <Color4>("f0", "F0");
            RegistShaderParam <Color4>("uniqueColor", "UniqueColor");

            RegistShaderParam <Vector3>("wCamDir", "WorldCameraDir");
            RegistShaderParam <Vector3>("wCamPos", "WorldCameraPosition");
            RegistShaderParam <Vector2>("resolutionInverse", "ResolutionInverse");
            RegistShaderParam <float>("deltaTime", "DeltaTime");

            RegistShaderParam("albedoMap", "AlbedoMap", TextureUnit.Texture0);
            RegistShaderParam("normalMap", "NormalMap", TextureUnit.Texture1);

            RegistShaderParam("shadowMap1", "ShadowMap1", TextureUnit.Texture3);
            RegistShaderParam("shadowMap2", "ShadowMap2", TextureUnit.Texture4);
            RegistShaderParam("shadowMap3", "ShadowMap3", TextureUnit.Texture5);

            whiteMap         = MMW.GetAsset <Texture2D>("WhiteMap");
            defaultNormalMap = MMW.GetAsset <Texture2D>("DefaultNormalMap");
        }
Пример #10
0
        private void Load_LoadCompleted(object sender, object e)
        {
            MMW.DestroyGameObjects(g => g.Name == "Background" || g.Name == "Title");
            var load = MMW.FindGameComponent <LoadingScript>();

            load.LoadCompleted -= Load_LoadCompleted;
        }
Пример #11
0
        public SelectWorldPanel(WorldInfo info)
        {
            Info         = info;
            defBackImage = Resources.mmw_defaultbackpanel;

            texImage = MMW.GetAsset <Texture2D>("default back panel");
            if (texImage == null)
            {
                texImage      = new Texture2D(defBackImage);
                texImage.Name = "default back panel";
                MMW.RegistAsset(texImage);
            }
            if (!texImage.Loaded)
            {
                texImage.Load();
            }

            Clicked += (s, e) => SelectedPanel = this;

            timer = new Timer((t) =>
            {
                var data = NetworkUtil.QueryWorldInfoUdp(info.HostName, info.Port);
                ReceivedServerDesc(data);
            }, null, 0, 3000);
        }
Пример #12
0
        protected override void OnLoad()
        {
            base.OnLoad();

            Layer = LayerUI + 3;

            Task.Factory.StartNew(() =>
            {
                //Thread.Sleep(1500);

                //text = "hello";

                Thread.Sleep(1500);

                text = "hello world";

                Thread.Sleep(3000);

                MMW.Invoke(() =>
                {
                    MMW.DestroyGameObject(GameObject);
                    MMW.Window.CursorVisible = true;

                    var objs = MMW.FindGameObjects(g => true);
                    foreach (var obj in objs)
                    {
                        obj.Enabled = true;
                    }
                });
            });
        }
Пример #13
0
        protected override void OnLoad()
        {
            base.OnLoad();

            Layer = LayerUI;

            lerp = new Lerper(MMW.ClientSize.Height + 40.0f);

            execs.Add("Show", (obj, args) =>
            {
                Show();
                return(true);
            });
            execs.Add("Hide", (obj, args) =>
            {
                Hide();
                return(true);
            });

            tex = new Texture2D(Resources.mmw_icon);
            tex.Load();

            userData  = MMW.GetAsset <UserData>();
            resources = MMW.GetAsset <WorldResources>();

            Show();
        }
        protected override void OnReceivedMessage(string message, params object[] args)
        {
            if (message == "get reward")
            {
                var rew = (Reward)args[0];
                if (!rew.Verify())
                {
                    return;
                }

                if (rew.Coin > 0)
                {
                    userData.AddCoin(rew.Coin);
                }
                if (rew.Exp > 0)
                {
                    userData.AddExp(rew.Exp);
                }

                if (rew.Achivement != null && rew.Achivement.Verify() && !userData.Achivements.Exists(ach => ach.Name == rew.Achivement.Name))
                {
                    userData.Achivements.Add(rew.Achivement);
                    MMW.BroadcastMessage("log", $"Archived [{rew.Achivement.Name}]");
                }
            }
        }
Пример #15
0
        protected internal override void OnLoad()
        {
            base.OnLoad();

            renderTexture              = new RenderTexture(MMW.RenderResolution);
            renderTexture.MagFilter    = TextureMagFilter.Linear;
            renderTexture.MinFilter    = TextureMinFilter.Linear;
            renderTexture.ColorFormat0 = PixelFormat;
            renderTexture.Load();

            fxaaShader = (FXAAShader)MMW.GetAsset <Shader>("FXAA");
            if (fxaaShader == null)
            {
                fxaaShader = new FXAAShader();
                MMW.RegistAsset(fxaaShader);
            }

            if (GameObject != null)
            {
                Camera           = GameObject.GetComponent <Camera>();
                DstRenderTexture = Camera.TargetTexture;
            }

            orthoMatrix = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1);
        }
Пример #16
0
 public void OnClear()
 {
     MMW.Invoke(() =>
     {
         MMW.DestroyGameObject(gameObj);
         gameObj = null;
     });
 }
Пример #17
0
 public HotbarItemFrame(Control parent, Vector2 pos, int itemIndex)
 {
     Size          = new Vector2(48.0f, 48.0f);
     Parent        = parent;
     LocalLocation = pos;
     ItemIndex     = itemIndex;
     userData      = MMW.GetAsset <UserData>();
     resources     = MMW.GetAsset <WorldResources>();
 }
 public WalkerGameObjectScript(GameObject go, GameObjectScript script, byte[] status)
 {
     script.GameObject = go;
     script.Server     = MMW.GetAsset <Server>();
     script.WorldData  = MMW.GetAsset <WorldData>();
     script.MasterData = MMW.MasterData;
     Status            = status;
     Script            = script;
 }
        public override void OnTcpReceived(int dataType, byte[] data)
        {
            if (dataType == DataType.PictureChat)
            {
                var chat = Util.DeserializeJsonBinaryCompress <NwPictureChat>(data);

                MMW.BroadcastMessage("picture chat", chat.From, chat.Data);
            }
        }
Пример #20
0
        protected override void OnLoad()
        {
            base.OnLoad();

            Layer = LayerUI;

            MMW.FindGameComponent <BackgroundScript>().Trans(new OpenTK.Graphics.Color4(148, 212, 222, 255), 0.25);

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            input = new MenuInputResolver();

            var label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "OPTION",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            controls.Add(label);

            userData = MMW.GetAsset <UserData>();

            var labelName = new Label(transit, "User Name", new Vector2(200.0f, 160.0f));

            labelName.Font = Control.DefaultFontB;
            controls.Add(labelName);
            var textBoxName = new TextBox2(labelName, userData.UserName, new Vector2(200.0f, 0.0f), new Vector2(300.0f, 32.0f));

            textBoxName.MaxLength    = 16;
            textBoxName.TextChanged += (s, e) => { userData.UserName = textBoxName.Text; };
            controls.Add(textBoxName);

            var labelArchive = new Label(transit, "Display Achivement", new Vector2(200.0f, 200.0f));

            labelArchive.Font = Control.DefaultFontB;
            controls.Add(labelArchive);
            var comboArchive = new ComboBox(labelArchive, new Vector2(200.0f, 0.0f), new Vector2(300.0f, 32.0f));

            if (userData.Achivements.Count > 0)
            {
                comboArchive.Items                 = userData.Achivements.ToArray();
                comboArchive.SelectedIndex         = userData.ArchiveIndex;
                comboArchive.DisplayMember         = "Name";
                comboArchive.SelectedIndexChanged += (s, e) => { userData.ArchiveIndex = e; };
            }
            else
            {
                comboArchive.Enabled = false;
            }
            controls.Add(comboArchive);
        }
Пример #21
0
        public IGameComponent[] FindGameComponents(Predicate <IGameComponent> match)
        {
            var res = MMW.FindGameComponents <GameComponent>(match);

            if (res == null)
            {
                return(null);
            }
            return(res);
        }
Пример #22
0
        protected override void Update(double deltaTime)
        {
            var cam  = MMW.MainCamera;
            var from = cam.Transform.WorldPosition;
            var to   = from + ((cam.Target - from).Normalized() * Distance);

            rays = Bullet.RayTest(from, to, GameObject);

            var prev = closed;

            closed = null;
            foreach (var r in rays)
            {
                if (r.GameObject.Destroyed)
                {
                    continue;
                }
                closed = r;
                break;
            }

            float rot = 0.0f;

            {
                var t = (cam.Target - from);
                t.Y = 0.0f;
                t.Normalize();
                rot = Vector3.CalculateAngle(-Vector3.UnitZ, t);
                var cross = Vector3.Cross(-Vector3.UnitZ, t);
                rot *= cross.Y >= 0.0f ? -1.0f : 1.0f;
            }

            if (closed != null)
            {
                data.gameobject = closed.GameObject;
                data.position   = closed.Position;
                data.normal     = closed.Normal;
                data.rotate     = new Vector3(0.0f, rot, 0.0f);
                data.distance   = Distance * closed.Rate;
            }

            if (prev == null && closed != null)
            {
                MMW.BroadcastMessage("focus enter", closed.GameObject, data);
            }
            else if (prev != null && closed == null)
            {
                MMW.BroadcastMessage("focus leave", prev.GameObject, data);
            }
            else if (prev != null && closed != null && prev != closed)
            {
                MMW.BroadcastMessage("focus leave", prev.GameObject, data);
                MMW.BroadcastMessage("focus enter", closed.GameObject, data);
            }
        }
Пример #23
0
        protected override void OnLoad()
        {
            base.OnLoad();

            SelectedStage = null;

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            load = MMW.FindGameComponent <InitLoading>();
            if (load.State != InitLoading.LoadingState.Finished)
            {
                load.LoadCompleted += Load_LoadCompleted;
            }

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            tabCtr = new TabControl()
            {
                Parent        = transit,
                LocalLocation = new Vector2(100, 164),
                Size          = new Vector2((MMW.ClientSize.Width / 2) - 100 - 64, MMW.ClientSize.Height - 164 - 48),
                Tabs          = new Tab[]
                {
                    new Tab()
                    {
                        Name = "PRESET", Items = load.PresetStages,
                    },
                    new Tab()
                    {
                        Name = "FREE", Items = load.FreeStages,
                    },
                },
                Focus = true,
            };

            label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "STAGE SELECT",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };
        }
Пример #24
0
        public TestShader() : base("Test")
        {
            VertexCode   = Resources.Test_vert;
            FragmentCode = Resources.Test_frag;

            RegistShaderParam <Matrix4>("MVP", "ModelViewProjection");
            RegistShaderParam <Matrix4>("MIT", "ModelInverseTranspose");
            RegistShaderParam <Vector3>("lightDir", "DirectionalLightDir");
            RegistShaderParam <Color4>("diffuse", "Diffuse");
            RegistShaderParam <Color4>("ambient", "Ambient");
            RegistShaderParam("albedoMap", "AlbedoMap", TextureUnit.Texture0);

            whiteMap = MMW.GetAsset <Texture2D>("WhiteMap");
        }
Пример #25
0
        protected internal override void OnLoad()
        {
            base.OnLoad();

            CreateShadowMap();

            whiteMap    = MMW.GetAsset <Texture2D>("WhiteMap");
            depthShader = (DepthShader)MMW.GetAsset <Shader>("Depth");
            colorShader = (ColorShader)MMW.GetAsset <Shader>("Color");

            depthRT = new RenderTexture(MMW.RenderResolution);
            depthRT.ColorFormat0 = PixelInternalFormat.Rgba16f;
            depthRT.Load();

            colorRT = new RenderTexture(MMW.RenderResolution);
            colorRT.ColorFormat0 = MMW.Configuration.DefaultPixelFormat;
            colorRT.Load();
            randColors = new Color4[ushort.MaxValue + 1];
            for (var i = 0; i < randColors.Length; i++)
            {
                randColors[i] = new Color4(
                    RandomHelper.NextFloat() * 0.5f + 0.5f,
                    RandomHelper.NextFloat() * 0.5f + 0.5f,
                    RandomHelper.NextFloat() * 0.5f + 0.5f,
                    1.0f);
            }

            shadowDepthBias = Matrix4.CreateScale(0.5f) * Matrix4.CreateTranslation(0.5f, 0.5f, 0.5f);

            velocityShader          = (VelocityShader)MMW.GetAsset <Shader>("Velocity");
            velocityRT              = new RenderTexture(MMW.RenderResolution);
            velocityRT.ColorFormat0 = PixelInternalFormat.Rgba16f;
            velocityRT.Load();

            sp = new ShaderUniqueParameter()
            {
                camera = this,
            };

            getter.Add("Orthographic", obj => Orthographic);
            getter.Add("Up", obj => Up);
            getter.Add("Width", obj => Width);
            getter.Add("Height", obj => Height);
            getter.Add("Aspect", obj => Aspect);
            getter.Add("FoV", obj => FoV);
            getter.Add("Near", obj => Near);
            getter.Add("Far", obj => Far);
            getter.Add("Depth", obj => Depth);
            getter.Add("ClearColor", obj => ClearColor);
        }
Пример #26
0
 public SelectRect(Control parent, Vector2 location, Vector2 size)
 {
     Parent        = parent;
     LocalLocation = location;
     Size          = size;
     Clicked      += (s, e) =>
     {
         if (Focused != this)
         {
             MMW.GetAsset <Sound>("select").Play();
         }
         Focused = this;
     };
 }
Пример #27
0
        public void OnCharacterLoaded(NwCharacter ch)
        {
            var chara = AssetConverter.FromNwCharacter(ch);

            MMW.Invoke(() =>
            {
                chara.Load();

                var go = CreateGameObject(chara, chara.Name, "Deferred Physical");
                go.AddComponent <CollisionRenderer>();
                MMW.RegistGameObject(go);

                gameObj = go;
            });
        }
Пример #28
0
        public void OnObjectLoaded(NwObject obj)
        {
            var wo = AssetConverter.FromNwObject(obj);

            MMW.Invoke(() =>
            {
                wo.Load();

                var go = CreateGameObject(wo, wo.Name, "Deferred Physical");
                go.AddComponent <CollisionRenderer>();
                MMW.RegistGameObject(go);

                gameObj = go;
            });
        }
Пример #29
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var effs = MMW.MainCamera.GameObject.GetComponents <ImageEffect>();

            foreach (var eff in effs)
            {
                eff.Enabled = false;
            }

            var hw = new GameObject("Hello World");

            hw.AddComponent <HelloWorld>();
            MMW.RegistGameObject(hw);
        }
Пример #30
0
 private void Server_Disconnected(object sender, EventArgs e)
 {
     if (!leave)
     {
         if (inventoryShown)
         {
             MMW.BroadcastMessage("close inventory");
         }
         if (menuShown)
         {
             MMW.BroadcastMessage("close menu");
         }
         MMW.BroadcastMessage("show dialog");
         MMW.BroadcastMessage("show leave window");
     }
 }