Beispiel #1
0
    private void Awake()
    {
        this.scriptTitleDirector = this.objectTitleDirector.GetComponent <TitleDirector>();

        this.objectBGMManager = GameObject.FindWithTag("BGMManager");
        this.scriptBGMManager = this.objectBGMManager.GetComponent <BGMManager>();

        this.objectSEManager = GameObject.FindWithTag("SEManager");
        this.scriptSEManager = this.objectSEManager.GetComponent <SEManager>();
    }
Beispiel #2
0
 public void OnStartGame()
 {
     TitleDirector.Get().StartGame();
 }
Beispiel #3
0
 public void OnSelectStage()
 {
     TitleDirector.Get().SelectStage();
 }
    // Start is called before the first frame update
    void Start()
    {
        //DontDestroyになっているTileDirectorという名前のゲームオブジェクトの取得
        GameObject tdGameObject = GameObject.Find("TitleDirector");
        //tdGameObjectのTitleDirectorコンポーネント取得
        TitleDirector titleDirector = tdGameObject.GetComponent <TitleDirector>();

        //TItleDirectorからisOnePlayer,difficulty,playerOrderを取得
        this.isOnePlayer = titleDirector.isOnePlayer;
        int difficulty  = titleDirector.difficulty;
        int playerOrder = titleDirector.playerOrder;

        //DontDestroyのため手動で破棄
        Destroy(tdGameObject);

        //playerOrderからplayerPieceを設定
        this.playerPiece = (playerOrder == 0 ? 1 : -1);

        //ボードの初期化
        this.board = new int[GRID_NUM, GRID_NUM];



        //表示用オブジェクトの初期化
        this.pieceSR = new SpriteRenderer[GRID_NUM, GRID_NUM];
        //コマの位置を調整する
        //中心が(2,2)となるようにするためのoffSet
        int offSet = -GRID_NUM / 2;
        //distance:コマ間の距離
        float pieceDis = 1.5f;

        for (int x = 0; x < GRID_NUM; x++)
        {
            for (int y = 0; y < GRID_NUM; y++)
            {
                GameObject piece = Instantiate(piecePrefab) as GameObject;
                piece.transform.position = new Vector3(x + offSet, y + offSet, 0) * pieceDis;

                pieceSR[x, y] = piece.GetComponent <SpriteRenderer>();
            }
        }


        //白先攻
        this.nextPiece = 1;


        this.canvas = GameObject.Find("Canvas");

        //矢印ボタン配列の生成
        this.arrowButtons = new GameObject[4, GRID_NUM];

        //矢印ボタンのゲームオブジェクトの生成し配列に保持
        for (int dir = 0; dir < 4; dir++)
        {
            for (int pos = 0; pos < GRID_NUM; pos++)
            {
                GameObject arrowButton = Instantiate(arrowButtonPrefab) as GameObject;
                //canvasの子とすることでbuttonとして機能するようにする
                arrowButton.transform.SetParent(this.canvas.transform);
                //canvas内での描画順を最初にする
                arrowButton.transform.SetAsFirstSibling();
                //ArrowButtonControlerにおけるinsertDirとinsertPosを対応させる。
                ArrowButtonController abc = arrowButton.GetComponent <ArrowButtonController>();
                abc.insertDir = dir;
                abc.insertPos = pos;
                this.arrowButtons[dir, pos] = arrowButton;
            }
        }

        //矢印ボタンの位置と向きの調整
        this.AdjustArrowButtons();

        //次のコマを表すImageの初期化
        this.nextPieceImage = GameObject.Find("NextPieceImage").GetComponent <Image>();
        //先攻は白
        this.nextPieceImage.color = Color.white;

        //pausePanelを初期化し、Inactiveにしておく
        this.pausePanel = GameObject.Find("PausePanel");
        this.pausePanel.SetActive(false);
        //最初はポーズ中ではない
        this.isPause = false;


        //最初は決着はついていない
        this.isGameEnd = false;
        //resultPanelとresultTextを初期化し、Inactiveにしておく
        this.resultPanel = GameObject.Find("ResultPanel");
        this.resultText  = GameObject.Find("ResultText").GetComponent <Text>();
        this.resultPanel.SetActive(false);

        //一人用のとき、difficultyとplayerPieceを用いて対戦相手を生成

        if (isOnePlayer)
        {
            //対戦相手のコマは-this.playerPieceで表される
            this.opponent = new Opponent(difficulty, -this.playerPiece);
        }
        //対戦相手の思考時間の初期化
        this.thinkTime = 0;

        //thinkPanelの初期化
        this.thinkPanel = GameObject.Find("ThinkPanel");
        this.thinkPanel.SetActive(false);
    }