// Use this for initialization void Start() { StartBlock = new mapBlock[ScreenHeightBlock, ScreenWidthBlock]; //設定初始地圖陣列大小 //初始旗標狀態 _isDraw = false; _isDebug = true; _isFullMap = false; _isReSet = false; //設定地圖像素大小 _mapWidth = transform.localScale.x; _mapHeight = transform.localScale.y; //初始化棋盤格子 InitBlock(); //初始化地圖 _mapMat = new Mat((int)_mapHeight, (int)_mapWidth, CvType.CV_8UC3); _mapMat.setTo(_FogOfWarColor); //設定戰爭迷霧 _tex = new Texture2D((int)_mapWidth, (int)_mapHeight); //設定結果圖片大小 //玩家位置創建空間 _pointPlayer = new Point[2]; _pointPlayer[0] = new Point(0, 4); _pointPlayer[1] = new Point(15, 3); //設定玩家初始位置 _mapData.setPlayerPos(_pointPlayer[0]); _mapData.setPlayerPos(_pointPlayer[1]); //設定寶藏初始位置 _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)); //設定回合&誰先遊戲&還沒有人贏 _winerFlag = -1; _round = 0; _whoRound = 0; //設定玩家顏色 _playerColor[0] = new Scalar(255, 0, 0); _playerColor[1] = new Scalar(0, 0, 255); //設定移動資訊 _moved = false; _movedTimer = 0f; _movedTriggerTime = 1; _pointRange = 5; //設定玩家視野 _playerCanSee[0] = 2; _playerCanSee[1] = 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; }