예제 #1
0
    public GameObject Getclickobj()
    {
        GameObject result = null;

        if (Input.GetMouseButtonDown(0))
        {
            Vector2    clickpoint  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Collider2D collition2D = Physics2D.OverlapPoint(clickpoint);
            if (collition2D)
            {
                result = collition2D.transform.gameObject;
            }
            else
            {
                if (selectedobj != null)
                {
                    if (selectedobj.tag != "motikinn")
                    {
                        koma Ko;
                        Ko = selectedobj.GetComponent <koma>();
                        Ko.InvisibleMove(selectedobj);
                        selectedobj = null;
                    }
                    else if (selectedobj.tag == "motikinn")
                    {
                        Motikinn Ko;
                        Ko = selectedobj.GetComponent <Motikinn>();
                        Ko.InvisibleMove();
                        selectedobj = null;
                    }
                }
            }
        }
        return(result);
    }
예제 #2
0
    private void Update()
    {
        if (gameset == true)
        {
            return;                  //勝負が着いた時updateを止める
        }
        if (mapdata.motikinn[0, MotikinnSumIndexnum] >= AmountOfWin || mapdata.motikinn[1, MotikinnSumIndexnum] >= AmountOfWin)
        {
            if ((mapdata.motikinn[0, MotikinnSumIndexnum] >= AmountOfWin) && (mapdata.motikinn[1, MotikinnSumIndexnum] >= AmountOfWin))
            {
                GameSet(0);
            }
            for (int i = 0; i < 2; i++)
            {
                if (mapdata.motikinn[i, MotikinnSumIndexnum] >= AmountOfWin)
                {
                    GameSet(i + 1);
                }
            }
        }

        GameObject komaobj = Getclickobj();

        if (komaobj != null)
        {
            if (((komaobj.tag != "toMove") && (komaobj.tag != "motikinn")) && (komaobj.tag != "motikinnToMove"))
            {
                komadata = komaobj.GetComponent <koma>();
                if (turnplayer == komadata.GetPorE())
                {    //駒を選んだとき
                    if (selectedobj != null)
                    {
                        if (selectedobj.tag != "motikinn")
                        {    //他のこまが選ばれていたとき
                            koma Ko;
                            Ko = selectedobj.GetComponent <koma>();
                            Ko.InvisibleMove(selectedobj);
                            selectedobj = null;
                        }
                        else if (selectedobj.tag == "motikinn")
                        {    //他の持ち金が選ばれていたとき
                            Motikinn moti;
                            moti = selectedobj.GetComponent <Motikinn>();
                            moti.InvisibleMove();
                            selectedobj = null;
                        }
                    }

                    selectedobj = komaobj;
                    komadata.ShowMove(komadata.GetKomakind(), turnplayer);
                }
            }
            else if ((komaobj.tag == "toMove") || (komaobj.tag == "motikinnToMove"))
            {//駒または持ち金をすでに選んでおり、移動先を選ぶとき
                if (selectedobj != null)
                {
                    if (komaobj.tag == "toMove")
                    {//駒の移動処理
                        koma Ko;
                        Ko = selectedobj.GetComponent <koma>();

                        KomaMove(selectedobj, komaobj);
                        Ko.InvisibleMove(selectedobj);
                    }
                    else if (komaobj.tag == "motikinnToMove")
                    {
                        //持ち金を打つ処理
                        Motikinn motikinnobj;
                        motikinnobj = selectedobj.GetComponent <Motikinn>();
                        // Debug.Log(motikinnobj.GetKomakind());
                        MotikinnwoBaniUtu(motikinnobj.GetKomakind(), turnplayer, komaobj);
                        motikinnobj.InvisibleMove();
                    }

                    if (turnplayer == 1)
                    {
                        turnplayer = 2;
                        turnOBJ2.gameObject.SetActive(true);
                        turnOBJ1.gameObject.SetActive(false);
                    }
                    else if (turnplayer == 2)
                    {
                        turnplayer = 1;
                        turnOBJ1.gameObject.SetActive(true);
                        turnOBJ2.gameObject.SetActive(false);
                    }
                    selectedobj = null;
                    //ここにターン開始時の処理

                    //tc.MoveTurnObj(turnplayer);

                    // PullOutProcess(turnplayer); //なぜかめちゃくちゃ重くなるのでこのまま
                    if (turnplayer == 1)
                    {//駒の自主撤退
                        for (int y = 7; y >= 6; y--)
                        {
                            for (int x = 0; x < 8; x++)
                            {
                                if (y != 6)
                                {
                                    if (mapdata.map[x, y] == 1)
                                    {
                                        ReturnKome(x, y);
                                    }
                                }
                                if (mapdata.map[x, y] == 50)
                                {
                                    ReturnKome(x, y);
                                }
                            }
                        }
                    }
                    else if (turnplayer == 2)
                    {
                        for (int y = 1; y <= 2; y++)
                        {
                            for (int x = 0; x < 8; x++)
                            {
                                if (y != 2)
                                {
                                    if (mapdata.map[x, y] == -1)
                                    {
                                        ReturnKome(x, y);
                                    }
                                }
                                if (mapdata.map[x, y] == -50)
                                {
                                    ReturnKome(x, y);
                                }
                            }
                        }
                    }
                }
            }
            else if (komaobj.tag == "motikinn")
            {
                //持ち金を選んだとき
                Motikinn motikinn = komaobj.GetComponent <Motikinn>();
                if (turnplayer == motikinn.GetPorE())
                {
                    if (selectedobj != null)
                    {
                        if (selectedobj.tag == "motikinn")
                        {//すでに別の持ち金が選ばれており、変更するとき
                            Motikinn Ko;
                            Ko = selectedobj.GetComponent <Motikinn>();
                            Ko.InvisibleMove();


                            if (mapdata.motikinn[(turnplayer - 1), mapdata.GetKomakindToIndexnum[motikinn.GetKomakind()]] >= 1)
                            {
                                motikinn.MotikinnShowMove(motikinn.GetKomakind(), turnplayer);
                                komaobj.transform.Find("motikinnselect").gameObject.SetActive(true);
                            }


                            selectedobj = null;
                        }
                        else if (selectedobj.tag != "motikinn")
                        {//すでに別の場の駒が選ばれており、持ち金に変更するとき
                            koma Ko;
                            Ko = selectedobj.GetComponent <koma>();
                            Ko.InvisibleMove(selectedobj);
                            selectedobj = null;
                            // komaobj.transform.Find("motikinnselect").gameObject.SetActive(true);
                        }
                    }
                    selectedobj = komaobj;
                    //ここに打てる場所のshowmove。

                    if (mapdata.motikinn[(turnplayer - 1), motikinn.GetKomakindToIndexnum[motikinn.GetKomakind()]] >= 1)
                    {
                        komaobj.transform.Find("motikinnselect").gameObject.SetActive(true);
                        motikinn.MotikinnShowMove(motikinn.GetKomakind(), turnplayer);
                    }
                }
            }
        }
    }