Esempio n. 1
0
 public void PerformAction(IGridAsset participant, Point point)
 {
     cooldown = 2.0f;
        action(participant, point);
 }
Esempio n. 2
0
 public CollisionHandler(IGridAsset act, CollisionEventHandler a)
 {
     actuator = act;
     action = a;
 }
Esempio n. 3
0
        private void CoarseGridFill(IGridAsset ent, IGridAssetCongolmerate conglomerate = null)
        {
            IGridAsset toFillGrid = ent;
            if (conglomerate != null)
                toFillGrid = conglomerate;

            for (int i = (int)(ent.boundry.Left / gridSize.X); i <= (int)(ent.boundry.Right / gridSize.X); i++)
            {
                for (int j = (int)(ent.boundry.Top / gridSize.Y); j <= (int)(ent.boundry.Bottom / gridSize.Y); j++)
                {
                    Point gridPos = new Point(i, j);
                    if (GridPosValid(gridPos))
                    {
                        if (!grid[gridPos.X, gridPos.Y].inhabitants.Contains(toFillGrid))
                        {
                            toFillGrid.gridPositions.Add(gridPos);
                            grid[gridPos.X, gridPos.Y].inhabitants.Add(toFillGrid);
                            if (grid[gridPos.X, gridPos.Y].inhabitants.Count > 1)
                                HandleCollision(grid[gridPos.X, gridPos.Y].inhabitants,gridPos);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 public void UpdateGridInfo(IGridAsset ent)
 {
     if (!enabled)
         return;
     Remove(ent);
     Add(ent);
 }
Esempio n. 5
0
 public void Remove(IGridAsset ent)
 {
     if (!enabled || ent.gridPositions == null)
         return;
     foreach (Point gridPos in ent.gridPositions)
     {
         if (gridPos.X < width && gridPos.Y < height)
             grid[gridPos.X, gridPos.Y].inhabitants.Remove(ent);
     }
     ent.gridPositions.Clear();
 }
Esempio n. 6
0
        public void Add(IGridAsset ent)
        {
            if (!enabled)
                return;

            CoarseGridFill(ent);
        }