float speed2 = 200; //靠近玩家时自动靠近的速度 #endregion Fields #region Constructors //构造函数都需要继承基类构造函数 public BoomPoint(TextureManager texturemanager, float X, float Y) : base() { this.Type = Item.Boom_Point; //确定弹射范围 Position.X = X; Position.Y = Y; OriPosition = new Vector2D(Position.X, Position.Y); breakPosition = new Vector2D(Direction.X * breakLength + Position.X, Direction.Y * breakLength + Position.Y); //正常状态 Texture texture = texturemanager.Get("Ef_etama2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetHeight(16); sprite.SetWidth(16); sprite.SetUVs(6*per_256, 8 * per_256, 8 * per_256, 10 * per_256); //顶部状态(三角形形态) Texture texture2 = texturemanager.Get("Ef_etama2"); littleState = new Sprite(); littleState.Texture = texture2; littleState.SetWidth(16); littleState.SetHeight(16); littleState.SetUVs(22 * per_256, 8 * per_256, 24 * per_256, 10 * per_256); }
public RedBox(TextureManager t) { name = "BlueBox"; sprite= new Sprite(); sprite.Texture = t.Get("Player2"); sprite.SetHeight(16); sprite.SetWidth(16); sprite.SetUVs(per_256,6,18,8,20); }
public BlueBox(TextureManager t) { name = "BlueBox"; sprite= new Sprite(); sprite.Texture = t.Get("Player2"); sprite.SetHeight(32); sprite.SetWidth(32); sprite.SetUVs(0, 22 * per_256, 4 * per_256, 26 * per_256); }
//复制构造函数 public Sprite(Sprite spr) { _texture = spr.Texture; for (int i = 0; i < VertexAmount; i++) { _vertexPositions[i] = spr._vertexPositions[i]; _vertexColors[i] = spr._vertexColors[i]; _vertexUVs[i] = spr._vertexUVs[i]; } }
float width_max = 64; //最大宽度 #endregion Fields #region Constructors /// <summary> /// 爆炸特效 /// </summary> /// <param name="texturemanager">纹理管理器</param> /// <param name="pos">绑定对象上的坐标组件</param> /// <param name="live_time">存活时间</param> /// <param name="min_r">特效半径最小大小</param> /// <param name="max_r">特效半径最大大小</param> public BreakOut_Blue(TextureManager texturemanager,Vector2D pos,int live_time = 15,float min_r=32,float max_r=64) { Pos_BindObject = pos; living_time = live_time; Texture texture = texturemanager.Get("Ef_etama2"); sprite = new Sprite(); sprite.Texture = texture; width = min_r; height = min_r; width_max = max_r; height_max = max_r; sprite.SetUVs(24 * per_256, 22 * per_256, 32 * per_256, 30 * per_256); }
public TextTestState(TextureManager textureManager) { _text.Texture = textureManager.Get("Font"); _textFont = new TextFont(textureManager); spr = _textFont.GetAci("终"); spr.SetPosition(-50, 50); spr.SetHeight(14);spr.SetWidth(14); _text.SetUVs(new Point(0.0547f*2, 0.0547f), new Point(0.0547f * 3, 0.0547f * 2)); _text.SetWidth(14); _text.SetHeight(14); }
public BlueCard(TextureManager _t) { Texture texture; texture = _t.Get("Player2"); name = "BlueCard"; sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(16); sprite.SetHeight(16); sprite.SetUVs(4 * per_256, 22 * per_256, 6 * per_256, 24 * per_256); sprite.SetColorUp(new Color(1, 1, 1, 0.5f)); sprite.SetColorDown(new Color(1, 1, 1, 0.5f)); }
// 坐标,文字,宽度, 透明值,间距,行数,每行长度 //从右到左(例如“ 1”,“ 11”,“ 111”,“ 1111”,“11111” ) public void DrawText2D2(Point position, string text, int width = 14, float Alpha = 1, int dw = 9, int rows = 1, int length = 20) { int len = text.Length; Sprite spr; for (int i = 0; i < len; i++) { spr = _textFont.GetAci(text.Substring(i, 1)); spr.SetWidth(width); spr.SetHeight(width); spr.SetPosition(new Vector(position.X - width / 2 - (len-1-i)* dw, position.Y - width / 2, 0)); spr.SetColor(new Color(1, 1, 1, Alpha)); _renderer.DrawSprite(spr); } }
public void AddSprite(Sprite sprite) { //If the batch is full , draw it , empty and start again if (sprite.VertexPositions.Length + _batchSize > MaxVertexNumber) Draw(); //Add the current sprite vertices to the batch for (int i = 0; i < sprite.VertexPositions.Length; i++) { _vertexPositions[_batchSize + i] = sprite.VertexPositions[i]; _vertexColors[_batchSize + i] = sprite.VertexColor[i]; _vertexUVs[_batchSize + i] = sprite.VertexUVs[i]; } _batchSize += sprite.VertexPositions.Length; }
public BlueButterfly(TextureManager texturemanager) { Texture texture = texturemanager.Get("enemys1"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(32); sprite.SetHeight(32); multiSprite = new MultiSprite(sprite); multiSprite.changeinterval = 0.15f; RecTangleF[] rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) { rects[i] = new RecTangleF(16 * per_512 + i * per_512 * 4, 16 * per_512, 16 * per_512 + (i + 1) * 4 * per_512, 20 * per_512); } multiSprite.RegeditState(0, rects); effect = new StartEffect_Red(Stage1State._textureManager); }
public DarkBlueLittleSprite(TextureManager texturemanager) { name = "DarkBlueLittleSprite"; Texture texture = texturemanager.Get("enemy"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(32); sprite.SetHeight(32); multiSprite = new MultiSprite(sprite); RecTangleF[] rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 4 * per_512 , 0, (i + 1) * 4 * per_512, 4 * per_512); multiSprite.RegeditState(0, rects); //将此rectangleF注册到0号state ,表示正面状态 rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 4 * per_512, 4 * per_512, (i + 1) * 4 * per_512, 8 * per_512); multiSprite.RegeditState(1, rects); //将此rectangleF注册到1号state ,表示右侧渐动的状态 rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 4 * per_512, 8 * per_512, (i + 1) * 4 * per_512, 12 * per_512); multiSprite.RegeditState(2, rects); //将此rectangleF注册到2号state ,表示右侧移动状态 rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF((i + 1) * 4 * per_512, 4 * per_512, i * 4 * per_512, 8 * per_512); multiSprite.RegeditState(3, rects); //将此rectangleF注册到3号state ,表示左侧渐动的状态 rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF((i + 1) * 4 * per_512, 8 * per_512, i * 4 * per_512, 12 * per_512); multiSprite.RegeditState(4, rects); //将此rectangleF注册到4号state ,表示左侧移动状态 multiSprite.RegeditCollection(1, 2); //将1号动画连接到2号动画上 multiSprite.RegeditCollection(3, 4); //将3号动画连接到4号动画上 multiSprite.State = 0; //将状态切换为0号state multiSprite.changeinterval = 0.1f; }
public override void DrawSprite(Sprite sprite, float x, float y, float rad) { x += (float)OffsetX; y += (float)OffsetY; Gl.glTranslatef(x, y, 0); Gl.glRotatef(rad, 0, 0, 1); Gl.glTranslatef(-x, -y, 0); Gl.glBindTexture(Gl.GL_TEXTURE_2D, sprite.Texture.ID); //利用迭代画出每个顶点(纹理) Gl.glBegin(Gl.GL_TRIANGLES); { for (int i = 0; i < Sprite.VertexAmount; i++) { DrawImmediateModeVertex( sprite.VertexPositions[i], sprite.VertexColor[i], sprite.VertexUVs[i]); } } Gl.glEnd(); Gl.glTranslatef(x, y, 0); Gl.glRotatef(-rad, 0, 0, 1); Gl.glTranslatef(-x, -y, 0); }
public ReiMu(TextureManager texturemanager) { this.texturemanager = texturemanager; name = "ReiMu"; Texture texture = texturemanager.Get("Player2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(32); sprite.SetHeight(48); sprite.SetColor(new Color(1, 1, 1, 0.2f)); multiSprite = new MultiSprite(sprite); RecTangleF[] rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256); multiSprite.RegeditState(0, rects); //将此rectangleF注册到0号state rects = new RecTangleF[3]; for (int i = 0; i < 3; i++) rects[i] = new RecTangleF(i * 4 * per_256, 6 * per_256, 4 * per_256 + i * 4 * per_256, 12 * per_256); multiSprite.RegeditState(1, rects); //将此rectangleF注册到1号state (过渡移动) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(12 * per_256 + i * 4 * per_256, 6 * per_256, 12 * per_256 + 4 * per_256 + i * 4 * per_256, 12 * per_256); multiSprite.RegeditState(2, rects); //将此rectangleF注册到2号state (移动) rects = new RecTangleF[3]; for (int i = 0; i < 3; i++) rects[i] = new RecTangleF(4 * per_256 + i * 4 * per_256, 6 * per_256, i * 4 * per_256, 12 * per_256); multiSprite.RegeditState(3, rects); //将此rectangleF注册到3号state (过渡移动,右) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(12 * per_256 + 4 * per_256 + i * 4 * per_256, 6 * per_256, 12 * per_256 + i * 4 * per_256, 12 * per_256); multiSprite.RegeditState(4, rects); //将此rectangleF注册到4号state (移动) multiSprite.RegeditCollection(1, 2); //将1号动画连接到2号动画上 multiSprite.RegeditCollection(3, 4); //将3号动画连接到4号动画上 multiSprite.State = 0; //将状态切换为3号state InitComponents(); }
public MissPoint(TextureManager texturemanager, double X, double Y,Vector2D dir,int score = 100) { //确定类型 this.Type = Item.Miss_Point; working = true; //确定弹射范围 Position.X = X; Position.Y = Y; if (dir.Y < 0) dir.Y = -dir.Y; if (dir.X >= 0) { double rad = dir.GetAngle(); if (rad > 60) rad = 60; direction = new Vector2D(0, 1); direction.rotate((float)(Datas.LooselyRandom.NextDouble() * (rad - 2*randDomain) + randDomain)); } else { double rad = dir.GetAngle(); rad = 360 - rad; if (rad > 60) rad = 60; direction = new Vector2D(0, 1); direction.rotate(-((float)(Datas.LooselyRandom.NextDouble() * (rad - 2 * randDomain) + randDomain))); } speed_right = speed_totle * direction.X; speed_up = speed_totle * direction.Y; double offset_x = Center_Distance * direction.X; double offset_y = Center_Distance * direction.Y; Position.X += offset_x; Position.Y += offset_y; offset_x = Datas.LooselyRandom.NextDouble() * 2 *randFireDomain - randFireDomain; Position.X += offset_x; Texture texture = texturemanager.Get("Ef_etama2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetHeight(16); sprite.SetWidth(16); sprite.SetUVs(14 * per_256, 8 * per_256, 16 * per_256, 10 * per_256); //保存了MissPoint的一些必要信息 ItemData = new itemdata.MissPoint(score,3); }
void initialize() { //正常状态 Texture texture = texturemanager.Get("Ef_etama2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetHeight(16); sprite.SetWidth(16); sprite.SetUVs(2.1f * per_256, 8 * per_256, 3.9f * per_256, 10 * per_256); //顶部状态(三角形形态) Texture texture2 = texturemanager.Get("Ef_etama2"); littleState = new Sprite(); littleState.Texture = texture2; littleState.SetWidth(16); littleState.SetHeight(16); littleState.SetUVs(18 * per_256, 8 * per_256, 20 * per_256, 10 * per_256); }
//允许绑定position,也可以不绑定(不绑定则需要自己指定坐标) public StartEffect_Red(TextureManager texturemanager, Vector2D position = null) { Texture texture = texturemanager.Get("etama2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(64); sprite.SetHeight(64); sprite.SetUVs(16 * per_256, 14 * per_256, 24 * per_256, 22 * per_256); if (position != null) Position = position; }
float _alpha; //那段时间的透明值 #endregion Fields #region Constructors public ReimuBullet_Follow(TextureManager texturemanager, Vector2D direction) { bulletbody = new BlueCard(texturemanager); direction.Normalize(); this.Direction.X = direction.X; this.Direction.Y = direction.Y; attack = 100; speed = 400; BlueEsc = (new BlueBox(texturemanager)).GetSprite() ; }
void CreateSprites() { Texture texture = _textureManager.Get("Font"); foreach(Charactor c in charactors) { Sprite spt = new Sprite(); spt.Texture = texture; spt.SetUVs(new Point(0.05467f*c.x,0.05467f*c.y), new Point(0.05467f*c.x+0.05467f,0.05467f*c.y+0.05467f)); Font_Sprites.Add(c.id, spt); } }
StateSystem _system; // 状态机 #endregion Fields #region Constructors public Stage1State(StateSystem system , TextureManager texturemanager , SoundManagerEx soundmanager ,Form1 form = null) { _system = system; _textureManager = texturemanager; _soundmanager = soundmanager; if(form != null) this.form = form; GamePlayer = new Player(); Datas.CurrentPlayer = GamePlayer; gameview = new GameView(texturemanager, soundmanager, 5 , GamePlayer); //中间层着色,注册角色 GamePlayer.RegisteredRCharactors(Datas.Charactors[Datas.Fore_People_Select], Datas.Charactors[Datas.Fore_People_Select]);// Form1.Charactors[Datas.Back_People_Select]); GamePlayer.Position.Y = 30; GamePlayer.RenderSpeed = 0.075f; //人物帧动画渲染速度 foretable = new ForeTable(texturemanager, 10); //最前层着色 foretable.HighScores = 0; foretable.Power = 0; foretable.Graze = 0; foretable.CurrentPoint = 0; foretable.LevelPoint = 1550; foretable.CurrentTims = 0; foretable.TotleTims = 6400; foretable.GameLevel = 1; Logo = new Sprite(); Logo.Texture = texturemanager.Get("logo1"); Logo.SetWidth(192); Logo.SetHeight(192); Logo.SetPosition(210, -130); test = new Extra.VariableSprite(); test.BindSprite(Logo); test.SetAttribute(210, -130, 0, 192, 192); fonc = new FontAciHuaKang(texturemanager); TextWriter = new FontWriterTool(fonc); }
void init() { Textures = new Texture[5]; Textures[0] = texturemanager.Get("FontAciP1"); Textures[1] = texturemanager.Get("FontAciP2"); Textures[2] = texturemanager.Get("FontAciP3"); Textures[3] = texturemanager.Get("FontAciP4"); Textures[4] = texturemanager.Get("FontAciP5"); sprite = new Sprite(); sprite.SetWidth(24); sprite.SetHeight(24); LoadData(); inited = true; }
void CreateSprites() { Texture texture = texturemanager.Get("fontex"); foreach (Charactor c in charactors) { Sprite spt = new Sprite(); spt.Texture = texture; spt.SetUVs(c.x * per_256, c.y * per_256, (c.x + 2) * per_256, (c.y + 2) * per_256); Font_Sprites.Add(c.id, spt); } }
public Wriggle(TextureManager texturemanager) { name = "Wriggle"; Texture texture = texturemanager.Get("Wriggle"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(32); sprite.SetHeight(42); sprite.SetColor(new Color(1, 1, 1, 0.2f)); multiSprite = new MultiSprite(sprite); float offset = 0.01f; RecTangleF[] rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 8 * per_256, per_256, (i + 1) * 8 * per_256 - offset, 13 * per_256); multiSprite.RegeditState(0, rects); //将此rectangleF注册到0号state rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 8 * per_256, per_256, (i + 1) * 8 * per_256 - offset, 13 * per_256); multiSprite.RegeditState(1, rects); //将此rectangleF注册到1号state (过渡移动) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 8 * per_256, per_256, (i + 1) * 8 * per_256 - offset, 13 * per_256); multiSprite.RegeditState(2, rects); //将此rectangleF注册到2号state (移动) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 8 * per_256, per_256, (i + 1) * 8 * per_256 - offset, 13 * per_256); multiSprite.RegeditState(3, rects); //将此rectangleF注册到3号state (过渡移动,右) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(i * 8 * per_256, per_256, (i + 1) * 8 * per_256 - offset, 13 * per_256); multiSprite.RegeditState(4, rects); //将此rectangleF注册到4号state (移动) multiSprite.RegeditCollection(1, 2); //将1号动画连接到2号动画上 multiSprite.RegeditCollection(3, 4); //将3号动画连接到4号动画上 multiSprite.State = 0; //将状态切换为3号state InitComponents(); }
public Yukari(TextureManager texturemanager) { name = "YuKaRi"; Texture texture = texturemanager.Get("Player2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(32); sprite.SetHeight(48); multiSprite = new MultiSprite(sprite); RecTangleF[] rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(4 * 4 * per_256 + i * 4 * per_256, 0, 4 * 4 * per_256 + 4 * per_256 + i * 4 * per_256, 6 * per_256); multiSprite.RegeditState(0, rects); //将此rectangleF注册到0号state rects = new RecTangleF[3]; for (int i = 0; i < 3; i++) rects[i] = new RecTangleF(i * 4 * per_256, 12 * per_256, 4 * per_256 + i * 4 * per_256, 18 * per_256); multiSprite.RegeditState(1, rects); //将此rectangleF注册到1号state (过渡移动) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(12 * per_256 + i * 4 * per_256, 12 * per_256, 12 * per_256 + 4 * per_256 + i * 4 * per_256, 18 * per_256); multiSprite.RegeditState(2, rects); //将此rectangleF注册到2号state (移动) rects = new RecTangleF[3]; for (int i = 0; i < 3; i++) rects[i] = new RecTangleF(4 * per_256 + i * 4 * per_256, 12 * per_256, i * 4 * per_256, 18 * per_256); multiSprite.RegeditState(3, rects); //将此rectangleF注册到3号state (过渡移动,右) rects = new RecTangleF[4]; for (int i = 0; i < 4; i++) rects[i] = new RecTangleF(12 * per_256 + 4 * per_256 + i * 4 * per_256, 12 * per_256, 12 * per_256 + i * 4 * per_256, 18 * per_256); multiSprite.RegeditState(4, rects); //将此rectangleF注册到4号state (移动) multiSprite.RegeditCollection(1, 2); //将1号动画连接到2号动画上 multiSprite.RegeditCollection(3, 4); //将3号动画连接到4号动画上 multiSprite.State = 0; //将状态切换为0号state }
public Score_Number(TextureManager _t) { texturemanager = _t; NumberDic = new Dictionary<string, Sprite>(); Texture texture = _t.Get("fontex"); for (int i = 0; i < 10; i++) { Sprite sp = new Sprite(); sp.Texture = texture; sp.SetWidth(8); sp.SetHeight(8); sp.SetUVs(i * per_256, 0, (i + 1) * per_256, per_256); NumberDic.Add(i.ToString(), sp); } }
float _alpha; //那段时间的透明值 #endregion Fields #region Constructors public ReimuBullet_Dir(TextureManager texturemanager, Vector2D direction) { bulletbody = new RedCard(texturemanager); direction.Normalize(); this.Direction.X = direction.X; this.Direction.Y = direction.Y; attack = 100; speed = 800; RedEsc = (new RedBox(texturemanager)).GetSprite(); }
//构造函数都需要继承基类构造函数 public GratePowerPoint(TextureManager texturemanager, double X, double Y) : base() { this.Type = Item.BigP_Point; //确定弹射范围 Position.X = X; Position.Y = Y; OriPosition = new Vector2D(Position.X, Position.Y); breakPosition = new Vector2D(Direction.X * breakLength + Position.X, Direction.Y * breakLength + Position.Y); //正常状态 Texture texture = texturemanager.Get("Ef_etama2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetHeight(16); sprite.SetWidth(16); sprite.SetUVs(4.1f * per_256, 8 * per_256, 6 * per_256, 9.9f * per_256); //顶部状态(三角形形态) Texture texture2 = texturemanager.Get("Ef_etama2"); littleState = new Sprite(); littleState.Texture = texture2; littleState.SetWidth(16); littleState.SetHeight(16); littleState.SetUVs(20 * per_256, 8 * per_256, 22 * per_256, 10 * per_256); }
public Blue_Ray(TextureManager _t , Vector2D position , Vector2D direction = null, bool goright = true) { right = goright; Direction = new Vector2D(0, -1); speed = 100; Texture texture = _t.Get("Rays"); this.Position = position; //头坐标 if (direction != null) this.Direction = direction; Sprite sp; for (int i = 0; i < dividecount; i++) { //切分为dividecount块 positions.Add(new Vector2D(position.X, position.Y )); sp = new Sprite(); sp.Texture = texture; sp.SetUVs(i / dividecount, per_256 *16, (i + 1) / dividecount, per_256 * 18); sp.SetWidth(256/dividecount*1.5f); sp.SetHeight(16/2); Rays_sprites.Add(sp); } radius = 8; }
//允许绑定position,也可以不绑定(不绑定则需要自己指定坐标) public NormalSlowEffect(TextureManager texturemanager , Vector2D position = null) { Texture texture = texturemanager.Get("Ef_etama2"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(64); sprite.SetHeight(64); sprite.SetUVs(0, 14 * per_256, 8 * per_256, 22 * per_256); if( position!= null) Position = position; }
public RedCard(TextureManager _t) { Texture texture = _t.Get("Player2"); name = "RedCard"; sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(72); sprite.SetHeight(16); sprite.SetUVs(2*per_256, 18 * per_256, 11 * per_256, 20 * per_256); sprite.SetColorUp(new Color(1,1,1,0.5f)); sprite.SetColorDown(new Color(1, 1, 1, 0.5f)); }
public BlueKnife(TextureManager _t) { Texture texture = _t.Get("etama1"); name = "blueknife"; sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(32); sprite.SetHeight(32); sprite.SetUVs(0, 18 * per_256, 4 * per_256, 22 * per_256); }