public override void performLowest(int column) { GameObjectTree temp = activeColumns; while (temp != null && temp.getStatus() == Status.Inactive) { temp = temp.nextNode; } GameObjectTree check = temp; while (temp != null) { if (temp.getStatus() == Status.Active) { if (temp.getPosY() < check.getPosY()) { check = temp; } } temp = temp.nextNode; } if (check != null) { check.performLowest(column); } }
public virtual void removeFromActive(int num) { GameObjectTree columnTemp = activeColumns; GameObjectTree columnTempPrev = null; while (columnTemp != null && columnTemp.getNum() != num) { columnTempPrev = columnTemp; columnTemp = columnTemp.nextNode; } if (columnTemp != null) { if (columnTempPrev == null) { activeColumns = activeColumns.nextNode; columnTemp.nextNode = null; } else { columnTempPrev.nextNode = columnTemp.nextNode; columnTemp.nextNode = null; } if (reserveColumns == null) { reserveColumns = columnTemp; } else { columnTemp.nextNode = reserveColumns; reserveColumns = columnTemp; } } }
public override void checkGameObjectTreeCollision(GameObjectTree tree) { if (tree.getCollisionComponent().checkCollision(tree.getCollisionComponent(), gameObject.getCollisionComponent())) { gameObject.notifyHit(); } }
public MovementController(GameObjectTree gameTree) { this.alienTree = gameTree; translationCommand = new CommandAlienTranslation(this, 10, timeOffset); animationCommand = new CommandAnimationAlien(this, 10, timeOffset); //Receiver.instance.addCommand(translationCommand); }
GameObjectTree makeGameObjectTree() { SpriteManager m = SpriteManagerFactory.createSpriteManager(SpriteType.Alien, 0); GameObjectTree g = new GameObjectTree(); Scale a = SizeFactory.getFactory.alienScale; for (int i = 0; i < 2; i++) { for (int j = 0; j < 11; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Crab); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Alien t = new Alien(temp, ScoreReferenceFactory.getFactory.getScore(SpriteType.Crab)); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, i, t); } } for (int i = 2; i < 4; i++) { for (int j = 0; j < 11; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Bug); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Alien t = new Alien(temp, ScoreReferenceFactory.getFactory.getScore(SpriteType.Bug)); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, i, t); } } for (int i = 4; i < 5; i++) { for (int j = 0; j < 11; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Squid); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Alien t = new Alien(temp, ScoreReferenceFactory.getFactory.getScore(SpriteType.Squid)); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, i, t); } } return(g); }
public void checkAlienCollision(GameObjectTree tree) { SLink temp = head; while (temp != null) { ((ShieldDataNode)temp).getShield().checkGameObjectTreeCollision(tree); temp = temp.next; } }
public override ObjectController acceptGameObjectVisit(CollisionSprite visitor) { GameObjectTree columnTemp = activeColumns; if (this.acceptGridVisit(visitor)) { return(gameObject); } return(null); }
public virtual void setAllActive(Status st) { this.currentStatus = st; collisionComponent.setStatus(st); GameObjectTree columnTemp = activeColumns; while (columnTemp != null) { columnTemp.setAllActive(st); columnTemp = columnTemp.nextNode; } }
public override ObjectController acceptGameObjectVisit(CollisionSprite visitor) { GameObjectTree columnTemp = activeColumns; while (columnTemp != null) { if (columnTemp.acceptGridVisit(visitor)) { return(columnTemp.acceptGameObjectVisit(visitor)); } } return(null); }
public virtual void performLowest(int column) { GameObjectTree temp = activeColumns; while (temp.nextNode != null && temp.getNum() != column) { temp = temp.nextNode; } if (temp.getStatus() == Status.Active) { temp.performLowest(column); } }
public void sendProjectiles(GameObjectTree gameTree) { DLink temp = pActive; while (temp != null) { if (((ProjectileDataNode)temp).getProjectile().getStatus() == Status.Active) { gameTree.checkProjectileCollision(((ProjectileDataNode)temp).getProjectile()); } temp = temp.pNext; } }
public override void setPos(float x, float y, float xOffset, float yOffset) { GameObjectTree columnTemp = activeColumns; int i = 0; while (columnTemp != null) { columnTemp.setPos(x, (y + (columnTemp.getNum() * yOffset)), xOffset, yOffset); columnTemp = columnTemp.nextNode; i++; } setCollisionComponent(); }
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); } }
public override void translate(float xOffset, float yOffset) { GameObjectTree columnTemp = activeColumns; int i = 0; //collisionComponent.setPosition(collisionComponent.getPosX() + xOffset, collisionComponent.getPosY() + yOffset); while (columnTemp != null) { columnTemp.translate(xOffset, yOffset); columnTemp = columnTemp.nextNode; i++; } setCollisionComponent(); }
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 GameObjectTreeFactory() { alien = makeGameObjectTree(); SpriteManager m = SpriteManagerFactory.createSpriteManager(SpriteType.Alien, 0); GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.UFO); Scale a = SizeFactory.getFactory.alienScale; m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); ufo = new Alien(temp, 0); ufo.setStatus(Status.Inactive); }
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 virtual bool checkProjectileCollision(Projectile projectile) { if (projectile.getCollisionComponent().checkCollision(this.collisionComponent, projectile.getCollisionComponent())) { GameObjectTree columnTemp = activeColumns; while (columnTemp != null) { if (columnTemp.getStatus() == Status.Active) { if (columnTemp.checkProjectileCollision(projectile)) { return(true); } } columnTemp = columnTemp.nextNode; } } return(false); }
public virtual int totalActive() { if (this.currentStatus == Status.Active) { int i = 0; GameObjectTree columnTemp = activeColumns; while (columnTemp != null) { if (columnTemp.getStatus() == Status.Active) { i = i + columnTemp.totalActive(); } columnTemp = columnTemp.nextNode; } return(i); } else { return(0); } }
public override void AddToActive(int column, int row, ObjectController gameObject) { if (this.activeColumns == null) { activeColumns = new GameObjectNode(row); ((GameObjectNode)activeColumns).setObj(gameObject); } else { GameObjectTree columnTemp = activeColumns; while (columnTemp.nextNode != null && columnTemp.getNum() != row) { columnTemp = columnTemp.nextNode; } columnTemp.nextNode = new GameObjectNode(row); columnTemp = columnTemp.nextNode; ((GameObjectNode)columnTemp).setObj(gameObject); } }
public virtual void AddToActive(int column, int row, ObjectController gameObject) { total++; if (activeColumns == null) { activeColumns = new GameObjectColumn(column); activeColumns.AddToActive(column, row, gameObject); } else { GameObjectTree columnTemp = activeColumns; while (columnTemp.nextNode != null && columnTemp.getNum() != column) { columnTemp = columnTemp.nextNode; } if (columnTemp.getNum() != column) { columnTemp.nextNode = new GameObjectColumn(column); columnTemp = columnTemp.nextNode; } columnTemp.AddToActive(column, row, gameObject); } }
public virtual bool acceptGameObjectTreeVisit(GameObjectTree gTree) { return(false); }
public ShieldDataNode(GameObjectTree tree, int num) { this.tree = tree; this.num = num; }
public AlienGridCollisionSubject(GameObjectTree tree, SpriteType name) : base(name) { this.tree = tree; }
public virtual void visit(GameObjectTree tree) { }
public GameObjectTree makeGameObjectTreeShield() { SpriteManager m = SpriteManagerFactory.createSpriteManager(SpriteType.Shield, 0); GameObjectTree g = new GameObjectTree(); Scale a = SizeFactory.getFactory.shieldScale; for (int i = 3; i < 11; i++) { for (int j = 0; j < 8; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Shield); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Shield t = new Shield(temp); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, i, t); } } for (int j = 0; j < 3; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Shield); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Shield t = new Shield(temp); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, 2, t); } for (int j = 5; j < 8; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Shield); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Shield t = new Shield(temp); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, 2, t); } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Shield); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Shield t = new Shield(temp); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, i, t); } for (int j = 6; j < 8; j++) { GameObject temp = GameObjectFactory.createGameObject(); Sprite s = ProxySpriteFactory.makeProxySprite(SpriteType.Shield); m.createActive(s); temp.setSprite(s); temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy); temp.setScale(a.spriteWidth, a.spriteHeight); temp.setColScale(a.colWidth, a.colHeight); Shield t = new Shield(temp); PlayerModeStatusManagerFactory.getFactory.addObject(t); g.AddToActive(j, i, t); } } return(g); }