// Grab initial gridblock info and load the grid void Initialize(){ gridInfoFilepath = Application.dataPath + "/levels" + "/level.xml"; if(!File.Exists(gridInfoFilepath)){ // Create file with dummy data just for creation. // Both bools isSpawnSpot and isWall default to false. // Dummy data creates an initial 10x10 grid. newGridInfo.gridSize = 10; saveGrid(); } loadGrid(gridInfoFilepath); // New copy of gridInfo to pass into serializer for future saving. currentGridInfo = newGridInfo; }
protected TileGridMappingBase(TileGridMappingBase ToCopy, Section section, string name) : base(section, name, ToCopy.TilePrefix, ToCopy.TilePostfix) { TileSizeX = ToCopy.TileSizeX; TileSizeY = ToCopy.TileSizeY; TotalTileSize = ToCopy.TotalTileSize; TileGridPath = ToCopy.TileGridPath; MinDownsample = ToCopy.MinDownsample; MaxDownsample = ToCopy.MaxDownsample; this.GridCoordFormat = ToCopy.GridCoordFormat; foreach(GridInfo info in ToCopy.LevelToGridInfo.Values) { GridInfo infoCopy = new GridInfo(info.GridXDim, info.GridYDim, info.Downsample, info.Path); LevelToGridInfo.Add(infoCopy.Downsample, infoCopy); } }
public void InitGrid() { gridArray.Clear(); if (NineGridRoot != null || gridArray.Count < 9) { gridArray.AddRange(NineGridRoot.GetComponentsInChildren <RectTransform> ()); gridArray.RemoveAt(0); } gridInfo.Clear(); for (int i = 0; i < gridSize; ++i) { var list = new List <GridInfo> (); for (int j = 0; j < gridSize; ++j) { var info = new GridInfo(); info.x = i; info.y = j; info.trans = GetGirdNine(i, j); list.Add(info); } gridInfo.Add(list); } }
// Fonction appelée lorsqu'une nouvelle grille est générée qui stock les informations de cette grille private void OnNewGameGrid(GridInfo gridInfo) { _currentGridInfo = gridInfo; }
/// <summary> /// ルート選択 /// </summary> /// <param name="_Grids">高低をあらわしたGridの2次配列、差が2以上あるものは壁とみなす</param> /// <returns>ルートがあるか</returns> public static bool SearchPath( int[,] _Grids, Vector2I _startPos, Vector2I _goalPos, out List<Vector2I> _PathList) { GridInfo[,] GridInfos; List<GridInfo> _ActiveGrids = new List<GridInfo>(); int GridWidth = _Grids.GetLength(0); int GridHeight = _Grids.GetLength(1); // 全グリッド情報を初期化 GridInfos = new GridInfo[GridWidth, GridHeight]; for (int y = 0; y < GridHeight; ++y) { for (int x = 0; x < GridWidth; ++x) { GridInfos[x, y].pos = new Vector2I(x, y); GridInfos[x, y].step = 0; GridInfos[x, y].dist = 0; GridInfos[x, y].weight = 1e10F; GridInfos[x, y].prev = new Vector2I(0, 0); } } // スタート地点をセット GridInfo info = GridInfos[_startPos.X, _startPos.Y]; info.dist = calcDist(_startPos, _goalPos); _ActiveGrids.Clear(); _ActiveGrids.Add(info); while (info.pos != _goalPos) { //周囲4グリッドを計算 for (int i = 0; i < 4; ++i) { int sx = ((i % 2 == 0) ? i - 1 : 0); int sy = ((i % 2 == 1) ? i - 2 : 0); int tx = info.pos.X + sx; int ty = info.pos.Y + sy; if (tx < 0 || tx > GridWidth - 1 || ty < 0 || ty > GridHeight - 1) continue; GridInfo neighbor = GridInfos[tx, ty]; // 移動コストを計算。平面のA*であれば通常は 1 で問題なし float weight = calcStepWeight(_Grids, info.pos, neighbor.pos); if (weight < 0) continue; // 0以下を壁とみなし探索を飛ばす neighbor.step = info.step + weight; neighbor.dist = calcDist(neighbor.pos, _goalPos); neighbor.weight = neighbor.step + neighbor.dist; neighbor.prev = info.pos; // 対象のグリッドがすでに計算されていて、ウェイトが低ければ上書きしない if (GridInfos[tx, ty].weight > neighbor.weight) { GridInfos[tx, ty] = neighbor; // ウェイトを元に探索対象リストへ挿入 bool added = false; for (int j = 0; j < _ActiveGrids.Count; ++j) { if (_ActiveGrids[j].weight > neighbor.weight) { _ActiveGrids.Insert(j, neighbor); added = true; break; } } if (added == false) _ActiveGrids.Add(neighbor); } } //検索済みのグリッドを削除 _ActiveGrids.Remove(info); if (_ActiveGrids.Count() == 0) { _PathList = null; // ルートなし return false; } // 次のグリッドをセット info = _ActiveGrids.First(); // 対象がゴール地点なら検索終了 if (_goalPos == info.pos) { _PathList = new List<Vector2I>(); while (info.pos != _startPos) { _PathList.Add(info.pos); info = GridInfos[info.prev.X, info.prev.Y]; } _PathList.Reverse(); return true; } } _PathList = null; return false; }
public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db) { IConfig gridConfig = config.Configs["GridService"]; if (gridConfig == null) { return; } if (!gridConfig.GetBoolean("HypergridLinker", false)) { return; } m_Database = db; m_GridService = gridService; m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType()); string assetService = gridConfig.GetString("AssetService", string.Empty); Object[] args = new Object[] { config }; if (assetService != string.Empty) { m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args); } string scope = gridConfig.GetString("ScopeID", string.Empty); if (scope != string.Empty) { UUID.TryParse(scope, out m_ScopeID); } // m_Check4096 = gridConfig.GetBoolean("Check4096", true); m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); m_ThisGridInfo = new GridInfo(config); if (!m_ThisGridInfo.HasHGConfig) { throw new Exception("missing HyperGrid configuration"); } m_log.DebugFormat("[HYPERGRID LINKER]: Local Gatekeeper: {0}", m_ThisGridInfo.GateKeeperURL); m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); if (!string.IsNullOrEmpty(m_MapTileDirectory)) { try { Directory.CreateDirectory(m_MapTileDirectory); } catch (Exception e) { m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); m_MapTileDirectory = string.Empty; } } if (MainConsole.Instance != null) { MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]", "Link a hypergrid region (deprecated)", RunCommand); MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region", "unlink-region <local name>", "Unlink a hypergrid region", RunCommand); MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]", "Set local coordinate to map HG regions to", RunCommand); MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks", "List the HG regions", HandleShow); } }
public static List <Tile> GetRangeObstacles(Tile startTile, int range, GridInfo gridInfo, out ThisIsCool cool) { List <TileRange> openSet = new List <TileRange>(); HashSet <Tile> closedSet = new HashSet <Tile>(); HashSet <Tile> finalSet = new HashSet <Tile>(); cool.outerTiles = new List <Tile>(); if (gridInfo == null) { gridInfo = new GridInfo(); gridInfo.cleanse = false; gridInfo.useLineOfSight = false; gridInfo.useMovementPenalty = false; gridInfo.useThisIsCool = false; gridInfo.allowEntitiesToBeTargeted = false; } foreach (Tile t in GridManager.grid) { t.isAvailableToPathfinding = true; t.isClickableForInput = true; } openSet.Add(new TileRange(startTile, range)); while (openSet.Count > 0) { TileRange currentTile = openSet[0]; openSet.Remove(currentTile); finalSet.Add(currentTile.tile); cool.outerTiles.Add(currentTile.tile); foreach (Tile n in GetNeighbors(currentTile.tile)) { if (finalSet.Contains(n)) { continue; } if (gridInfo.unreachableTiles != null) { if (gridInfo.unreachableTiles.Contains(n) == true) { continue; } } int comparerWeight = BattleManager.distanceCoefficient; if (gridInfo.useMovementPenalty == true) { comparerWeight = n.baseWeight; } if (currentTile.rangeLeft >= comparerWeight && ((n.isEmpty || gridInfo.allowEntitiesToBeTargeted) || gridInfo.useThisIsCool)) { if (cool.outerTiles.Contains(currentTile.tile)) { cool.outerTiles.Remove(currentTile.tile); } if (gridInfo.cleanse) { if (gridInfo.unPathableTiles.Contains(n)) { finalSet.Add(n); } else if (closedSet.Contains(n) == false) { openSet.Add(new TileRange(n, currentTile.rangeLeft - comparerWeight)); closedSet.Add(n); } } else if (closedSet.Contains(n) == false) { openSet.Add(new TileRange(n, currentTile.rangeLeft - comparerWeight)); closedSet.Add(n); } else { finalSet.Add(n); } } } } List <Tile> result = new List <Tile>(); foreach (Tile t in GridManager.grid) { if (finalSet.Contains(t)) { result.Add(t); } else { t.isAvailableToPathfinding = false; t.isClickableForInput = false; } } result.Remove(startTile); return(result); }
/// <summary> /// ルート選択 /// </summary> /// <param name="_Grids">高低をあらわしたGridの2次配列、差が2以上あるものは壁とみなす</param> /// <returns>ルートがあるか</returns> public static bool SearchPath( int[,] _Grids, Vector2I _startPos, Vector2I _goalPos, out List <Vector2I> _PathList) { GridInfo[,] GridInfos; List <GridInfo> _ActiveGrids = new List <GridInfo>(); int GridWidth = _Grids.GetLength(0); int GridHeight = _Grids.GetLength(1); // 全グリッド情報を初期化 GridInfos = new GridInfo[GridWidth, GridHeight]; for (int y = 0; y < GridHeight; ++y) { for (int x = 0; x < GridWidth; ++x) { GridInfos[x, y].pos = new Vector2I(x, y); GridInfos[x, y].step = 0; GridInfos[x, y].dist = 0; GridInfos[x, y].weight = 1e10F; GridInfos[x, y].prev = new Vector2I(0, 0); } } // スタート地点をセット GridInfo info = GridInfos[_startPos.X, _startPos.Y]; info.dist = calcDist(_startPos, _goalPos); _ActiveGrids.Clear(); _ActiveGrids.Add(info); while (info.pos != _goalPos) { //周囲4グリッドを計算 for (int i = 0; i < 4; ++i) { int sx = ((i % 2 == 0) ? i - 1 : 0); int sy = ((i % 2 == 1) ? i - 2 : 0); int tx = info.pos.X + sx; int ty = info.pos.Y + sy; if (tx < 0 || tx > GridWidth - 1 || ty < 0 || ty > GridHeight - 1) { continue; } GridInfo neighbor = GridInfos[tx, ty]; // 移動コストを計算。平面のA*であれば通常は 1 で問題なし float weight = calcStepWeight(_Grids, info.pos, neighbor.pos); if (weight < 0) { continue; // 0以下を壁とみなし探索を飛ばす } neighbor.step = info.step + weight; neighbor.dist = calcDist(neighbor.pos, _goalPos); neighbor.weight = neighbor.step + neighbor.dist; neighbor.prev = info.pos; // 対象のグリッドがすでに計算されていて、ウェイトが低ければ上書きしない if (GridInfos[tx, ty].weight > neighbor.weight) { GridInfos[tx, ty] = neighbor; // ウェイトを元に探索対象リストへ挿入 bool added = false; for (int j = 0; j < _ActiveGrids.Count; ++j) { if (_ActiveGrids[j].weight > neighbor.weight) { _ActiveGrids.Insert(j, neighbor); added = true; break; } } if (added == false) { _ActiveGrids.Add(neighbor); } } } //検索済みのグリッドを削除 _ActiveGrids.Remove(info); if (_ActiveGrids.Count() == 0) { _PathList = null; // ルートなし return(false); } // 次のグリッドをセット info = _ActiveGrids.First(); // 対象がゴール地点なら検索終了 if (_goalPos == info.pos) { _PathList = new List <Vector2I>(); while (info.pos != _startPos) { _PathList.Add(info.pos); info = GridInfos[info.prev.X, info.prev.Y]; } _PathList.Reverse(); return(true); } } _PathList = null; return(false); }
public void saveGrid(){ FileStream stream = null; try{ XmlSerializer serializer = new XmlSerializer(typeof(GridInfo)); stream = new FileStream(gridInfoFilepath, FileMode.CreateNew); // New grid info to disk here. serializer.Serialize(stream, currentGridInfo); stream.Close(); } catch(Exception ex){ Debug.LogError(ex.ToString()); if(stream != null) stream.Close(); } currentGridInfo = newGridInfo; }
public void Close() { m_thisGridInfo = null; }
private void ReadGndFile() { string Root = textBox2.Text; using( FileStream s = File.OpenRead( textBox1.Text ) ) { using( BinaryReader bin = new BinaryReader( s, Encoding.GetEncoding( "ISO-8859-1" ) ) ) { bin.BaseStream.Position += 6; mHeader = new HeaderInfo(); mHeader.Width = bin.ReadUInt32(); mHeader.Height = bin.ReadUInt32(); mHeader.Ratio = bin.ReadUInt32(); mHeader.TextureCount = bin.ReadUInt32(); mHeader.TextureSize = bin.ReadUInt32(); mTextures = new TextureInfo[ mHeader.TextureCount ]; for( int i = 0; i < mTextures.Length; i++ ) { mTextures[ i ] = new TextureInfo(); mTextures[ i ].TexPath = ReadWord( bin, 40 ).ToLower(); mTextures[ i ].Unknown = ReadWord( bin, 40 ).ToCharArray(); mTextures[ i ].TextureBmp = Bitmap.FromFile( Root + @"\" + mTextures[ i ].TexPath ) as Bitmap; } mLightmapCount = (uint)bin.ReadInt32(); mGrid = new GridInfo(); mGrid.X = bin.ReadUInt32(); mGrid.Y = bin.ReadUInt32(); mGrid.Cells = bin.ReadUInt32(); mLightmaps = new LitghmapInfo[ mLightmapCount ]; for( int i = 0; i < mLightmaps.Length; i++ ) { mLightmaps[ i ] = new LitghmapInfo(); mLightmaps[ i ].brightness = bin.ReadChars( 64 ); mLightmaps[ i ].colorrbg = bin.ReadChars( 192 ); } mTileCount = (uint)bin.ReadInt32(); mTiles = new TileInfo[ mTileCount ]; for( int i = 0; i < mTiles.Length; i++ ) { mTiles[ i ] = new TileInfo(); mTiles[ i ].VectorWidth = ReadVector4( bin ); mTiles[ i ].VectorHeight = ReadVector4( bin ); mTiles[ i ].TextureIndex = bin.ReadUInt16(); mTiles[ i ].Lightmap = bin.ReadUInt16(); mTiles[ i ].color = bin.ReadChars( 4 ); } mCubeCount = mHeader.Width * mHeader.Height; mCubes = new CubeInfo[ mCubeCount ]; for( int i = 0; i < mCubes.Length; i++ ) { mCubes[ i ] = new CubeInfo(); mCubes[ i ].Height = ReadVector4( bin ); mCubes[ i ].tile_up = bin.ReadInt32(); mCubes[ i ].tile_side = bin.ReadInt32(); mCubes[ i ].tile_aside = bin.ReadInt32(); } } } }
/// <summary> /// Add a level to the tile grid mapping /// </summary> /// <param name="Downsample"></param> /// <param name="GridDimX">Number of tiles on X axis</param> /// <param name="GridDimY">Number of tiles on Y axis</param> /// <param name="LevelPath">Path to level data</param> /// <returns></returns> public void AddLevel(int Downsample, int GridDimX, int GridDimY, string LevelPath) { if (Downsample > this.MaxDownsample) this.MaxDownsample = Downsample; if (Downsample < this.MinDownsample) this.MinDownsample = Downsample; GridInfo Level = new GridInfo(GridDimX, GridDimY, Downsample, LevelPath); LevelToGridInfo.Add(Downsample, Level); this._AvailableLevels = null; }
public void Clear(int width, int length) { dimWidth = width; dimLength = length; myGridSpots.Clear(); for(int i = 0; i < width; ++i) { for(int j = 0; j < length; ++j) { GridInfo newGridInfo = new GridInfo(); newGridInfo.x = i; newGridInfo.y = j; ModifyGrid(newGridInfo, i, j, width, length); myGridSpots.Add(newGridInfo); } } }
// Tests to ensure that it is valid to place an object over the given grid rectangle public bool TestGrid(GridInfo info, int dimX, int dimY) { for(int i = 0; i < dimX; ++i) { if (myGridSpots[Index(info.x + i, info.y)].downSquares < (dimY-1)) return false; } return true; }
public void ModifyGrid(GridInfo info, int i, int j, int width, int length) { info.leftSquares = i; info.rightSquares = width - i - 1; info.upSquares = j; info.downSquares= length - j - 1; }
private void SetALLList(GridInfo gridInfo) { this.C_LBFields.Items.Clear(); Webb.Reports.DataProvider.WebbDataProvider PublicDataProvider = Webb.Reports.DataProvider.VideoPlayBackManager.PublicDBProvider; if (PublicDataProvider != null && PublicDataProvider.DBSourceConfig != null && PublicDataProvider.DBSourceConfig.WebbDBType == Webb.Reports.DataProvider.WebbDBTypes.CoachCRM) { #region CoachCRM List DataSet ds = Webb.Reports.DataProvider.VideoPlayBackManager.DataSource; if (ds != null && ds.Tables.Count > 1) { #region Have Structure this.cmbAllFieldCategories.Visible = true; this.lblSelectedColumns.Visible = true; this.TBXEdit.Visible = false; this.TBXEdit.Location = this.C_LBFields.Location; HashCategories.Clear(); List <string> categories = new List <string>(); string strCategoriesName = ds.Tables[0].TableName; categories.Add(strCategoriesName); GridColumnCollection colfieldsInAllcategories = new GridColumnCollection(); HashCategories.Add(strCategoriesName, colfieldsInAllcategories); foreach (DataRow dr in ds.Tables[1].Rows) { string strValue = string.Empty; if (dr["CurrentField"] == null || (dr["CurrentField"] is System.DBNull)) { continue; } string strTableName = dr["Category"].ToString(); strValue = dr["CurrentField"].ToString(); string strDefaultHeader = dr["DefaultHeader"].ToString(); GridColumnCollection colfieldList; GridColumn column = new GridColumn(strValue, strDefaultHeader); column.Description = strDefaultHeader; if (HashCategories.Contains(strTableName)) { colfieldList = (GridColumnCollection)HashCategories[strTableName]; if (!colfieldList.Contains(strValue)) { colfieldList.Add(column); } } else { colfieldList = new GridColumnCollection(); colfieldList.Add(column); categories.Add(strTableName); HashCategories.Add(strTableName, colfieldList); } if (!colfieldsInAllcategories.Contains(strValue)) { colfieldsInAllcategories.Add(column); } } this.cmbAllFieldCategories.Items.Clear(); this.cmbAllFieldCategories.Text = string.Empty; foreach (string strKey in categories) { this.cmbAllFieldCategories.Items.Add(strKey); } this.cmbAllFieldCategories.SelectedIndex = 0; #endregion } else { this.cmbAllFieldCategories.Visible = false; this.lblSelectedColumns.Visible = false; this.TBXEdit.Visible = false; this.TBXEdit.Location = this.C_LBFields.Location; foreach (string strField in Webb.Data.PublicDBFieldConverter.AvialableFields) { if (gridInfo.Columns.Contains(strField)) { continue; } GridColumn column = new GridColumn(strField); this.C_LBFields.Items.Add(column); } } #endregion } else { this.cmbAllFieldCategories.Visible = false; this.lblSelectedColumns.Visible = false; this.TBXEdit.Visible = false; this.TBXEdit.Location = this.C_LBFields.Location; foreach (string strField in Webb.Data.PublicDBFieldConverter.AvialableFields) { if (gridInfo.Columns.Contains(strField)) { continue; } GridColumn column = new GridColumn(strField); this.C_LBFields.Items.Add(column); } } }
/// <summary> /// Gets the grid extra features. /// </summary> /// <param name='featuresURI'> /// The URI Robust uses to handle the get_extra_features request /// </param> private void GetGridExtraFeatures(Scene scene) { Dictionary <string, object> extraFeatures = scene.GridService.GetExtraFeatures(); if (extraFeatures.ContainsKey("Result") && extraFeatures["Result"] != null && extraFeatures["Result"].ToString() == "Failure") { m_log.WarnFormat("[SIMULATOR FEATURES MODULE]: Unable to retrieve grid-wide features"); return; } GridInfo ginfo = scene.SceneGridInfo; lock (m_features) { OSDMap extrasMap; if (m_features.TryGetValue("OpenSimExtras", out OSD extra)) { extrasMap = extra as OSDMap; } else { extrasMap = new OSDMap(); } foreach (string key in extraFeatures.Keys) { string val = (string)extraFeatures[key]; switch (key) { case "GridName": ginfo.GridName = val; break; case "GridNick": ginfo.GridNick = val; break; case "GridURL": ginfo.GridUrl = val; break; case "GridURLAlias": string[] vals = val.Split(','); if (vals.Length > 0) { ginfo.GridUrlAlias = vals; } break; case "search-server-url": ginfo.SearchURL = val; break; case "destination-guide-url": ginfo.DestinationGuideURL = val; break; /* keep this local to avoid issues with diferent modules * case "currency-base-uri": * ginfo.EconomyURL = val; * break; */ default: extrasMap[key] = val; if (key == "ExportSupported") { bool.TryParse(val, out m_ExportSupported); } break; } } m_features["OpenSimExtras"] = extrasMap; } }
// Use this for initialization void Awake() { var platform = ComputePlatform.Platforms[0]; _context = new ComputeContext(ComputeDeviceTypes.Cpu, new ComputeContextPropertyList(platform), null, System.IntPtr.Zero); _queue = new ComputeCommandQueue(_context, _context.Devices[0], ComputeCommandQueueFlags.None); string clSource = System.IO.File.ReadAllText(clProgramPath); _program = new ComputeProgram(_context, clSource); try { _program.Build(null, null, null, System.IntPtr.Zero); } catch(BuildProgramFailureComputeException) { Debug.Log(_program.GetBuildLog(_context.Devices[0])); throw; } _events = new ComputeEventList(); _updateGridKernel = _program.CreateKernel(clUpdateGridKernelName); _updateBoidsKernel = _program.CreateKernel(clUpdateBoidsKernelName); _boundaryKernel = _program.CreateKernel(clBoundaryKernelName); _pointCounters = new int[nGridPartitions * nGridPartitions * nGridPartitions]; _pointIndices = new int[_pointCounters.Length * maxIndices]; _pointCountersBuffer = new Cloo.ComputeBuffer<int>( _context, ComputeMemoryFlags.WriteOnly, _pointCounters.Length); _pointIndicesBuffer = new Cloo.ComputeBuffer<int>( _context, ComputeMemoryFlags.WriteOnly, _pointIndices.Length); _gridInfo = new GridInfo() { worldOrigin = gridbounds.min, worldSize = gridbounds.size, cellSize = gridbounds.size * (1f / nGridPartitions), nGridPartitions = nGridPartitions, maxIndices = maxIndices }; _boundaryKernel.SetValueArgument(1, _gridInfo); _updateGridKernel.SetMemoryArgument(1, _pointCountersBuffer); _updateGridKernel.SetMemoryArgument(2, _pointIndicesBuffer); _updateGridKernel.SetValueArgument(3, _gridInfo); _updateBoidsKernel.SetMemoryArgument(2, _pointCountersBuffer); _updateBoidsKernel.SetMemoryArgument(3, _pointIndicesBuffer); _updateBoidsKernel.SetValueArgument(4, _gridInfo); }
// Fonction pour initialiser les components de la tuile, lorsqu'elle spawn public virtual void InitializeTile(Vector2 tileDimensions, GridMode gridMode, GridInfo currentGridInfo) { AssignGridInfo(currentGridInfo); InitializeTile(tileDimensions, gridMode); }
/// <summary> /// 临时版 获取警车列表 /// </summary> /// <param name="polygon"></param> /// <returns></returns> public List <PoliceCar> GetPoliceCarListByPoly(List <Point> polygon) { List <GridInfo> xzqhList = new List <GridInfo>(); //从文本文件读取市局、县区列表 String policeCarPath = ConfigHelper.GetAssemblyPath() + "PoliceCar.txt"; StreamReader reader = new StreamReader(policeCarPath); try { do { string line = reader.ReadLine(); string[] lineList = line.Split(null); GridInfo gridInfo = new GridInfo { ZZJGDM = lineList[0], JD = lineList[1], WD = lineList[2] }; //todo xzqhList.Add(gridInfo); }while (reader.Peek() != -1); } catch (System.IO.FileNotFoundException) { throw new FileNotFoundException("未发现警车点文件"); } finally { reader.Close(); } List <GridInfo> filterXzqhList = new List <GridInfo>(); foreach (GridInfo js in xzqhList) { if (js.JD != null && js.WD != null) { double jd, wd; double.TryParse(js.JD, out jd); double.TryParse(js.WD, out wd); bool re = PtInPolygon(jd, wd, polygon); if (re == true) { filterXzqhList.Add(js); } } } List <PoliceCar> plcList = JsonConvert.DeserializeObject <List <PoliceCar> >((ServiceUtil.GetRemoteXmlStream(ConfigHelper.GetValueByKey("webservice.config", "圈选警车统计"), null))); List <PoliceCar> plcListRe = new List <PoliceCar>(); string quxian = null; foreach (GridInfo pcs in filterXzqhList) { string pcsid = pcs.ZZJGDM.Substring(0, 6); if (pcsid.Equals(quxian)) { continue; } else { quxian = pcsid; } foreach (PoliceCar plc in plcList) { string plcid = plc.ORGID.Substring(0, 6); if (pcsid.Equals(plcid)) { plcListRe.Add(plc); } } } return(plcListRe); }
public static MvcHtmlString GridCr(this HtmlHelper helper, string gridName, GridInfo gridTotalConfig, Type viewModelType, ClientDependentFeature clientDependency, string Width = null, string Height = null) { return((new GridCr <object>(helper, gridName, gridTotalConfig, viewModelType, clientDependency, Width, Height)).Render()); }
public BoardPiece(GridInfo info, TileBase tile, Vector2 pos) { this.info = info; this.tile = tile; this.pos = pos; }
/// <summary> /// Creates a plane in axis XZ and uvs /// </summary> /// <returns>The plane X zwith U.</returns> /// <param name="parentM">Parent m.</param> /// <param name="sizeRec">Size rec.</param> /// <param name="numX">Number x.</param> /// <param name="numZ">Number z.</param> public static GridInfo CreatePlaneXZwithUV(Transform parentM, int sizeRec, int numX, int numZ) { Vector3 iniPos = new Vector3(-0.5f * sizeRec * numX, 0, -0.5f * sizeRec * numZ); GridInfo info = new GridInfo(); int indexCenter = 0; Dictionary <int, Vector3> centers = new Dictionary <int, Vector3> (); Mesh ml = new Mesh(); ml.name = "GridXZ"; int hCount = numX + 1; int vCount = numZ + 1; int numTriangles = numX * numZ * 6; int numVertices = hCount * vCount; Vector3[] vertices = new Vector3[numVertices]; Vector2[] uvs = new Vector2[numVertices]; int[] triangles = new int[numTriangles]; int index = 0; float uvFactorX = 1.0f / numX; float uvFactorZ = 1.0f / numZ; for (float z = 0.0f; z < vCount; z++) { for (float x = 0.0f; x < hCount; x++) { vertices[index] = (new Vector3(x * sizeRec + iniPos.x, 0, z * sizeRec + iniPos.z)); uvs[index++] = new Vector2(x * uvFactorX, z * uvFactorZ); } } index = 0; for (int z = 0; z < numZ; z++) { for (int x = 0; x < numX; x++) { triangles[index] = (z * hCount) + x; triangles[index + 1] = ((z + 1) * hCount) + x; triangles[index + 2] = (z * hCount) + x + 1; triangles[index + 3] = ((z + 1) * hCount) + x; triangles[index + 4] = ((z + 1) * hCount) + x + 1; triangles[index + 5] = (z * hCount) + x + 1; index += 6; } } for (float z = 0.0f; z < vCount - 1; ++z) { for (float x = 0.0f; x < hCount - 1; ++x) { centers.Add(indexCenter++, new Vector3((x + 0.5f) * sizeRec + iniPos.x, 0, (z + 0.5f) * sizeRec + iniPos.z)); } } ml.vertices = vertices; ml.uv = uvs; ml.triangles = triangles; ml.RecalculateNormals(); ml.RecalculateBounds(); ml.Optimize(); info.mesh = ml; info.centers = centers; return(info); }
public void Load(GridPool Grid, string loadpath) { List <BuildPartsPool>[] baseParts = Singleton <CraftCommandListBaseObject> .Instance.BaseParts; FileStream fileStream = new FileStream(loadpath, FileMode.Open, FileAccess.Read); Encoding utF8 = Encoding.UTF8; BinaryReader br = new BinaryReader((Stream)fileStream, utF8); if (br != null) { PngFile.SkipPng(br); int num1 = (int)br.ReadChar(); char ch = br.ReadChar(); if (!ch.Equals('P')) { fileStream.Seek(-2L, SeekOrigin.Current); } this.data.MaxFloorNum = br.ReadInt32(); this.data.nPutPartsNum = br.ReadInt32(); Vector3 vector3; while (!ch.Equals('P')) { vector3.x = (__Null)br.ReadDouble(); vector3.y = (__Null)br.ReadDouble(); vector3.z = (__Null)br.ReadDouble(); this.data.GridPos.Add(vector3); int num2 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('P')) { fileStream.Seek(-2L, SeekOrigin.Current); } } int num3 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('U')) { fileStream.Seek(-2L, SeekOrigin.Current); } while (!ch.Equals('U')) { this.data.GridUseState.Add(br.ReadBoolean()); int num2 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('U')) { fileStream.Seek(-2L, SeekOrigin.Current); } } int num4 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('F')) { fileStream.Seek(-2L, SeekOrigin.Current); } while (!ch.Equals('F')) { this.data.nFloorPartsHeight.Add(br.ReadInt32()); int num2 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('F')) { fileStream.Seek(-2L, SeekOrigin.Current); } } int num5 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('S')) { fileStream.Seek(-2L, SeekOrigin.Current); } int index1 = 0; int index2 = 0; int num6 = 0; this.data.SmallGridState.Add(new List <List <int> >()); this.data.SmallGridOnParts.Add(new List <List <int[]> >()); this.data.SmallGridOnStackWall.Add(new List <List <int[]> >()); this.data.SmallGridCanRoofState.Add(new List <List <int> >()); this.data.SmallGridInRoomState.Add(new List <List <bool> >()); this.data.SmallGridState[index1].Add(new List <int>()); this.data.SmallGridOnParts[index1].Add(new List <int[]>()); this.data.SmallGridOnStackWall[index1].Add(new List <int[]>()); this.data.SmallGridCanRoofState[index1].Add(new List <int>()); this.data.SmallGridInRoomState[index1].Add(new List <bool>()); while (!ch.Equals('S')) { this.data.SmallGridState[index1][index2].Add(br.ReadInt32()); int[] numArray1 = new int[7]; for (int index3 = 0; index3 < numArray1.Length; ++index3) { numArray1[index3] = br.ReadInt32(); } this.data.SmallGridOnParts[index1][index2].Add(numArray1); int[] numArray2 = new int[9]; for (int index3 = 0; index3 < numArray2.Length; ++index3) { numArray2[index3] = br.ReadInt32(); } this.data.SmallGridOnStackWall[index1][index2].Add(numArray2); this.data.SmallGridCanRoofState[index1][index2].Add(br.ReadInt32()); this.data.SmallGridInRoomState[index1][index2].Add(br.ReadBoolean()); int num2 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('S')) { fileStream.Seek(-2L, SeekOrigin.Current); } ++num6; if (num6 == 4) { num6 = 0; ++index2; if (index2 != this.data.MaxFloorNum) { this.data.SmallGridState[index1].Add(new List <int>()); this.data.SmallGridOnParts[index1].Add(new List <int[]>()); this.data.SmallGridOnStackWall[index1].Add(new List <int[]>()); this.data.SmallGridCanRoofState[index1].Add(new List <int>()); this.data.SmallGridInRoomState[index1].Add(new List <bool>()); } if (index2 == this.data.MaxFloorNum) { index2 = 0; ++index1; this.data.SmallGridState.Add(new List <List <int> >()); this.data.SmallGridOnParts.Add(new List <List <int[]> >()); this.data.SmallGridOnStackWall.Add(new List <List <int[]> >()); this.data.SmallGridCanRoofState.Add(new List <List <int> >()); this.data.SmallGridInRoomState.Add(new List <List <bool> >()); this.data.SmallGridState[index1].Add(new List <int>()); this.data.SmallGridOnParts[index1].Add(new List <int[]>()); this.data.SmallGridOnStackWall[index1].Add(new List <int[]>()); this.data.SmallGridCanRoofState[index1].Add(new List <int>()); this.data.SmallGridInRoomState[index1].Add(new List <bool>()); } } } int num7 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('B')) { fileStream.Seek(-2L, SeekOrigin.Current); } List <int> intList1 = new List <int>(); List <int> intList2 = new List <int>(); while (!ch.Equals('B')) { this.data.BuildPartsGridKind.Add(br.ReadInt32()); this.data.BuildPartsKind.Add(br.ReadInt32()); this.data.BuildPartsFloor.Add(br.ReadInt32()); vector3.x = (__Null)br.ReadDouble(); vector3.y = (__Null)br.ReadDouble(); vector3.z = (__Null)br.ReadDouble(); this.data.BuildPartsPos.Add(vector3); Quaternion quaternion; quaternion.x = (__Null)br.ReadDouble(); quaternion.y = (__Null)br.ReadDouble(); quaternion.z = (__Null)br.ReadDouble(); quaternion.w = (__Null)br.ReadDouble(); this.data.BuildPartsRot.Add(quaternion); this.data.BuildPartsPutGridInfosNum.Add(br.ReadInt32()); intList1.Clear(); intList2.Clear(); for (int index3 = 0; index3 < this.data.BuildPartsPutGridInfosNum[this.data.BuildPartsPutGridInfosNum.Count - 1]; ++index3) { intList1.Add(br.ReadInt32()); intList2.Add(br.ReadInt32()); } this.data.BuildPartsPutGridInfos.Add(intList1); this.data.BuildPartsPutSmallGridInfos.Add(intList2); int num2 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('B')) { fileStream.Seek(-2L, SeekOrigin.Current); } } int num8 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('A')) { fileStream.Seek(-2L, SeekOrigin.Current); } bool[] flagArray = new bool[this.data.GridPos.Count]; while (!ch.Equals('A')) { for (int index3 = 0; index3 < flagArray.Length; ++index3) { flagArray[index3] = br.ReadBoolean(); } this.data.tmpGridActiveList.Add(flagArray); this.data.tmpGridActiveListUpdate.Add(br.ReadBoolean()); this.data.MaxPutHeight.Add(br.ReadInt32()); int num2 = (int)br.ReadChar(); ch = br.ReadChar(); if (!ch.Equals('A')) { fileStream.Seek(-2L, SeekOrigin.Current); } } br.Close(); } if (this.data.SmallGridState[this.data.SmallGridState.Count - 1][this.data.SmallGridState[this.data.SmallGridState.Count - 1].Count - 1].Count == 0) { this.data.SmallGridState.RemoveAt(this.data.SmallGridState.Count - 1); this.data.SmallGridOnParts.RemoveAt(this.data.SmallGridOnParts.Count - 1); this.data.SmallGridOnStackWall.RemoveAt(this.data.SmallGridOnStackWall.Count - 1); this.data.SmallGridCanRoofState.RemoveAt(this.data.SmallGridCanRoofState.Count - 1); this.data.SmallGridInRoomState.RemoveAt(this.data.SmallGridInRoomState.Count - 1); } Singleton <CraftCommandListBaseObject> .Instance.nMaxFloorCnt = this.data.MaxFloorNum; Singleton <CraftCommandListBaseObject> .Instance.nPutPartsNum = this.data.nPutPartsNum; List <GameObject> list1 = Grid.GetList(); List <GridInfo> Grid1 = new List <GridInfo>(); using (List <GameObject> .Enumerator enumerator = list1.GetEnumerator()) { while (enumerator.MoveNext()) { GameObject current = enumerator.Current; Grid1.Add((GridInfo)current.GetComponent <GridInfo>()); } } int num = this.data.GridPos.Count - list1.Count; if (num > 0) { for (int index = 0; index < num; ++index) { Grid.Get(); } } for (int index1 = 0; index1 < list1.Count; ++index1) { list1[index1].SetActive(true); list1[index1].get_transform().set_localPosition(this.data.GridPos[index1]); Grid1[index1].DelFloor(0); for (int floorNum = Grid1[index1].GetFloorNum(); floorNum < this.data.MaxFloorNum; ++floorNum) { Grid1[index1].AddFloor(); } for (int index2 = 0; index2 < this.data.MaxFloorNum; ++index2) { Grid1[index1].SetUseState(index2, this.data.GridUseState[index2 + Grid1[index1].GetFloorNum() * index1]); Grid1[index1].nFloorPartsHeight[index2] = this.data.nFloorPartsHeight[index2]; for (int index3 = 0; index3 < 4; ++index3) { for (int index4 = 0; index4 < 7; ++index4) { Grid1[index1].ChangeSmallGrid(index3, this.data.SmallGridState[index1][index2][index3], this.data.SmallGridOnParts[index1][index2][index3][index4], index2, false); } for (int index4 = 0; index4 < 5; ++index4) { Grid1[index1].ChangeSmallGrid(index3, this.data.SmallGridState[index1][index2][index3], this.data.SmallGridOnStackWall[index1][index2][index3][index4], index2, false); } if (index2 == 0) { Grid1[index1].ChangeSmallGridColor(index2, index3); } Grid1[index1].SetCanRoofSmallGrid(index3, index2, this.data.SmallGridCanRoofState[index1][index2][index3]); Grid1[index1].SetInRoomSmallGrid(index3, this.data.SmallGridInRoomState[index1][index2][index3], index2); } } } for (int floorcnt = 0; floorcnt < this.data.MaxFloorNum; ++floorcnt) { GridInfo.ChangeGridInfo(Grid1, floorcnt); } List <GameObject> gameObjectList = new List <GameObject>(); for (int index1 = 0; index1 < baseParts.Length; ++index1) { for (int index2 = 0; index2 < baseParts[index1].Count; ++index2) { List <GameObject> list2 = baseParts[index1][index2].GetList(); for (int index3 = 0; index3 < list2.Count; ++index3) { if (list2[index3].get_activeSelf()) { list2[index3].SetActive(false); } if (((BuildPartsInfo)list2[index3].GetComponent <BuildPartsInfo>()).nPutFloor != -1) { ((BuildPartsInfo)list2[index3].GetComponent <BuildPartsInfo>()).nPutFloor = -1; } } baseParts[index1][index2].ReserveListDel(0, 1); } } for (int index1 = 0; index1 < this.data.BuildPartsPos.Count; ++index1) { if (gameObjectList != baseParts[this.data.BuildPartsGridKind[index1]][this.data.BuildPartsKind[index1]].GetList()) { gameObjectList = baseParts[this.data.BuildPartsGridKind[index1]][this.data.BuildPartsKind[index1]].GetList(); } int ID = -1; baseParts[this.data.BuildPartsGridKind[index1]][this.data.BuildPartsKind[index1]].Get(ref ID); BuildPartsInfo component = (BuildPartsInfo)gameObjectList[ID].GetComponent <BuildPartsInfo>(); gameObjectList[ID].SetActive(true); gameObjectList[ID].get_transform().set_localPosition(this.data.BuildPartsPos[index1]); gameObjectList[ID].get_transform().set_localRotation(this.data.BuildPartsRot[index1]); component.nPutFloor = this.data.BuildPartsFloor[index1]; component.putGridInfos.Clear(); component.putSmallGridInfos.Clear(); for (int index2 = 0; index2 < this.data.BuildPartsPutGridInfos.Count; ++index2) { component.putGridInfos.Add(Singleton <CraftCommandListBaseObject> .Instance.BaseGridInfo[this.data.BuildPartsPutGridInfos[index1][index2]]); component.putSmallGridInfos.Add(this.data.BuildPartsPutSmallGridInfos[index1][index2]); } } Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveList = this.data.tmpGridActiveList; Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveListUpdate = this.data.tmpGridActiveListUpdate; Singleton <CraftCommandListBaseObject> .Instance.MaxPutHeight = this.data.MaxPutHeight; this.data.MaxFloorNum = 0; this.data.nPutPartsNum = 0; this.data.GridPos.Clear(); this.data.GridUseState.Clear(); this.data.nFloorPartsHeight.Clear(); this.data.SmallGridState.Clear(); this.data.SmallGridOnParts.Clear(); this.data.SmallGridOnStackWall.Clear(); this.data.SmallGridCanRoofState.Clear(); this.data.SmallGridInRoomState.Clear(); this.data.BuildPartsGridKind.Clear(); this.data.BuildPartsKind.Clear(); this.data.BuildPartsFloor.Clear(); this.data.BuildPartsPos.Clear(); this.data.BuildPartsRot.Clear(); this.data.BuildPartsPutGridInfos.Clear(); this.data.BuildPartsPutSmallGridInfos.Clear(); this.data.BuildPartsPutGridInfosNum.Clear(); this.data.tmpGridActiveList.Clear(); this.data.tmpGridActiveListUpdate.Clear(); this.data.MaxPutHeight.Clear(); }
public static Tile[] FindPath(Tile startTile, Tile targetTile, out int cost, GridInfo gridInfo) { foreach (Tile t in GridManager.grid) { t.ResetCosts(); } cost = 0; List <Tile> openSet = new List <Tile>(); HashSet <Tile> closedSet = new HashSet <Tile>(); openSet.Add(startTile); while (openSet.Count > 0) { Tile currentTile = openSet[0]; for (int i = 1; i < openSet.Count; i++) { if (openSet[i].fCost < currentTile.fCost || openSet[i].fCost == currentTile.fCost && openSet[i].hCost < currentTile.hCost) { currentTile = openSet[i]; } } openSet.Remove(currentTile); closedSet.Add(currentTile); if (currentTile == targetTile) { return(RetracePath(startTile, targetTile, out cost)); } foreach (Tile n in GetNeighbors(currentTile)) { if (gridInfo.unreachableTiles != null) { if (gridInfo.unreachableTiles.Contains(n)) { continue; } } if (n.isEmpty == false) { continue; } if (closedSet.Contains(n) == true) { continue; } int weight = n.baseWeight; int newMovementCostToNeighbor = currentTile.gCost + (int)(Tile.Distance(currentTile, n) * BattleManager.distanceCoefficient * weight); if (newMovementCostToNeighbor < n.gCost || !openSet.Contains(n)) { n.gCost = newMovementCostToNeighbor; n.hCost = Tile.Distance(n, targetTile) * BattleManager.distanceCoefficient; n.parent = currentTile; if (!openSet.Contains(n)) { openSet.Add(n); } } } } return(null); }
public void Save(ObjPool Grid) { List <BuildPartsPool>[] baseParts = Singleton <CraftCommandListBaseObject> .Instance.BaseParts; int nMaxFloorCnt = Singleton <CraftCommandListBaseObject> .Instance.nMaxFloorCnt; this.data.MaxFloorNum = nMaxFloorCnt; this.data.nPutPartsNum = Singleton <CraftCommandListBaseObject> .Instance.nPutPartsNum; List <GameObject> list1 = Grid.GetList(); for (int index = 0; index < list1.Count; ++index) { this.data.SmallGridState.Add(new List <List <int> >()); this.data.SmallGridOnParts.Add(new List <List <int[]> >()); this.data.SmallGridOnStackWall.Add(new List <List <int[]> >()); this.data.SmallGridCanRoofState.Add(new List <List <int> >()); this.data.SmallGridInRoomState.Add(new List <List <bool> >()); GridInfo component = (GridInfo)list1[index].GetComponent <GridInfo>(); this.data.GridPos.Add(component.InitPos); for (int floorcnt = 0; floorcnt < nMaxFloorCnt; ++floorcnt) { this.data.SmallGridState[index].Add(new List <int>()); this.data.SmallGridOnParts[index].Add(new List <int[]>()); this.data.SmallGridOnStackWall[index].Add(new List <int[]>()); this.data.SmallGridCanRoofState[index].Add(new List <int>()); this.data.SmallGridInRoomState[index].Add(new List <bool>()); this.data.GridUseState.Add(component.GetUseState(floorcnt)); this.data.nFloorPartsHeight.Add(component.nFloorPartsHeight[floorcnt]); for (int id = 0; id < 4; ++id) { this.data.SmallGridState[index][floorcnt].Add(component.GetStateSmallGrid(id, floorcnt)); int[] partOnSmallGrid = component.GetPartOnSmallGrid(id, floorcnt); this.data.SmallGridOnParts[index][floorcnt].Add(partOnSmallGrid); this.data.SmallGridOnStackWall[index][floorcnt].Add(component.GetStackWallOnSmallGrid(id, floorcnt)); this.data.SmallGridCanRoofState[index][floorcnt].Add(component.GetSmallGridCanRoof(id, floorcnt)); this.data.SmallGridInRoomState[index][floorcnt].Add(component.GetSmallGridInRoom(id, floorcnt)); } } } for (int index1 = 0; index1 < baseParts.Length; ++index1) { for (int index2 = 0; index2 < baseParts[index1].Count; ++index2) { List <GameObject> list2 = baseParts[index1][index2].GetList(); for (int ID = 0; ID < list2.Count; ++ID) { if (baseParts[index1][index2].ReserveListCheck(ID)) { BuildPartsInfo component = (BuildPartsInfo)list2[ID].GetComponent <BuildPartsInfo>(); this.data.BuildPartsGridKind.Add(index1); this.data.BuildPartsKind.Add(index2); this.data.BuildPartsFloor.Add(component.nPutFloor); this.data.BuildPartsPos.Add(list2[ID].get_transform().get_localPosition()); this.data.BuildPartsRot.Add(list2[ID].get_transform().get_localRotation()); this.data.BuildPartsPutGridInfos.Add(component.putGridInfos.Select <GridInfo, int>((Func <GridInfo, int>)(v => v.nID)).ToList <int>()); this.data.BuildPartsPutSmallGridInfos.Add(component.putSmallGridInfos); this.data.BuildPartsPutGridInfosNum.Add(component.putGridInfos.Count); } } } } this.data.tmpGridActiveList = Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveList; this.data.tmpGridActiveListUpdate = Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveListUpdate; this.data.MaxPutHeight = Singleton <CraftCommandListBaseObject> .Instance.MaxPutHeight; BinaryWriter binaryWriter = new BinaryWriter((Stream) new FileStream(Application.get_dataPath() + "/in-house/Scripts/Game/Scene/Map/Craft/SaveData" + string.Format("/CraftSave{0}_{1:MM}{2}_{3:HH}{4:mm}_{5:ss}{6:ff}.png", (object)DateTime.Now.Year, (object)DateTime.Now, (object)DateTime.Now.Day, (object)DateTime.Now, (object)DateTime.Now, (object)DateTime.Now, (object)DateTime.Now), FileMode.Create, FileAccess.Write), Encoding.UTF8); this.pngData = this.CreatePngScreen(320, 180); binaryWriter.Write(this.pngData); binaryWriter.Write(this.data.MaxFloorNum); binaryWriter.Write(this.data.nPutPartsNum); for (int index = 0; index < this.data.GridPos.Count; ++index) { binaryWriter.Write((double)this.data.GridPos[index].x); binaryWriter.Write((double)this.data.GridPos[index].y); binaryWriter.Write((double)this.data.GridPos[index].z); } binaryWriter.Write("P"); for (int index = 0; index < this.data.GridUseState.Count; ++index) { binaryWriter.Write(this.data.GridUseState[index]); } binaryWriter.Write("U"); for (int index = 0; index < this.data.nFloorPartsHeight.Count; ++index) { binaryWriter.Write(this.data.nFloorPartsHeight[index]); } binaryWriter.Write("F"); for (int index1 = 0; index1 < list1.Count; ++index1) { for (int index2 = 0; index2 < nMaxFloorCnt; ++index2) { for (int index3 = 0; index3 < this.data.SmallGridState[index1][index2].Count; ++index3) { binaryWriter.Write(this.data.SmallGridState[index1][index2][index3]); for (int index4 = 0; index4 < this.data.SmallGridOnParts[index1][index2][index3].Length; ++index4) { binaryWriter.Write(this.data.SmallGridOnParts[index1][index2][index3][index4]); } for (int index4 = 0; index4 < this.data.SmallGridOnStackWall[index1][index2][index3].Length; ++index4) { binaryWriter.Write(this.data.SmallGridOnStackWall[index1][index2][index3][index4]); } binaryWriter.Write(this.data.SmallGridCanRoofState[index1][index2][index3]); binaryWriter.Write(this.data.SmallGridInRoomState[index1][index2][index3]); } } } binaryWriter.Write("S"); for (int index1 = 0; index1 < this.data.BuildPartsPos.Count; ++index1) { binaryWriter.Write(this.data.BuildPartsGridKind[index1]); binaryWriter.Write(this.data.BuildPartsKind[index1]); binaryWriter.Write(this.data.BuildPartsFloor[index1]); binaryWriter.Write((double)this.data.BuildPartsPos[index1].x); binaryWriter.Write((double)this.data.BuildPartsPos[index1].y); binaryWriter.Write((double)this.data.BuildPartsPos[index1].z); binaryWriter.Write((double)this.data.BuildPartsRot[index1].x); binaryWriter.Write((double)this.data.BuildPartsRot[index1].y); binaryWriter.Write((double)this.data.BuildPartsRot[index1].z); binaryWriter.Write((double)this.data.BuildPartsRot[index1].w); binaryWriter.Write(this.data.BuildPartsPutGridInfosNum[index1]); for (int index2 = 0; index2 < this.data.BuildPartsPutGridInfos[index1].Count; ++index2) { binaryWriter.Write(this.data.BuildPartsPutGridInfos[index1][index2]); binaryWriter.Write(this.data.BuildPartsPutSmallGridInfos[index1][index2]); } } binaryWriter.Write("B"); for (int index1 = 0; index1 < this.data.MaxFloorNum; ++index1) { for (int index2 = 0; index2 < this.data.GridPos.Count; ++index2) { binaryWriter.Write(this.data.tmpGridActiveList[index1][index2]); } binaryWriter.Write(this.data.tmpGridActiveListUpdate[index1]); binaryWriter.Write(this.data.MaxPutHeight[index1]); } binaryWriter.Write("A"); binaryWriter.Close(); this.data.MaxFloorNum = 0; this.data.nPutPartsNum = 0; this.data.GridPos.Clear(); this.data.GridUseState.Clear(); this.data.nFloorPartsHeight.Clear(); this.data.SmallGridState.Clear(); this.data.SmallGridOnParts.Clear(); this.data.SmallGridOnStackWall.Clear(); this.data.SmallGridCanRoofState.Clear(); this.data.SmallGridInRoomState.Clear(); this.data.BuildPartsGridKind.Clear(); this.data.BuildPartsKind.Clear(); this.data.BuildPartsFloor.Clear(); this.data.BuildPartsPos.Clear(); this.data.BuildPartsRot.Clear(); this.data.BuildPartsPutGridInfos.Clear(); this.data.BuildPartsPutSmallGridInfos.Clear(); this.data.BuildPartsPutGridInfosNum.Clear(); this.data.tmpGridActiveList.Clear(); this.data.tmpGridActiveListUpdate.Clear(); this.data.MaxPutHeight.Clear(); }
protected void GridInfo_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridInfo.PageIndex = e.NewPageIndex; GridInfo.DataSource = ViewState["dt"]; GridInfo.DataBind(); }
public GridMemento(GridInfo storedData) { Data = new GridInfo(storedData); }
private void OnNewGrid(GridInfo info) { Vector3 offset = new Vector3(1f, -0.5f, 0f); _currentDeskSpawnPos = info.gameGridWorldBounds.max + offset; }
public GridInfo(GridInfo another) { this.height = another.height; this.width = another.width; this.content = new Dictionary <(int, int), CellInfo>(another.content); }
// Fonction appelée lorsque l'anomalie a été assignée, afin d'assigner par la suite les planètes //private void OnFirstAnomalyTile() //{ // SpawnHazards(); //} // Fonction appelée lorsque la grille actuelle est détruite qui reset les variables et références private void OnGridDataDestroyed() { _allHazards.Clear(); _currentGridInfo = null; }
public void AssignGridInfo(GridInfo info) { currentGridInfo = info; grid = info.gameGridTiles; }
// Fonction appelée lorsqu'une nouvelle grille est générée qui stock les informations de cette grille private void OnNewGameGrid(GridInfo gridInfo) { _currentGridInfo = gridInfo; SpawnPlanetTiles(); RevealStartingPlanets(_currentSettings); }
public static int GetAsIndex(this Vector2 vec, GridInfo info) { return((int)(vec.x / info.CellSize.x) + (int)(vec.y / info.CellSize.y) * info.Width); }
private void UpdateName(InteractiveObject p_interactiveObject) { Boolean flag = false; IEnumerable <InteractiveObjectTooltipStaticData> iterator = StaticDataHandler.GetIterator <InteractiveObjectTooltipStaticData>(EDataType.INTERACTIVE_OBJECT_TOOLTIPS); KeyCode keyCode = KeyConfigManager.KeyBindings[EHotkeyType.INTERACT].Key1; if (keyCode == KeyCode.None) { keyCode = KeyConfigManager.KeyBindings[EHotkeyType.INTERACT].AltKey1; } String text = m_actionColorHex + "[" + LocaManager.GetText("OPTIONS_INPUT_KEYNAME_" + keyCode.ToString().ToUpper()) + "][-]"; if (!String.IsNullOrEmpty(p_interactiveObject.Prefab)) { String directoryName = Path.GetDirectoryName(p_interactiveObject.Prefab); foreach (InteractiveObjectTooltipStaticData interactiveObjectTooltipStaticData in iterator) { if (interactiveObjectTooltipStaticData.PrefabFolder == directoryName || interactiveObjectTooltipStaticData.PrefabFolder == p_interactiveObject.Prefab) { m_label.text = LocaManager.GetText(interactiveObjectTooltipStaticData.LocaKey, text); flag = true; break; } } } if (p_interactiveObject is Button) { if (!flag) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_BUTTON", text); } return; } if (p_interactiveObject is Lever) { if (!flag) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_LEVER", text); } return; } if (!(p_interactiveObject is Barrel)) { if (p_interactiveObject is Container) { Container container = p_interactiveObject as Container; if (!container.IsEmpty()) { if (!flag) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_CONTAINER", text); } } else { foreach (SpawnCommand spawnCommand in container.Commands) { if (spawnCommand.Type == EInteraction.CHANGE_ATTRIBUTE) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_CONTAINER", text); return; } } m_label.text = String.Empty; } return; } if (p_interactiveObject is Door) { if (LegacyLogic.Instance.WorldManager.Party.SelectedInteractiveObject == null || p_interactiveObject.IsSecret) { m_label.text = String.Empty; return; } if (((Door)p_interactiveObject).State == EInteractiveObjectState.DOOR_OPEN) { m_label.text = String.Empty; } else { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_DOOR", text); } return; } else { if (p_interactiveObject is Sign) { if (!flag) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_SIGN", text); } return; } if (p_interactiveObject is Entrance) { if (flag) { return; } Entrance entrance = (Entrance)p_interactiveObject; String text2 = entrance.MinimapTooltipLocaKey; if (!String.IsNullOrEmpty(text2)) { text2 = LocaManager.GetText(entrance.MinimapTooltipLocaKey); m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_ENTRANCE", text, text2); return; } text2 = null; foreach (SpawnCommand spawnCommand2 in entrance.Commands) { if (spawnCommand2.Type == EInteraction.USE_ENTRANCE) { String[] array = spawnCommand2.Extra.Split(new Char[] { ',' }); text2 = array[0].Replace(".xml", String.Empty); break; } } if (text2 != null) { GridInfo gridInfo = LegacyLogic.Instance.MapLoader.FindGridInfo(text2); if (gridInfo != null) { text2 = LocaManager.GetText(gridInfo.LocationLocaName); if (LegacyLogic.Instance.MapLoader.Grid.Type == EMapType.DUNGEON) { text2 = text2.Replace("@", ", "); } else if (text2.LastIndexOf('@') != -1) { text2 = text2.Remove(text2.LastIndexOf('@')); } m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_ENTRANCE", text, text2); return; } Debug.LogError("Grid Info not found " + text2); } } else if (p_interactiveObject is NpcContainer) { NpcContainer npcContainer = (NpcContainer)p_interactiveObject; if (!npcContainer.IsEnabled) { m_label.text = String.Empty; return; } String minimapTooltipLocaKey = npcContainer.MinimapTooltipLocaKey; if (!String.IsNullOrEmpty(npcContainer.IndoorScene)) { if (!String.IsNullOrEmpty(minimapTooltipLocaKey)) { String text3 = LocaManager.GetText(minimapTooltipLocaKey); m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_BUILDING_DEFAULT", text, text3); return; } foreach (InteractiveObjectTooltipStaticData interactiveObjectTooltipStaticData2 in iterator) { if (interactiveObjectTooltipStaticData2.PrefabFolder == npcContainer.IndoorScene) { m_label.text = LocaManager.GetText(interactiveObjectTooltipStaticData2.LocaKey, text); return; } } m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_INDOOR_CONTEXT", text); return; } else { if (!npcContainer.Npcs[0].IsEnabled) { m_label.text = String.Empty; return; } foreach (SpawnCommand spawnCommand3 in npcContainer.Commands) { if (spawnCommand3.Type == EInteraction.START_DEFINED_DIALOG && !String.IsNullOrEmpty(spawnCommand3.Precondition) && spawnCommand3.Precondition.StartsWith("PARTY_CHECK")) { BasePrecondition basePrecondition = BaseInteraction.ParsePrecondition(spawnCommand3.Precondition); if (basePrecondition is PartyCheckPrecondition && !((PartyCheckPrecondition)basePrecondition).Evaluate()) { m_label.text = String.Empty; return; } } } if (flag) { return; } if (!String.IsNullOrEmpty(minimapTooltipLocaKey)) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_NPC", text, minimapTooltipLocaKey); return; } if (npcContainer.Npcs[0].StaticID != 224 && npcContainer.Npcs[0].StaticID != 225) { String text4 = LocaManager.GetText(npcContainer.Npcs[0].StaticData.NameKey); m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_NPC", text, text4); return; } } } else if (p_interactiveObject is RechargingObject) { RechargingObject rechargingObject = (RechargingObject)p_interactiveObject; if (rechargingObject.IsFountain()) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_FOUNTAIN", text); } else if (rechargingObject.IsCrystal()) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_CRYSTAL", text); } else { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_STATUE", text); } return; } m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_FALLBACK", text); } return; } Barrel barrel = p_interactiveObject as Barrel; if (barrel.State == EInteractiveObjectState.BARREL_EMPTY) { m_label.text = String.Empty; return; } if (barrel.State == EInteractiveObjectState.BARREL_OPEN) { m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_FALLBACK", text); return; } m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_BARREL", text); }
public static MvcHtmlString GridCr(this HtmlHelper helper, string gridName, GridInfo gridTotalConfig, string Width = null, string Height = null)// where T : class { return((new GridCr <object>(helper, gridName, gridTotalConfig, null, null, Width, Height)).Render()); }
// Assigner l'information de grille (appelée par l'action de nouvelle grille du GridManager) private void AssignGridInfo(GridInfo currentGridInfo) { _gridInfo = currentGridInfo; PathNode = new PathNode(currentGridInfo.gameGridTiles, this, tileX, tileY); UpdateNeighbours(); }
public static MvcHtmlString GridCr(this HtmlHelper helper, string gridName, GridInfo gridTotalConfig, string fullName, ClientDependentFeature clientDependency = null, string Width = null, string Height = null)// where T : class { return((new GridCr <object>(helper, gridName, gridTotalConfig, ReflectionHelpers.GetType(fullName), clientDependency, Width, Height)).Render()); }
// Assigne les valeurs de _currentGridInfo (appel à chaque nouvelle grille) private void AssignGridInfo(GridInfo info) { _currentGridInfo = info; }
public static MvcHtmlString GridCr <T>(this HtmlHelper helper, string gridName, GridInfo gridTotalConfig, ClientDependentFeature clientDependency, string Width = null, string Height = null) where T : IViewModel, new() { return((new GridCr <T>(helper, gridName, gridTotalConfig, null, clientDependency, Width, Height)).Render()); }