Example #1
0
            public multi(string line)
            {
                //先分割成多個 basic
                string[] parts = line.Split(';');
                basics = new IRunnable[parts.Length];

                //然後就每一個 basic 進行分類
                for (int i = 0; i < parts.Length; i++)
                {
                    if (IsComment(parts[i]))
                    {
                        basics[i] = new empty();
                    }
                    else if (IsTerm(parts[i]))
                    {
                        basics[i] = new term(parts[i].Trim());
                    }
                    else if (IsExec(parts[i]))
                    {
                        basics[i] = new exec(parts[i].Trim());
                    }
                    else
                    {
                        basics[i] = new decla(parts[i].Trim());
                    }
                }
            }
Example #2
0
    /// При прыжке игрока сверху - получаем урон, при встрече с пулей - получаем урон
    /// при встрече с "пустым объектом" - разворачиваемся
    protected override void OnTriggerEnter2D(Collider2D collider)
    {
        Unit unit = collider.GetComponent <Unit>();

        if (unit && unit is Character)
        {
            if (Mathf.Abs(unit.transform.position.x - transform.position.x) < 0.3F)
            {
                ReceiveDamage();
            }
            else
            {
                unit.ReceiveDamage();
            }
        }

        Bullet bullet = collider.GetComponent <Bullet>();

        if (bullet)
        {
            ReceiveDamage();
        }

        empty empty = collider.GetComponent <empty>();

        if (empty)
        {
            direction   *= -1.0F;
            sprite.flipX = !sprite.flipX;
        }
    }
Example #3
0
        private void start_the_game()
        {
            Int32.TryParse(textBox1.Text, out wc); hc = wc;
            w    = ww / wc;
            h    = hw / hc;
            dots = new dot[wc, hc];
            Random rand = new Random(69);

            for (int x = 0; x < wc; x++)
            {
                for (int y = 0; y < hc; y++)
                {
                    int n = rand.Next(0, 100);
                    if (n < fullness)
                    {
                        dots[x, y] = new bomb();
                    }
                    else
                    {
                        dots[x, y] = new empty();
                    }
                }
            }
            for (int x = 0; x < wc; x++)
            {
                for (int y = 0; y < hc; y++)
                {
                    if (dots[x, y].tp != type.bomb)
                    {
                        int count = 0;
                        for (int x1 = -1; x1 <= 1; x1++)
                        {
                            for (int y1 = -1; y1 <= 1; y1++)
                            {
                                if (x + x1 < 0 || y + y1 < 0 || y + y1 >= hc || x + x1 >= wc)
                                {
                                    continue;
                                }
                                if (dots[x + x1, y + y1].tp == type.bomb)
                                {
                                    count++;
                                }
                            }
                        }
                        if (count == 0)
                        {
                            dots[x, y] = new empty();
                        }
                        else
                        {
                            dots[x, y] = new num(count);
                        }
                    }
                }
            }
            this.Controls.Clear();
            form = state.game;
            Invalidate();
        }
Example #4
0
        public void TestEmptyClass()
        {
            empty[]           a  = new empty[] { new empty(), new empty(), new empty() };
            CompactSerializer cs = new CompactSerializer();
            string            d  = cs.Serialize(a);

            Assert.AreEqual(3, cs.Deserialize <empty[]>(d).Length);
        }
Example #5
0
    /// <summary>
    /// атака фигур
    /// </summary>
    public void AttackFigure()
    {
        empty empt = new empty();

        if (board[second_z, second_x].figure_name == "king")
        {
            Application.LoadLevel("End");
        }

        board[second_z, second_x] = empt;
        MoveFigure();
    }
Example #6
0
            //嘗試解析, 成功回傳 true, 並作成執行物件輸出到 obj
            //失敗回傳 false, obj 返回 null
            static public bool TryParse(string ln, out IRunnable obj)
            {
                //先把多餘的空白去掉
                string line = ln.Trim();

                //如果是空行就回傳一個空物件
                if (line.Trim() == "")
                {
                    obj = new empty();
                    return(true);
                }

                //從上層結構開始檢查, 這樣就保証層級關係的正確性
                //Parsing should begin from large scale structure to small scale structure
                //in order to ensure correct priority

                //單行指令可以是 loop, cond 或 multi
                if (IsLoop(line))
                {
                    obj = new loop(line);
                    return(true);
                }

                if (IsCond(line))
                {
                    obj = new cond(line);
                    return(true);
                }

                if (IsMulti(line))
                {
                    obj = new multi(line);
                    return(true);
                }


                obj = null;
                return(false);
            }
        public override Task <ListMhs> GetListMahasiswa(empty request, ServerCallContext context)
        {
            ListMahasiswa    Res       = new ListMahasiswa();
            List <Mahasiswa> mahasiswa = new List <Mahasiswa>();

            Res = home.GetListMahasiswa();

            foreach (var data in Res.mahasiswa)
            {
                Mahasiswa mhs = new Mahasiswa();
                mhs.Nama      = data.nama;
                mhs.Asal      = data.asal;
                mhs.Nim       = data.nim;
                mhs.Datebirth = data.datebirth;

                mahasiswa.Add(mhs);
            }
            var rslt = new ListMhs
            {
                Mahasiswa = { mahasiswa }
            };

            return(Task.FromResult(rslt));
        }
Example #8
0
            //嘗試解析, 成功回傳 true, 並作成執行物件輸出到 obj
            //失敗回傳 false, obj 返回 null
            public static bool TryParse(string ln, out IRunnable obj)
            {
                //先把多餘的空白去掉
                string line = ln.Trim();

                //如果是空行就回傳一個空物件
                if (line.Trim() == "")
                {
                    obj = new empty();
                    return true;
                }

                //從上層結構開始檢查, 這樣就保証層級關係的正確性
                //Parsing should begin from large scale structure to small scale structure
                //in order to ensure correct priority

                //單行指令可以是 loop, cond 或 multi
                if (IsLoop(line))
                {
                    obj = new loop(line);
                    return true;
                }

                if (IsCond(line))
                {
                    obj = new cond(line);
                    return true;
                }

                if (IsMulti(line))
                {
                    obj = new multi(line);
                    return true;
                }

                obj = null;
                return false;
            }
Example #9
0
            public multi(string line)
            {
                //先分割成多個 basic
                string[] parts = line.Split(';');
                basics = new IRunnable[parts.Length];

                //然後就每一個 basic 進行分類
                for (int i = 0; i < parts.Length; i++)
                {
                    if (IsComment(parts[i]))
                    {
                        basics[i] = new empty();
                    }
                    else if (IsTerm(parts[i]))
                    {
                        basics[i] = new term(parts[i].Trim());
                    }
                    else if (IsExec(parts[i]))
                    {
                        basics[i] = new exec(parts[i].Trim());
                    }
                    else
                    {
                        basics[i] = new decla(parts[i].Trim());
                    }
                }
            }
Example #10
0
    /// <summary>
    /// заполняем доску
    /// </summary>
    void filing_table()
    {
        for (int i = 0; i < 8; i++) // заполнение всей доски пустыми значениями
        {
            for (int j = 0; j < 8; j++)
            {
                empty emp = new empty();
                emp.figure_name = emp.name;
                board[i, j]     = emp;
            }
        }

        for (int i = 0; i < 8; i++) // заполнение первой строки белыми пешками
        {
            pawn pn = new pawn();
            pn.colors_of_figure = 0;
            pn.figure_name      = pn.name;
            pn.direction        = false;
            board[1, i]         = pn;
        }


        rook rk = new rook();

        rk.colors_of_figure = 0;    // белые ладьи
        rk.figure_name      = rk.name;
        board[0, 0]         = rk;
        board[0, 7]         = rk;


        rook rk_black = new rook();

        rk_black.colors_of_figure = 1;    // чёрные ладьи
        rk_black.figure_name      = rk_black.name;
        board[7, 0] = rk_black;
        board[7, 7] = rk_black;



        knight kn = new knight();

        kn.colors_of_figure = 0;    // белые кони
        kn.figure_name      = kn.name;
        board[0, 1]         = kn;
        board[0, 6]         = kn;

        knight kn_black = new knight();

        kn_black.colors_of_figure = 1;    // черные кони
        kn_black.figure_name      = kn_black.name;
        board[7, 1] = kn_black;
        board[7, 6] = kn_black;



        bishop bs = new bishop();

        bs.colors_of_figure = 0;    // белые слоны
        bs.figure_name      = bs.name;
        board[0, 2]         = bs;
        board[0, 5]         = bs;

        bishop bs_black = new bishop();

        bs_black.colors_of_figure = 1;    // черные слоны
        bs_black.figure_name      = bs_black.name;
        board[7, 2] = bs_black;
        board[7, 5] = bs_black;

        queen q = new queen();   // белая королева

        q.colors_of_figure = 0;
        q.figure_name      = q.name;
        board[0, 3]        = q;

        queen q_black = new queen();     // черная королева

        q_black.colors_of_figure = 1;
        q_black.figure_name      = q_black.name;
        board[7, 3] = q_black;

        king kg = new king();

        kg.colors_of_figure = 0;    // белый король
        kg.figure_name      = kg.name;
        board[0, 4]         = kg;

        king kg_black = new king();

        kg_black.colors_of_figure = 1;    // черный король
        kg_black.figure_name      = kg_black.name;
        board[7, 4] = kg_black;


        for (int i = 0; i < 8; i++) // заполнение 7ой строки черными пешками
        {
            pawn pn = new pawn();
            pn.colors_of_figure = 1;
            pn.figure_name      = pn.name;
            pn.direction        = true;
            board[6, i]         = pn;
        }
    }