public override bool Collision(Collider c) { if (working) if (c is RoundCollider) { RoundCollider rd = (RoundCollider)c; double missDistance = 15; if (Datas.CurrentPlayer.CurrentCharactor.Name == "") { missDistance = 25; } double r = rd.GetRadius(); double x = rd.GetX(); double y = rd.GetY(); lenth = ((x - Position.X) * (x - Position.X) + (y - Position.Y) * (y - Position.Y)); if (lenth < (missDistance + radius) * (missDistance + radius)) { //擦弹 missed = true; missedPosition = new Vector2D(x - Position.X, y - Position.Y).GetNormalize(); if (lenth < (r + radius) * (r + radius)) { return true; } } } return false; }
public EnemyData(Vector2D pos, Vector2D dir, Vector2D scl, float speed) { Position = pos; Direction = dir; Scale = scl; Speed = speed; }
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 void refresh() { Vector2D vct = new Vector2D(MainVector.X, MainVector.Y); vct.rotate(-count / 2 * angle); for (int i = 0; i < count; i++) { childvectors[i] = new Vector2D(vct.X, vct.Y); vct.rotate(angle); } }
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 Stage01_EB01(TextureManager _t, Vector2D direction , Vector2D position,int color = 5) { texturemanager = _t; Direction.X = direction.X; Position.X = position.X; Direction.Y = direction.Y; Position.Y = position.Y; bulletbody = new BulletBodys.RoundB_B(_t, color); //敌机子弹皮肤(miniRice) speed = 100; BulletData bulletdata = new BulletData(Position , Direction , Scale , speed); contorler = new Entities.Controlors.DirectControler(bulletdata); //选择直线控制器 renderlevel = 0; //需要提前约定好 MissTick = 61; MissRefresh = 60; }
public EqualAngleMultiVctor(Vector2D _mainvector, int _count, float _angle) { if (_count % 2 != 0) _count++; this.angle = _angle; this.count = _count; MainVector = _mainvector; //设定主矢量 childvectors = new Vector2D[count]; Vector2D vct = new Vector2D(_mainvector.X, _mainvector.Y); vct.rotate(- count/2 *angle); for (int i = 0; i < count; i++) { childvectors[i] = new Vector2D(vct.X, vct.Y); vct.rotate(angle); } }
public Stage01_E01c(EnemyData edt,bool _turnleft = false) { turnleft = _turnleft; enemydata = edt; enemydata.Speed = 150; direction = enemydata.Direction; position = enemydata.Position; direction.X = 0; direction.Y = -1; TCset godir = new TCset(0,200); //0-200帧行走直线并且进行减速 godir.Name = "godir"; commands.Add(godir); TCset rotate = new TCset(500, 580); //500-580帧时进行旋转,并且进行加速 rotate .Name = "rotate"; commands .Add(rotate); }
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() ; }
public override void Fire(Vector2D positon, double elapsedTime) { Level0_Fire0.currentTick += 1; Level0_Fire1.currentTick += 1; switch (level) { case 0: //等级0 时的发射表 if (Level0_Fire0.currentTick >= Level0_Fire0.allTick) { Bullet b; b = new ReimuBullet_Dir(Stage1State._textureManager, new Vector2D(0, 1)); b.Position.X = positon.X - 10; b.Position.Y = positon.Y + 10; bullets_toAdd.Add(b); b = new ReimuBullet_Dir(Stage1State._textureManager, new Vector2D(0, 1)); b.Position.X = positon.X + 10; b.Position.Y = positon.Y + 10; bullets_toAdd.Add(b); Level0_Fire0.currentTick = 0; //刷新发射帧数计时器 } if (Level0_Fire1.currentTick >= Level0_Fire1.allTick) { Bullet b = new ReimuBullet_Follow(Stage1State._textureManager, new Vector2D(-1, 3).GetNormalize()); b.Position.X = positon.X - 15; b.Position.Y = positon.Y + 10; bullets_toAdd.Add(b); b = new ReimuBullet_Follow(Stage1State._textureManager, new Vector2D(1, 3).GetNormalize()); b.Position.X = positon.X + 15; b.Position.Y = positon.Y + 10; bullets_toAdd.Add(b); Level0_Fire1.currentTick = 0; //refresh } break; } }
/// <summary> /// 切换攻击形态 /// </summary> /// <param name="state">更换的形态状态标记</param> /// <param name="vct">技能所要追随的Vector2D组件</param> public virtual void ChangeAttack(ATKSTATETYPE state,Vector2D vct) { }
public virtual void Render(Renderer renderer, Vector2D Pos) { sprite.SetPosition(Pos.X, Pos.Y); renderer.DrawSprite(sprite); foreach (CollisionComponent c in AttackComponents) { c.Render(renderer); } }
public override void Update(double elapsedTime) { base.Update(elapsedTime); double x= Datas.CurrentPlayer.Position.X; double y = Datas.CurrentPlayer.Position.Y; double dis = (Position.X - x) * (Position.X - x) + (Position.Y - y) * (Position.Y - y); if (dis < distance2) { Vector2D vct = new Vector2D(x - Position.X, y - Position.Y); vct.Normalize(); x = elapsedTime * vct.X * speed2; y = elapsedTime * vct.Y * speed2; x = Position.X + x; y = Position.Y + y; Position.X = x; Position.Y = y; } }
//擦弹判定(如果存在擦弹则返回一个坐标信息【道具出现的坐标信息】,返回的道具结果) public bool MissBullet(Player p, ref Vector2D position , ref Item itm) { if (MissTick < MissRefresh) return false; double x = p.GetX(); double y = p.GetY(); //获取到玩家坐标 double MissJudgeDistance = 15; //擦弹判定距离 if (p.CurrentCharactor.Name == "da") //不同人物具有不同的擦弹判定距离 { MissJudgeDistance = 25; } if (MissJudge(MissJudgeDistance, x, y ,ref position , ref itm)) { MissTick = 0; //擦弹计时器清零(重新进入计时周期) return true; } return false; }
public override void Render() { //for (int i = 1; i < dividecount; i++) //{ // Rays_sprites[i].SetPosition(positions[i].X, positions[i].Y); // //方向定义为指向前一个块 // Vector2D vct = new Vector2D(positions[i].X - positions[i - 1].X, // positions[i].Y - positions[i - 1].Y); // vct.Normalize(); // ag = vct.getcurve(); // Stage1State._renderer.DrawSprite(Rays_sprites[i], positions[i].X, positions[i].Y, ag + 90); //} float ag = 0; for (int i = ((int)dividecount-1); i > 0; i--) { Rays_sprites[i].SetPosition(positions[i].X, positions[i].Y); //方向定义为指向前一个块 Vector2D vct = new Vector2D(positions[i].X - positions[i - 1].X, positions[i].Y - positions[i - 1].Y); //如果点没有发生变化,则跳过本次循环 if (vct.X == 0 && vct.Y == 0) continue; vct.Normalize(); ag = vct.getcurve(); double x = positions[i].X; double y = positions[i].Y; if (x < 200 && x > -200 && y > -10 && y < 450) Stage1State._renderer.DrawSprite(Rays_sprites[i], (float)positions[i].X, (float)positions[i].Y, ag + 90); } ag = Direction.getcurve(); Rays_sprites[0].SetPosition(positions[0].X, positions[0].Y); Stage1State._renderer.DrawSprite(Rays_sprites[0], (float)positions[0].X, (float)positions[0].Y, ag - 90); }
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; }
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); }
protected virtual void DoMessages(double elapsedTime) { foreach (CmpMessage msg in ComponentMessages) { //0号攻击判定 if (msg.Tag == CmpMessage.CollisionMasseageNormal) { CollisionMessages.CollisionMasseageNormal m = msg as CollisionMessages.CollisionMasseageNormal; if (attackMessageBox.AllowAttack[0]) { this.Direction.rotate(180); attackMessageBox.ClosePort(0); double x, y,x1,y1; x = Position.X; y = Position.Y; x1 = m.Position.X; y1 = m.Position.Y; Vector2D vct = new Vector2D(); vct.X = x-x1; vct.Y = y-y1; vct.Normalize(); this.Direction.X = vct.X; this.Direction.Y = vct.Y; } } } ComponentMessages.Clear(); }
/// <summary> /// 提供一个分数参数,将其画下来 /// </summary> /// <param name="isc">Score参数</param> /// <param name="distance">数字间的距离</param> public void DrawNumber(Renderer _renderer, IScore isc , float distance) { float alpha = isc.alpha; Vector2D vct = new Vector2D(isc.Position.X, isc.Position.Y); string num = isc.Score.ToString(); char[] arr = num.ToArray<char>(); int length = arr.Length; int len2 = length / 2; for (int i = 0; i < length; i++) { Sprite sp = score_number.GetNumber(arr[i].ToString()); sp.SetPosition(vct.X + (i-len2) * distance, vct.Y); //数字居中显示 sp.SetColor(new Color(1, 1, 1, alpha*0.5f)); _renderer.DrawSprite(sp); } }
/// <summary> /// 可重载的对擦弹判定的描述 /// </summary> /// <param name="missDistance">擦弹判定中心的圆形判定距离</param> /// <param name="x">擦弹中心的x坐标</param> /// <param name="y">擦弹中心的y坐标</param> /// <param name="postion">返回擦弹获得的点数坐标</param> /// <returns></returns> protected virtual bool MissJudge(double missDistance, double x, double y , ref Vector2D postion , ref Item itm) { return false; }
public override void ChangeAttack(ATKSTATETYPE state,Vector2D vct) { base.ChangeAttack(state,vct); //生成一个攻击判定组件 //1阶技能组件 if (state == ATKSTATETYPE.First) { Entities.Players.WriggleCmp1 cmp = new Entities.Players.WriggleCmp1(texturemanager, vct,50); AttackComponents.Add(cmp); } //2阶技能组件 if (state == ATKSTATETYPE.Second) { Entities.Players.WriggleCmp1 cmp = new Entities.Players.WriggleCmp1(texturemanager, vct); AttackComponents.Add(cmp); } //3阶技能组件 if (state == ATKSTATETYPE.Third) { Entities.Players.WriggleCmp1 cmp = new Entities.Players.WriggleCmp1(texturemanager, vct); AttackComponents.Add(cmp); } //最终技能组件 if (state == ATKSTATETYPE.Final) { Entities.Players.WriggleCmp1 cmp = new Entities.Players.WriggleCmp1(texturemanager, vct); AttackComponents.Add(cmp); } }
public Direct_BlueKnife(TextureManager texturemanager , Vector2D direction) { bulletbody = new BlueKnife(texturemanager); direction.Normalize(); this.Direction.X = direction.X; this.Direction.Y = direction.Y; attack = 20; speed = 300; }
//每一个角色都会Fire, (将其发送到bullet的加入队列,需要提供当前player的坐标位置) public virtual void Fire(Vector2D position , double elapsedTime) { }
public Controler(Vector2D v) { Position = v; }
public override void Fire(Vector2D position , double elapsedTime) { }
//构造函数都需要继承基类构造函数 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); }
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 GrazePoint(TextureManager texturemanager, double X, double Y,int score) : base() { this.Type = Item.Blue_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); this.texturemanager = texturemanager; ItemData = new itemdata.BluePoint(score); //携带分数信息 initialize(); }
public override void Update(double elapsedTime) { if (!working) { if (disposing) { if (disposingTime > 0) { angle += (float)elapsedTime * 360 * 3; _alpha = disposingTime / 12.0f; disposingTime--; //注销计时-1 } else { disposing = false; disabled = true; //在最后的旋转特效以后,同意注销此子弹 } } return; } speed += 2; //每帧速度+1 if (Datas.CurrentEnemys.Count > 0) { double distance = 100000000; //取一个极端数值,使每一个求得值都会小于这个值 double lastdistance = distance; foreach (Enemy e in Datas.CurrentEnemys) //将离Player距离最短的作为跟踪对象 { if (e.Position.X < -200 || e.Position.X > 200 || e.Position.Y < -40 || e.Position.Y > 500) continue; distance = (Datas.CurrentPlayer.Position.X - e.Position.X) * (Datas.CurrentPlayer.Position.X - e.Position.X) + (Datas.CurrentPlayer.Position.Y - e.Position.Y) * (Datas.CurrentPlayer.Position.Y - e.Position.Y); if (distance < lastdistance) { FollowEnemy = e; } lastdistance = distance; } } if (Position.X < -190 || Position.X > 190 || Position.Y < -20 || Position.Y > 450) { speed = 0; working = false; disabled = true; } move(elapsedTime); //跟踪旋转 if (FollowEnemy != null && !FollowEnemy.disabled && FollowEnemy.living) { Vector2D vct = new Vector2D(FollowEnemy.Position.X - Position.X, FollowEnemy.Position.Y - Position.Y); if (!(vct.X == 0 && vct.Y == 0)) { double distance = vct.X * vct.X + vct.Y * vct.Y; double percent = distance / 40000; if (percent > 1) percent = 1; percent = 1 - percent; float addangle = (float)percent * 1080; vct.Normalize(); double vct_angle = vct.GetAngle(); //目标的角度值 double dir_angle = Direction.GetAngle(); //当前方向的角度值 if (vct_angle < dir_angle) { if (dir_angle - vct_angle < 180) { Direction.rotate( (addangle + rotateSpeed) * (float)elapsedTime); double d_2 = Direction.GetAngle(); if (d_2 > dir_angle) //如果左旋转后反而比原本角度更大,则证明旋转过度 { Direction.X = vct.X; Direction.Y = vct.Y; } else if (d_2 < vct_angle) //如果旋转后跑到方向角左边,则证明旋转过度 { Direction.X = vct.X; Direction.Y = vct.Y; } } else { Direction.rotate((- addangle -rotateSpeed) * (float)elapsedTime); double d_2 = Direction.GetAngle(); if (d_2 < dir_angle) //如果旋转后反而比原本角度更小,则证明旋转过了一周 { if (d_2 > vct_angle) { Direction.X = vct.X; Direction.Y = vct.Y; } } } } else if (vct_angle > dir_angle) { if (vct_angle - dir_angle < 180) { Direction.rotate((-addangle -rotateSpeed) * (float)elapsedTime); double d_2 = Direction.GetAngle(); if (d_2 < dir_angle) { Direction.X = vct.X; Direction.Y = vct.Y; } else if (d_2 > vct_angle) { Direction.X = vct.X; Direction.Y = vct.Y; } } else { Direction.rotate((addangle + rotateSpeed) * (float)elapsedTime); double d_2 = Direction.GetAngle(); if (d_2 > dir_angle) { if (d_2 < vct_angle) { Direction.X = vct.X; Direction.Y = vct.Y; } } } } } } }
float upspeed = 10; //向上位移的速度 #endregion Fields #region Constructors public IScore(double x, double y, int score) { Position = new Vector2D(x, y); Score = score; alpha = 1; }