//Event Handler
        //---------------------------------------------------------------------------
        public void Handle_PlayerLeaveChunk(IEvent _event)
        {
            GSW.RestartTimer();
            //Interpret Event
            E_Player_LeaveChunk LeaveChunk = (_event as E_Player_LeaveChunk);

            AreaRect TempArea = m_CoverArea;

            TempArea.Move(LeaveChunk.Offset);

            int          i, j = 0;
            ChunkInWorld SpawnLoc;

            for (i = TempArea.left; i <= TempArea.right; ++i)
            {
                for (j = TempArea.bottom; j <= TempArea.top; ++j)
                {
                    SpawnLoc = new ChunkInWorld(new Vector2Int(i, j), m_World);

                    m_WorldEntity.Spawn(SpawnLoc);

                    m_CoveredLoc.Remove(SpawnLoc.Value);
                }
            }

            //remove not covered chunk
            foreach (var uncoverd in m_CoveredLoc)
            {
                m_WorldEntity.Remove(new ChunkInWorld(uncoverd, m_World));
            }
            //update cover area
            SetCoverArea(TempArea);
        }
Beispiel #2
0
 protected override void OnAdded()
 {
     Area = new AreaRect
     {
         TopSide = new asd.LineShape
         {
             StartingPosition = Position - Config.PlayerConfig.Size,
             EndingPosition   = new asd.Vector2DF(Position.X + Width, Position.Y - Config.PlayerConfig.Height)
         },
         BottomSide = new asd.LineShape
         {
             StartingPosition = new asd.Vector2DF(Position.X - Config.PlayerConfig.Width, Position.Y + Height),
             EndingPosition   = Position + Size
         },
         LeftSide  = new asd.LineShape(),
         RightSide = new asd.LineShape(),
         T_y       = (int)Position.Y - Config.PlayerConfig.Height,
         B_y       = (int)Position.Y + Height,
         L_x       = (int)Position.X - Config.PlayerConfig.Width,
         R_x       = (int)Position.X + Width
     };
     Area.LeftSide.StartingPosition  = Area.TopSide.StartingPosition;
     Area.LeftSide.EndingPosition    = Area.BottomSide.StartingPosition;
     Area.RightSide.StartingPosition = Area.TopSide.EndingPosition;
     Area.RightSide.EndingPosition   = Area.BottomSide.EndingPosition;
 }
Beispiel #3
0
        private double AreaContainingFixations(List <Fixation> fixations, double percentToDrop)
        {
            // find centre of all fixations
            System.Windows.Point centre = CalculateMean(fixations);

            // get lengths from centre to each fixation and sort them
            var distances = DistancesFromPointToOtherPoints(centre, fixations);

            distances.Sort((x, y) => x.Item2.CompareTo(y.Item2));

            // drop the fixations that were in the top 10% of
            int numToDrop = (int)(distances.Count * percentToDrop);
            var dropped   = distances.GetRange(0, distances.Count - numToDrop);

            // for each remaining fixation,
            // if the fixations falls within the rectangle do nothing, else
            // extend the rectangle to encompass the fixations
            // return the area of the rectangle
            var areaRect = new AreaRect(fixations[dropped[0].Item1].x, fixations[dropped[0].Item1].y);

            for (int i = 1; i < dropped.Count; i++)
            {
                areaRect.IncreaseRectSizeToContainPoint(fixations[dropped[i].Item1].x, fixations[dropped[i].Item1].y);
            }

            return(areaRect.CalculateArea());
        }
Beispiel #4
0
        public ActionResult Index(AreaRect obj)
        {
            int area = obj.length * obj.width;

            ViewBag.Result = area;
            return(View());
        }
Beispiel #5
0
 //Says if param 'other' intersects the route area
 public bool IntersectMyRouteArea(Rect other)
 {
     if (AreaRect.Overlaps(other))
     {
         return(true);
     }
     return(false);
 }
Beispiel #6
0
            public AreaRect Clone()
            {
                AreaRect areaRectClone = new AreaRect(color);

                areaRectClone.rect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);

                return(areaRectClone);
            }
Beispiel #7
0
        public void AddRenterToArea(AreaRect area, RenterRect renter)
        {
            var ar   = context.Value.RentAreas.Where(a => a.Id == area.Id).Select(c => c).FirstOrDefault();
            var rent = context.Value.Renters.Where(r => r.Id == renter.Id).Select(c => c).FirstOrDefault();

            ar.Renter = rent;
            context.Value.SaveChanges();
        }
        public void Handle_PlayerSpawn(IEvent _event)
        {
            E_Player_Spawned Player_Spawned = _event.Cast <E_Player_Spawned>();

            ChunkInWorld SpawnCenter = new ChunkInWorld(Player_Spawned.SpawnPos, m_World);

            //figure out visiable area
            m_CoverArea = new AreaRect(SpawnCenter.Value, (int)m_PlayerMng.PlayerView);
        }
 public AreaRectProvider()
 {
     //TODO: move to constants
     _areaRect = new AreaRect(10, 10)
     {
         Height = 100,
         Width  = 100
     };
 }
Beispiel #10
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     ar = new AreaRect()
     {
         AreaName = tbName.Text, Square = float.TryParse(tbSquare.Text, out float s) ? s : 0,
         Price    = float.TryParse(tbPrice.Text, out float p) ? p : 0,
         Cost     = float.TryParse(tbCost.Text, out float c) ? c : 0
     };
     DialogResult = DialogResult.OK;
 }
Beispiel #11
0
            public static AreaRect[] InitArray(int num, Color c)
            {
                AreaRect[] areaRect = new AreaRect[num];
                int        i;

                for (i = 0; i < num; i++)
                {
                    areaRect[i] = new AreaRect(c);
                }

                return(areaRect);
            }
Beispiel #12
0
        public void AddLayerArea(LayerRect layer, AreaRect area)
        {
            var dbl = context.Value.RentLayers.Where(x => x.Id == layer.Id).FirstOrDefault();

            Transform.PointsToDimensions(area.x1, area.y1, area.x2, area.y2, out int width, out int height);
            context.Value.RentAreas.Add(new RentArea()
            {
                Layer  = dbl, Name = area.AreaName,
                X      = area.x1, Y = area.y1, Width = width, Height = height,
                Square = area.Square, Price = area.Price, Cost = area.Cost
            });
            context.Value.SaveChanges();
        }
        public void SetCoverArea(AreaRect area)
        {
            m_CoverArea = area;
            m_CoveredLoc.Clear();

            int i, j;

            for (i = m_CoverArea.left; i <= m_CoverArea.right; ++i)
            {
                for (j = m_CoverArea.bottom; j <= m_CoverArea.top; ++j)
                {
                    m_CoveredLoc.Add(new Vector2Int(i, j));
                }
            }
        }
Beispiel #14
0
 public RenterRect GetAreaRenter(AreaRect area)
 {
     return(context.Value.RentAreas
            .Where(a => a.Id == area.Id)
            .Select(r => new RenterRect()
     {
         RenterName = r.Renter.RenterName,
         Contract = r.Renter.Contract,
         StartDate = r.Renter.StartDate,
         EndDate = r.Renter.EndDate,
         ContactPerson = r.Renter.ContactPerson,
         ContactPhone = r.Renter.ContactPhone,
         Annotation = r.Renter.Annotation
     }).FirstOrDefault());
 }
Beispiel #15
0
        protected override void OnGUI()
        {
#if MOCK
            WndProc(-1);
#else
            AreaRect = GUI.Window(ID, AreaRect, WndProc, Title);

            var oldMouseState = _mouseIsOver;
            var newMouseState = AreaRect.Contains(Event.current.mousePosition);
            if (newMouseState != oldMouseState)
            {
                _mouseIsOver = newMouseState;
                MouseOver.Invoke(new JankyEventArgs <bool>(ID, Name, oldMouseState, newMouseState));
            }
#endif
        }
        //Event Handler
        //---------------------------------------------------------------------------
        public bool SpawnAtArea(Vector3 center, int extend, IWorld world)
        {
            ChunkInWorld SpawnCenter = new ChunkInWorld(center, world);

            //figure out visiable area
            AreaRect ViewArea = new AreaRect(SpawnCenter.Value, extend);

            for (int i = ViewArea.left; i <= ViewArea.right; ++i)
            {
                for (int j = ViewArea.bottom; j <= ViewArea.top; ++j)
                {
                    m_CoveredLoc.Add(new Vector2Int(i, j));
                    m_WorldEntity.Spawn(new ChunkInWorld(new Vector2Int(i, j), world));
                }
            }

            SetCoverArea(ViewArea);

            return(true);
        }