/// <summary> /// 工人到位后开始拆除 /// </summary> /// <param name="commandType"></param> /// <param name="finish"></param> /// <returns></returns> public IEnumerator Remove(BuildCommandType commandType, Action finish) { switch (commandType) { case BuildCommandType.RemoveGroundwork: if (HaveGroundwork) { yield return(StartCoroutine(mGroundworkItem.Remove())); mGroundworkItem = null; } break; case BuildCommandType.RemoveBuildingMaterials: if (HaveWall) { yield return(StartCoroutine(WallItem.Remove())); WallItem = null; foreach (var item in TilesManager.GetArroundTiles(IndexX, IndexY)) { if (item.HaveWall) { item.WallItem.SetWallImage(false); } } } else if (HaveDoor) { yield return(StartCoroutine(DoorItem.Remove())); DoorItem = null; foreach (var item in TilesManager.GetArroundTiles(IndexX, IndexY)) { if (item.HaveWall) { item.WallItem.SetWallImage(false); } } } break; case BuildCommandType.RemoveRoom: break; case BuildCommandType.RemoveDecorate: break; } finish(); }
/// <summary> /// 预建造 /// </summary> /// <param name="commandType"></param> /// <param name="item"></param> /// <param name="contents">建造物所包含的格子(房间等占多个格子)</param> public void PreBuild(BuildCommandType commandType, BuildingItem item, List <TileItem> contents = null) { //生成新的建造物并放置在指定层 switch (commandType) { case BuildCommandType.BuildGroundwork: mGroundworkItem = (GroundworkItem)item; mGroundworkItem.BindTileItem(this); break; case BuildCommandType.BuildWall: WallItem = (WallItem)item; WallItem.BindTileItem(this); if (BelongRoom) //在已有房间内建墙,墙壁不属于房间的一部分 { RoomItem.UnBindTileItem(this); RoomItem = null; } break; case BuildCommandType.BuildDoor: DoorItem = (DoorItem)item; DoorItem.BindTileItem(this); break; case BuildCommandType.BuildRoom: RoomItem = (RoomItem)item; RoomItem.BindTileItem(contents); break; case BuildCommandType.BuildDecorate: break; } mPreBuildingItem = item; mPreBuildingItem.PreBuild(); }