示例#1
0
 public void settype(KOMA_TYPE koma_type)
 {
     if (koma_type == KOMA_TYPE.Black)
     {
         Debug.Log("setBlack");
         GetComponent <Animator>().Play("setBlack", 0);
     }
     else
     {
         Debug.Log("setWhite");
         GetComponent <Animator>().Play("setWhite", 0);
     }
 }
示例#2
0
 public void koma_rotation(bool forced)
 {
     if (forced || defaultY == transform.position.y)
     {
         KOMA_TYPE type = GetComponent <komaScript>().type;
         if (type == KOMA_TYPE.Black)
         {
             Debug.Log("BlackToWhite");
             GetComponent <Animator>().Play("BlackToWhite", 0);
             GetComponent <komaScript>().type = KOMA_TYPE.White;
         }
         else
         {
             Debug.Log("WhiteToBlack");
             GetComponent <Animator>().Play("WhiteToBlack", 0);
             GetComponent <komaScript>().type = KOMA_TYPE.Black;
         }
     }
 }
示例#3
0
文件: board.cs 项目: KK56ken/Othello
    public GameObject setDummy(int x, int y, KOMA_TYPE type)
    {
        float width     = this.transform.localScale.x;
        float height    = this.transform.localScale.z;
        float thisX     = this.transform.localPosition.x - (width / 2);  //boardの左上X
        float thisZ     = this.transform.localPosition.z - (height / 2); //boardの左上のZ
        float space_obj = width / 8;

        GameObject dummy       = (GameObject)Resources.Load(@"dummy");
        float      dummyWidth  = dummy.transform.localScale.x;
        float      dummyHeight = dummy.transform.localScale.z;
        float      vecZ        = thisZ + space_obj * y + (dummyHeight / 2);
        float      vecX        = thisX + space_obj * x + (dummyWidth / 2);

        dummy.GetComponent <DummyScript>().x              = x;
        dummy.GetComponent <DummyScript>().y              = y;
        dummy.GetComponent <DummyScript>().koma_type      = type;
        dummy.GetComponent <DummyScript>().system_manager = system_manager;
        dummy.SetActive(false);
        Debug.Log("<COLOR=blue>ダミーを生成</COLOR>");

        return(Instantiate(dummy, new Vector3(vecX, dummy.transform.localPosition.y, vecZ), Quaternion.identity));
    }
示例#4
0
文件: board.cs 项目: KK56ken/Othello
    public void SetKoma(int x, int y, KOMA_TYPE type)
    {
        float width     = this.transform.localScale.x;
        float height    = this.transform.localScale.z;
        float thisX     = this.transform.localPosition.x - (width / 2);  //boardの左上X
        float thisZ     = this.transform.localPosition.z - (height / 2); //boardの左上のZ
        float space_obj = width / 8;

        GameObject obj       = (GameObject)Resources.Load(@"koma_pare");
        float      objWidth  = obj.transform.localScale.x;
        float      objHeight = obj.transform.localScale.z;
        float      vecX      = thisX + space_obj * x + (objWidth / 2);
        float      vecZ      = thisZ + space_obj * y + (objHeight / 2);

        komaArray[x, y] = Instantiate(obj, new Vector3(vecX, obj.transform.localPosition.y, vecZ), Quaternion.identity);
        komaArray[x, y].GetComponent <komaScript>().x    = x;
        komaArray[x, y].GetComponent <komaScript>().y    = y;
        komaArray[x, y].GetComponent <komaScript>().type = type;

        komaArray[x, y].GetComponent <komaScript>().setTyoe(get_koma_type(x, y));

        revers(x, y);
    }
示例#5
0
 public void setTyoe(KOMA_TYPE koma_type)
 {
     anim.settype(koma_type);
 }
示例#6
0
文件: board.cs 项目: KK56ken/Othello
    public void revers(int x, int y)
    {
        //置いた色
        KOMA_TYPE set_type = get_koma_type(x, y);
        //相手の色
        KOMA_TYPE opp_type = KOMA_TYPE.None;

        if (set_type == KOMA_TYPE.Black)
        {
            opp_type = KOMA_TYPE.White;
        }
        else
        {
            opp_type = KOMA_TYPE.Black;
        }


        Debug.Log("==========================================================================\n" +
                  "==========================================================================\n" +
                  "<color=blue>置いた場所 x:" + x + " y:" + y + "</ color >\n" +
                  "<color=blue>置いた色:" + set_type + "</color>\n" +
                  "<color=blue>相手の色" + opp_type + "</color>");
        //ひっくり返す処理
        for (int dir_x = -1; dir_x <= 1; dir_x++)
        {
            for (int dir_y = -1; dir_y <= 1; dir_y++)
            {
                //周囲の座標を取得
                if (get_koma_type(x + dir_x, y + dir_y) == opp_type)
                {
                    Debug.Log("<COLOR=GREEN>" + dir_x + "," + dir_y + "方向に" + opp_type + "を確認</COLOR>");
                    int cnt = 2;
                    while (true)
                    {
                        //範囲外:ループを抜ける
                        if (y + (dir_y * cnt) < 0 || y + (dir_y * cnt) > 7 ||
                            x + (dir_x * cnt) < 0 || x + (dir_x * cnt) > 7)
                        {
                            break;
                        }
                        //探索先にコマが置かれていないorダミーが置かれている:ループを抜ける
                        if (get_koma_type(x + (dir_x * cnt), y + (dir_y * cnt)) == KOMA_TYPE.None)
                        {
                            break;
                        }
                        //探索先に自分のマス:返しながら戻る
                        if (get_koma_type(x + (dir_x * cnt), y + (dir_y * cnt)) == set_type)
                        {
                            Debug.Log("<COLOR=GREEN>" + (x + (dir_x * cnt)) + "," + (y + (dir_y * cnt)) + "に" + set_type + "を確認</COLOR>");
                            cnt--;
                            //打てる
                            while (cnt > 0)
                            {
                                Debug.Log("<COLOR=GREEN>" + (x + (dir_x * cnt)) + ", " + (y + (dir_y * cnt)) + "を反転</COLOR>");
                                komaArray[x + (dir_x * cnt), y + (dir_y * cnt)].GetComponent <komaScript>().rotation(true);
                                cnt--;
                            }
                            break;
                        }
                        if (cnt > 8)
                        {
                            Debug.LogError("whileが規定回数以上回りました");
                            return;
                        }
                        cnt++;
                    }
                }
            }
        }
    }
示例#7
0
文件: board.cs 项目: KK56ken/Othello
    public void can_set(TURN now_turn)
    {
        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                dummy_array[i, j].SetActive(false);
            }
        }

        //相手のターンを取得する

        KOMA_TYPE now_type = KOMA_TYPE.None;
        KOMA_TYPE opp_type = KOMA_TYPE.None;

        if (now_turn == TURN.play_first)
        {
            now_type = KOMA_TYPE.Black;
            opp_type = KOMA_TYPE.White;
        }
        else if (now_turn == TURN.draw_first)
        {
            now_type = KOMA_TYPE.White;
            opp_type = KOMA_TYPE.Black;
        }
        else
        {
            Debug.LogError("TURNの値が不正です");
        }


        Debug.Log("<COLOR=RED>" + now_type + "</COLOR><COLOR=YELLOW>の打てる場所探索</COLOR>");

        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if (get_koma_type(i, j) == KOMA_TYPE.None)
                {
                    for (int dir_x = -1; dir_x <= 1; dir_x++)
                    {
                        for (int dir_y = -1; dir_y <= 1; dir_y++)
                        {
                            //探索先が探索元のマスの場合スルー
                            if (i + dir_x == 0 && j + dir_y == 0)
                            {
                                continue;
                            }
                            //周囲8マスに相手のマスがあったら
                            if (get_koma_type((i + dir_x), (j + dir_y)) == opp_type)
                            {
                                //Debug.Log("<COLOR=YELLOW>y:" + i + " x:" + j + "から" + dir_y + "," + dir_x + "方向へ探索</COLOR>");
                                //延長線上探索
                                int cnt = 2;
                                while (true)
                                {
                                    //範囲外:ループを抜ける
                                    if (i + (dir_x * cnt) < 0 || i + (dir_x * cnt) > 7 ||
                                        j + (dir_y * cnt) < 0 || j + (dir_y * cnt) > 7)
                                    {
                                        break;
                                    }
                                    //探索先にコマが置かれていないorダミーが置かれている:ループを抜ける
                                    if (get_koma_type(i + (dir_x * cnt), j + (dir_y * cnt)) == KOMA_TYPE.None)
                                    {
                                        break;
                                    }
                                    //探索先に自分のマス:ダミー表示,ループを抜ける
                                    if (get_koma_type(i + (dir_x * cnt), j + (dir_y * cnt)) == now_type)
                                    {
                                        Debug.Log("<COLOR=blue>ダミー[" + i + "," + j + "]:true</COLOR>");
                                        dummy_array[i, j].SetActive(true);
                                        dummy_array[i, j].GetComponent <DummyScript>().koma_type = turnToKomaType(now_turn);
                                        break;
                                    }
                                    if (cnt > 8)
                                    {
                                        Debug.LogError("whileが規定回数以上回りました");
                                        return;
                                    }
                                    cnt++;
                                }
                            }
                        }
                    }
                }
            }
        }
    }