Exemplo n.º 1
0
        //枝の途中からの初期化
        public void Init(BulletMLTree node)
        {
            BulletMLTask task = tasks[0];

            task.taskList.Clear();
            task.Parse(node, this);
            task.Init();
            this.tree = node;
        }
Exemplo n.º 2
0
 public BulletMLTree()
 {
     Children = new List<BulletMLTree>();
     Values = new List<BulletValue>();
     Parent = null;
     Next = null;
     #if ExpandedBulletML
     visible = true;
     bulletName = "";
     #endif
 }
Exemplo n.º 3
0
        public BulletMLTree()
        {
            Children = new List <BulletMLTree>();
            Values   = new List <BulletValue>();
            Parent   = null;
            Next     = null;
#if ExpandedBulletML
            visible    = true;
            bulletName = "";
#endif
        }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        public BulletMLTree GetLabelNode(string label, BLName name)
        {
            BulletMLTree rootNode = this;             //先頭までさかのぼる

            while (rootNode.parent != null)
            {
                rootNode = rootNode.parent;
            }

            foreach (BulletMLTree tree in rootNode.children)
            {
                if (tree.label == label && tree.name == name)
                {
                    return(tree);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        //木構造のトップからの初期化
        public void InitTop(BulletMLTree node)
        {
            //トップノードからの初期化
            this.tree = node;
            //task.taskList.Clear();
            //task.Parse(tree);
            //task.Init();

            BulletMLTree tree = node.GetLabelNode("top", BLName.Action);

            if (tree != null)
            {
                BulletMLTask task = tasks[0];
                task.taskList.Clear();
                task.Parse(tree, this);
                task.Init();
            }
            else
            {
                for (int i = 1; i < 10; i++)
                {
                    BulletMLTree tree2 = node.GetLabelNode("top" + i, BLName.Action);
                    if (tree2 != null)
                    {
                        if (i > 1)
                        {
                            tasks.Add(new BulletMLTask());
                            fireData.Add(new FireData());
                        }

                        BulletMLTask task = tasks[i - 1];
                        task.taskList.Clear();
                        task.Parse(tree2, this);
                        task.Init();
                    }
                }
            }
        }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
        //木構造のトップからの初期化
        public void InitTop(BulletMLTree node)
        {
            //トップノードからの初期化
            this.tree = node;
            //task.taskList.Clear();
            //task.Parse(tree);
            //task.Init();

            BulletMLTree tree = node.GetLabelNode("top", BLName.Action);
            if (tree != null)
            {
                BulletMLTask task = tasks[0];
                task.taskList.Clear();
                task.Parse(tree, this);
                task.Init();
            }
            else
            {
                for (int i = 1; i < 10; i++)
                {
                    BulletMLTree tree2 = node.GetLabelNode("top" + i, BLName.Action);
                    if (tree2 != null)
                    {
                        if (i > 1)
                        {
                            tasks.Add(new BulletMLTask());
                            fireData.Add(new FireData());
                        }

                        BulletMLTask task = tasks[i - 1];
                        task.taskList.Clear();
                        task.Parse(tree2, this);
                        task.Init();
                    }
                }
            }
        }
Exemplo n.º 9
0
 //枝の途中からの初期化
 public void Init(BulletMLTree node)
 {
     BulletMLTask task = tasks[0];
     task.taskList.Clear();
     task.Parse(node, this);
     task.Init();
     this.tree = node;
 }
Exemplo n.º 10
0
 public BulletMLAction(BulletMLTree node, int repeatNumMax)
 {
     this.node         = node;
     this.repeatNumMax = repeatNumMax;
 }
Exemplo n.º 11
0
 public BulletMLChangeDirection(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 12
0
 public BulletMLSetSpeed(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 13
0
 public BulletMLWait(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 14
0
 /// BulletMLの弾幕定義を自分にセット
 public void SetBullet(BulletMLTree tree)
 {
     mlBullet.InitTop(tree);
 }
Exemplo n.º 15
0
        //static void Main(string[] args)
        //{
        //    Random r = new Random();
        //    BulletMLSystem.Init(r);
        //    BulletMLParser parser = new BulletMLParser();
        //    parser.ParseXML("test.xml");
        //    BulletMLSrc mover = new BulletMLSrc(parser.tree);
        //    for (int i = 0; i < 200; i++)
        //    {
        //        mover.Update();
        //    }
        //    Debug.Write("\n--end--\n");
        //    Debug.Read();

        //}

        public void ParseXml(string xmlFileName)
        {
            //Debug.WriteLine(" ----- " + xmlFileName + " ----- ");
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ProhibitDtd = false;

            settings.ValidationType = ValidationType.DTD;
            XmlReader      reader = XmlReader.Create(xmlFileName, settings);
            BulletMLParser parser = new BulletMLParser();

            try
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        //Debug.Write("<" + reader.Name + ">\n");

                        BulletMLTree element = new BulletMLTree();
                        element.Name = parser.StringToName(reader.Name);
                        if (reader.HasAttributes)
                        {
                            element.Type  = parser.StringToType(reader.GetAttribute("type"));
                            element.Label = reader.GetAttribute("label");
#if ExpandedBulletML
                            element.visible    = reader.GetAttribute("visible") == "false" ? false : true;
                            element.bulletName = reader.GetAttribute("name");
#endif
                        }

                        if (Tree == null)
                        {
                            Tree = element;
                        }
                        else
                        {
                            Tree.Children.Add(element);
                            if (Tree.Children.Count > 1)
                            {
                                Tree.Children[Tree.Children.Count - 2].Next = Tree.Children[Tree.Children.Count - 1];
                            }

                            element.Parent = Tree;
                            if (!reader.IsEmptyElement)
                            {
                                Tree = element;
                            }
                        }

                        break;

                    case XmlNodeType.Text:     //Display the text in each element.

                        //Debug.WriteLine(reader.Value +"\n");

                        string line = reader.Value;
                        string word = "";
                        for (int i = 0; i < line.Length; i++)
                        {
                            if (('0' <= line[i] && line[i] <= '9') || line[i] == '.')
                            {
                                word = word + line[i];
                                if (i < line.Length - 1)     //まだ続きがあれば
                                {
                                    continue;
                                }
                            }

                            if (word != "")
                            {
                                float num;
                                if (float.TryParse(word, out num))
                                {
                                    Tree.Values.Add(new BulletValue(BLValueType.Number, num));
                                    word = "";
                                    //Debug.WriteLine("数値を代入" + num);
                                }
                                else
                                {
                                    //Debug.WriteLine("構文にエラーがあります : " + line[i]);
                                }
                            }

                            if (line[i] == '$')
                            {
                                if (line[i + 1] >= '0' && line[i + 1] <= '9')
                                {
                                    Tree.Values.Add(new BulletValue(BLValueType.Param, Convert.ToInt32(line[i + 1].ToString())));
                                    i++;
                                    //Debug.WriteLine("パラメータを代入");
                                }
                                else if (line.Substring(i, 5) == "$rank")
                                {
                                    //Debug.WriteLine("ランクを代入");
                                    i += 4;
                                    Tree.Values.Add(new BulletValue(BLValueType.Rank, 0));
                                }
                                else if (line.Substring(i, 5) == "$rand")
                                {
                                    //Debug.WriteLine("Randを代入");
                                    i += 4;
                                    Tree.Values.Add(new BulletValue(BLValueType.Rand, 0));
                                }
                            }
                            else if (line[i] == '*' || line[i] == '/' || line[i] == '+' || line[i] == '-' || line[i] == '(' || line[i] == ')')
                            {
                                Tree.Values.Add(new BulletValue(BLValueType.Operator, line[i]));
                                //Debug.WriteLine("演算子を代入 " + line[i]);
                            }
                            else if (line[i] == ' ' || line[i] == '\n')
                            {
                            }
                            else
                            {
                                //Debug.WriteLine("構文にエラーがあります : " + line[i]);
                            }
                        }

                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (Tree.Parent != null)
                        {
                            Tree = Tree.Parent;
                        }

                        //Debug.Write("</" + reader.Name + ">\n");
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                reader.Close();
            }

            //Debug.WriteLine("\n-------------end-----------------");
        }
Exemplo n.º 16
0
 public BulletMLChangeSpeed(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 17
0
 public BulletMLChangeDirection(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 18
0
        //static void Main(string[] args)
        //{
        //    Random r = new Random();
        //    BulletMLSystem.Init(r);
        //    BulletMLParser parser = new BulletMLParser();
        //    parser.ParseXML("test.xml");
        //    BulletMLSrc mover = new BulletMLSrc(parser.tree);
        //    for (int i = 0; i < 200; i++)
        //    {
        //        mover.Update();
        //    }
        //    Debug.Write("\n--end--\n");
        //    Debug.Read();
        //}
        public void ParseXml(string xmlFileName)
        {
            //Debug.WriteLine(" ----- " + xmlFileName + " ----- ");
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ProhibitDtd = false;

            settings.ValidationType = ValidationType.DTD;
            XmlReader reader = XmlReader.Create(xmlFileName, settings);
            BulletMLParser parser = new BulletMLParser();

            try
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element: // The node is an element.
                            //Debug.Write("<" + reader.Name + ">\n");

                            BulletMLTree element = new BulletMLTree();
                            element.Name = parser.StringToName(reader.Name);
                            if (reader.HasAttributes)
                            {
                                element.Type = parser.StringToType(reader.GetAttribute("type"));
                                element.Label = reader.GetAttribute("label");
            #if ExpandedBulletML
                                element.visible = reader.GetAttribute("visible") == "false" ? false : true;
                                element.bulletName = reader.GetAttribute("name");
            #endif
                            }

                            if (Tree == null)
                                Tree = element;
                            else
                            {
                                Tree.Children.Add(element);
                                if (Tree.Children.Count > 1)
                                    Tree.Children[Tree.Children.Count - 2].Next = Tree.Children[Tree.Children.Count - 1];

                                element.Parent = Tree;
                                if (!reader.IsEmptyElement)
                                    Tree = element;
                            }

                            break;

                        case XmlNodeType.Text: //Display the text in each element.

                            //Debug.WriteLine(reader.Value +"\n");

                            string line = reader.Value;
                            string word = "";
                            for (int i = 0; i < line.Length; i++)
                            {
                                if (('0' <= line[i] && line[i] <= '9') || line[i] == '.')
                                {
                                    word = word + line[i];
                                    if (i < line.Length - 1) //まだ続きがあれば
                                        continue;
                                }

                                if (word != "")
                                {
                                    float num;
                                    if (float.TryParse(word, out num))
                                    {
                                        Tree.Values.Add(new BulletValue(BLValueType.Number, num));
                                        word = "";
                                        //Debug.WriteLine("数値を代入" + num);
                                    }
                                    else
                                    {
                                        //Debug.WriteLine("構文にエラーがあります : " + line[i]);
                                    }
                                }

                                if (line[i] == '$')
                                {
                                    if (line[i + 1] >= '0' && line[i + 1] <= '9')
                                    {
                                        Tree.Values.Add(new BulletValue(BLValueType.Param, Convert.ToInt32(line[i + 1].ToString())));
                                        i++;
                                        //Debug.WriteLine("パラメータを代入");
                                    }
                                    else if (line.Substring(i, 5) == "$rank")
                                    {
                                        //Debug.WriteLine("ランクを代入");
                                        i += 4;
                                        Tree.Values.Add(new BulletValue(BLValueType.Rank, 0));
                                    }
                                    else if (line.Substring(i, 5) == "$rand")
                                    {
                                        //Debug.WriteLine("Randを代入");
                                        i += 4;
                                        Tree.Values.Add(new BulletValue(BLValueType.Rand, 0));
                                    }
                                }
                                else if (line[i] == '*' || line[i] == '/' || line[i] == '+' || line[i] == '-' || line[i] == '(' || line[i] == ')')
                                {
                                    Tree.Values.Add(new BulletValue(BLValueType.Operator, line[i]));
                                    //Debug.WriteLine("演算子を代入 " + line[i]);
                                }
                                else if (line[i] == ' ' || line[i] == '\n')
                                {
                                }
                                else
                                {
                                    //Debug.WriteLine("構文にエラーがあります : " + line[i]);
                                }
                            }

                            break;
                        case XmlNodeType.EndElement: //Display the end of the element.
                            if (Tree.Parent != null)
                                Tree = Tree.Parent;

                            //Debug.Write("</" + reader.Name + ">\n");
                            break;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                reader.Close();
            }

            //Debug.WriteLine("\n-------------end-----------------");
        }
Exemplo n.º 19
0
 public BulletMLAction(BulletMLTree node, int repeatNumMax)
 {
     this.node = node;
     this.repeatNumMax = repeatNumMax;
 }
Exemplo n.º 20
0
 public BulletMLSetDirection(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 21
0
 public BulletMLChangeSpeed(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 22
0
 public BulletMLSetDirection(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 23
0
        // BulletMLTreeの内容を元に、実行のための各種クラスを生成し、自身を初期化する
        public void Parse(BulletMLTree tree, BulletMLBullet bullet)
        {
            foreach (BulletMLTree node in tree.Children)
            {
                // Action
                if (node.Name == BLName.Repeat)
                {
                    Parse(node, bullet);
                }
                else if (node.Name == BLName.Action)
                {
                    ////Debug.WriteLine("Action");
                    int repeatNum = 1;
                    if (node.Parent.Name == BLName.Repeat)
                    {
                        repeatNum = (int)node.Parent.GetChildValue(BLName.Times, this);
                    }
                    BulletMLAction task = new BulletMLAction(node, repeatNum);
                    task.Owner = this;
                    TaskList.Add(task);
                    task.Parse(node, bullet);
                }
                else if (node.Name == BLName.ActionRef)
                {
                    BulletMLTree refNode   = tree.GetLabelNode(node.Label, BLName.Action);
                    int          repeatNum = 1;
                    if (node.Parent.Name == BLName.Repeat)
                    {
                        repeatNum = (int)node.Parent.GetChildValue(BLName.Times, this);
                    }
                    BulletMLAction task = new BulletMLAction(refNode, repeatNum);
                    task.Owner = this;
                    TaskList.Add(task);

                    // パラメータを取得
                    for (int i = 0; i < node.Children.Count; i++)
                    {
                        task.ParamList.Add(node.Children[i].GetValue(this));
                    }
                    //if (node.children.Count > 0)
                    //{
                    //    task.paramNode = node;
                    //}

                    task.Parse(refNode, bullet);
                }
                else if (node.Name == BLName.ChangeSpeed)
                {
                    BulletMLChangeSpeed blChangeSpeed = new BulletMLChangeSpeed(node);
                    blChangeSpeed.Owner = this;
                    TaskList.Add(blChangeSpeed);
                    ////Debug.WriteLine("ChangeSpeed");
                }
                else if (node.Name == BLName.ChangeDirection)
                {
                    BulletMLChangeDirection blChangeDir = new BulletMLChangeDirection(node);
                    blChangeDir.Owner = this;
                    TaskList.Add(blChangeDir);
                    ////Debug.WriteLine("ChangeDirection");
                }
                else if (node.Name == BLName.Fire)
                {
                    if (TaskList == null)
                    {
                        TaskList = new List <BulletMLTask>();
                    }
                    BulletMLFire fire = new BulletMLFire(node);
                    fire.Owner = this;
                    TaskList.Add(fire);
                }
                else if (node.Name == BLName.FireRef)
                {
                    if (TaskList == null)
                    {
                        TaskList = new List <BulletMLTask>();
                    }
                    BulletMLTree refNode = tree.GetLabelNode(node.Label, BLName.Fire);
                    BulletMLFire fire    = new BulletMLFire(refNode);
                    fire.Owner = this;
                    TaskList.Add(fire);
                    // パラメータを取得
                    //if (node.children.Count > 0)
                    //{
                    //    fire.paramNode = node;
                    //}
                    for (int i = 0; i < node.Children.Count; i++)
                    {
                        fire.ParamList.Add(node.Children[i].GetValue(this));
                    }
                }
                else if (node.Name == BLName.Wait)
                {
                    BulletMLWait wait = new BulletMLWait(node);
                    wait.Owner = this;
                    TaskList.Add(wait);
                }
                else if (node.Name == BLName.Speed)
                {
                    //BulletMLSetSpeed task = new BulletMLSetSpeed(node);
                    //task.owner = this;
                    //taskList.Add(task);
                    bullet.GetFireData().SpeedInit = true; // 値を明示的にセットしたことを示す
                    bullet.Speed = node.GetValue(this);
                }
                else if (node.Name == BLName.Direction)
                {
                    BulletMLSetDirection task = new BulletMLSetDirection(node);
                    task.Owner = this;
                    TaskList.Add(task);
                }
                else if (node.Name == BLName.Vanish)
                {
                    BulletMLVanish task = new BulletMLVanish();
                    task.Owner = this;
                    TaskList.Add(task);
                }
                else if (node.Name == BLName.Accel)
                {
                    BulletMLAccel task = new BulletMLAccel(node);
                    task.Owner = this;
                    TaskList.Add(task);
                }
                else
                {
                    ////Debug.WriteLine("node.name:{0}", node.name);
                }
            }
        }
Exemplo n.º 24
0
        //BulletMLTreeの内容を元に、実行のための各種クラスを生成し、自身を初期化する
        public void Parse(BulletMLTree tree, BulletMLBullet bullet)
        {
            foreach (BulletMLTree node in tree.children)
            {
                // Action
                if (node.name == BLName.Repeat)
                {
                    Parse(node, bullet);
                }
                else if (node.name == BLName.Action)
                {
                    ////Debug.WriteLine("Action");
                    int repeatNum = 1;
                    if (node.parent.name == BLName.Repeat)
                        repeatNum = (int)node.parent.GetChildValue(BLName.Times, this);
                    BulletMLAction task = new BulletMLAction(node, repeatNum);
                    task.owner = this;
                    taskList.Add(task);
                    task.Parse(node, bullet);
                }
                else if (node.name == BLName.ActionRef)
                {
                    BulletMLTree refNode = tree.GetLabelNode(node.label, BLName.Action);
                    int repeatNum = 1;
                    if (node.parent.name == BLName.Repeat)
                        repeatNum = (int)node.parent.GetChildValue(BLName.Times, this);
                    BulletMLAction task = new BulletMLAction(refNode, repeatNum);
                    task.owner = this;
                    taskList.Add(task);

                    // パラメータを取得
                    for (int i = 0; i < node.children.Count; i++)
                    {
                        task.paramList.Add(node.children[i].GetValue(this));
                    }
                    //if (node.children.Count > 0)
                    //{
                    //    task.paramNode = node;
                    //}

                    task.Parse(refNode, bullet);
                }
                else if (node.name == BLName.ChangeSpeed)
                {
                    BulletMLChangeSpeed blChangeSpeed = new BulletMLChangeSpeed(node);
                    blChangeSpeed.owner = this;
                    taskList.Add(blChangeSpeed);
                    ////Debug.WriteLine("ChangeSpeed");
                }
                else if (node.name == BLName.ChangeDirection)
                {
                    BulletMLChangeDirection blChangeDir = new BulletMLChangeDirection(node);
                    blChangeDir.owner = this;
                    taskList.Add(blChangeDir);
                    ////Debug.WriteLine("ChangeDirection");
                }
                else if (node.name == BLName.Fire)
                {
                    if (taskList == null) taskList = new List<BulletMLTask>();
                    BulletMLFire fire = new BulletMLFire(node);
                    fire.owner = this;
                    taskList.Add(fire);
                }
                else if (node.name == BLName.FireRef)
                {
                    if (taskList == null) taskList = new List<BulletMLTask>();
                    BulletMLTree refNode = tree.GetLabelNode(node.label, BLName.Fire);
                    BulletMLFire fire = new BulletMLFire(refNode);
                    fire.owner = this;
                    taskList.Add(fire);
                    // パラメータを取得
                    //if (node.children.Count > 0)
                    //{
                    //    fire.paramNode = node;
                    //}
                    for (int i = 0; i < node.children.Count; i++)
                    {
                        fire.paramList.Add(node.children[i].GetValue(this));
                    }
                }
                else if (node.name == BLName.Wait)
                {
                    BulletMLWait wait = new BulletMLWait(node);
                    wait.owner = this;
                    taskList.Add(wait);
                }
                else if (node.name == BLName.Speed)
                {
                    //BulletMLSetSpeed task = new BulletMLSetSpeed(node);
                    //task.owner = this;
                    //taskList.Add(task);
                    bullet.GetFireData().speedInit = true; // 値を明示的にセットしたことを示す
                    bullet.Speed = node.GetValue(this);
                }
                else if (node.name == BLName.Direction)
                {
                    BulletMLSetDirection task = new BulletMLSetDirection(node);
                    task.owner = this;
                    taskList.Add(task);
                }
                else if (node.name == BLName.Vanish)
                {
                    BulletMLVanish task = new BulletMLVanish();
                    task.owner = this;
                    taskList.Add(task);
                }
                else if (node.name == BLName.Accel)
                {
                    BulletMLAccel task = new BulletMLAccel(node);
                    task.owner = this;
                    taskList.Add(task);
                }
                else
                {
                    ////Debug.WriteLine("node.name:{0}", node.name);
                }
            }
        }
Exemplo n.º 25
0
 public BulletMLSetSpeed(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 26
0
 public BulletMLAccel(BulletMLTree node)
 {
     this.node = node;
 }
Exemplo n.º 27
0
 public BulletMLWait(BulletMLTree node)
 {
     this.node = node;
 }