Ejemplo n.º 1
0
    /// <summary>
    /// 盤面に相手の配置情報をマージする
    /// </summary>
    /// <param name="alignInfo"></param>
    private void MargeOpponentBoard(int[] alignInfo)
    {
        GameObject topPref = Resources.Load <GameObject>("GameObjects/BattleScene/Top");

        for (int i = 1; i < 6; i++)
        {
            if (alignInfo[i] == 0)
            {
                continue;
            }

            GameObject top = Instantiate(topPref);

            //マテリアル設定
            Material[] mats = top.GetComponent <MeshRenderer>().materials;
            mats[0] = Resources.Load <Material>("Materials/" + topTableList.Find(topTable => topTable.Id == alignInfo[i]).AssetName);
            top.GetComponent <MeshRenderer>().materials = mats;

            BattleTopCtrl topCtrl = top.GetComponent <BattleTopCtrl>();
            BoardIndex    index   = new BoardIndex((GameDef.BOARD_CELLS + 1) - i, 1);
            Vector2       tmpVec  = board.GetBoardPosByIndex(index);
            top.transform.position = new Vector3(tmpVec.x, 1, tmpVec.y);
            topCtrl.topId          = alignInfo[i];
            topCtrl.SetIsMine(false);
            topCtrl.SetIsMyTurn(false);
            board.SetBoardInf(alignInfo[i], top, false, index);
        }

        //初期位置は塗っておく
        for (int i = 1; i <= GameDef.BOARD_CELLS; i++)
        {
            BoardIndex index = new BoardIndex(i, 1);
            PaintCell(index, false);
        }
    }
Ejemplo n.º 2
0
    private ShogiBoard opponentTopStage;  /* 相手の持ち駒情報   */

    void Start()
    {
        turnManager = GetComponent <PunTurnManager>();
        turnManager.TurnManagerListener = this;
        turnManager.TurnDuration        = 30f;

        PhotonNetwork.IsMessageQueueRunning = true;

        GameManager.Instance.RefTopTableList(ref topTableList);
        GameManager.Instance.RefTopAlignInfo(ref alignInfo);
        opponentAlignInfo = new int[GameDef.BOARD_CELLS + 1];
        //ボードのインスタンス化
        board         = new ShogiBoard(GameDef.BOARD_CELLS, new Vector2(BoardObj.transform.position.x, BoardObj.transform.position.z));
        redCellObj    = new GameObject[GameDef.BOARD_CELLS + 1, GameDef.BOARD_CELLS + 1];
        blueCellObj   = new GameObject[GameDef.BOARD_CELLS + 1, GameDef.BOARD_CELLS + 1];
        yellowCellObj = new GameObject[GameDef.BOARD_CELLS + 1, GameDef.BOARD_CELLS + 1];
        whiteCellObj  = new GameObject[GameDef.BOARD_CELLS + 1, GameDef.BOARD_CELLS + 1];
        GameObject redCellPref    = Resources.Load <GameObject>("GameObjects/BattleScene/RedCellObject");
        GameObject blueCellPref   = Resources.Load <GameObject>("GameObjects/BattleScene/BlueCellObject");
        GameObject yellowCellPref = Resources.Load <GameObject>("GameObjects/BattleScene/YellowCellObject");
        GameObject whiteCellPref  = Resources.Load <GameObject>("GameObjects/BattleScene/WhiteCellObject");

        PopupPanel.SetActive(false);
        //配置情報をもとに盤面を初期化する
        //コマ配置情報をもとにコマを再配置する
        GameObject topPref = Resources.Load <GameObject>("GameObjects/BattleScene/Top");

        for (int i = 1; i <= GameDef.BOARD_CELLS; i++)
        {
            if (alignInfo[i] == 0)
            {
                continue;
            }

            GameObject top = Instantiate(topPref);
            //マテリアル設定
            Material[] mats = top.GetComponent <MeshRenderer>().materials;
            mats[0] = Resources.Load <Material>("Materials/" + topTableList.Find(topTable => topTable.Id == alignInfo[i]).AssetName);
            top.GetComponent <MeshRenderer>().materials = mats;

            BattleTopCtrl topCtrl = top.GetComponent <BattleTopCtrl>();
            BoardIndex    index   = new BoardIndex(i, GameDef.BOARD_CELLS);
            Vector2       tmpVec  = board.GetBoardPosByIndex(index);
            top.transform.position = new Vector3(tmpVec.x, 1, tmpVec.y);
            topCtrl.topId          = alignInfo[i];
            topCtrl.isMine         = true;
            topCtrl.SetIsMine(true);
            topCtrl.SetIsMyTurn(false);
            board.SetBoardInf(alignInfo[i], top, true, index);
        }

        for (int i = 1; i <= GameDef.BOARD_CELLS; i++)
        {
            for (int j = 1; j <= GameDef.BOARD_CELLS; j++)
            {
                BoardIndex index   = new BoardIndex(i, j);
                Vector2    tmpVal  = board.GetBoardPosByIndex(index);
                Vector3    tmpVal2 = new Vector3(tmpVal.x, 1, tmpVal.y);

                //色付きセル(黄色、赤)を配置する
                GameObject redCell = Instantiate(redCellPref, tmpVal2, Quaternion.identity);
                redCellObj[i, j] = redCell;
                GameObject yellowCell = Instantiate(yellowCellPref, tmpVal2, Quaternion.identity);
                yellowCellObj[i, j] = yellowCell;
                GameObject blueCell = Instantiate(blueCellPref, tmpVal2, Quaternion.identity);
                blueCellObj[i, j] = blueCell;
                GameObject whiteCell = Instantiate(whiteCellPref, tmpVal2, Quaternion.identity);
                whiteCellObj[i, j] = whiteCell;

                //赤セルを少し下げておく
                redCellObj[i, j].transform.position = new Vector3(redCellObj[i, j].transform.position.x,
                                                                  0.5f,
                                                                  redCellObj[i, j].transform.position.z);
                //青セルを少し下げておく
                blueCellObj[i, j].transform.position = new Vector3(blueCellObj[i, j].transform.position.x,
                                                                   0.5f,
                                                                   blueCellObj[i, j].transform.position.z);
                //黄セルを少し下げておく
                yellowCellObj[i, j].transform.position = new Vector3(yellowCellObj[i, j].transform.position.x,
                                                                     0.5f,
                                                                     yellowCellObj[i, j].transform.position.z);
            }
        }

        //コマ置き場のインスタンス化
        myTopStage = new ShogiBoard(3, new Vector2(myTopStageObj.transform.position.x,
                                                   myTopStageObj.transform.position.z));
        opponentTopStage = new ShogiBoard(3, new Vector2(oppenentsTopStageObj.transform.position.x,
                                                         oppenentsTopStageObj.transform.position.z));
        //初期位置は塗っておく
        for (int i = 1; i <= 5; i++)
        {
            BoardIndex index = new BoardIndex(i, 5);
            PaintCell(index, true);
        }

        //すでに部屋に相手がいる場合はゲーム開始します
        if (PhotonNetwork.CurrentRoom.PlayerCount == 2)
        {
            machingPanel.SetActive(false);
            StartCoroutine(StartGameSequence());
        }
        else
        {
            machingPanel.SetActive(true);
        }
    }