void checkForBacteriaAndPlayerCollision() { // check if player was hit bool playerHit = false; Rect playerRect = player_.localRect.CloneAndScaleThenOffset(Math.Abs(player_.scaleX), player_.scaleY, player_.x, player_.y); for (int b = bacterias_.Count - 1; b >= 0; b--) { BacteriaBubble bacteria = bacterias_[b]; Rect bacteriaRect = bacteria.localRect.CloneAndScaleThenOffset(Math.Abs(bacteria.scaleX), bacteria.scaleY, bacteria.x, bacteria.y); if (playerRect.CheckIntersect(bacteriaRect)) { // only do more damage if the player isn't already hit and isn't blocking if (player_.CurrentState != PlayerCharacter.PlayerState.BLOCK && player_.CurrentState != PlayerCharacter.PlayerState.HIT) { playerHit = true; } HandleGotBacteria(bacteria); } } if (playerHit) { HandlePlayerHit(PlayerCharacter.MAX_HEALTH * 0.01f); } }
private void checkForPlayerBubbleAndBacteriaCollision() { // check if any of the bubbles have collided with any of the bacteria // TODO: Make this algorithm more efficient for (int b = bubbles_.Count - 1; b >= 0; b--) { PlayerBubble bubble = bubbles_[b]; Rect bubbleRect = bubble.localRect.CloneAndScaleThenOffset(.2f, .2f, bubble.x, bubble.y); //bubble.scale, bubble.scale, bubble.x, bubble.y); for (int j = bacterias_.Count - 1; j >= 0; j--) { BacteriaBubble bacteria = bacterias_[j]; Rect bacteriaRect = bacteria.localRect.CloneAndScaleThenOffset(Math.Abs(bacteria.scaleX), bacteria.scaleY, bacteria.x, bacteria.y); if (bubbleRect.CheckIntersect(bacteriaRect)) { HandleGotBacteria(bacteria); bubbles_.Remove(bubble); bubbleContainer_.RemoveChild(bubble); break; } } } }
public void CreateBacteria(Vector2 location, Vector2 direction) { BacteriaBubble bacteria = new BacteriaBubble(location, direction); bacteriaContainer_.AddChild(bacteria); bacteria.play("idle"); bacterias_.Add(bacteria); totalBacterialCreated_++; }
public void HandleGotBacteria(BacteriaBubble bacteria) { bacteriaContainer_.RemoveChild(bacteria); bacterias_.Remove(bacteria); dyingBacteriaHolder_.AddChild(bacteria); dyingBacterias_.Add(bacteria); bacteria.play("pop"); FSoundManager.PlaySound("bacteria_pop"); }
void checkForDeadBacteria() { for (int b = dyingBacterias_.Count - 1; b >= 0; b--) { BacteriaBubble bacteria = dyingBacterias_[b]; if (bacteria.FinishedCount >= 1) { dyingBacterias_.Remove(bacteria); dyingBacteriaHolder_.RemoveChild(bacteria); } } }
/*private void addComponentsToStage() * { * AddChild(ImmunityCombatManager.instance.stage.getBackground()); * AddChild(ImmunityCombatManager.instance.stage.getMidBack ()); * AddChild(ImmunityCombatManager.instance.stage.getMid ()); * AddChild(ImmunityCombatManager.instance.stage.getForeMid ()); * AddChild(ImmunityCombatManager.instance.stage.getForeground()); * List<FAnimatedSprite> animations = ImmunityCombatManager.instance.stage.getAnimation(); * foreach(FAnimatedSprite animation in animations) * AddChild(animation); * }*/ private void checkForBacteriaOffScreen() { for (int b = bacterias_.Count - 1; b >= 0; b--) { BacteriaBubble bacteria = bacterias_[b]; // remove a bacteria if it falls off screen if (bacteria.y < -Futile.screen.halfHeight - 50) { bacterias_.Remove(bacteria); bacteriaContainer_.RemoveChild(bacteria); } } }