//滑鼠點擊事件 private void ClickMouseUpEvent() { bool isMouse = false; if (Input.GetMouseButtonUp(0)) { isMouse = true; } if (_moved || isMouse) { Point triggerPoint = new Point(); for (int i = 0; i < 9; i++) { for (int j = 0; j < 16; j++) { if (isMouse) { //trigger到指定格子 if (StartBlock[i, j].Check(_rayPosData.getPos().x, _rayPosData.getPos().y)) { //Debug.Log("PosX:" + j + "PosX:" + i); triggerPoint.x = j; triggerPoint.y = i; } } else { //維持原本格子 if (StartBlock[i, j].Check(_pointPlayer[_whoRound].x, _pointPlayer[_whoRound].y)) { //Debug.Log("PosX:" + j + "PosX:" + i); triggerPoint.x = j; triggerPoint.y = i; } } } } _whoRound = _round % 2; this.RefreshOneCanMoveArea(_whoRound); this._mapData.RemovePlayerArea(); //判斷是否為可走區域以及是否沒有玩家在該格子上 if (_mapData.getCanMoveArea().Exists(List => List.x == triggerPoint.x && List.y == triggerPoint.y) && _mapData.isExistPlayerPos(new Point(triggerPoint.x, triggerPoint.y)) == false) { //可以的話,設定玩家到新座標 _mapData.setPlayerPos(_whoRound, new Point(triggerPoint.x, triggerPoint.y)); _round++; _roundText.text = "Round:" + ((_round / 2) + 1); this.FlageMove(); this.RefreshCanMoveArea(); //Debug.Log("This point can be move!" + "X = " + triggerPoint.x + ",Y = " + triggerPoint.y); } else { _moveState.text = "can't move!" + "X = " + triggerPoint.x + ",Y = " + triggerPoint.y; Point[] mistakeBlock = this.PosToBlock((int)triggerPoint.x, (int)triggerPoint.y); Imgproc.line(_mapMat, new Point(_mapWidth - mistakeBlock[0].x, _mapHeight - mistakeBlock[0].y), new Point(_mapWidth - mistakeBlock[1].x, _mapHeight - mistakeBlock[1].y), new Scalar(255, 0, 0)); Imgproc.line(_mapMat, new Point(_mapWidth - mistakeBlock[1].x, _mapHeight - mistakeBlock[0].y), new Point(_mapWidth - mistakeBlock[0].x, _mapHeight - mistakeBlock[1].y), new Scalar(255, 0, 0)); Debug.Log("This point can't be move!" + "X = " + triggerPoint.x + ",Y = " + triggerPoint.y); } //重新跑過各玩家可以走的地方 this.RefreshOneCanMoveArea(0); this.RefreshOneCanMoveArea(1); //Debug.Log("WR" + _whoRound + "R " + _round + "NUM " + _mapData.getPlayerCount()); //Debug.Log("ID = 0" + "X = " + _mapData.getPlayerPos(0).x + "Y = " + _mapData.getPlayerPos(0).y); //Debug.Log("ID = 1" + "X = " + _mapData.getPlayerPos(1).x + "Y = " + _mapData.getPlayerPos(1).y); _moved = false; } }