예제 #1
0
    public void DrawRadar(RadarElement[] radarElements, float radius)
    {
        if (dot != null)
        {
            UpdateDotCount(radarElements.Length, radarElements);

            for(int i = 0; i < dotCount; i++)
            {
                if (radarElements[i] != null)
                {
                    Vector2 finalPosition = Vector2.zero;
                    Vector2 dotPosPercentage = radarElements[i].position / radius;

                    finalPosition.x = (rectTransform.rect.width / 2) * dotPosPercentage.x;
                    finalPosition.y = (rectTransform.rect.height / 2) * dotPosPercentage.y;

                    dots[i].anchoredPosition = finalPosition;
                }
            }
        }
        else
        {
            Debug.Log("Dot is not set in UI Radar");
        }
    }
예제 #2
0
        public IList <NewsRadarView> GetNewsRadarViewList(MobileParam mobileParams, int cver, out int sver)
        {
            var imageType = NewsServiceHelper.GetImageURLTypeByResolution(mobileParams);

            var radarlist    = new RadarCategory().ReturnRadarInstance <RadarCategory>(cver, out sver);
            var subradarlist = new RadarElement().ReturnRadarInstance <RadarElement>(cver, out sver);

            return(ConvertByRadar(imageType, radarlist, subradarlist));
        }
예제 #3
0
        public ActionResult RadarElementEdit(RadarElement model, FormCollection parameters)
        {
            var radarcategoryIds = parameters["radarcategory"].GetIds();

            var radarElement = dbContextService.Single <RadarElement>(model.Id);

            radarElement.Name             = model.Name;
            radarElement.RadarCategoryIds = radarcategoryIds.GetString();
            radarElement.Comment          = model.Comment;
            radarElement.Status           = model.Status;
            radarElement.CreateDateTime   = DateTime.Now;

            var ret = dbContextService.Update <RadarElement>(radarElement);

            RadarService.UpdateServerVersion <RadarElement>();

            return(RedirectToAction("RadarElementList"));
        }
예제 #4
0
        public ActionResult RadarElementAdd(RadarElement model, FormCollection parameters)
        {
            var radarcategoryIds = parameters["radarcategory"].GetIds();

            var exist = dbContextService.Exists <RadarElement>(x => x.Name == model.Name);

            if (exist)
            {
                TempData["errorMsg"] = "该元素已存在!";
                return(View());
            }
            model.RadarCategoryIds = radarcategoryIds.GetString();
            var ret = dbContextService.Add <RadarElement>(model);

            RadarService.UpdateServerVersion <RadarElement>();

            return(RedirectToAction("RadarElementList"));
        }
예제 #5
0
    void UpdateDotCount(int newCount, RadarElement[] radarElements)
    {
        while (newCount != dotCount)
        {
            if (newCount > dotCount)
            {
                if (radarElements[dotCount] != null)
                {
                    GameObject obj = Instantiate(dot, Vector3.zero, Quaternion.identity) as GameObject;
                    dots.Add(obj.GetComponent<RectTransform>());

                    obj.gameObject.transform.SetParent(transform);
                    dotCount++;
                }
            }
            else if (newCount < dotCount)
            {
                Destroy(dots[dotCount - 1].gameObject);
                dots.Remove(dots[dotCount - 1]);
                dotCount--;
            }
        }
    }
예제 #6
0
    void UpdateRadar()
    {
        dotPositions = new Vector2[gameObjectsInRadarRange.Count];
        dotTypes = new RadarDotType[gameObjectsInRadarRange.Count];
        radarElements = new RadarElement[gameObjectsInRadarRange.Count];

        for (int i = 0; i < gameObjectsInRadarRange.Count; i++ )
        {
            if (gameObjectsInRadarRange[i] == null)
            {
                gameObjectsInRadarRange.Remove(gameObjectsInRadarRange[i]);
                continue;
            }
            else
            {
                Vector3 objectDirection = gameObjectsInRadarRange[i].transform.position - transform.position;
                objectDirection *= radarRadius / collider.radius;

                dotPositions[i] = new Vector2(objectDirection.x, objectDirection.z);
                dotTypes[i] = GetDotType(gameObjectsInRadarRange[i]);

                radarElements[i] = new RadarElement(new Vector2(objectDirection.x, objectDirection.z), GetDotType(gameObjectsInRadarRange[i]));
            }
        }
    }