コード例 #1
0
        private void UpdateCave(CavesModel cave)
        {
            var index = Caves.IndexOf(cave);

            Caves.Remove(cave);
            Caves.Insert(index, cave);
        }
コード例 #2
0
ファイル: Day12.cs プロジェクト: AtOMiCNebula/AdventOfCode
        public static Cave GetCave(string caveName)
        {
            if (!Caves.ContainsKey(caveName))
            {
                Caves.Add(caveName, new Cave(caveName));
            }

            return(Caves[caveName]);
        }
コード例 #3
0
ファイル: Cave.cs プロジェクト: XF9/Fenrir
        /// <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);
        }
コード例 #4
0
ファイル: CaveDAO.cs プロジェクト: AlexisJugnon/CaveAVin
        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);
        }
コード例 #5
0
ファイル: Day12.cs プロジェクト: mixco1a0/AdventOfCode
            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;
                }
            }