public override void collide(TiledObj tile) { if(tile.solid && tile.canMove){ tile.setVel(tile.x-x, tile.y-y); } base.collide(tile); }
public override void collide(TiledObj tile) { if(tile.tileType==Character.TILE_TYPE){ setVel(x-tile.x, y-tile.y); } base.collide(tile); }
public void doOverCollide(TiledObj tile) { TiledObj nativeTile; Dimension dim=tile.dim; for (int x=tile.x; x<tile.x+dim.width; x++) { for (int y=tile.y; y<tile.y+dim.height; y++) { for (int j=0; j<depth; j++) { nativeTile = grid [x,y,j]; if (nativeTile != tile && nativeTile!=null) { nativeTile.onOver(tile); tile.onOver(nativeTile); } } } } }
public override void onOver(TiledObj tile) { base.onOver (tile); if(tile.tileType==Character.TILE_TYPE) { tile.setVel(dir.x,dir.y); } }
public override void onOver(TiledObj tile) { base.onOver (tile); if (tile.tileType == Character.TILE_TYPE) { this.SetTriggered (!this.IsTriggered); } }
public override void onLeave(TiledObj tile) { base.onLeave (tile); if(tile.tileType==Character.TILE_TYPE) { this.SetTriggered(false); } }
public override void onOver(TiledObj tile) { base.onOver (tile); if(tile.tileType==Character.TILE_TYPE) { Debug.Log("TriggerOverSET TRIGGER"); this.SetTriggered(true); } }
//returns a list of tiles at a specific location and radius. public TiledObj[] getTilesAt(Point location, int radius) { TiledObj nativeTile; TiledObj[] output; //a list that will contain all object found with the radius. We need to trim this before returning it though. //not super efficient, but for the sake of returning a trimmed array as opposed to one that would contain null index's. TiledObj[] allInRadius = new TiledObj[depth + radius * radius * depth]; int tileCount = 0; for (int x=location.x-radius; x<=location.x+radius; x++) { for (int y=location.y-radius; y<=location.y+radius; y++) { if (isWithinRange (x, y)) { for (int j=0; j<depth; j++) { nativeTile = grid [x, y, j]; if (nativeTile != null) { allInRadius [tileCount] = nativeTile; tileCount++; } } } } } output = new TiledObj[tileCount]; //reset the variable, use it again in this next loop. tileCount = 0; //this code will trim the larger array created before being returned. for (int i=0; i<allInRadius.Length; i++) { if (allInRadius [i] != null) { output [tileCount++] = allInRadius [i]; } } Debug.Log(output.Length); return output; }
public virtual void onOver(TiledObj tile) { }
public virtual void onLeave(TiledObj tile) { }
public void hit(TiledObj obj) { }
//return true if this method is meant to change velocity of the tile it is hitting. False if no change is intended. public virtual void collide(TiledObj tile) { }
public void resolveMovement(TiledObj tile) { if(resolveTileList.IndexOf(tile)<0){ //resolveTileList.Add(tile); } }
public void insertTile(TiledObj tile) { objList.Add(tile); moveTile (tile, tile.vel); }
private void moveTile(TiledObj tile, Point newPos) { TiledObj nativeTile; Dimension dim=tile.dim; //REMOVE TILE FROM OLD POSITION for (int x=tile.x; x<tile.x+dim.width; x++) { for (int y=tile.y; y<tile.y+dim.height; y++) { for (int j=0; j<depth; j++) { nativeTile = grid [x,y,j]; //add to the end of the depth list. if (nativeTile == tile) { //if tile has been found, then the last index will always be null. //shift loop was not causing the last index to null. grid[x,y,depth-1]=null; //if I found the location of where the current tile sits in the depth, then remove it. //we are just shifting the list one space to the left. will overrite the current tile, and keep the list from becoming staggard. for(int i=j;i<depth-1;i++) { grid[x,y,i]=grid[x,y,i+1]; } }else if (nativeTile!=null) { nativeTile.onLeave(tile); tile.onLeave(nativeTile); }else{ break; } } } } //ADD TO NEW POSITION for (int x=newPos.x; x<newPos.x+dim.width; x++) { for (int y=newPos.y; y<newPos.y+dim.height; y++) { for (int j=0; j<depth; j++) { nativeTile = grid [x,y,j]; //add to the end of the depth list. if (nativeTile == null) { //if there is no tile occupying that particular depth, then occupy it. grid[x,y,j]=tile; //break, we only want to occupy 1 space of depth. break; } } } } tile.setPos(newPos.x, newPos.y); tile.stopVel(); }