private void UpdateCave(CavesModel cave) { var index = Caves.IndexOf(cave); Caves.Remove(cave); Caves.Insert(index, cave); }
public static Cave GetCave(string caveName) { if (!Caves.ContainsKey(caveName)) { Caves.Add(caveName, new Cave(caveName)); } return(Caves[caveName]); }
/// <summary> /// Creates a cave /// </summary> /// <param name="blueprint">the shape of the cave</param> /// <param name="offset"></param> public Cave(Caves.CaveBlueprint blueprint, Point offset) { this.blockers = new List<Point>(); this.caveBlocksToMine = new List<Point>(); this.modelName = blueprint.CaveModel; foreach (Point blocker in blueprint.Blockers) this.blockers.Add(new Point(blocker.X + offset.X, blocker.Y + offset.Y)); foreach (Point cavePart in blueprint.CaveBlocks.Keys) this.caveBlocksToMine.Add(new Point(cavePart.X + offset.X, cavePart.Y + offset.Y)); this.cavePosition = new Vector3(offset.X * FenrirGame.Instance.InGame.Scene.Properties.TileSize, offset.Y * FenrirGame.Instance.InGame.Scene.Properties.TileSize, -1); }
public Caves Lister() { Caves liste = new Caves(); con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Cave"; IDataReader reader = com.ExecuteReader(); while (reader.Read()) { Cave c = reader2Cave(reader); liste.Ajouter(c); } } finally { con.Close(); } return(liste); }
public void AddConnectedCaves(string[] names) { const int StartId = 0; const int EndId = int.MaxValue; Cave first = null, second = null; for (int i = 0; i <= 1; ++i) { if (!CaveIds.ContainsKey(names[i])) { if (names[i] == "start") { CaveIds[names[i]] = StartId; } else if (names[i] == "end") { CaveIds[names[i]] = EndId; } else if (char.IsUpper(names[i][0])) { CaveIds[names[i]] = m_largeCaveId++; } else { CaveIds[names[i]] = m_smallCaveId--; } Caves.Add(new Cave(CaveIds[names[i]], names[i])); } if (i == 0) { first = Caves.Single(c => c.ID == CaveIds[names[i]]); } else { second = Caves.Single(c => c.ID == CaveIds[names[i]]); } } first.Connections.Add(second); second.Connections.Add(first); if (first.ID == StartId) { Start = first; } else if (first.ID == EndId) { End = first; } if (second.ID == StartId) { Start = second; } else if (second.ID == EndId) { End = second; } }