public CenterTypeController(CenterTypeContext context)
        {
            if (context.CenterTypes.Count() == 0)
            {
                var file = System.IO.File.ReadAllText(@"C:\Users\dloconte\Downloads\RESTapp\HackathonREST\HackathonREST\App-Data\centers.json");

                var jObject = JObject.Parse(file);

                if (jObject != null)
                {
                    JArray centerTypesArray = (JArray)jObject["CenterTypes"];

                    foreach (var centerType in centerTypesArray)
                    {
                        CenterType ctype = new CenterType();

                        ctype.Id    = (int)centerType["Id"];
                        ctype.Value = centerType["Value"].ToString();

                        context.CenterTypes.Add(ctype);
                    }
                }
                context.SaveChangesAsync();
            }
            _context = context;
        }
        public async Task <ActionResult <CenterType> > PostCenterType(CenterType ctype)
        {
            _context.CenterTypes.Add(ctype);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetCenterType), new { id = ctype.Id }, ctype));
        }
Esempio n. 3
0
        public static Vector2 CenterTypeToVector2(CenterType centerType)
        {
            switch (centerType)
            {
            case CenterType.TopLeft:
                return(new Vector2(0f, 0f));

            case CenterType.TopCenter:
                return(new Vector2(0.5f, 0.5f));

            case CenterType.TopRight:
                return(new Vector2(1f, 0f));

            case CenterType.MiddleLeft:
                return(new Vector2(0f, 0.5f));

            case CenterType.MiddleCenter:
                return(new Vector2(0.5f, 0.5f));

            case CenterType.MiddleRight:
                return(new Vector2(1f, 0.5f));

            case CenterType.BottomLeft:
                return(new Vector2(0f, 1f));

            case CenterType.BottomCenter:
                return(new Vector2(0.5f, 1f));

            case CenterType.BottomRight:
                return(new Vector2(1f, 1f));

            default:
                return(default);
            }
        }
Esempio n. 4
0
        public Grid <Vector2Int, Vector2> MakeGrid2Di(CenterType type, DataType dataType, Grid2DConfigure config)
        {
            Grid <Vector2Int, Vector2> ret = Grid <Vector2Int, Vector2> .NullGrid.Instance;

            switch (dataType)
            {
            case DataType.Scalar:
            {
                if (type == CenterType.CellCentered)
                {
                    ret = new CellCenteredScalarGrid2Di(config.Resolution, config.CellSize, config.Origin);
                }
                else
                {
                    Assert.IsFalse(true);
                }
            }
            break;

            case DataType.Vector:     //no vector int grid for now
            default: Assert.IsFalse(true); break;
            }

            return(ret);
        }
Esempio n. 5
0
        /// <summary>
        /// Center (Horizontally or Vertically) GUI Content within a Layout Area
        /// </summary>
        /// <param name="ct">Enum specifying the direction to center the content in</param>
        /// <param name="rd">Delegate function for creating centered content</param>
        public static void Center(CenterType ct, RenderDelegate rd)
        {
            if (ct != CenterType.Horizontal)
            {
                GUILayout.BeginVertical();
            }

            GUILayout.FlexibleSpace();
            if (ct != CenterType.Vertical)
            {
                GUILayout.BeginHorizontal();
            }

            GUILayout.FlexibleSpace();
            rd.Invoke();
            GUILayout.FlexibleSpace();
            if (ct != CenterType.Vertical)
            {
                GUILayout.EndHorizontal();
            }

            GUILayout.FlexibleSpace();
            if (ct != CenterType.Horizontal)
            {
                GUILayout.EndVertical();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 将自身位置设置到父物体的正中心,
        /// Parent不可为null
        /// </summary>
        /// <param name="type">
        /// type==CenterType.Both时Anchor和Pivot都会设置到正中心,
        /// type==CenterType.OnlyPosition时只修改自身x,y值,Parent不可为null
        /// </param>
        public void SetToCenter(CenterType type)
        {
            if (type == CenterType.Both)
            {
                AnchorMin = Anchor.MiddleCenter;
                AnchorMax = Anchor.MiddleCenter;
                Pivot     = Anchor.MiddleCenter;
                SetPosition(0, 0);
            }
            else if (type == CenterType.OnlyPosition)
            {
                if (this.Parent != null)
                {
                    if (this.AnchorMin == this.AnchorMax)
                    {
                        float parentx = (0.5f - this.AnchorMin.x) * Parent.Width * Parent.Scale.x;
                        float parenty = (0.5f - this.AnchorMin.y) * Parent.Height * Parent.Scale.y;

                        float selfx = (this.Pivot.x - 0.5f) * this.Width * this.Scale.x;
                        float selfy = (this.Pivot.y - 0.5f) * this.Height * this.Scale.y;

                        SetPosition(parentx + selfx, -(parenty + selfy));
                    }
                    else
                    {
                        Debug.LogError($"\"{Name}\" SetToCenter() error, because \"this.AnchorMin != this.AnchorMax\"");
                    }
                }
                else
                {
                    Debug.LogError($"\"{Name}\" SetToCenter() error, because parent is null");
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 某条边是否是海岸线
 /// </summary>
 private bool _AvailableCoastPoint(uint curX, uint curY, uint nextX, uint nextY)
 {
     // 上下
     if (nextX == curX)
     {
         uint y = nextY < curY ? nextY : curY;
         // 左,右四边形
         CenterType left  = _centerTypes[curX - 1, y];
         CenterType right = _centerTypes[curX, y];
         return
             (left == CenterType.kLand && right == CenterType.kOcean ||
              left == CenterType.kOcean && right == CenterType.kLand);
     }
     // 左右
     else if (nextY == curY)
     {
         uint x = nextX < curX ? nextX : curX;
         // 上,下四边形
         CenterType up   = _centerTypes[x, curY - 1];
         CenterType down = _centerTypes[x, curY];
         return
             (up == CenterType.kLand && down == CenterType.kOcean ||
              up == CenterType.kOcean && down == CenterType.kLand);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 8
0
        public IActionResult Get(string title              = null, string provinceId     = null,
                                 string cityId             = null, CenterType centerType = CenterType.Null,
                                 DeliveryType deliveryType = DeliveryType.Null,
                                 int?from = 0, int?count = 20,
                                 CenterOrderBy centerOrderBy = CenterOrderBy.Null)
        {
            var centersDto = centerService.Get(title, provinceId, cityId,
                                               centerType, deliveryType, centerOrderBy, from, count);

            return(Ok(centersDto));
        }
        public async Task <IActionResult> PutCenterType(int id, CenterType ctype)
        {
            if (id != ctype.Id)
            {
                return(BadRequest());
            }

            _context.Entry(ctype).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 10
0
    public Center()
    {
        _name        = string.Empty;
        _description = string.Empty;
        _type        = CenterType.None;
        _level       = 1;
        _xp          = 0;
        _xpRequired  = Constants.CenterXpPerLevel[_level];

        _stats     = new Dictionary <StatType, Stat>();
        _staff     = new StaffCollection(this);
        _consortia = new List <Consortium>();
    }
Esempio n. 11
0
        public Grid <Vector2Int, Vector2> MakeGrid2D(CenterType type, DataType dataType, Grid2DConfigure config)
        {
            Grid <Vector2Int, Vector2> ret = Grid <Vector2Int, Vector2> .NullGrid.Instance;

            switch (dataType)
            {
            case DataType.Scalar: ret = this.MakeScalar(type, config); break;

            case DataType.Vector: ret = this.MakeVector(type, config); break;

            default: Assert.IsFalse(true); break;
            }

            return(ret);
        }
Esempio n. 12
0
        protected Grid <Vector2Int, Vector2> MakeScalar(CenterType center, Grid2DConfigure config)
        {
            switch (center)
            {
            case CenterType.CellCentered:
                return(new CellCenteredScalarGrid2D(config.Resolution, config.CellSize, config.Origin));

            case CenterType.VertexCentered:
                return(new VertexCenteredScalarGrid2D(config.Resolution, config.CellSize, config.Origin));

            case CenterType.FaceCentered:
            default:
                Assert.IsFalse(true);
                return(Grid <Vector2Int, Vector2> .NullGrid.Instance);
            }
        }
Esempio n. 13
0
        public IEnumerable <CenterDto> Get(string title                = null, string provinceId     = null,
                                           string cityId               = null, CenterType centerType = CenterType.Null,
                                           DeliveryType deliveryType   = DeliveryType.Null,
                                           CenterOrderBy centerOrderBy = CenterOrderBy.Null,
                                           int?from = 0, int?count = 20)
        {
            var centers = unitOfWork.CenterRepository.Get(title,
                                                          provinceId.ToNullableGuid(), cityId.ToNullableGuid(),
                                                          centerType, deliveryType, centerOrderBy,
                                                          from, count);

            if (centers == null || centers.Count() == 0)
            {
                throw new EntityNotFoundException(typeof(CenterDto), "Query");
            }

            var centersDtos = centerFatory.CreateDto(centers);

            return(centersDtos);
        }
Esempio n. 14
0
        public IEnumerable <Center> Get(string title = null, Guid?provinceId       = null,
                                        Guid?cityId  = null, CenterType centerType = CenterType.Restaurant,
                                        DeliveryType deliveryType   = DeliveryType.Null,
                                        CenterOrderBy centerOrderBy = CenterOrderBy.Null,
                                        int?from = 0, int?count = 20)
        {
            var result = set.Include("City").Include("City.Province").AsQueryable();

            if (!string.IsNullOrEmpty(title))
            {
                result = result.Where(x => x.Title.Contains(title));
            }
            if (provinceId != null)
            {
                result = result.Where(x => x.City.Province.Id == provinceId);
            }
            if (cityId != null)
            {
                result = result.Where(x => x.City.Id == cityId);
            }
            if (centerType != CenterType.Null)
            {
                result = result.Where(x => x.CenterType == centerType);
            }
            if (deliveryType != DeliveryType.Null)
            {
                result = result.Where(x => x.DeliveryType == deliveryType);
            }

            if (centerOrderBy != CenterOrderBy.Null)
            {
            }

            var _ = from.Value * count;

            result = result.Skip(_.Value).Take(count.Value);

            return(result);
        }
Esempio n. 15
0
        public static Vector3 GetCenter(this Transform transform, CenterType centerType)
        {
            if (centerType == CenterType.Solo)
            {
                Renderer renderer = transform.GetComponent <Renderer>();
                if (renderer != null)
                {
                    return(renderer.bounds.center);
                }
                else
                {
                    return(transform.position);
                }
            }
            else if (centerType == CenterType.All)
            {
                Bounds totalBounds = new Bounds(transform.position, Vector3.zero);
                GetCenterAll(transform, ref totalBounds);
                return(totalBounds.center);
            }

            return(transform.position);
        }
Esempio n. 16
0
    public Center(string name, CenterType type)
    {
        _name        = name;
        _description = string.Empty;
        _type        = type;
        _level       = 1;
        _xp          = 0;
        _xp          = 0;
        _xpRequired  = Constants.CenterXpPerLevel[_level];

        _stats     = new Dictionary <StatType, Stat>();
        _staff     = new StaffCollection(this);
        _consortia = new List <Consortium>();

        _stats.Add(StatType.Funding, new Stat("Funding", 3));
        _stats.Add(StatType.Time, new Stat("Time", 4));
        _stats.Add(StatType.Network, new Stat("Network", 1));
        _stats.Add(StatType.Recognition, new Stat("Recognition", 0));
        _stats.Add(StatType.Support, new Stat("Support", 0));
        _stats.Add(StatType.Mentorship, new Stat("Mentorship", 0));

        CalculateTime();
        TimeRemaining = _stats[StatType.Time].Value;
    }
Esempio n. 17
0
 public void SetCenterType(CenterType centerTypeMapped)
 {
     _dbContext.CenterType.Add(centerTypeMapped);
 }
Esempio n. 18
0
        /// <summary>
        /// Used to centerize with a sprite as reference
        /// </summary>
        /// <param name="d1">Main sprite</param>
        /// <param name="obj">Sprite as Reference</param>
        /// <param name="type">How it will be centerized</param>
        /// <returns></returns>
        public static PositionerStyle CenterTo(this PositionerStyle p1, DrawableObject obj, CenterType type)
        {
            // Calculate bounds
            var d1   = p1.Modified;
            var pos1 = p1.Modified.BoundingBox;
            var pos2 = obj.BoundingBox;

            switch (type)
            {
            case CenterType.Horizontally:
                d1.Position = new Vector2((pos2.X + (pos2.Width / 2)) - (pos1.Width / 2), pos1.Y);
                break;

            case CenterType.Vertically:
                d1.Position = new Vector2(pos1.X, (pos2.Y + (pos2.Height / 2)) - (pos1.Height / 2));
                break;

            case CenterType.Both:
                // To avoid copying code, we do this
                p1.CenterTo(obj, CenterType.Horizontally);
                p1.CenterTo(obj, CenterType.Vertically);
                break;
            }

            return(p1);
        }
Esempio n. 19
0
 public ReqConsortiumType(CenterType type)
 {
     Name  = string.Empty;
     _type = type;
 }
Esempio n. 20
0
 public MPMGrid(int3 dimesion, float3 cellSpacing, float3 leftBottom, CenterType centerType = CenterType.Center) : base(dimesion, cellSpacing, leftBottom, centerType)
 {
     this.cellScale = 0.05f;
 }
Esempio n. 21
0
 public static CenterTypeDatabaseService ToDatabaseService(CenterType centerType)
 {
     return (CenterTypeDatabaseService)centerType;
 }
        void SetSpaceAndType()
        {
            if (Input.GetKey(ActionKey))
            {
                return;
            }

            if (Input.GetKeyDown(SetMoveType))
            {
                type = TransformType.Move;
            }
            else if (Input.GetKeyDown(SetRotateType))
            {
                type = TransformType.Rotate;
            }
            else if (Input.GetKeyDown(SetScaleType))
            {
                type = TransformType.Scale;
            }

            if (Input.GetKeyDown(SetPivotModeToggle))
            {
                if (pivot == TransformPivot.Pivot)
                {
                    pivot = TransformPivot.Center;
                }
                else if (pivot == TransformPivot.Center)
                {
                    pivot = TransformPivot.Pivot;
                }

                SetPivotPoint();
            }

            if (Input.GetKeyDown(SetCenterTypeToggle))
            {
                if (centerType == CenterType.All)
                {
                    centerType = CenterType.Solo;
                }
                else if (centerType == CenterType.Solo)
                {
                    centerType = CenterType.All;
                }

                SetPivotPoint();
            }

            if (Input.GetKeyDown(SetSpaceToggle))
            {
                if (space == TransformSpace.Global)
                {
                    space = TransformSpace.Local;
                }
                else if (space == TransformSpace.Local)
                {
                    space = TransformSpace.Global;
                }
            }

            if (Input.GetKeyDown(SetScaleTypeToggle))
            {
                if (scaleType == ScaleType.FromPoint)
                {
                    scaleType = ScaleType.FromPointOffset;
                }
                else if (scaleType == ScaleType.FromPointOffset)
                {
                    scaleType = ScaleType.FromPoint;
                }
            }

            if (type == TransformType.Scale)
            {
                space = TransformSpace.Local;                 //Only support local scale
                if (pivot == TransformPivot.Pivot)
                {
                    scaleType = ScaleType.FromPoint;                                               //FromPointOffset can be inaccurate and should only really be used in Center mode if desired.
                }
            }
        }
Esempio n. 23
0
 public APICGrid(int3 dimesion, float3 cellSpacing, float3 leftBottom, CenterType centerType = CenterType.Center) : base(dimesion, cellSpacing, leftBottom, centerType)
 {
     this.visualize = true;
     this.cellScale = 0.05f;
 }