Example #1
0
    /// <summary>
    /// ターンスタート可能か確認する
    /// </summary>
    /// <returns></returns>
    private bool IsAbleTurnStart()
    {
        int indexListCnt = 0;

        List <GameObject> myObjList    = myTopStage.GetGameObjectAll();
        List <BoardIndex> boardObjList = board.GetMyTopBoardIndex();

        foreach (BoardIndex index in boardObjList)
        {
            int id = board.GetTopIdByIndex(index);
            List <BoardIndex> indexList = board.GetMovableIndex(id, index);

            foreach (BoardIndex index2 in indexList)
            {
                indexListCnt++;
            }
        }

        if (myObjList.Count == 0 && indexListCnt == 0)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
    /// <summary>
    /// メニューボタンを押したときの処理
    /// </summary>
    public void PushMenuButton()
    {
        //コマ配置情報に登録
        for (int i = 1; i <= GameDef.BOARD_CELLS; i++)
        {
            BoardIndex index = new BoardIndex(i, GameDef.BOARD_CELLS);
            int        topId = board.GetTopIdByIndex(index);
            topArignInfo[i] = topId;
        }

        GameManager.Instance.SetAlignInfo(topArignInfo);

        GameManager.Instance.LoadScene("MenuScene");
    }
    void Update()
    {
        //レイを飛ばして当たっていれば移動許可フラグを立てる
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                if (hit.transform.gameObject == this.gameObject)
                {
                    movePermitFlg = true;
                    board.DelBoardInf(index);

                    indexies = board.GetMovableIndex(topId, index);

                    prepareSceneManager.CellHighLight(indexies);
                    foreach (BoardIndex index in indexies)
                    {
                        Vector2 tmpVal  = board.GetBoardPosByIndex(index);
                        Vector3 tmpVal2 = new Vector3(tmpVal.x, tmpVal.y, -6.85f);
                    }
                }
            }
        }

        if (Input.GetMouseButton(0))
        {
            if (movePermitFlg)
            {
                Vector2 tmpPos = Input.mousePosition;
                Vector3 pos    = Camera.main.WorldToScreenPoint(transform.position);
                Vector3 a      = new Vector3(tmpPos.x, tmpPos.y, pos.z);
                pos                = Camera.main.ScreenToWorldPoint(a);
                tmpPos             = board.GetCellPosByPos(pos, ref index);
                transform.position = new Vector3(tmpPos.x, tmpPos.y, pos.z);


                indexies = board.GetMovableIndex(topId, index);
                prepareSceneManager.CellHighLight(indexies);

                //持っている間少しでかくする
                transform.localScale = 1.2f * scale;

                //位置が下すぎる場合はホバーする
                if (pos.y < 0.58f)
                {
                    hideFlg            = true;
                    transform.position = pos;
                }
                else
                {
                    hideFlg = false;
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (movePermitFlg)
            {
                //離したら大きさを戻す
                transform.localScale = scale;

                //盤面も初期化しておく
                prepareSceneManager.CellHighLight(new List <BoardIndex>());

                //非表示状態のときは削除する
                if (hideFlg)
                {
                    //コマをしまった
                    prepareSceneManager.EndOutATop(topId);

                    Destroy(gameObject);
                }
                //ドロップ位置が5行目ではない場合は削除する
                else if (index.yIndex != 5)
                {
                    //コマをしまった
                    prepareSceneManager.EndOutATop(topId);

                    Destroy(gameObject);
                }
                //ドロップ位置にコマがない場合、盤面情報に登録する
                else if (!board.ChkBoardTop(index))
                {
                    prepareSceneManager.PutATop(topId, gameObject, index);
                }
                //コマがある場合はそのコマを削除し、上書きする
                else
                {
                    int delId = board.GetTopIdByIndex(index);

                    //コマをしまった
                    prepareSceneManager.EndOutATop(delId);

                    GameObject obj = board.DelBoardInf(index);

                    Destroy(obj);
                    prepareSceneManager.PutATop(topId, gameObject, index);
                }

                movePermitFlg = false;
            }
        }
    }