示例#1
0
 public void PerformAction(IGridAsset participant, Point point)
 {
     cooldown = 2.0f;
        action(participant, point);
 }
示例#2
0
 public CollisionHandler(IGridAsset act, CollisionEventHandler a)
 {
     actuator = act;
     action = a;
 }
示例#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);
                        }
                    }
                }
            }
        }
示例#4
0
 public void UpdateGridInfo(IGridAsset ent)
 {
     if (!enabled)
         return;
     Remove(ent);
     Add(ent);
 }
示例#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();
 }
示例#6
0
        public void Add(IGridAsset ent)
        {
            if (!enabled)
                return;

            CoarseGridFill(ent);
        }