Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
0
        protected override void Update(double deltaTime)
        {
            base.Update(deltaTime);

            showtime -= deltaTime;

            var l = logs.Count - 1;

            for (var i = l; i > (l - 30) && i >= 0; i--)
            {
                logs[i].position.X = MMWMath.Lerp(logs[i].position.X, 8.0f, MMWMath.Saturate((float)deltaTime * 12.0f));
            }

            if (Input.Ctrl && Input.IsKeyDown(OpenTK.Input.Key.Down))
            {
                Scroll  -= (float)deltaTime * ScrollSpeed;
                showtime = ShowTime;
            }
            else if (Input.Ctrl && Input.IsKeyDown(OpenTK.Input.Key.Up))
            {
                Scroll  += (float)deltaTime * ScrollSpeed;
                showtime = ShowTime;
            }

            var max = logs.Sum(log => log.tex.Size.Height + Interval) + 8.0f - Size.Y;

            if (max < 0.0f)
            {
                max = 0.0f;
            }
            Scroll = MMWMath.Clamp(Scroll, 0.0f, max);
        }
Exemplo n.º 3
0
        protected override void Update(double deltaTime)
        {
            base.Update(deltaTime);

            //rate = MMWMath.Lerp(rate, 1.0f, (float)deltaTime * 10.0f);

            transition += (trans ? -1.0f : 1.0f) * (float)deltaTime * 5.0f;
            transition  = MMWMath.Saturate(transition);

            transit.Update(deltaTime);

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

                //if (input.IsDown || input.IsUp) rate = 0.0f;

                /*
                 * if (state == State.ModeSelect)
                 * {
                 *  if (input.IsDown)
                 *  {
                 *      modeSelectIndex = MMWMath.Repeat(modeSelectIndex + 1, 0, 3);
                 *      soundSelect.Play();
                 *  }
                 *  else if (input.IsUp)
                 *  {
                 *      modeSelectIndex = MMWMath.Repeat(modeSelectIndex - 1, 0, 3);
                 *      soundSelect.Play();
                 *  }
                 *  else if (input.IsSelect)
                 *  {
                 *      soundClick.Play();
                 *      if (modeSelectIndex == (int)ModeSelect.PlayOffline)
                 *      {
                 *          trans = true;
                 *          GameObject.AddComponent<PlayerSelectScript>();
                 *
                 *      }
                 *      else if (modeSelectIndex == (int)ModeSelect.PlayOnline)
                 *      {
                 *          trans = true;
                 *          GameObject.AddComponent<ServerSelectScript>();
                 *      }
                 *  }
                 * }
                 * else if (state == State.Option)
                 * {
                 *
                 * }
                 */
            }

            if (trans && transition < 0.01f)
            {
                Destroy();
            }
        }
Exemplo n.º 4
0
        protected override void Update(double deltaTime)
        {
            base.Update(deltaTime);

            transition += (trans ? -1.0f : 1.0f) * (float)deltaTime * 5.0f;
            transition  = MMWMath.Saturate(transition);

            transit.Update(deltaTime);

            if (AcceptInput && !trans)
            {
                input.Update(deltaTime);

                var prev = tabCtr.SelectedObject;

                if (input.IsRight)
                {
                    tabCtr.NextTab();
                    if (prev != tabCtr.SelectedObject)
                    {
                        MMW.DestroyGameObject(player);
                        player = null;
                    }
                }
                else if (input.IsLeft)
                {
                    tabCtr.PrevTab();
                    if (prev != tabCtr.SelectedObject)
                    {
                        MMW.DestroyGameObject(player);
                        player = null;
                    }
                }
                else if (input.IsDown)
                {
                    tabCtr.NextSelect();
                    if (prev != tabCtr.SelectedObject)
                    {
                        MMW.DestroyGameObject(player);
                        player = null;
                    }
                }
                else if (input.IsUp)
                {
                    tabCtr.PrevSelect();
                    if (prev != tabCtr.SelectedObject)
                    {
                        MMW.DestroyGameObject(player);
                        player = null;
                    }
                }
                else if (input.IsBack)
                {
                    if (player != null)
                    {
                        MMW.DestroyGameObject(player);
                    }
                    trans          = true;
                    transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                    GameObject.AddComponent <TitleScript>();
                }
                else if (input.IsSelect && player != null)
                {
                    MMW.DestroyGameObject(player);
                    SelectedPlayer = (ImportedObject)tabCtr.SelectedObject;
                    MMW.GetAsset <GameData>().Player = SelectedPlayer;
                    trans          = true;
                    transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                    GameObject.AddComponent <StageSelectScript>();
                }
            }

            if (trans && transition < 0.01f)
            {
                Destroy();
            }

            if (player == null && tabCtr.SelectedObject != null)
            {
                var path = ((ImportedObject)tabCtr.SelectedObject).Path;

                var go = GameObjectFactory.CreateMeshObject(path, MMW.GetAsset <GameData>().SkinShader);
                //go.Layer = 1;
                go.Transform.Rotate.Y = -2.8f;
                go.UpdateAction      += (s, e) =>
                {
                    //go.Transform.Rotate.Y += (float)e.deltaTime * 0.5f;
                };

                // Test: モーションを取得
                var motions = Array.FindAll(load.PresetObjects, o => o.Type == ImportedObjectType.Motion && o.Property != null);
                if (motions.Length > 0)
                {
                    var animator = go.AddComponent <ComputeAnimator>();
                    var mr       = go.GetComponent <MeshRenderer>();
                    animator.Bones = mr.Bones;
                    foreach (var m in motions)
                    {
                        var impo = MMW.GetSupportedImporter(m.Path);
                        var mo   = impo.Import(m.Path, Importers.ImportType.Full)[0];
                        animator.AddMotion(mo.Name, mo.Motions[0]);
                    }
                    //animator.SetRate("secret", 1.0f);
                    animator.SetRate("nekomimi_mikuv2", 1.0f);
                    animator.Frame = 0.0f;
                    go.AddComponent <AnimationController>();
                    //go.UpdateAction += (se, e) =>
                    //{
                    //animator.Frame = MMWMath.Repeat(animator.Frame + ((float)e.deltaTime * 30.0f), 0.0f, 5000.0f);
                    //if (Input.IsKeyDown(Key.Right)) animator.AddRate("nekomimi_mikuv2", (float)e.deltaTime, 0.0f, 1.0f);
                    //if (Input.IsKeyDown(Key.Left)) animator.AddRate("nekomimi_mikuv2", -(float)e.deltaTime, 0.0f, 1.0f);
                    //if (Input.IsKeyDown(Key.Right)) go.Transform.Rotate.Y += (float)e.deltaTime;
                    //if (Input.IsKeyDown(Key.Left)) go.Transform.Rotate.Y -= (float)e.deltaTime;
                    //};
                }

                MMW.RegistGameObject(go);
                player = go;
            }
        }
Exemplo n.º 5
0
        protected override void Update(double deltaTime)
        {
            base.Update(deltaTime);

            transition += (trans ? -1.0f : 1.0f) * (float)deltaTime * 5.0f;
            transition  = MMWMath.Saturate(transition);

            transit.Update(deltaTime);

            if (AcceptInput && !trans)
            {
                input.Update(deltaTime);

                if (input.IsRight)
                {
                    tabCtr.NextTab();
                }
                else if (input.IsLeft)
                {
                    tabCtr.PrevTab();
                }
                else if (input.IsDown)
                {
                    tabCtr.NextSelect();
                }
                else if (input.IsUp)
                {
                    tabCtr.PrevSelect();
                }
                else if (input.IsBack)
                {
                    trans          = true;
                    transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                    GameObject.AddComponent <PlayerSelectScript>();
                }
                else if (input.IsSelect && tabCtr.SelectedObject != null)
                {
                    SelectedStage = (ImportedObject)tabCtr.SelectedObject;
                    MMW.GetAsset <GameData>().Stage = SelectedStage;
                    trans          = true;
                    transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                    var loadScript = MMW.FindGameComponent <LoadingScript>();
                    loadScript.StartLoading(null, (args) =>
                    {
                        var data = MMW.GetAsset <GameData>();

                        // プレイヤ
                        var player = GameObjectFactory.CreateMeshObject(data.Player.Path, data.SkinShader);
                        //player.Layer = 20;
                        player.AddComponent <SetNameScript>();
                        player.Tags.Add("player");

                        var motions = Array.FindAll(load.PresetObjects, o => o.Type == ImportedObjectType.Motion && o.Property != null);
                        if (motions.Length > 0)
                        {
                            var animator   = player.AddComponent <ComputeAnimator>();
                            var mr         = player.GetComponent <MeshRenderer>();
                            animator.Bones = mr.Bones;
                            foreach (var m in motions)
                            {
                                var impo = MMW.GetSupportedImporter(m.Path);
                                var mo   = impo.Import(m.Path, Importers.ImportType.Full)[0];
                                animator.AddMotion(mo.Name, mo.Motions[0]);
                            }
                            animator.SetRate("nekomimi_mikuv2", 1.0f);
                            player.AddComponent <AnimationController>();
                        }

                        // テストライト
                        {
                            var pl       = player.AddComponent <PointLight>();
                            pl.Intensity = 1.0f;
                            pl.Radius    = 4.0f;
                            pl.Color     = Color4.White;
                        }

                        {
                            var c                    = player.AddComponent <CapsuleCollider>(0.3f, 1.0f);
                            c.Position.Y             = 0.8f;
                            var rb                   = player.AddComponent <RigidBody>();
                            rb.Mass                  = 50.0f;
                            rb.FreezeRotation        = true;
                            rb.DisableDeactivation   = true;
                            rb.LinearDamping         = 0.3f;
                            rb.LinearVelocityLimitXZ = 2.0f;
                            rb.Friction              = 0.95f;
                            player.UpdateAction     += (s, ev) =>
                            {
                                player.Transform.Rotate.Y         += Input.MouseDelta.X * 0.0025f;
                                MMW.MainCamera.Transform.Rotate.X += Input.MouseDelta.Y * 0.0025f;
                                MMW.MainCamera.Transform.Rotate.X  = MathHelper.Clamp(MMW.MainCamera.Transform.Rotate.X, -1.0f, 1.0f);

                                var front = player.Transform.WorldDirectionZ;
                                var left  = player.Transform.WorldDirectionX;
                                var speed = (float)ev.deltaTime * 2.0f;

                                var deltaDir = Vector3.Zero;
                                if (Input.IsKeyDown(Key.W))
                                {
                                    deltaDir += front;
                                }
                                if (Input.IsKeyDown(Key.S))
                                {
                                    deltaDir -= front;
                                }
                                if (Input.IsKeyDown(Key.A))
                                {
                                    deltaDir += left;
                                }
                                if (Input.IsKeyDown(Key.D))
                                {
                                    deltaDir -= left;
                                }

                                if (deltaDir != Vector3.Zero)
                                {
                                    deltaDir.Normalize();
                                    //rb.ApplyImpulse(deltaDir * speed * 80.0f);
                                    player.Transform.Position += deltaDir * speed;
                                }
                                if (Input.IsKeyPressed(Key.Space))
                                {
                                    rb.ApplyImpulse(Vector3.UnitY * 36.0f);
                                }

                                player.Transform.UpdatePhysicalTransform();

                                var cam = MMW.MainCamera;
                                var pos = cam.Transform.WorldPosition;
                                //var vel = (cam.Transform.Position - prevPos) * (float)deltaTime;
                                var dirv = cam.Transform.WorldDirectionZ;
                                var ori  = new float[] { dirv.X, dirv.Y, dirv.Z, cam.Up.X, cam.Up.Y, cam.Up.Z };
                                AL.Listener(OpenTK.Audio.OpenAL.ALListener3f.Position, ref pos);
                                //AL.Listener(OpenTK.Audio.OpenAL.ALListener3f.Velocity, ref vel);
                                AL.Listener(OpenTK.Audio.OpenAL.ALListenerfv.Orientation, ref ori);
                            };

                            MMW.MainCamera.ShadowMapping            = true;
                            MMW.MainCamera.Transform.Parent         = player.Transform;
                            MMW.MainCamera.GameObject.UpdateAction += (s, ev) =>
                            {
                                if (Input.IsKeyDown(Key.ShiftLeft))
                                {
                                    MMW.MainCamera.Transform.Position = new Vector3(-0.5f, 1.5f, -0.5f);
                                }
                                else
                                {
                                    MMW.MainCamera.Transform.Position = new Vector3(0.0f, 1.5f, -1.3f);
                                }

                                //MMW.DirectionalLight.Transform.Rotate.Y += (float)ev.deltaTime * 0.01f;
                            };
                        }

                        // ステージ
                        var stage = GameObjectFactory.CreateStage(data.Stage.Path, data.Shader);
                        stage.Tags.Add("stage");
                        {
                            var sCol      = stage.GetComponent <PhysicalGameComponent>();
                            sCol.Collide += SCol_Collide;
                        }

                        MMW.RegistGameObject(player);
                        MMW.RegistGameObject(stage);

                        for (var i = 0; i < 1; i++)
                        {
                            var tsts = GameObjectFactory.CreateMeshObject(data.Player.Path, data.SkinShader);
                            tsts.Tags.Add("test");
                            //tsts.Layer = 20;
                            tsts.AddComponent <SetNameScript>();
                            tsts.Transform.Position.Z = (i + 1) * 1.0f;
                            var c                  = tsts.AddComponent <CapsuleCollider>(0.3f, 1.0f);
                            c.Position.Y           = 0.8f;
                            var rb                 = tsts.AddComponent <RigidBody>();
                            rb.Mass                = 50.0f;
                            rb.FreezeRotation      = true;
                            rb.DisableDeactivation = true;
                            rb.LinearDamping       = 0.3f;

                            var animator   = tsts.AddComponent <ComputeAnimator>();
                            var mr         = tsts.GetComponent <MeshRenderer>();
                            animator.Bones = mr.Bones;
                            foreach (var m in motions)
                            {
                                var impo = MMW.GetSupportedImporter(m.Path);
                                var mo   = impo.Import(m.Path, Importers.ImportType.Full)[0];
                                animator.AddMotion(mo.Name, mo.Motions[0]);
                            }
                            animator.SetRate("nekomimi_mikuv2", 1.0f);
                            var s    = i + 1;
                            var ac   = tsts.AddComponent <AnimationController>();
                            ac.Speed = i * 0.25;

                            var sound = new Sound("C:/Users/yoshihiro/Downloads/dbg2.wav");
                            sound.Load();
                            var sc = tsts.AddComponent <SoundController>();
                            sc.Sounds.Add("test", sound);
                            sc.Play("test", 1.0f);

                            tsts.UpdateAction += (se, e) =>
                            {
                                tsts.Transform.Position = new Vector3((float)Math.Sin(MMW.TotalElapsedTime * 4.0) * 4.0f, 0.0f, (float)Math.Cos(MMW.TotalElapsedTime * 4.0) * 4.0f);
                            };

                            MMW.RegistGameObject(tsts);
                        }

                        var effs = MMW.MainCamera.GameObject.GetComponents <ImageEffect>();
                        foreach (var eff in effs)
                        {
                            eff.Enabled = true;
                        }

                        MMW.GlobalAmbient = new Color4(0.2f, 0.18f, 0.16f, 0.0f);
                        MMW.DirectionalLight.Intensity = 6.0f;
                        MMW.IBLIntensity = 0.0f;

                        return(true);
                    });
                    loadScript.LoadCompleted += Load_LoadCompleted;
                }
            }

            if (trans && transition < 0.01f)
            {
                Destroy();
            }
        }