public static Result Create(ref Building building) { List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>(); JsonPlan plan = new JsonPlan { creates = new List<JsonCreate> { new JsonCreate { buildingid = building.BaseId, rectangle = string.Format("{0},{1};{2},{3}", building.Location.Point.X, building.Location.Point.Y, building.Location.Width, building.Location.Length) } } }; postData.Add(new KeyValuePair<string, string>( "plan", JsonHelper.JavaScriptSerialize<JsonPlan>(plan) )); string strResult = RequestManager.SendRequest(MoveUrl, postData, true); JsonResultCreate jsonResultCreate = null; IJsonResult jr = (IJsonResult)jsonResultCreate; Result result = ResponseManager.ProcessResponse<JsonResultCreate>(strResult, out jr); if (result.Flag == ResultFlag.Success) building.BaseId = ((JsonResultCreate)jr).UserBuildings[0].UserBuildingId; return result; }
public static Result Destory(Building building) { List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>(); JsonPlan plan = new JsonPlan { removes = new List<JsonRemove> { new JsonRemove { userbuildingid = building.BaseId } } }; postData.Add(new KeyValuePair<string, string>( "plan", JsonHelper.JavaScriptSerialize<JsonPlan>(plan) )); string result = RequestManager.SendRequest(MoveUrl, postData, true); return ResponseManager.ProcessResponse(result); }
public static Result MoveBuilding(Building building, Point target) { List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>(); JsonPlan plan = new JsonPlan { moves = new List<JsonMove> { new JsonMove { userbuildingid = building.Id, rectangle = string.Format("{0},{1};{2},{3}", target.X, target.Y, building.Location.Width, building.Location.Length) } }, revolves = new List<JsonRevolve> { new JsonRevolve { userbuildingid = building.Id, showdirection = 0 } } }; postData.Add(new KeyValuePair<string, string>( "plan", JsonHelper.JavaScriptSerialize<JsonPlan>(plan) )); string result = RequestManager.SendRequest(MoveUrl, postData, true); return ResponseManager.ProcessResponse(result); }