public override bool Update(GameTime gameTime) { double dt = gameTime.ElapsedGameTime.TotalSeconds; bool flg = true; time += gameTime.ElapsedGameTime; if (RecVisible.Width < maxSize) { double ex = Math.Min(maxSize, RecVisible.Width + expandSpeed * dt) / RecVisible.Width; RectangleD.ExtendRect(RecVisible, ex, ex, RecVisible); time = TimeSpan.Zero; Chase(); flg = false; } else if (color != maxColor) { color = new Vector3( (float)Math.Min(color.X + dColor.X * dt, 1), (float)Math.Min(color.Y + dColor.Y * dt, 1), (float)Math.Min(color.Z + dColor.Z * dt, 1) ); EmissiveColor = color; if (time > TimeSpan.FromSeconds(stopTime)) { // 敵(target1)を追尾する velocity = target1.RecCollision.Center; velocity -= RecVisible.Center; if (velocity == Vector2.Zero) { velocity.X = 1; } velocity.Normalize(); velocity.X *= (float)speed; velocity.Y *= (float)speed; RecVisible.Offset(velocity.X * dt, velocity.Y * dt); // 何かにあたったら爆発 flg = false; ArrayList ls = new ArrayList(scene.SolidList); if (owner != 0) ls.Add(scene.Character1P); if (owner != 1) ls.Add(scene.Character2P); Hashtable ht = Collision.GetColState(this, ls); foreach (DictionaryEntry de in ht) { velocity = Vector2.Zero; flg = true; break; } if (flg == false) { ht = Collision.GetColState(this, scene.AttackerList); foreach (DictionaryEntry de in ht) { if ((de.Key).GetType() == typeof(AttackArea)) { AttackArea a = (AttackArea)(de.Key); if (a.IsTarget[owner] == false) { continue; } } velocity = Vector2.Zero; flg = true; break; } } } else { flg = false; } } else { flg = true; } Depth = RecVisible.Width; attackArea.RecCollision.Copy(RecVisible); if (flg) { Object o = scene.Parameters["AttackArea"]; AttackArea tmp = null; if (o != null) { tmp = new AttackArea(scene, (Hashtable)o, RectangleD.ExtendRect(RecVisible, eX, eY)); tmp.NotAttack(owner); tmp.SetExpandSpeed(attackExpandSpeedX, attackExpandSpeedY); tmp.SetTime(attackTime); tmp.Power = power; tmp.Damage = damage; scene.EntityList.Add(tmp); scene.AttackerList.Add(tmp); Cue sound = GLOBAL.soundBank.GetCue("bomb"); sound.Play(); } o = scene.Parameters["ExplosionParticles"]; if (o != null) { scene.EntityList.Add(new ParticleManager(scene, "ExplosionParticles", RecCollision.Center)); } attackArea.Dispose(); Dispose(); } return base.Update(gameTime); }
public override bool Update(GameTime gameTime) { double dt = gameTime.ElapsedGameTime.TotalSeconds; bool flg = true; if (RecVisible.Width < maxSize) { double ex = Math.Min(maxSize, RecVisible.Width + expandSpeed * dt) / RecVisible.Width; RectangleD.ExtendRect(RecVisible, ex, ex, RecVisible); time = TimeSpan.Zero; Chase(); flg = false; } else if (color != maxColor) { color = new Vector3( (float)Math.Min(color.X + dColor.X * dt, 1), (float)Math.Min(color.Y + dColor.Y * dt, 1), (float)Math.Min(color.Z + dColor.Z * dt, 1) ); EmissiveColor = color; if (velocity == Vector2.Zero) { flg = false; Hashtable ht = Collision.GetColState(this, scene.AttackerList); foreach (DictionaryEntry de in ht) { Entity he = (Entity)(de.Key); if (he.GetType() == typeof(AttackArea) && ((AttackArea)he).IsTarget[owner] == true) { flg = true; break; } else { velocity = RecCollision.Center - he.RecCollision.Center; if (velocity == Vector2.Zero) { velocity.X = 1; } velocity.Normalize(); velocity.X *= (float)speed; velocity.Y *= (float)speed; tmp = he; Cue c = GLOBAL.soundBank.GetCue("B2"); c.Play(); break; } } } else { RecVisible.Offset(velocity.X * dt, velocity.Y * dt); flg = false; ArrayList ls = new ArrayList(scene.SolidList); if (owner != 0) ls.Add(scene.Character1P); if (owner != 1) ls.Add(scene.Character2P); Hashtable ht = Collision.GetColState(this, ls); foreach (DictionaryEntry de in ht) { velocity = Vector2.Zero; flg = true; break; } if (flg == false) { ht = Collision.GetColState(this, scene.AttackerList); foreach (DictionaryEntry de in ht) { if (de.Key == tmp) { continue; } velocity = Vector2.Zero; flg = true; break; } } } } else { flg = true; } Depth = RecVisible.Width; if (flg) { Object o = scene.Parameters["AttackArea"]; AttackArea attackArea = null; if (o != null) { Vector2 v = RecVisible.Center; attackArea = new AttackArea(scene, (Hashtable)o, new RectangleD(v.X - attackMinSizeX * 0.5, v.Y - attackMinSizeY * 0.5, attackMinSizeX, attackMinSizeY)); attackArea.NotAttack(owner); attackArea.SetExpandSpeed(attackExpandSpeedX, attackExpandSpeedY); attackArea.SetTime(attackTime); attackArea.Power = attackPower; attackArea.Damage = attackDamage; scene.EntityList.Add(attackArea); scene.AttackerList.Add(attackArea); Cue sound = GLOBAL.soundBank.GetCue("bomb"); sound.Play(); } scene.EntityList.Add(new ParticleManager(scene, "ExplosionParticles", RecCollision.Center)); Dispose(); } return base.Update(gameTime); }