public override void checkGameObjectTreeCollision(GameObjectTree tree) { if (tree.getCollisionComponent().checkCollision(tree.getCollisionComponent(), gameObject.getCollisionComponent())) { gameObject.notifyHit(); } }
public virtual void checkGameObjectTreeCollision(GameObjectTree tree) { if (tree.getCollisionComponent().checkCollision(this.collisionComponent, tree.getCollisionComponent())) { GameObjectTree columnTemp = activeColumns; while (columnTemp != null) { if (columnTemp.getStatus() == Status.Active) { columnTemp.checkGameObjectTreeCollision(tree); } columnTemp = columnTemp.nextNode; } } }
public override void setCollisionComponent() { GameObjectTree columnTemp = activeColumns; while (columnTemp != null && columnTemp.getStatus() != Status.Active) { columnTemp = columnTemp.nextNode; } if (columnTemp != null) { float x = columnTemp.getCollisionComponent().getPosX(); float width = columnTemp.getCollisionComponent().getWidth(); float height = columnTemp.getCollisionComponent().getHeight(); float lowY = columnTemp.getCollisionComponent().getPosY(); float highY = columnTemp.getCollisionComponent().getPosY(); columnTemp = columnTemp.nextNode; while (columnTemp != null) { if (columnTemp.getStatus() == Status.Active) { if (lowY > columnTemp.getCollisionComponent().getPosY()) { lowY = columnTemp.getCollisionComponent().getPosY(); } else if (highY < columnTemp.getCollisionComponent().getPosY()) { highY = columnTemp.getCollisionComponent().getPosY(); } columnTemp.getCollisionComponent(); } else { Console.WriteLine("hi"); } columnTemp = columnTemp.nextNode; } collisionComponent.setTransformation(x, ((highY - lowY) / 2) + lowY, width, (highY - lowY) + height); } else { collisionComponent.setStatus(Status.Inactive); currentStatus = Status.Inactive; } }
public override void visit(GridWallCollisionList grid) { if (grid.checkCollision(tree.getCollisionComponent())) { notifyObsevers(SpriteType.Wall); canNotify = true; } else if (canNotify) { notifyObsevers(SpriteType.Shield); canNotify = false; } }
public virtual void setCollisionComponent() { GameObjectTree columnTemp = activeColumns; //columnTemp.setCollisionComponent(); while (columnTemp != null && columnTemp.getStatus() != Status.Active) { columnTemp = columnTemp.nextNode; } if (columnTemp != null) { float smallX = columnTemp.getCollisionComponent().getPosX(); float largeX = smallX; float width = columnTemp.getCollisionComponent().getWidth(); float height = columnTemp.getCollisionComponent().getHeight(); float y = columnTemp.getCollisionComponent().getPosY(); columnTemp = columnTemp.nextNode; while (columnTemp != null) { if (columnTemp.getStatus() == Status.Active) { if (height < columnTemp.getCollisionComponent().getHeight()) { height = columnTemp.getCollisionComponent().getHeight(); y = columnTemp.getCollisionComponent().getPosY(); } if (largeX < columnTemp.getCollisionComponent().getPosX()) { largeX = columnTemp.getCollisionComponent().getPosX(); } else if (smallX > columnTemp.getCollisionComponent().getPosX()) { smallX = columnTemp.getCollisionComponent().getPosX(); } columnTemp.getCollisionComponent(); } else { Console.WriteLine("hi Tree"); } columnTemp = columnTemp.nextNode; } collisionComponent.setTransformation(((largeX - smallX) / 2) + smallX, y, (largeX - smallX) + width, height); } else { currentStatus = Status.Inactive; collisionComponent.setStatus(Status.Inactive); } }