示例#1
0
        /// <inheritdoc />
        public async Task <ResponseBase> SendPowerStatusChangedNotification(PowerTypeEnum powerStatus)
        {
            var responseData = new ResponseBase()
            {
                HasBeenSuccessful = false
            };

            var request = new NewPowerStatusRequest();

            request.PowerStatus = powerStatus;
            var result = await this._apiWrapper.SendPowerStatusChangedNotification(request);

            string content = await result.Content.ReadAsStringAsync();

            if (result.StatusCode == HttpStatusCode.OK)
            {
                try
                {
                    var deserializedContent = JsonConvert.DeserializeObject <ResponseBase>(content);
                    if (!deserializedContent.HasBeenSuccessful)
                    {
                        responseData.HasBeenSuccessful = false;
                        responseData.Error             = "Internal Server Error";
                        return(responseData);
                    }

                    responseData.HasBeenSuccessful = true;
                    responseData.Error             = null;
                    return(responseData);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                    responseData.HasBeenSuccessful = false;
                    responseData.Error             = "Deserialization Error";
                    return(responseData);
                }
            }
            else
            {
                responseData.HasBeenSuccessful = false;
                responseData.Error             = "Internal Error" + result.StatusCode.ToString();;
                return(responseData);
            }
        }
        public static void CreatePower(OsmWay lineData, OsmBounds bounds, Transform parent)
        {
            GameObject result = new GameObject();

            result.name = "<powerline>";

            PowerTypeEnum type = OSMtoSharp.Enums.Helpers.EnumExtensions.
                                 GetTagKeyEnum <PowerTypeEnum>
                                     (lineData.Tags[TagKeyEnum.Power]);

            Vector3[] linePoints = new Vector3[lineData.Nodes.Count];

            for (int i = 0; i < lineData.Nodes.Count; i++)
            {
                linePoints[i]   = OsmToUnityConverter.GetPointFromUnityPointVec3(lineData.Nodes[i].Point, bounds);
                linePoints[i].y = GetPowerLineHeight(type);
            }

            LineRenderer lineRender = result.AddComponent <LineRenderer>();

            lineRender.positionCount = lineData.Nodes.Count;

            lineRender.material = new Material(Shader.Find("Sprites/Default"));

            float width = GetPowerLineWidth(type);
            Color color = GetPowerLineColor(type);

            lineRender.startWidth = width;
            lineRender.endWidth   = width;

            lineRender.startColor = color;
            lineRender.endColor   = color;

            lineRender.SetPositions(linePoints);

            result.transform.parent = parent;
        }
 private static float GetPowerLineHeight(PowerTypeEnum type)
 {
     return(PowerLinesConstants.defaultHeight * Assets.Scripts.Constants.Constants.Scale);
 }
 private static Color GetPowerLineColor(PowerTypeEnum type)
 {
     return(PowerLinesConstants.defaultColor);
 }
 private static float GetPowerLineWidth(PowerTypeEnum type)
 {
     return(PowerLinesConstants.defaultWidth * Assets.Scripts.Constants.Constants.Scale);
 }