public void RandomDynamicData() { mDynamicDataDic.Clear(); for (int i = 0; i < mTileConfigDatas.GetLength(0); ++i) { for (int j = 0; j < mTileConfigDatas.GetLength(1); ++j) { MapTileConfigType tileType = MapTileConfigBase.DecodeTileType(mTileConfigDatas [i, j]); if (tileType == MapTileConfigType.Free) { int value = Random.Range(0, 1); MapTileDynamicBase dynamicData = null; if (value == 0) { dynamicData = new MapTileDynamicCity(); } else { dynamicData = new MapTileDynamicTribe(); } mDynamicDataDic[TileCoordToTileKey(i, j)] = dynamicData; } } } }
public MapTileConfigBase GetTileConfig(int x, int y) { if (!IsValidTileCoord(x, y)) { return(null); } int tileData = mTileConfigDatas [x, y]; MapTileConfigType tileType = MapTileConfigBase.DecodeTileType(tileData); MapTileConfigBase ret = null; switch (tileType) { case MapTileConfigType.Block: ret = new MapTileConfigBlock(); break; case MapTileConfigType.Free: ret = new MapTileConfigFree(); break; default: break; } ret.tileCoord = new IntVector2(x, y); ret.Decode(tileData); return(ret); }
public bool IsBlock(int x, int y) { if (!IsValidTileCoord(x, y)) { return(true); } int tileData = mTileConfigDatas [x, y]; MapTileConfigType tileType = MapTileConfigBase.DecodeTileType(tileData); return(tileType == MapTileConfigType.Block); }
void InitTile(int x, int y) { MapTileConfigBase configBase = MapDataManager.Instance.GetTileConfig(x, y); int tileKey = MapDataManager.TileCoordToTileKey(x, y); switch (configBase.tileType) { case MapTileConfigType.Block: MapTileBlock tileBlock = new MapTileBlock(mCacheTransform); mTileDic.Add(tileKey, tileBlock); tileBlock.SetConfigData(configBase); tileBlock.Refresh(); break; case MapTileConfigType.Free: { MapTileDynamicBase dynamicData = MapDataManager.Instance.GetTileDynamicData(x, y); if (null != dynamicData) { switch (dynamicData.TileType) { case MapTileDynamicType.City: break; case MapTileDynamicType.Tribe: break; default: break; } } } break; default: break; } }
public void SetConfigData(MapTileConfigBase configData) { mConfigData = configData; }