public SongInfoControl(Device device, Sprite sprite) { state = State.normal; resource = new Dictionary <string, ImageResource>(); pictureobjects = new List <PictureObject>(); anim = new EffectObject("img\\default\\difficulty.etd", 0, 0, resource, device); anim.Alignment = EffectObject.EffectAlignment.TopLeft; anim.PlayType = Effect2D.EffectManager.PlayType.Loop; anim.Play(); string filename = "img\\default\\difficulty.png"; ImageResource p = new ImageResource(filename, device); resource.Add(filename, p); PictureObject po = new PictureObject(filename, 450, secondheight + 120, resource, device); pictureobjects.Add(po); po = new PictureObject(filename, 535, secondheight + 120, resource, device); pictureobjects.Add(po); po = new PictureObject(filename, 620, secondheight + 120, resource, device); pictureobjects.Add(po); po = new PictureObject(filename, 705, secondheight + 120, resource, device); pictureobjects.Add(po); infoboards = new PictureObject[2]; p = new ImageResource("img\\default\\infoboard1.png", device); resource.Add("img\\default\\infoboard1.png", p); po = new PictureObject("img\\default\\infoboard1.png", 520, height - 14, resource, device); infoboards[0] = po; p = new ImageResource("img\\default\\infoboard2.png", device); resource.Add("img\\default\\infoboard2.png", p); po = new PictureObject("img\\default\\infoboard2.png", 500, 235, resource, device); infoboards[1] = po; infos = new StringObject[6]; for (int i = 0; i < 6; i++) { StringObject st = new StringObject("", xx + 20, height + 30 * i, 20, new Color4(1, 1, 1, 1), device, sprite); infos[i] = st; } difficulties = new StringObject[4]; for (int i = 0; i < 4; i++) { string fn = ""; switch (i) { case 0: fn = "EASY"; break; case 1: fn = "NORMAL"; break; case 2: fn = "HARD"; break; case 3: fn = "EXTREME"; break; } StringObject st = new StringObject(fn, 0, secondheight + 125, 20, new Color4(1, 1, 1, 1), device, sprite); st.Position = new Vector2(490 + 85 * i - st.Width / 2, st.Position.Y); difficulties[i] = st; } bpm = new StringObject("BPM", 600, height, 20, new Color4(1, 1, 1, 1), device, sprite); easy = new StringObject("EASY", 600, height + 30, 20, new Color4(1, 1, 1, 1), device, sprite); normal = new StringObject("NORMAL", 600, height + 60, 20, new Color4(1, 1, 1, 1), device, sprite); hard = new StringObject("HARD", 600, height + 90, 20, new Color4(1, 1, 1, 1), device, sprite); extreme = new StringObject("EXTREME", 600, height + 120, 20, new Color4(1, 1, 1, 1), device, sprite); SA = new StringObject("S.A.", 600, height + 150, 20, new Color4(1, 1, 1, 1), device, sprite); bpm.Position = new Vector2(xx - bpm.Width, bpm.Position.Y); easy.Position = new Vector2(xx - easy.Width, easy.Position.Y); normal.Position = new Vector2(xx - normal.Width, normal.Position.Y); hard.Position = new Vector2(xx - hard.Width, hard.Position.Y); extreme.Position = new Vector2(xx - extreme.Width, extreme.Position.Y); SA.Position = new Vector2(xx - SA.Width, SA.Position.Y); focusedbpm = new StringObject("BPM", 600, secondheight, 20, new Color4(1, 1, 1, 1), device, sprite); hiscore = new StringObject("BPM", 600, secondheight + 40, 20, new Color4(1, 1, 1, 1), device, sprite); difficulty = new StringObject("BPM", 600, secondheight + 80, 20, new Color4(1, 1, 1, 1), device, sprite); }
public void Draw(PictureObject po) { float zure = 0 * po.Scale.X; float press = 0.8f; float alpha = 0.4f; int w = 1; float z = 0.5f; Vector4[] positions = new Vector4[4]; positions[0] = new Vector4(po.Position.X - po.Width / 2, po.Position.Y - po.Height / 2, z, w); positions[1] = new Vector4(po.Position.X + po.rec.Width - po.Width / 2, po.Position.Y - po.Height / 2, z, w); positions[2] = new Vector4(po.Position.X - po.Width / 2, po.Position.Y + po.rec.Height - po.Height / 2, z, w); positions[3] = new Vector4(po.Position.X + po.rec.Width - po.Width / 2, po.Position.Y + po.rec.Height - po.Height / 2, z, w); Matrix m = Matrix.Transformation2D(new Vector2(po.Position.X, po.Position.Y), 0f, po.Scale, new Vector2(po.Position.X, po.Position.Y), po.Rotation, new Vector2(0, 0)); for (int i = 0; i < positions.Length; i++) { positions[i] = Vector4.Transform(positions[i], m); } var cv = new TransformedColoredTexturedVertex[6] { // 左上の頂点 new TransformedColoredTexturedVertex() { Position = new Vector4(positions[0].X - zure, (positions[2].Y - positions[0].Y) * press + positions[2].Y, z, w), Color = new Color4(0, 1, 1, 1).ToArgb(), TextureCoordinates = new Vector2() { X = po.rec.X / po.Width, Y = po.rec.Y / po.Height }, }, // 右上の頂点 new TransformedColoredTexturedVertex() { Position = new Vector4(positions[1].X + zure, (positions[2].Y - positions[0].Y) * press + positions[2].Y, z, w), Color = new Color4(0, 1, 1, 1).ToArgb(), TextureCoordinates = new Vector2() { X = (po.rec.X + po.rec.Width) / po.Width, Y = po.rec.Y / po.Height }, }, // 左真ん中の頂点 new TransformedColoredTexturedVertex() { Position = new Vector4(positions[0].X - zure / 2, (positions[2].Y - positions[0].Y) * press / 2 + positions[2].Y, z, w), Color = new Color4(0, 1, 1, 1).ToArgb(), TextureCoordinates = new Vector2() { X = po.rec.X / po.Width, Y = (po.rec.Y + po.rec.Height) / po.Height / 2 }, }, // 右真ん中の頂点 new TransformedColoredTexturedVertex() { Position = new Vector4(positions[1].X + zure / 2, (positions[2].Y - positions[0].Y) * press / 2 + positions[2].Y, z, w), Color = new Color4(0, 1, 1, 1).ToArgb(), TextureCoordinates = new Vector2() { X = (po.rec.X + po.rec.Width) / po.Width, Y = (po.rec.Y + po.rec.Height) / po.Height / 2 }, }, // 左下の頂点 new TransformedColoredTexturedVertex() { Position = new Vector4(positions[2].X, positions[2].Y, z, w), Color = new Color4(alpha, 1, 1, 1).ToArgb(), TextureCoordinates = new Vector2() { X = po.rec.X / po.Width, Y = (po.rec.Y + po.rec.Height) / po.Height }, }, // 右下の頂点 new TransformedColoredTexturedVertex() { Position = new Vector4(positions[3].X, positions[3].Y, z, w), Color = new Color4(alpha, 1, 1, 1).ToArgb(), TextureCoordinates = new Vector2() { X = (po.rec.X + po.rec.Width) / po.Width, Y = (po.rec.Y + po.rec.Height) / po.Height }, } }; Texture t = po.Texture; if (t != null) { this.device.SetTexture(0, t); this.device.VertexFormat = TransformedColoredTexturedVertex.Format; this.device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 4, cv); } }
public void Focus() { state = State.focused; Focused = true; selectdifficulty = Difficulty.Normal; int count = 0; while (!exist[(int)selectdifficulty + 1] && count < 3) { selectdifficulty += 1; if (selectdifficulty > Difficulty.Extreme) { selectdifficulty = Difficulty.Easy; } if (selectdifficulty < 0) { selectdifficulty = Difficulty.Extreme; } count++; } if (count >= 4) { selectdifficulty = Difficulty.Other; return; } PictureObject po = pictureobjects[(int)selectdifficulty]; anim.Position = new Vector2(po.Position.X - 4, po.Position.Y - 4); focusedbpm.Text = "BPM " + infos[0].Text; focusedbpm.Position = new Vector2(xxx - focusedbpm.Width / 2, focusedbpm.Position.Y); hiscore.Text = "ハイスコア " + score[(int)selectdifficulty]; hiscore.Position = new Vector2(xxx - hiscore.Width / 2, hiscore.Position.Y); switch (selectdifficulty) { case Difficulty.Easy: difficulty.Text = infos[1].Text; break; case Difficulty.Normal: difficulty.Text = infos[2].Text; break; case Difficulty.Hard: difficulty.Text = infos[3].Text; break; case Difficulty.Extreme: difficulty.Text = infos[4].Text; break; } difficulty.Position = new Vector2(xxx - difficulty.Width / 2, difficulty.Position.Y); foreach (PictureObject p in pictureobjects) { p.Alpha = 1f; } focusedbpm.Alpha = 1f; difficulty.Alpha = 1f; hiscore.Alpha = 1f; foreach (StringObject st in difficulties) { st.Alpha = 1f; } }