public IEnumerable <ODData <float> > Read() { using (var reader = new CsvReader(LoadFrom, true)) { if (ContainsHeader) { reader.LoadLine(); } while (reader.LoadLine(out int columns)) { if (columns >= 2) { ODData <float> data = new ODData <float>(); reader.Get(out data.O, 0); if (columns >= 3) { reader.Get(out data.D, 1); reader.Get(out data.Data, 2); } else { reader.Get(out data.Data, 1); } yield return(data); } } } }
protected virtual bool ReadDataLine(BinaryReader reader, out ODData <float> data) { char c = '\0'; // Read in the origin data.O = 0; data.D = 0; data.Data = 0f; if (!ReadInteger(reader, ref c, out data.O)) { return(false); } if (!ReadInteger(reader, ref c, out data.D)) { return(false); } if (!ReadFloat(reader, ref c, out data.Data)) { return(false); } // burn the remainder of the line if (c != '\n') { BurnLine(reader); } return(true); }
public IEnumerable <ODData <float> > Read() { string line; int pos; ODData <float> data = new ODData <float>(); // do this because highest zone isn't high enough for array indexes using (StreamReader reader = new StreamReader(new FileStream(EmmeFile.GetFileName(Root.InputBaseDirectory), FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.SequentialScan))) { BurnHeader(reader); while ((line = reader.ReadLine()) != null) { pos = 0; int length = line.Length; // don't read blank lines if (ReadNextInt(line, length, ref pos, out data.O)) { while (ReadNextInt(line, length, ref pos, out data.D)) { if (ReadNextFloat(line, length, ref pos, out data.Data)) { yield return(data); } } } } } }
public void initShip() { ClearExistCells(); shipCells = ODData.GetMap(); ownedCellNum = 0; for (int i = 0; i < shipSize; ++i) { for (int j = 0; j < shipSize; ++j) { if (cellPrefab) { if (shipCells[i, j] == (int)CellType.Buyed) { CreateBuyedBorder(i, j); } else if (shipCells[i, j] == (int)CellType.CanBuy) { CreateCanBuyBorder(i, j); } else if (Pokedex.isPokemon(shipCells[i, j])) { CreateBuyedBorder(i, j, shipCells[i, j]); } } } } UpdateAllCellPrice(); }
protected override bool ReadDataLine(BinaryReader reader, out ODData <float> data) { char c = '\0'; // Read in the origin data.O = 0; data.D = 0; data.Data = 0f; if (!ReadInteger(reader, ref c, out data.O)) { return(false); } if (!ReadInteger(reader, ref c, out data.D)) { return(false); } // This line is what makes this special since we are now reading in a type to filter by if (!ReadInteger(reader, ref c, out int type)) { return(false); } if (!ReadFloat(reader, ref c, out data.Data)) { return(false); } // burn the remainder of the line if (c != '\n') { BurnLine(reader); } return(ContainsType(type)); }
private IEnumerable <ODData <float> > ReadThirdNormalized() { if (!File.Exists(LoadFrom)) { throw new XTMFRuntimeException(this, $"In {Name} the file '{LoadFrom.GetFilePath()}' does not exist!"); } using (var reader = new CsvReader(LoadFrom, true)) { if (ContainsHeader) { reader.LoadLine(); } while (reader.LoadLine(out int columns)) { if (columns >= 2) { ODData <float> data = new ODData <float>(); reader.Get(out data.O, 0); if (columns >= 3) { reader.Get(out data.D, 1); reader.Get(out data.Data, 2); } else { reader.Get(out data.Data, 1); } yield return(data); } } } }
void Awake() { instance = this; canBuyList = new ArrayList(); cellPrice = ODData.GetCellPrices(); initShip(); }
public void SetPokemon(int pokemonID) { building.sprite = Pokedex.instance[pokemonID - 1].icon; _pokemonID = pokemonID; building.gameObject.SetActive(true); ODData.UpdateCell(x, y, _pokemonID); }
public void ChooseStartPokemon(PokedexItem item) { ODGame.isFirstStart = false; Log.WriteLog("你选择了 " + item.characterName + " 作为你的初始神奇宝贝!"); ODUI.instance.ShowFirstStartPanel(false); pokemons[item.id - 1].discovery = true; ODData.OwnPokemon(item.id); }
public void SetBuilding() { if (spriteRenderer) { spriteRenderer.sprite = Pokedex.pokemonIcons[id]; } ODData.SetPokemonData(this, id); }
public void ClearPlayerInfo() { Log.WriteLog("正在清楚用户信息中,请稍候"); isFirstStart = true; ODData.ClearPokemons(); ODData.ClearSpaceShip(); ODData.InitResource(); Application.LoadLevel(Application.loadedLevel); Log.WriteLog("清楚用户信息成功"); }
void Awake() { instance = this; pokemons = (PokedexItem[])ODData.GetPokedex().ToArray(typeof(PokedexItem)); startPokemonsID = ODData.GetStartPokemonsID(); startPokemons = new PokedexItem[startPokemonsID.Count]; for (int i = 0; i < startPokemonsID.Count; i++) { startPokemons[i] = pokemons[(int)startPokemonsID[i] - 1]; } }
public IEnumerable <ODData <float> > Read() { // if there isn't anything just exit if (!FixedFormatFile.ContainsFileName()) { yield break; } // otherwise load in the data ODData <float> currentData = new ODData <float>(); var zoneArray = Root.ZoneSystem.ZoneArray; var zoneNumbers = zoneArray.ValidIndexArray(); var zones = zoneArray.GetFlatData(); StreamReader reader = null; try { reader = new StreamReader(FixedFormatFile.GetFileName()); } catch (IOException e) { throw new XTMFRuntimeException("In '" + this.Name + "' we were unable to open up the file named '" + FixedFormatFile.GetFileName() + "' with the exception '" + e.Message + "'"); } // find the ammount of data in the line that we need in order to process anything var dataInLine = Math.Max(this.OriginStart + this.OriginLenth, this.DestinationStart + this.DestinationLenth); dataInLine = Math.Max(dataInLine, this.DataStart + this.DataLenth); using ( reader ) { string line; while ((line = reader.ReadLine()) != null) { // if there is not enough data just continue if (line.Length < dataInLine) { continue; } currentData.O = int.Parse(line.Substring(this.OriginStart, this.OriginLenth)); currentData.D = int.Parse(line.Substring(this.DestinationStart, this.DestinationLenth)); if (EToTheData) { currentData.Data = (float)(Math.Exp(double.Parse(line.Substring(this.DataStart, this.DataLenth)))); } else { currentData.Data = (float)double.Parse(line.Substring(this.DataStart, this.DataLenth)); } yield return(currentData); } } }
public ArrayList GetCanEvolutions(int pokemonID) { ArrayList evolutions = ODData.GetEvolutions(pokemonID); ArrayList pokemons = new ArrayList(); foreach (int _pokemonID in evolutions) { if (ODData.IsHavePokemon(_pokemonID)) { pokemons.Add(_pokemonID); } } return(pokemons); }
public void CreateCellsNearBy(int x, int y) { for (int i = 0; i < 4; i++) { int x1 = x + addedValues[i, 0]; int y1 = y + addedValues[i, 1]; if (x1 >= 0 && x1 < shipSize && y1 >= 0 && y1 < shipSize) { if (SpaceShip.shipCells[x1, y1] == (int)CellType.CanNotBuy) { SpaceShip.shipCells[x1, y1] = (int)CellType.CanBuy; CreateCanBuyBorder(x1, y1); ODData.UpdateCell(x1, y1, (int)CellType.CanBuy); } } } }
protected override bool ReadDataLine(BinaryReader reader, out ODData <float> data) { char c = '\0'; data.Data = 0; data.O = 0; data.D = -1; if (!ReadInteger(reader, ref c, out data.O)) { return(false); } if (!ReadFloat(reader, ref c, out data.Data)) { return(false); } return(true); }
public void SetUpgrateButtonsCallBack(Action <int> action, ArrayList pokemonIDs) { for (int i = 0; i < upgrateButtons.Length; ++i) { upgrateButtons[i].gameObject.SetActive(false); } int maxL = Mathf.Min(upgrateButtons.Length, upgrateTexts.Length, pokemonIDs.Count); for (int i = 0; i < maxL; ++i) { upgrateButtons[i].gameObject.SetActive(true); upgrateTexts[i].text = "建造 " + ODData.GetPokedexItemById((int)pokemonIDs[i]).characterName; int _i = i; upgrateButtons[i].onClick.RemoveAllListeners(); upgrateButtons[i].onClick.AddListener(() => action((int)pokemonIDs[_i])); } }
public IEnumerable <ODData <float> > Read() { // if there isn't anything just exit if (!FileToRead.ContainsFileName()) { yield break; } // otherwise load in the data ODData <float> currentData = new ODData <float>(); var zoneArray = Root.ZoneSystem.ZoneArray; var zoneNumbers = zoneArray.ValidIndexArray(); var zones = zoneArray.GetFlatData(); BinaryReader reader; try { reader = new BinaryReader(File.OpenRead(FileToRead.GetFileName())); } catch (IOException e) { throw new XTMFRuntimeException(this, "In '" + Name + "' we were unable to open up the file named '" + FileToRead.GetFileName() + "' with the exception '" + e.Message + "'"); } var fileSize = reader.BaseStream.Length; // make sure the file is of the right size (a float is 4 bytes) if (fileSize != 4 * zones.Length * zones.Length) { reader.Close(); throw new XTMFRuntimeException(this, "In '" + Name + "' we found the file named '" + FileToRead.GetFileName() + "' was not a flat binary OD data file for the current zone system!"); } using (reader) { for (int o = 0; o < zones.Length; o++) { currentData.O = zoneNumbers[o]; for (int d = 0; d < zones.Length; d++) { currentData.D = zoneNumbers[d]; currentData.Data = reader.ReadSingle(); yield return(currentData); } } } }
public IEnumerable <ODData <float> > Read() { var firstSparse = First.AquireResource <SparseTwinIndex <float> >(); var first = firstSparse.GetFlatData(); var second = Second.AquireResource <SparseTwinIndex <float> >().GetFlatData(); ODData <float> point = new ODData <float>(); for (int i = 0; i < first.Length; i++) { point.O = firstSparse.GetSparseIndex(i); for (int j = 0; j < first[i].Length; j++) { point.D = firstSparse.GetSparseIndex(i, j); point.Data = first[i][j] - second[i][j]; yield return(point); } } }
public IEnumerable <ODData <float> > Read() { this.LoadData(); var flatData = this.Data.GetFlatData(); var zones = this.Root.ZoneSystem.ZoneArray.GetFlatData(); ODData <float> point = new ODData <float>(); for (int i = 0; i < zones.Length; i++) { point.O = zones[i].ZoneNumber; for (int j = 0; j < zones.Length; j++) { point.D = zones[j].ZoneNumber; point.Data = flatData[i][j]; yield return(point); } } this.UnloadData(); }
public IEnumerable <ODData <float> > Read() { IPurpose purpose = GetPurpose(); var zones = this.Root.ZoneSystem.ZoneArray.GetFlatData(); float[] ret = new float[zones.Length * zones.Length]; LoadData(ret, purpose); var odData = new ODData <float>(); for (int i = 0; i < zones.Length; i++) { odData.O = zones[i].ZoneNumber; for (int j = 0; j < zones.Length; j++) { odData.D = zones[j].ZoneNumber; odData.Data = ret[i * zones.Length + j]; yield return(odData); } } }
public IEnumerable <ODData <float> > Read() { var zones = this.Root.ZoneSystem.ZoneArray; var matrix = zones.CreateSquareTwinArray <float>().GetFlatData(); CombineData(zones, matrix); var zoneIndexes = zones.ValidIndexArray(); ODData <float> currentData = new ODData <float>(); for (int i = 0; i < matrix.Length; i++) { currentData.O = zoneIndexes[i]; for (int j = 0; j < matrix[i].Length; j++) { currentData.D = zoneIndexes[j]; currentData.Data = matrix[i][j]; yield return(currentData); } } }
protected override bool ReadDataLine(BinaryReader reader, out ODData<float> data) { char c = '\0'; // Read in the origin data.O = 0; data.D = 0; data.Data = 0f; int type; if ( !ReadInteger( reader, ref c, out data.O ) ) return false; if ( !ReadInteger( reader, ref c, out data.D ) ) return false; // This line is what makes this special since we are now reading in a type to filter by if ( !ReadInteger( reader, ref c, out type ) ) return false; if ( !ReadFloat( reader, ref c, out data.Data ) ) return false; // burn the remainder of the line if ( c != '\n' ) { BurnLine( reader ); } return ContainsType( type ); }
public IEnumerable <ODData <float> > Read() { IZone[] zones = this.Root.ZoneSystem.ZoneArray.GetFlatData(); var numberOfZones = zones.Length; Stream s = null; var f = this.UseInputDirectory ? this.GetFileLocation(this.FileName) : this.FileName; try { s = File.OpenRead(f); } catch (IOException e) { if (s != null) { s.Close(); } throw; } if (s.Length < (numberOfZones * numberOfZones) * 4) { throw new XTMFRuntimeException("The file '" + f + "' does not contain enough data to be used as a flat OD matrix!"); } ODData <float> ret = new ODData <float>(); // this will close the file at the end of reading it using (BinaryReader reader = new BinaryReader(s)) { for (int i = 0; i < numberOfZones; i++) { ret.O = zones[i].ZoneNumber; for (int j = 0; j < numberOfZones; j++) { ret.D = zones[j].ZoneNumber; ret.Data = reader.ReadSingle(); yield return(ret); } } } }
public void BuyCell() { if (Player.instance.TryToAford(new Dictionary <int, float>() { { 1, _price } })) { SetCellType(CellType.Buyed); SpaceShip.shipCells[x, y] = (int)CellType.Buyed; SpaceShip.ownedCellNum++; ODData.UpdateCell(x, y, (int)CellType.Buyed); SpaceShip.instance.MoveCellToBuyedList(gameObject); SpaceShip.instance.CreateCellsNearBy(x, y); SpaceShip.instance.UpdateAllCellPrice(); OnClickCell(); } else { print("金币不够"); } }
private IEnumerable <ODData <float> > ReadSquareMatrix() { var anyLinesRead = false; // Spaces are not delimiters if (!File.Exists(LoadFrom)) { throw new XTMFRuntimeException(this, $"In {Name} the file '{LoadFrom.GetFilePath()}' does not exist!"); } using (var reader = new CsvReader(LoadFrom, false)) { // read in the destinations reader.LoadLine(out int columns); int[] destinations = new int[columns - 1]; for (int i = 0; i < destinations.Length; i++) { reader.Get(out destinations[i], i + 1); } while (reader.LoadLine(out columns)) { if (columns >= destinations.Length + 1) { anyLinesRead = true; ODData <float> data = new ODData <float>(); reader.Get(out data.O, 0); for (int i = 0; i < destinations.Length; i++) { data.D = destinations[i]; reader.Get(out data.Data, i + 1); yield return(data); } } } } if (!anyLinesRead) { throw new XTMFRuntimeException(this, $"In {Name} when reading the file '{LoadFrom}' we did not load any information!"); } }
public IEnumerable <ODData <float> > Read() { string line; int pos; var path = EmmeFile.GetFilePath(); if (!File.Exists(path)) { throw new XTMFRuntimeException(this, $"File not found at '{path}'!"); } ODData <float> data = new ODData <float>(); // do this because highest zone isn't high enough for array indexes using (StreamReader reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.SequentialScan))) { BurnHeader(reader); while ((line = reader.ReadLine()) != null) { pos = 0; int length = line.Length; // don't read blank lines if (ReadNextInt(line, length, ref pos, out data.O)) { while (ReadNextInt(line, length, ref pos, out data.D)) { if (ReadNextFloat(line, length, ref pos, out data.Data)) { yield return(data); } } } } } }
public IEnumerable <ODData <float> > Read() { if (!File.Exists(InputFile)) { throw new XTMFRuntimeException(this, $"Unable to read an EMME Binary Matrix located at {InputFile.GetFilePath()}"); } using (BinaryReader reader = new BinaryReader(new FileStream(InputFile, FileMode.Open, FileAccess.Read))) { EmmeMatrix matrix = new EmmeMatrix(reader); if (!matrix.IsValidHeader()) { throw new XTMFRuntimeException(this, "In '" + Name + "' we were unable to load the matrix '" + InputFile + "'"); } ODData <float> result = new ODData <float>(); int pos = 0; var indexes = matrix.Indexes; var originIndexes = indexes[0]; var destinationIndexes = indexes[1]; switch (matrix.Type) { case EmmeMatrix.DataType.Float: { var data = matrix.FloatData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = data[pos++]; yield return(result); } } } break; case EmmeMatrix.DataType.Double: { var data = matrix.DoubleData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = (float)data[pos++]; yield return(result); } } } break; case EmmeMatrix.DataType.SignedInteger: { var data = matrix.SignedIntData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = data[pos++]; yield return(result); } } } break; case EmmeMatrix.DataType.UnsignedInteger: { var data = matrix.UnsignedIntData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = data[pos++]; yield return(result); } } } break; } } }
static public void SetCurrentResourcesBySql() { currentResources = ODData.GetCurrentResources(); Player.instance.SetCurrentResource(currentResources); }
public IEnumerable <ODData <float> > Read() { var zones = this.Root.ZoneSystem.ZoneArray.GetFlatData(); using (BinaryReader reader = new BinaryReader(new FileStream(InputFile, FileMode.Open, FileAccess.Read))) { EmmeMatrix matrix = new EmmeMatrix(reader); if (!matrix.IsValidHeader()) { throw new XTMFRuntimeException("In '" + this.Name + "' we were unable to load the matrix '" + (string)InputFile + "'"); } ODData <float> result = new ODData <float>(); int pos = 0; var indexes = matrix.Indexes; var originIndexes = indexes[0]; var destinationIndexes = indexes[1]; switch (matrix.Type) { case EmmeMatrix.DataType.Float: { var data = matrix.FloatData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = data[pos++]; yield return(result); } } } break; case EmmeMatrix.DataType.Double: { var data = matrix.DoubleData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = (float)data[pos++]; yield return(result); } } } break; case EmmeMatrix.DataType.SignedInteger: { var data = matrix.SignedIntData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = data[pos++]; yield return(result); } } } break; case EmmeMatrix.DataType.UnsignedInteger: { var data = matrix.UnsignedIntData; for (int i = 0; i < originIndexes.Length; i++) { result.O = originIndexes[i]; for (int j = 0; j < destinationIndexes.Length; j++) { result.D = destinationIndexes[j]; result.Data = data[pos++]; yield return(result); } } } break; } } }