예제 #1
0
파일: clsMap.cs 프로젝트: galantida/GameJS
 // delete all objects in a particular area
 public int deleteArea(int x1, int y1, int x2, int y2, int containerId = 0)
 {
     // get all objects in the area and mark each one for delete
     int result = 0;
     clsObject obj = new clsObject(_db);
     result += obj.deleteArea(x1, y1, x2, y2, containerId);
     return result;
 }
예제 #2
0
파일: clsMap.cs 프로젝트: galantida/GameJS
 // destroy all objects in a particular area
 public int destroyArea(clsPoint topLeft, clsPoint bottomRight, int containerId = 0)
 {
     // initiate destruction method for each object
     int result = 0;
     clsObject obj = new clsObject(_db);
     result += obj.destroyArea((int)topLeft.x, (int)topLeft.y, (int)bottomRight.x, (int)bottomRight.y, containerId);
     return result;
 }
예제 #3
0
파일: clsMap.cs 프로젝트: galantida/GameJS
        public int destroyAll()
        {
            int result = 0;

            clsObject obj = new clsObject(_db);
            result += obj.destroyAll();

            clsAttribute attribute = new clsAttribute(_db);
            result += attribute.destroyAll();

            return result;
        }
예제 #4
0
파일: clsMap.cs 프로젝트: galantida/GameJS
 public List<clsObject> getArea(int x1, int y1, int x2, int y2, int containerId = 0, DateTime? modified = null)
 {
     clsObject obj = new clsObject(_db);
     return obj.getArea(x1, y1, x2, y2, containerId, modified);
 }
예제 #5
0
파일: clsMap.cs 프로젝트: galantida/GameJS
 public int deleteAll()
 {
     clsObject obj = new clsObject(_db);
     return obj.deleteAll();
 }
예제 #6
0
파일: clsMap.cs 프로젝트: galantida/GameJS
 public List<clsObject> getObjectsByType(string objectType)
 {
     clsObject obj = new clsObject(_db);
     return obj.getByType(objectType);
 }
예제 #7
0
파일: clsMap.cs 프로젝트: galantida/GameJS
 public List<clsObject> getAllObjects()
 {
     clsObject obj = new clsObject(_db);
     return obj.getAll();
 }
예제 #8
0
파일: clsMap.cs 프로젝트: galantida/GameJS
        public string SaveMap(clsPoint worldLocation)
        {
            int size = heights.GetLength(0);

            // clear block
            clsPoint worldLocationBotRight = new clsPoint(worldLocation.x + heights.Length - 1, worldLocation.y + heights.Length - 1);
            this.destroyArea(worldLocation, worldLocationBotRight);

            // load templates
            clsTemplate template = new clsTemplate(_db);
            List<clsTemplate> templates = template.getAllTemplates();

            int waterLevel = 0;

            // save results to database
            clsObject obj = new clsObject(_db);
            List<clsObject> results = new List<clsObject>();
            for (int y = 0; y < size; y++)
            {
                for (int x = 0; x < size; x++)
                {
                    obj = this.createObject((int)worldLocation.x + x, (int)worldLocation.y + y, heights[x, y] * 32, templates.Find(i => i.name.Contains("MC Grass")));

                    if (heights[x, y] < waterLevel)
                    {
                        for (int z = heights[x, y] + 1; z <= waterLevel; z++)
                        {
                            obj = this.createObject((int)worldLocation.x + x, (int)worldLocation.y + y, z * 32, templates.Find(i => i.name.Contains("MC Water")));
                        }
                    }

                }
            }

            // height map to JSON
            string JSON;
            JSON = "{";
            JSON = "\"objectsCreated\":" + results.Count + "";
            JSON += "}";
            return JSON;

        }
예제 #9
0
        public List<clsObject> fromJSON(JArray JSONArray)
        {
            List<clsObject> results = new List<clsObject>();

            // loop thorugh all the JSON obects in the JSON array
            foreach (JObject JSONObject in JSONArray)
            {
                clsObject obj = new clsObject(_db); // create new blank template
                obj.fromJSON(JSONObject); // load based on JSON Object
                results.Add(obj); // add new to results
            }
            return results;
        }