public override BLRunStatus Run(BulletMLBullet bullet) { if (first) { first = false; if (node.GetChild(BLName.Speed).type == BLType.Sequence) { changeSpeed = node.GetChildValue(BLName.Speed, this); } else if (node.GetChild(BLName.Speed).type == BLType.Relative) { changeSpeed = node.GetChildValue(BLName.Speed, this) / term; } else { changeSpeed = (node.GetChildValue(BLName.Speed, this) - bullet.Speed) / term; } } term--; bullet.Speed += changeSpeed; // if (bullet.index == DISP_BULLET_INDEX) Debug.WriteLine(String.Format("ChangeSpeed:{0} (type:{1} val:{2})", bullet.Speed, node.GetChild(BLName.Speed).type, node.GetChildValue(BLName.Speed, this))); if (term <= 0) { end = true; return(BLRunStatus.End); } else { return(BLRunStatus.Continue); } }
public BulletMLFire(BulletMLTree node) { this.node = node; this.dirNode = node.GetChild(BLName.Direction); this.spdNode = node.GetChild(BLName.Speed); this.refNode = node.GetChild(BLName.BulletRef); this.bulletNode = node.GetChild(BLName.Bullet); if(dirNode == null && refNode != null) dirNode = refNode.GetChild(BLName.Direction); if(dirNode == null && bulletNode != null) dirNode = bulletNode.GetChild(BLName.Direction); if(spdNode == null && refNode != null) spdNode = refNode.GetChild(BLName.Speed); if(spdNode == null && bulletNode != null) spdNode = bulletNode.GetChild(BLName.Speed); }
public BulletMLFire(BulletMLTree node) { this.node = node; this.dirNode = node.GetChild(BLName.Direction); this.spdNode = node.GetChild(BLName.Speed); this.refNode = node.GetChild(BLName.BulletRef); this.bulletNode = node.GetChild(BLName.Bullet); if (dirNode == null && refNode != null) { dirNode = refNode.GetChild(BLName.Direction); } if (dirNode == null && bulletNode != null) { dirNode = bulletNode.GetChild(BLName.Direction); } if (spdNode == null && refNode != null) { spdNode = refNode.GetChild(BLName.Speed); } if (spdNode == null && bulletNode != null) { spdNode = bulletNode.GetChild(BLName.Speed); } }
public override BLRunStatus Run(BulletMLBullet bullet) { if (first) { first = false; float value = (float)(node.GetChildValue(BLName.Direction, this) * Math.PI / 180); blType = node.GetChild(BLName.Direction).type; if (blType == BLType.Sequence) { changeDir = value; } else { if (blType == BLType.Absolute) { changeDir = (float)((value - bullet.Direction)); } else if (blType == BLType.Relative) { changeDir = (float)(value); } else { changeDir = (float)((bullet.GetAimDir() + value - bullet.Direction)); } if (changeDir > Math.PI) { changeDir -= 2 * (float)Math.PI; } if (changeDir < -Math.PI) { changeDir += 2 * (float)Math.PI; } changeDir /= term; /* * float finalDir = 0; * * if (blType == BLType.Absolute) * { * finalDir = value; * } * else if (blType == BLType.Relative) * { * finalDir = bullet.Direction + value; * } * else * { * finalDir = bullet.GetAimDir() + value; * } * * // 角度の小さいほうへ回転する * float changeDir1 = finalDir - bullet.Direction; * float changeDir2; * changeDir2 = changeDir1 > 0 ? changeDir2 = changeDir1 - 360: changeDir2 = changeDir1 + 360; * changeDir = Math.Abs(changeDir1) < Math.Abs(changeDir2) ? changeDir1 : changeDir2; * changeDir = changeDir / term; */ } } term--; bullet.Direction = bullet.Direction + changeDir; // if (bullet.index == DISP_BULLET_INDEX) Debug.WriteLine(String.Format("changeDirection:{0}度 (changeDir:{1} type:{2})", bullet.Direction / Math.PI * 180, changeDir, node.GetChild(BLName.Direction).type)); if (term <= 0) { end = true; return(BLRunStatus.End); } else { return(BLRunStatus.Continue); } }