/// <summary> /// 获取建筑工人小屋组件 /// </summary> /// <returns></returns> public WorkerHouseComponent GetWorkerHouseComponent() { if (_cacheWorkerHouse == null) { // REMARK:建筑工人小屋就一个设施、并且属于防御方。 foreach (var entity in GetAllEntitiesByOwner(OwnerType.Defender)) { if (EntityTypeUtil.IsWorkerHouse(entity.model)) { _cacheWorkerHouse = entity.GetComponent <WorkerHouseComponent>(); break; } } } Assert.Should(_cacheWorkerHouse != null); return(_cacheWorkerHouse); }
public void Init() { for (int x = 0; x < Constants.EDGE_WIDTH; x++) { for (int y = 0; y < Constants.EDGE_HEIGHT; y++) { m_routeMap[x, y] = new IsoPathGrid { EntityID = 0, X = x, Y = y, }; m_entityCount[x, y] = 0; } } m_buildingMap = new int[Constants.WIDTH, Constants.HEIGHT]; for (int i = 0; i < (int)OwnerType.Count; i++) { m_entities[i] = new List <TileEntity>(); } m_entityHash.Clear(); m_entitiesToAdd.Clear(); m_entitiesToRemove.Clear(); m_aStar = new PathSolver <IMoveGrid, IsoPathGrid, AStarUserContext>(m_routeMap); m_dijkstra = new Dijkstra(); m_wallLinker = new object(); m_wallLinkerId = m_wallLinker.GetHashCode(); _cacheWorkerHouse = null; m_guardAreaMap = null; }