GetAimDir() public méthode

public GetAimDir ( ) : float
Résultat float
Exemple #1
0
        public override BLRunStatus Run(BulletMLBullet bullet)
        {
            BLType blType = node.Type;
            float  value  = (float)(node.GetValue(this) * Math.PI / 180);

            if (blType == BLType.Sequence)
            {
                bullet.Direction = bullet.GetFireData().SourceDirection + value;
            }
            else if (blType == BLType.Absolute)
            {
                bullet.Direction = value;
            }
            else if (blType == BLType.Relative)
            {
                bullet.Direction = bullet.Direction + value;
            }
            else //if (blType == BLType.Aim || blType == BLType.None)
            {
                bullet.Direction = bullet.GetAimDir() + value;
            }

            //Debug.WriteLine(String.Format("SetDirecton:{0},  (type:{1} val:{2})", bullet.Direction / Math.PI * 180, node.type, value / Math.PI * 180));
            End = true;

            return(BLRunStatus.End);
        }
        public override BLRunStatus Run(BulletMLBullet bullet)
        {
            BLType blType = node.Type;
            float value = (float)(node.GetValue(this) * Math.PI / 180);

            if (blType == BLType.Sequence)
            {
                bullet.Direction = bullet.GetFireData().SourceDirection + value;
            }
            else if (blType == BLType.Absolute)
            {
                bullet.Direction = value;
            }
            else if (blType == BLType.Relative)
            {
                bullet.Direction = bullet.Direction + value;
            }
            else //if (blType == BLType.Aim || blType == BLType.None)
            {
                bullet.Direction = bullet.GetAimDir() + value;
            }

            //Debug.WriteLine(String.Format("SetDirecton:{0},  (type:{1} val:{2})", bullet.Direction / Math.PI * 180, node.type, value / Math.PI * 180));
            End = true;

            return BLRunStatus.End;
        }
Exemple #3
0
        public override BLRunStatus Run(BulletMLBullet bullet)
        {
            float changeDir = 0;
            float changeSpd = 0;

            // 方向の設定
            if (dirNode != null)
            {
                changeDir = (int)dirNode.GetValue(this) * (float)Math.PI / (float)180;
                if (dirNode.Type == BLType.Sequence)
                {
                    bullet.GetFireData().SourceDirection += changeDir;
                }
                else if (dirNode.Type == BLType.Absolute)
                {
                    bullet.GetFireData().SourceDirection = changeDir;
                }
                else if (dirNode.Type == BLType.Relative)
                {
                    bullet.GetFireData().SourceDirection = changeDir + bullet.Direction;
                }
                else
                {
                    bullet.GetFireData().SourceDirection = changeDir + bullet.GetAimDir();
                }
            }
            else
            {
                bullet.GetFireData().SourceDirection = bullet.GetAimDir();
            }



            // 弾の生成
#if ExpandedBulletML
            string blName = "";
            if (bulletNode != null)
            {
                blName = bulletNode.bulletName;
            }
            else if (refNode != null)
            {
                blName = refNode.bulletName;
            }
            BulletMLBullet newBullet = bullet.GetNewBullet(blName); //bullet.tree);
#else
            BulletMLBullet newBullet = bullet.GetNewBullet();       //bullet.tree);
#endif

            if (newBullet == null)
            {
                End = true;
                return(BLRunStatus.End);
            }

            if (refNode != null)
            {
                // パラメータを取得
                for (int i = 0; i < refNode.Children.Count; i++)
                {
                    newBullet.Tasks[0].ParamList.Add(refNode.Children[i].GetValue(this));
                }

                //if (refNode.children.Count > 0)
                //{
                //    newBullet.task.paramNode = refNode;// node;
                //}
                // refBulletで参照
                newBullet.Init(bullet.Tree.GetLabelNode(refNode.Label, BLName.Bullet));
#if ExpandedBulletML
                newBullet.Visible = refNode.visible;
#endif
            }
            else
            {
                newBullet.Init(bulletNode);
#if ExpandedBulletML
                newBullet.Visible = bulletNode.visible;
#endif
            }

            newBullet.X = bullet.X;
            newBullet.Y = bullet.Y;
            newBullet.Tasks[0].Owner = this;
            newBullet.Direction      = bullet.GetFireData().SourceDirection;


            if (!bullet.GetFireData().SpeedInit&& newBullet.GetFireData().SpeedInit)
            {
                // 自分の弾発射速度の初期化がまだのとき、子供の弾の速度を使って初期値とする
                bullet.GetFireData().SourceSpeed = newBullet.Speed;
                bullet.GetFireData().SpeedInit   = true;
            }
            else
            {
                // 自分の弾発射速度の初期化済みのとき
                // スピードの設定
                if (spdNode != null)
                {
                    changeSpd = spdNode.GetValue(this);
                    if (spdNode.Type == BLType.Sequence || spdNode.Type == BLType.Relative)
                    {
                        bullet.GetFireData().SourceSpeed += changeSpd;
                    }
                    else
                    {
                        bullet.GetFireData().SourceSpeed = changeSpd;
                    }
                }
                else
                {
                    // 特に弾に速度が設定されていないとき
                    if (!newBullet.GetFireData().SpeedInit)
                    {
                        bullet.GetFireData().SourceSpeed = 1;
                    }
                    else
                    {
                        bullet.GetFireData().SourceSpeed = newBullet.Speed;
                    }
                }
            }

            newBullet.GetFireData().SpeedInit = false;
            newBullet.Speed = bullet.GetFireData().SourceSpeed;

            //if(bullet.index == DISP_BULLET_INDEX) Debug.WriteLine(String.Format("Fire dir:{0} spd:{1} label:{2}", bullet.srcDir / Math.PI * 180, bullet.srcSpeed, refNode != null ? refNode.label : ""));
            //Debug.WriteLine("index({3}) Fire dir:{0} spd:{1} label:{2}", bullet.srcDir / Math.PI * 180, bullet.srcSpeed, refNode != null ? refNode.label : "", bullet.index);

            End = true;
            return(BLRunStatus.End);
        }
        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;
        }
Exemple #5
0
        public override BLRunStatus Run(BulletMLBullet bullet)
        {
            float changeDir = 0;
            float changeSpd = 0;

            // 方向の設定
            if (dirNode != null)
            {
                changeDir = (int)dirNode.GetValue(this) * (float)Math.PI / (float)180;
                if (dirNode.Type == BLType.Sequence)
                {
                    bullet.GetFireData().SourceDirection += changeDir;
                }
                else if (dirNode.Type == BLType.Absolute)
                {
                    bullet.GetFireData().SourceDirection = changeDir;
                }
                else if (dirNode.Type == BLType.Relative)
                {
                    bullet.GetFireData().SourceDirection = changeDir + bullet.Direction;
                }
                else
                {
                    bullet.GetFireData().SourceDirection = changeDir + bullet.GetAimDir();
                }
            }
            else
            {
                bullet.GetFireData().SourceDirection = bullet.GetAimDir();
            }

            // 弾の生成
            #if ExpandedBulletML
            string blName = "";
            if (bulletNode != null)
                blName = bulletNode.bulletName;
            else if (refNode != null)
                blName = refNode.bulletName;
            BulletMLBullet newBullet = bullet.GetNewBullet(blName);//bullet.tree);
            #else
            BulletMLBullet newBullet = bullet.GetNewBullet();//bullet.tree);
            #endif

            if (newBullet == null)
            {
                End = true;
                return BLRunStatus.End;
            }

            if (refNode != null)
            {
                // パラメータを取得
                for (int i = 0; i < refNode.Children.Count; i++)
                {
                    newBullet.Tasks[0].ParamList.Add(refNode.Children[i].GetValue(this));
                }

                //if (refNode.children.Count > 0)
                //{
                //    newBullet.task.paramNode = refNode;// node;
                //}
                // refBulletで参照
                newBullet.Init( bullet.Tree.GetLabelNode(refNode.Label, BLName.Bullet) );
            #if ExpandedBulletML
                newBullet.Visible = refNode.visible;
            #endif
            }
            else
            {
                newBullet.Init(bulletNode);
            #if ExpandedBulletML
               newBullet.Visible = bulletNode.visible;
            #endif
            }

            newBullet.X = bullet.X;
            newBullet.Y = bullet.Y;
            newBullet.Tasks[0].Owner = this;
            newBullet.Direction = bullet.GetFireData().SourceDirection;

            if (!bullet.GetFireData().SpeedInit && newBullet.GetFireData().SpeedInit)
            {
                // 自分の弾発射速度の初期化がまだのとき、子供の弾の速度を使って初期値とする
                bullet.GetFireData().SourceSpeed = newBullet.Speed;
                bullet.GetFireData().SpeedInit = true;
            }
            else
            {
                // 自分の弾発射速度の初期化済みのとき
                // スピードの設定
                if (spdNode != null)
                {
                    changeSpd = spdNode.GetValue(this);
                    if (spdNode.Type == BLType.Sequence || spdNode.Type == BLType.Relative)
                    {
                        bullet.GetFireData().SourceSpeed += changeSpd;
                    }
                    else
                    {
                        bullet.GetFireData().SourceSpeed = changeSpd;
                    }
                }
                else
                {
                    // 特に弾に速度が設定されていないとき
                    if(!newBullet.GetFireData().SpeedInit)
                        bullet.GetFireData().SourceSpeed = 1;
                    else
                        bullet.GetFireData().SourceSpeed = newBullet.Speed;
                }
            }

            newBullet.GetFireData().SpeedInit = false;
            newBullet.Speed = bullet.GetFireData().SourceSpeed;

            //if(bullet.index == DISP_BULLET_INDEX) Debug.WriteLine(String.Format("Fire dir:{0} spd:{1} label:{2}", bullet.srcDir / Math.PI * 180, bullet.srcSpeed, refNode != null ? refNode.label : ""));
            //Debug.WriteLine("index({3}) Fire dir:{0} spd:{1} label:{2}", bullet.srcDir / Math.PI * 180, bullet.srcSpeed, refNode != null ? refNode.label : "", bullet.index);

            End = true;
            return BLRunStatus.End;
        }
Exemple #6
0
        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);
            }
        }