//顯示提示圖示的副程式 private void ViewActiveEnableOrDisable(bool value) { //遊戲提示顯示 for (int i = 0; i < gameTip.Length; i++) { if (gameTip[i] == null) { continue; } gameTip[i].SetActive(value); } //玩家狀態顯示 for (int i = 0; i < playerStateObject.Length; i++) { if (playerStateObject[i] == null || !_playerState.GetIsPlayerEnableOrNotByIndex(i)) { continue; } playerStateObject[i].SetActive(value); } //玩家座標顯示 for (int i = 0; i < playerCoordinate.Length; i++) { if (playerCoordinate[i] == null || !_playerState.GetIsPlayerEnableOrNotByIndex(i)) { continue; } playerCoordinate[i].SetActive(value); } this.gameObject.GetComponent <GHSMain>().GameStart = true; }
private void ViewActiveEnable() { //遊戲提示顯示 for (int i = 0; i < gameTip.Length; i++) { if (gameTip[i] == null) { continue; } gameTip[i].SetActive(!gameTip[i].activeSelf); } //玩家狀態顯示 for (int i = 0; i < playerStateObject.Length; i++) { if (playerStateObject[i] == null || !_playerState.GetIsPlayerEnableOrNotByIndex(i)) { continue; } playerStateObject[i].SetActive(!playerStateObject[i].activeSelf); } //玩家座標顯示 for (int i = 0; i < playerCoordinate.Length; i++) { if (playerCoordinate[i] == null || !_playerState.GetIsPlayerEnableOrNotByIndex(i)) { continue; } playerCoordinate[i].SetActive(!playerCoordinate[i].activeSelf); } }
//初始化 void Start() { ScreenHeightBlock = _mapData.ScreenHeightBlock; ScreenWidthBlock = _mapData.ScreenWidthBlock; _playerState.SetPlayerEnableOrNotByIndex(0, true); _playerState.SetPlayerEnableOrNotByIndex(1, true); _playerState.SetPlayerEnableOrNotByIndex(2, false); _playerState.SetPlayerEnableOrNotByIndex(3, true); _playerState.InitializeRealPlayer(); StartBlock = new mapBlock[ScreenHeightBlock, ScreenWidthBlock]; //設定初始地圖陣列大小 //初始旗標狀態 _isDraw = true; _isDebug = true; _isCheatMode = true; _isReSet = false; //設定地圖像素大小 _mapWidth = transform.localScale.x; _mapHeight = transform.localScale.y; //初始化棋盤格子 for (int i = 0; i < ScreenHeightBlock; i++) { for (int j = 0; j < ScreenWidthBlock; j++) { StartBlock[i, j] = new mapBlock(); } } InitBlock(); //初始化地圖 _mapMat = new Mat((int)_mapHeight, (int)_mapWidth, CvType.CV_8UC3); _mapMat.setTo(_FogOfWarColor); //設定戰爭迷霧 _tex = new Texture2D((int)_mapWidth, (int)_mapHeight); //設定結果圖片大小 //玩家位置創建空間 _pointPlayer = new Point[4]; _pointPlayer[0] = new Point(0, 0); _pointPlayer[1] = new Point(ScreenWidthBlock - 1, 0); _pointPlayer[2] = new Point(ScreenWidthBlock - 1, ScreenHeightBlock - 1); _pointPlayer[3] = new Point(0, ScreenHeightBlock - 1); //設定玩家初始位置 for (int ID = 0; ID < 4; ID++) { _mapData.setPlayerPos(_pointPlayer[ID]); } //設定寶藏初始位置 _mapData.setTreadsurePos(new Point(5, 5)); //設定視野道具初始位置 _mapData.setSightPos(new Point(1, 1)); _mapData.setSightPos(new Point(6, 6)); //設定炸彈位置 _mapData.setBombPos(new Point(1, 2)); _mapData.setBombPos(new Point(10, 6)); //設定照明彈位置 _mapData.setFlashLightPos(new Point(1, 0)); //設定回合&誰先遊戲&還沒有人贏 _winerFlag = -1; _round = 0; _whoRound = _playerState.GetRealPlayerCornerByIndex(_round % _playerState.GetEnablePlayerCount()); this.FlageMove(); //設定玩家顏色 _playerColor[0] = new Scalar(255, 0, 0); _playerColor[1] = new Scalar(0, 0, 255); _playerColor[2] = new Scalar(0, 255, 0); _playerColor[3] = new Scalar(255, 255, 255); //設定移動資訊 _moved = false; _movedTimer = 0f; _movedTriggerTime = 1; _pointRange = 5; //設定玩家視野 for (int enablePlayer = 0; enablePlayer < 4; enablePlayer++) { if (_playerState.GetIsPlayerEnableOrNotByIndex(enablePlayer)) { _playerCanSee[enablePlayer] = 2; } } //創造寶藏 Point PBlock = new Point(_mapData.getTreadsurePos(0).x, _mapData.getTreadsurePos(0).y); Point[] PT = PosToBlock((int)PBlock.x, (int)PBlock.y); //設定寶藏位置(說明: 原始座標是0,0在中心點 先減掉0.5倍的原始物件 再加上位置座標) _treasure.transform.localPosition = new Vector3((float)-0.5 + ((float)(PT[0].x + PT[1].x) / 2 / _mapWidth), (float)0.5 - ((float)(PT[0].y + PT[1].y) / 2 / _mapHeight), -1); SightPosInit(); BoomPosInit(); //設定炸彈計時 _boomTimer = 0f; _boomTriggerTime = 1; //設定閃爍時間 _flicker = true; _flickerTimer = 0f; _flickerTriggerTime = 1; //UI初始化 _moveState.text = ""; this.RefreshOneCanMoveArea(_whoRound); }