/// <summary> /// 移动建筑物到指定位置 /// </summary> /// <param name="x"></param> /// <param name="y"></param> public void DraggingBuildingTo(int x, int y) { //REMARK 一个建筑格子占2个小格子 if (x % 2 == 1) { x -= 1; } if (y % 2 == 1) { y -= 1; } if (currentBuilding.GetTilePos().x == x && currentBuilding.GetTilePos().y == y) { return; } if (!draged) { draged = true; EventDispather.DispatherEvent(GameEvents.BEGIN_DRAG_BUILDING); } currentBuilding.SetTilePosition(new TilePoint(x, y)); currentBuilding.view.transform.position = currentBuilding.GetRenderPosition(); var pos = IsoHelper.GridToPosition(x, y); buildableView.gameObject.SetActive(true); buildableView.transform.position = pos; IsoHelper.MoveAlongCamera(buildableView.transform, 5f); buildArrow.transform.position = pos; // IsoHelper.MoveAlongCamera(buildArrow.transform,-1f); buildConfirm.transform.position = pos; IsoHelper.MoveAlongCamera(buildConfirm.transform, -1f); // 是否可以建造 buildableView.SetBuildable(IsoMap.Instance.CanPlaceBuilding(x, y, currentBuilding.width, currentBuilding.height)); }