public void Initialize(City parentCity, InventoryItem inventoryItem) { City = parentCity; CityInventory = City.CityInventory; SetInventoryItem(inventoryItem); SetGridPos(InventoryItem.GridPos_World); BuildingGridRoot.SetInUsed(true); }
public void Init(CityInventory cityInventory, CityConfig cityConfig, UnityAction <Building> onHoverBuilding = null, UnityAction <Building> onHoverEndBuilding = null) { CityInventory = cityInventory; CityConfig = cityConfig; OnHoverBuilding = onHoverBuilding; OnHoverEndBuilding = onHoverEndBuilding; CityInventory.RefreshInventoryGrids(); CityInventory.RefreshConflictAndIsolation(); CityEditAreaIndicator.Init(CityInventory); cityInventoryGirdMatrix = new CityInventoryGrid[cityInventory.Columns, cityInventory.Rows]; while (rockPosSet.Count < 2) { rockPosSet.Add(new GridPos(Random.Range(0, CityInventory.Columns / 2), Random.Range(0, CityInventory.Rows / 2))); } while (rockPosSet.Count < 4) { rockPosSet.Add(new GridPos(Random.Range(CityInventory.Columns / 2, CityInventory.Columns), Random.Range(0, CityInventory.Rows / 2))); } while (rockPosSet.Count < 6) { rockPosSet.Add(new GridPos(Random.Range(0, CityInventory.Columns / 2), Random.Range(CityInventory.Rows / 2, CityInventory.Rows))); } while (rockPosSet.Count < 8) { rockPosSet.Add(new GridPos(Random.Range(CityInventory.Columns / 2, CityInventory.Columns), Random.Range(CityInventory.Rows / 2, CityInventory.Rows))); } while (rockPosSet.Count < 10) { rockPosSet.Add(new GridPos(Random.Range(CityInventory.Columns / 3 * 1, CityInventory.Columns / 3 * 2), Random.Range(CityInventory.Rows / 3 * 1, CityInventory.Rows / 3 * 2))); } PerlinRandomOffset = new Vector2(Random.Range(-99872.3213f, 344.1239123f), Random.Range(-12312.1231f, 39291.1231f)); for (int col = 0; col < cityInventory.Columns; col++) { for (int row = 0; row < cityInventory.Rows; row++) { CityInventoryGrid grid = cityInventory.CreateCityInventoryGrid(CityInventoryGridContainer); grid.transform.localPosition = new Vector3((col - cityInventory.Columns / 2) * cityInventory.GridSize, 0, (row - cityInventory.Rows / 2) * cityInventory.GridSize); TerrainType tt = GenerateTerrainByPerlinNoise(col, row); grid.Init(new GridPos(col, row), CityInventory, tt); cityInventoryGirdMatrix[col, row] = grid; } } CityInventory.OnAddItemSucAction = OnAddBuildingSuc; CityInventory.OnRemoveItemSucAction = OnRemoveBuildingSuc; GridShown = false; RefreshBuildingCoverMaskMatrix(false); }
private void Init() { foreach (Building buildingPrefab in BuildingPrefabList) { LevelManager.Instance.BuildingPrefabDict.Add(buildingPrefab.BuildingInfo.buildingKey, buildingPrefab); LevelManager.Instance.BuildingInfoDict.Add(buildingPrefab.BuildingInfo.buildingKey, buildingPrefab.BuildingInfo); } DragProcessor <Building> DragProcessor_Building = new DragProcessor <Building>(); DragProcessor_Building.Init( UIManager.Instance.UICamera, BuildingLayerMask.value, (out Vector2 mouseScreenPos) => { mouseScreenPos = Input.mousePosition; return(true); }, City.CityEditAreaIndicator.GetMousePosOnThisArea, delegate(Building building, Collider collider, DragProcessor dragProcessor) { }, delegate(Building building, Collider collider, DragProcessor dragProcessor) { } ); CityInventory = new CityInventory( InventoryName, City.CityEditAreaIndicator, DragProcessor_Building, gridSize: ConfigManager.GRID_SIZE, // UI units rows: Rows, columns: Columns, x_Mirror: false, z_Mirror: false, unlockedPartialGrids: false, unlockedGridCount: Rows * Columns, dragOutDrop: false, rotateItemKeyDownHandler: () => Input.GetKeyDown(KeyCode.R), // Rotate building instantiateCityInventoryVirtualOccupationQuadHandler: (parent) => Instantiate(CityInventoryVirtualOccupationQuadPrefab, parent).GetComponent <CityInventoryVirtualOccupationQuad>(), instantiateCityInventoryGridHandler: (parent) => Instantiate(CityInventoryGridPrefab, parent).GetComponent <CityInventoryGrid>() ); CityInventory.ToggleDebugKeyDownHandler = () => Input.GetKeyDown(KeyCode.BackQuote); // Toggle debug log City.Init(CityInventory, CityConfig); CityInventory.City = City; }
public void Init(CityInventory cityInventory) { CityInventory = cityInventory; DragProcessor = DragManager.Instance.GetDragProcessor <Building>(); }