コード例 #1
0
ファイル: Map.cs プロジェクト: sugar10w/NumberHero
        public void AttackAction(Stnum stnum)
        {
            Player pl = game.nowPlayer;

            for (int i = 0; i < MapX; ++i)
                for (int j = 0; j < MapY; ++j) bo[i, j] = false;

            if (!pl.AttackAction(stnum, bo))
            {
                pl.AddHealth(stnum.n);
                game.alg.ClearAlg();
                game.WaitAttacking = false;
                return;
            }

            for (int i = 0; i < MapX; ++i)
                for (int j = 0; j < MapY; ++j)
                    if (bo[i, j])
                        for (int k=0;k<game.cntPlayer;++k)
                            if (game.player[k].X==i&&game.player[k].Y==j&&game.player[k].Alive)
                                cmd[i, j].Appear(game.player[k].HP.ToString(), i, j);
            bo[pl.X, pl.Y] = true;
            cmd[pl.X, pl.Y].Appear("["+stnum.n.ToString()+"]", pl.X, pl.Y, 0, 200, Mover.colorA, 50);

            Resize(2);
        }
コード例 #2
0
        public bool AttackAction(Stnum stnum, bool[,] bo)
        {
            Atn = stnum.n;

            int    a = 0, b = 0, c = 0, d = 0;
            string st = stnum.st;

            for (int i = 0; i < st.Length; ++i)
            {
                switch (st[i])
                {
                case '+': ++a; break;

                case '-': ++b; break;

                case '*': ++c; break;

                case '/': ++d; break;
                }
            }

            //       if (b != 0) ++a;
            //       if (d != 0) ++c;
            a += b;
            c += d;
            if (a < c)
            {
                a = c;
            }

            bool flag = false;

            for (int i = 0; i < game.cntPlayer; ++i)
            {
                if (i != PlayerID)
                {
                    Player e = game.player[i];
                    if (!e.canAttack)
                    {
                        continue;
                    }
                    if (e.X == X && Math.Abs(e.Y - Y) <= a)
                    {
                        flag = true; bo[e.X, e.Y] = true;
                    }
                    if (e.Y == Y && Math.Abs(e.X - X) <= a)
                    {
                        flag = true; bo[e.X, e.Y] = true;
                    }
                    if (Math.Abs(e.X - X) <= c && Math.Abs(e.X - X) == Math.Abs(e.Y - Y))
                    {
                        flag = true; bo[e.X, e.Y] = true;
                    }
                }
            }

            //    bo[X, Y] = true;

            return(flag);
        }
コード例 #3
0
ファイル: Alg.cs プロジェクト: karma19350/NumberHero
        void AttackAction(Stnum stnum, int[] d)
        {
            int j = 0, i;

            for (i = 0; i < 10; ++i)
            {
                for (; j < stnum.st.Length; ++j)
                {
                    if (d[i] != -1 && num[d[i]].str[0] == stnum.st[j])
                    {
                        num[d[i]].MoveTo(num[d[i]].str, 200 + j);
                        ++j;
                        break;
                    }
                }
            }

            i = 0;
            for (j = 0; j < stnum.st.Length; ++j)
            {
                if (stnum.st[j] > '9' || stnum.st[j] < '0')
                {
                    opr[i].Appear(stnum.st[j].ToString(), 200 + j);
                    ++i;
                }
            }
            Am.SetTo(new Point(0, Form1.H));

            game.map.AttackAction(stnum);
        }
コード例 #4
0
ファイル: Calc.cs プロジェクト: sugar10w/NumberHero
        public static Stnum CheckAttack(string s,bool full=true)
        {
            int ttt = 0;
            const string p = " +-*/";
            string st = "";
            int l = 0, pl = p.Length;
            int cnt = 0;
            double max = Math.Pow((double)pl, (int)(s.Length - 1));
            Stnum best = new Stnum("", -1);

            for (int x0 = 0; x0 < max; ++x0)
            {
                ++ttt; if (!full && ttt > stop) break;

                int x = x0;
                st = "";
                for (int j = 0; j < s.Length; ++j)
                {
                    st += s[j]; ++l;
                    if (j != s.Length - 1) st += p[x % pl]; ++l;
                    x /= pl;
                }

                int i;
                for (i = st.Length - 2; i > 0; i -= 2) if (st[i] != ' ') break;

                if (i < 1) i = 1;
                for (; i < st.Length; i += 2)
                {
                    if (st[i] == ' ')
                    {
                        string stt = "";
                        stt = st.Substring(0, i) + "=" + st.Substring(i + 1, st.Length - i - 1);

                        Stnum stn = CheckEqual(stt);

                        if (stn.n > 0)
                        {
                            if (stn.n > best.n) best = stn;
                            ++cnt;
                            if (cnt > 20) return best;
                        }
                    }
                }
            }

            return best;
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: sugar10w/NumberHero
        public bool AttackAction(Stnum stnum,bool[,] bo)
        {
            Atn = stnum.n;

            int a = 0, b = 0, c = 0, d = 0;
            string st = stnum.st;
            for (int i = 0; i < st.Length; ++i)
            {
                switch (st[i])
                {
                    case '+': ++a; break;
                    case '-': ++b; break;
                    case '*': ++c; break;
                    case '/': ++d; break;
                }
            }

             //       if (b != 0) ++a;
             //       if (d != 0) ++c;
            a += b;
            c += d;
            if (a < c) a = c;

            bool flag = false;

            for (int i = 0; i < game.cntPlayer; ++i)
                if (i != PlayerID)
                {
                    Player e = game.player[i];
                    if (!e.canAttack) continue;
                    if (e.X == X && Math.Abs(e.Y - Y) <= a)
                    { flag = true; bo[e.X, e.Y] = true; }
                    if (e.Y == Y && Math.Abs(e.X - X) <= a)
                    { flag = true; bo[e.X, e.Y] = true; }
                    if (Math.Abs(e.X - X) <= c && Math.Abs(e.X - X) == Math.Abs(e.Y - Y))
                    { flag = true; bo[e.X, e.Y] = true; }
                }

            //    bo[X, Y] = true;

            return flag;
        }
コード例 #6
0
ファイル: Map.cs プロジェクト: karma19350/NumberHero
        public void AttackAction(Stnum stnum)
        {
            Player pl = game.nowPlayer;

            for (int i = 0; i < MapX; ++i)
            {
                for (int j = 0; j < MapY; ++j)
                {
                    bo[i, j] = false;
                }
            }

            if (!pl.AttackAction(stnum, bo))
            {
                pl.AddHealth(stnum.n);
                game.alg.ClearAlg();
                game.WaitAttacking = false;
                return;
            }

            for (int i = 0; i < MapX; ++i)
            {
                for (int j = 0; j < MapY; ++j)
                {
                    if (bo[i, j])
                    {
                        for (int k = 0; k < game.cntPlayer; ++k)
                        {
                            if (game.player[k].X == i && game.player[k].Y == j && game.player[k].Alive)
                            {
                                cmd[i, j].Appear(game.player[k].HP.ToString(), i, j);
                            }
                        }
                    }
                }
            }
            bo[pl.X, pl.Y] = true;
            cmd[pl.X, pl.Y].Appear("[" + stnum.n.ToString() + "]", pl.X, pl.Y, 0, 200, Mover.colorA, 50);

            Resize(2);
        }
コード例 #7
0
        static public Stnum CheckAttack(string s, bool full = true)
        {
            int          ttt = 0;
            const string p = " +-*/";
            string       st = "";
            int          l = 0, pl = p.Length;
            int          cnt  = 0;
            double       max  = Math.Pow((double)pl, (int)(s.Length - 1));
            Stnum        best = new Stnum("", -1);

            for (int x0 = 0; x0 < max; ++x0)
            {
                ++ttt; if (!full && ttt > stop)
                {
                    break;
                }

                int x = x0;
                st = "";
                for (int j = 0; j < s.Length; ++j)
                {
                    st += s[j]; ++l;
                    if (j != s.Length - 1)
                    {
                        st += p[x % pl];
                    }
                    ++l;
                    x /= pl;
                }

                int i;
                for (i = st.Length - 2; i > 0; i -= 2)
                {
                    if (st[i] != ' ')
                    {
                        break;
                    }
                }

                if (i < 1)
                {
                    i = 1;
                }
                for (; i < st.Length; i += 2)
                {
                    if (st[i] == ' ')
                    {
                        string stt = "";
                        stt = st.Substring(0, i) + "=" + st.Substring(i + 1, st.Length - i - 1);

                        Stnum stn = CheckEqual(stt);

                        if (stn.n > 0)
                        {
                            if (stn.n > best.n)
                            {
                                best = stn;
                            }
                            ++cnt;
                            if (cnt > 20)
                            {
                                return(best);
                            }
                        }
                    }
                }
            }

            return(best);
        }