public void attack() { Vector2 pos = getLocation(); if (getState() == sSTATE_ATTACKING) { if (getCurrentSprite().getCurrentFrame() == 24 && !shotBullet) { RockManager.getInstance().createObject(pos + new Vector2(30, 20), new Vector2(getCurrentSprite().isFlipped()? 10:-10, -200), color_); shotBullet = true; SoundManager.PlaySound(cSOUND_SHOOT); } else { shotBullet = false; } } }
public override void update(GameTime gameTime) { base.update(gameTime);//getCurrentSprite().update(); rockerWing.mX = mX - getCurrentSprite().getWidth() / 2 - 2; rockerWing.mY = mY - getCurrentSprite().getHeight() / 2 + 30; rockerWing.update(gameTime); rockPos.X = mX + 12; rockPos.Y = mY + 65; //provisorio if (!attacking) { if (mX < GamePlayScreen.sCURRENT_STAGE_X && tempMove == false) { offsetX = -3; tempMove = true; } if (tempMove == true) { changeState(sSTATE_FLYING_RIGHT); moveRight(3); } if (mX > GamePlayScreen.sCURRENT_STAGE_X + 800 - 120 && tempMove == true) { tempMove = false; } if (tempMove == false) { offsetX = 3; changeState(sSTATE_FLYING_LEFT); moveLeft(3); } if (mX + (getCurrentSprite().getWidth() / 2) > getPlayerCenter() - 2 && (mX + getCurrentSprite().getWidth() / 2) < getPlayerCenter() + 2) { attacking = true; offsetX = 0; changeState(sSTATE_FLYING_STOPPED); } x += 0.1f; float sinMov = 5.0f * (float)Math.Sin(x); mY += sinMov; } if (getState() == sSTATE_FLYING_STOPPED) { if (attackTimer < 60) { attackTimer++; } else { changeState(sSTATE_FLYING_ATTACKING); RockManager.getInstance().createObject(new Vector2((int)rockPos.X + offsetX, (int)rockPos.Y + offsetY)); isRockActive = false; } } if (getState() == sSTATE_FLYING_ATTACKING) { if (waitTimer < 60) { waitTimer++; } else { attackTimer = 0; waitTimer = 0; alphaTexture = 0; attacking = false; isRockActive = true; } } if (alphaTexture < 1) { alphaTexture += 0.01f; } }