예제 #1
0
파일: BAMap.cs 프로젝트: kappuna/PNET
        private Map GenerateRoads(Map map)
        {
            map.Roads = new System.Data.Objects.DataClasses.EntityCollection<CommonLayer.Road>();
            //List to save the Villages that we already created roads for
            List<Village> _prevCities = new List<Village>();

            foreach (Village village in map.Village)
            {
                foreach (Village pV in _prevCities)
                {

                    Road r = new Road();
                    r.ID = Guid.NewGuid();
                    r.VillageFrom = pV.ID;
                    r.VillageTo = village.ID;

                    r.VillFrom = pV;
                    r.VillTo = village;

                    r.Distance = (int)CalculateDistance(new Point(pV.XCoor, pV.YCoor), new Point(village.XCoor, village.YCoor));

                    //Add Roads to Map

                    map.Roads.Add(r);
                }

                _prevCities.Add(village);
            }

            return map;
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Session["Map"] = new CommonLayer.Map();
                Session["VillageList"] = new List<Village>();
                Session["RoadList"] = new List<Road>();

                BindDropDown();
            }
        }
예제 #3
0
파일: BAMap.cs 프로젝트: kappuna/PNET
        public Map GenerateMap(int width, int height, int number)
        {
            Map map = new Map();
            map.ID = Guid.NewGuid();

            //Call the method to generate Villages and add them to the map
            map = GenerateVillages(number,map,width,height);

            //Call the method to generate Roads and add them to the map
            map = GenerateRoads(map);

            return map;
        }
예제 #4
0
        public void DrawMap(Map map)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script>");
            sb.Append("var c = document.getElementById(\"myCanvas\");");
            sb.Append("var ctx = c.getContext(\"2d\");");

            _DrawRoads(map.Roads.ToList(), sb);
            DrawVillages(map.Village.ToList(), sb);

            sb.Append("</script>");
            ClientScript.RegisterStartupScript(this.GetType(), "TestScript", sb.ToString());
        }
예제 #5
0
파일: DAMap.cs 프로젝트: kappuna/PNET
 public void UpdateMap(Map p)
 {
     this.Entities.SaveChanges();
 }
예제 #6
0
파일: DAMap.cs 프로젝트: kappuna/PNET
 public void DeleteMap(Map p)
 {
     this.Entities.Map.DeleteObject(p);
     this.Entities.SaveChanges();
 }
예제 #7
0
파일: DAMap.cs 프로젝트: kappuna/PNET
 public void AddMap(Map p)
 {
     this.Entities.Map.AddObject(p);
     this.Entities.SaveChanges();
 }
예제 #8
0
파일: BAMap.cs 프로젝트: kappuna/PNET
 /// <summary>
 /// Save the map to the database
 /// </summary>
 /// <param name="map"></param>
 public void Save(Map map)
 {
     new DAMap().AddMap(map);
 }
예제 #9
0
 /// <summary>
 /// Create a new Map object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Map CreateMap(global::System.Guid id, global::System.String name)
 {
     Map map = new Map();
     map.ID = id;
     map.Name = name;
     return map;
 }
예제 #10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Map EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMap(Map map)
 {
     base.AddObject("Map", map);
 }