BulletMLLib.BulletMLTree.GetChildValue C# (CSharp) Метод

GetChildValue() публичный Метод

public GetChildValue ( BLName name, BulletMLTask task ) : float
name BLName
task BulletMLTask
Результат float
        public float GetChildValue(BLName name, BulletMLTask task)
        {
            foreach (BulletMLTree tree in children)
            {
                if (tree.name == name)
                    return tree.GetValue(task);
            }
            return 0;
        }

Usage Example

Пример #1
0
        public override BLRunStatus Run(BulletMLBullet bullet)
        {
            if (first)
            {
                first = false;
                term  = (int)node.GetChildValue(BLName.Term, this);
                if (node.type == BLType.Sequence)
                {
                    horizontalAccel = node.GetChildValue(BLName.Horizontal, this);
                    verticalAccel   = node.GetChildValue(BLName.Vertical, this);
                }
                else if (node.type == BLType.Relative)
                {
                    horizontalAccel = node.GetChildValue(BLName.Horizontal, this) / term;
                    verticalAccel   = node.GetChildValue(BLName.Vertical, this) / term;
                }
                else
                {
                    // spdX = (float)(bullet.speed * Math.Sin(bullet.Direction));
                    // spdY = (float)(bullet.speed * Math.Cos(bullet.Direction));
                    horizontalAccel = (node.GetChildValue(BLName.Horizontal, this) - bullet.spdX) / term;
                    verticalAccel   = (node.GetChildValue(BLName.Vertical, this) - bullet.spdY) / term;
                }
            }

            term--;
            if (term < 0)
            {
                end = true;
                return(BLRunStatus.End);
            }

            bullet.spdX += horizontalAccel;
            bullet.spdY += verticalAccel;

            //Debug.WriteLine(String.Format("accel spdX={0} spdY={1} verAcl={2} horAcl={3} term={4}", bullet.spdX, bullet.spdY, verticalAccel, horizontalAccel, term));

            /*
             * double speedX = bullet.speed * Math.Sin(bullet.Direction);
             * double speedY = bullet.speed * Math.Cos(bullet.Direction);
             * speedX += horizontalAccel;
             * speedY += verticalAccel;
             *
             * bullet.Direction = (float)Math.Atan2(speedX ,speedY);
             * bullet.speed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
             * //Debug.WriteLine("accel speed={0} dir={1} verAcl={2} horAcl={3} term={4}", bullet.speed, bullet.Direction / Math.PI * 180, verticalAccel, horizontalAccel, term); */
            return(BLRunStatus.Continue);
        }
All Usage Examples Of BulletMLLib.BulletMLTree::GetChildValue