Example #1
0
    public List <KomaMove> GetMotigomaMoves(KomaScript sc, bool reverse = false)
    {
        List <KomaMove> moves   = new List <KomaMove> ();
        MasuManager     manager = MasuManager.Instance;
        int             ymin    = 1;
        int             ymax    = 9;

        if (reverse)
        {
            ymax = 8;
        }
        else
        {
            ymin = 2;
        }
        for (int x = 1; x <= 9; x++)
        {
            bool nifuFlag = false;
            for (int y = ymin; y <= ymax; y++)
            {
                MasuInit masu = manager.GetMasu(x, y);
                // 味方側
                if (!reverse && masu.komaName.Equals(KomaConst.komaFu))
                {
                    nifuFlag = true;
                    break;
                    // 敵側
                }
                else if (reverse && masu.komaName.Equals(KomaConst.komaFu2))
                {
                    nifuFlag = true;
                    break;
                }
            }
            if (!nifuFlag)
            {
                for (int y = ymin; y <= ymax; y++)
                {
                    MasuInit masu = manager.GetMasu(x, y);
                    // 敵味方の駒がいないとき
                    if (!masu.exists)
                    {
                        KomaMove move = new KomaMove();
                        move.x = x;
                        move.y = y;
                        moves.Add(move);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
        return(moves);
    }
Example #2
0
    public List <KomaMove> GetMoves(KomaScript sc, bool reverse = false)
    {
        int reversenum = 1;

        if (reverse)
        {
            reversenum = -1;
        }
        List <KomaMove> moves   = new List <KomaMove>();
        MasuManager     manager = MasuManager.Instance;

        int[] xs = { 0, -1, -1, 0, 1, 1 };
        int[] ys = { 1, 0, -1, -1, -1, 0 };
        int   i  = 0;

        foreach (int x in xs)
        {
            int      y    = ys [i];
            MasuInit masu = manager.GetMasu(sc.x + x, sc.y + y * reversenum);
            if (masu.selfFlag != sc.selfFlag || masu.enemyFlag != sc.enemyFlag)
            {
                KomaMove move = new KomaMove();
                move.x = x;
                move.y = y * reversenum;
                moves.Add(move);
            }
            i++;
        }
        return(moves);
    }
Example #3
0
    public List <KomaMove> GetMotigomaMoves(KomaScript sc)
    {
        List <KomaMove> moves   = new List <KomaMove> ();
        MasuManager     manager = MasuManager.Instance;

        for (int x = 1; x <= 9; x++)
        {
            for (int y = 1; y <= 9; y++)
            {
                MasuInit masu = manager.GetMasu(x, y);
                // 敵味方の駒がいないとき
                if (!masu.exists)
                {
                    KomaMove move = new KomaMove();
                    move.x = x;
                    move.y = y;
                    moves.Add(move);
                }
                else
                {
                    continue;
                }
            }
        }
        return(moves);
    }
Example #4
0
    public void EmptyKoma()
    {
        MasuManager manager = MasuManager.Instance;

        for (int y = 1; y <= 9; y++)
        {
            for (int x = 1; x <= 9; x++)
            {
                MasuInit masu = manager.GetMasu(x, y);
                if (masu.exists)
                {
                    DestroyKomaObj(masu.objName);
                }
            }
        }
    }
Example #5
0
    public void RefreshKoma()
    {
        MasuManager manager = MasuManager.Instance;

        for (int y = 1; y <= 9; y++)
        {
            for (int x = 1; x <= 9; x++)
            {
                MasuInit masu = manager.GetMasu(x, y);
                if (masu.exists)
                {
                    string objName = CreateKomaObj(masu.komaName, x, y);
                    manager.UpdMasuObjNameByXAndY(objName, x, y);
                }
            }
        }
    }
Example #6
0
    public List <KomaMove> GetMoves(KomaScript sc, bool reverse = false)
    {
        int reversenum = 1;

        if (reverse)
        {
            reversenum = -1;
        }
        List <KomaMove> moves   = new List <KomaMove> ();
        MasuManager     manager = MasuManager.Instance;

        for (int i = 1; i <= 8; i++)
        {
            MasuInit masu = manager.GetMasu(sc.x, sc.y + -1 * i * reversenum);
            // 敵の駒に当たったとき
            if (masu.enemyFlag && sc.selfFlag || masu.selfFlag && sc.enemyFlag)
            {
                KomaMove move = new KomaMove();
                move.x = 0;
                move.y = -1 * i * reversenum;
                moves.Add(move);
                break;
                // 味方の駒に当たってないとき
            }
            else if (masu.selfFlag != sc.selfFlag || masu.enemyFlag != sc.enemyFlag)
            {
                KomaMove move = new KomaMove();
                move.x = 0;
                move.y = -1 * i * reversenum;
                moves.Add(move);
            }
            else
            {
                break;
            }
        }
        return(moves);
    }
Example #7
0
    public List <KomaMove> GetMotigomaMoves(KomaScript sc, bool reverse = false)
    {
        List <KomaMove> moves   = new List <KomaMove> ();
        MasuManager     manager = MasuManager.Instance;
        int             ymin    = 1;
        int             ymax    = 9;

        if (reverse)
        {
            ymax = 7;
        }
        else
        {
            ymin = 3;
        }
        for (int x = 1; x <= 9; x++)
        {
            for (int y = ymin; y <= ymax; y++)
            {
                MasuInit masu = manager.GetMasu(x, y);
                // 敵味方の駒がいないとき
                if (!masu.exists)
                {
                    KomaMove move = new KomaMove();
                    move.x = x;
                    move.y = y;
                    moves.Add(move);
                }
                else
                {
                    continue;
                }
            }
        }
        return(moves);
    }
Example #8
0
    // 相手の駒を取ったか確認&実行時
    void execCheckGetEnemyKoma(string objName, int x, int y)
    {
        GameObject      gameObj  = GameObject.Find(objName);
        KomaScript      sc       = gameObj.GetComponent <KomaScript>();
        MasuManager     manager  = MasuManager.Instance;
        MasuInit        masu     = manager.GetMasu(x, y);
        MotigomaManager mManager = MotigomaManager.Instance;

        if (sc.selfFlag && masu.enemyFlag)
        {
            if (masu.komaName.Equals(KomaConst.komaOu2) || masu.komaName.Equals(KomaConst.komaGy2))
            {
                mManager.Plus(KomaConst.komaOu);
            }
            else if (masu.komaName.Equals(KomaConst.komaHi2) || masu.komaName.Equals(KomaConst.komaRy2))
            {
                mManager.Plus(KomaConst.komaHi);
            }
            else if (masu.komaName.Equals(KomaConst.komaKa2) || masu.komaName.Equals(KomaConst.komaUm2))
            {
                mManager.Plus(KomaConst.komaKa);
            }
            else if (masu.komaName.Equals(KomaConst.komaKi2))
            {
                mManager.Plus(KomaConst.komaKi);
            }
            else if (masu.komaName.Equals(KomaConst.komaGi2) || masu.komaName.Equals(KomaConst.komaNg2))
            {
                mManager.Plus(KomaConst.komaGi);
            }
            else if (masu.komaName.Equals(KomaConst.komaKe2) || masu.komaName.Equals(KomaConst.komaNk2))
            {
                mManager.Plus(KomaConst.komaKe);
            }
            else if (masu.komaName.Equals(KomaConst.komaKy2) || masu.komaName.Equals(KomaConst.komaNy2))
            {
                mManager.Plus(KomaConst.komaKy);
            }
            else if (masu.komaName.Equals(KomaConst.komaFu2) || masu.komaName.Equals(KomaConst.komaTo2))
            {
                mManager.Plus(KomaConst.komaFu);
            }
            GameObject     obj = transform.Find("../Motigoma1").gameObject;
            MotigomaScript mSc = obj.GetComponent <MotigomaScript>();
            mSc.RefreshKoma();
            DestroyKomaObj(masu.objName);
        }
        else if (sc.enemyFlag && masu.selfFlag)
        {
            if (masu.komaName.Equals(KomaConst.komaOu) || masu.komaName.Equals(KomaConst.komaGy))
            {
                mManager.Plus(KomaConst.komaOu2);
            }
            else if (masu.komaName.Equals(KomaConst.komaHi) || masu.komaName.Equals(KomaConst.komaRy))
            {
                mManager.Plus(KomaConst.komaHi2);
            }
            else if (masu.komaName.Equals(KomaConst.komaKa) || masu.komaName.Equals(KomaConst.komaUm))
            {
                mManager.Plus(KomaConst.komaKa2);
            }
            else if (masu.komaName.Equals(KomaConst.komaKi))
            {
                mManager.Plus(KomaConst.komaKi2);
            }
            else if (masu.komaName.Equals(KomaConst.komaGi) || masu.komaName.Equals(KomaConst.komaNg))
            {
                mManager.Plus(KomaConst.komaGi2);
            }
            else if (masu.komaName.Equals(KomaConst.komaKe) || masu.komaName.Equals(KomaConst.komaNk))
            {
                mManager.Plus(KomaConst.komaKe2);
            }
            else if (masu.komaName.Equals(KomaConst.komaKy) || masu.komaName.Equals(KomaConst.komaNy))
            {
                mManager.Plus(KomaConst.komaKy2);
            }
            else if (masu.komaName.Equals(KomaConst.komaFu) || masu.komaName.Equals(KomaConst.komaTo))
            {
                mManager.Plus(KomaConst.komaFu2);
            }
            GameObject     obj = transform.Find("../Motigoma2").gameObject;
            MotigomaScript mSc = obj.GetComponent <MotigomaScript>();
            mSc.RefreshKoma();
            DestroyKomaObj(masu.objName);
        }
    }