void SkillController::Update() { if (game_obj_ev != nullptr) { updateRun(); updateHide(); updateCoolDownTimer(false); if (*game_obj_ev == SKILL) { if (!game_obj_info->skill_list.empty()) { updateGlobalVibration(); unsigned int skill_size = game_obj_info->skill_list.size(); if (current_skill >= 0 && current_skill < skill_size) { skill_info* skill_iter = getCurrentSkill(); const char* skill_type = skill_iter->skill_type; if (!strcmp(skill_type, "Charge")) updateCharge(); else if (!strcmp(skill_type, "Power")) updatePower(); else if (!strcmp(skill_type, "Chain")) updateChain(); } if (isSkillFinish) { *game_obj_ev = SEARCHING_RECOGNIZE_AREA; chain_index = 0; } } } else onVibration = false; } }
bool CandyBoss::update(float dt) { //When smiley triggers the boss' enemy blocks start his dialogue. if (state == CANDY_STATE_INACTIVE && !startedIntroDialogue) { if (smh->enemyGroupManager->groups[groupID].triggeredYet) { smh->windowManager->openDialogueTextBox(-1, CANDY_INTRO_TEXT); startedIntroDialogue = true; } else { return false; } } //Activate the boss when the intro dialogue is closed if (state == CANDY_STATE_INACTIVE && startedIntroDialogue && !smh->windowManager->isTextBoxOpen()) { enterState(FIRST_STATE); smh->soundManager->playMusic("bossMusic"); } //Squash silly pads with Bartli's massive girth if (!jumping) { gridX = Util::getGridX(x); gridY = Util::getGridY(y); for (int i = gridX-1; i < gridX + 1; i++) { for (int j = gridY-1; j < gridY + 1; j++) { smh->environment->destroySillyPad(i, j); } } } if (shrinking) { size -= (NUM_LIVES - numLives + 1) * .0225 * dt; if (smh->timePassedSince(timeStartedShrink) > SHRINKING_DURATION) { shrinking = false; } else if (!spawnedBartletYet && smh->timePassedSince(timeStartedShrink) > SHRINKING_DURATION / 2.0) { spawnBartlet(x, y); spawnedBartletYet = true; } } else { timeInState += dt; //Stage 1 - running if (state == CANDY_STATE_RUNNING) { updateRun(dt); if (timeInState > RUN_STATE_DURATION) { enterState(CANDY_STATE_MOVING_TO_CENTER); } } //Stage 2a - move back to the middle of the arena before throwing candy if (state == CANDY_STATE_MOVING_TO_CENTER) { updateRun(dt); if (timeInState >= timeToGetToCenter) { enterState(CANDY_STATE_THROWING_CANDY); //Play a sound smh->soundManager->playSound("snd_BartliRapid"); } } //Stage 2b - throwing candy if (state == CANDY_STATE_THROWING_CANDY) { updateThrowingCandy(dt); if (timeInState > THROWING_CANDY_STATE_DURATION) { enterState(CANDY_STATE_JUMPING); } } //Stage 3a - jumping if (state == CANDY_STATE_JUMPING) { updateJumping(dt); if (numJumps >= 6) { jumping = false; enterState(CANDY_STATE_RESTING); } } //Stage 3b - multi jump (only if you get hit by the shockwave) if (state == CANDY_STATE_MULTI_JUMP) { updateJumping(dt); if (numJumps >= 5) { jumping = false; //Go back to stage one if they got hit by the shockwave! enterState(CANDY_STATE_RUNNING); } } //Stage 4 - resting if (state == CANDY_STATE_RESTING) { updateResting(dt); if (timeInState > REST_STATE_DURATION) { enterState(CANDY_STATE_RUNNING); } } //Player collision if (jumpYOffset < 65.0) { setCollisionBox(collisionBox, x, y - jumpYOffset); } else { //Bartli can't collide with the player when she is in the air setCollisionBox(collisionBox, -1.0, -1.0); } if (smh->player->collisionCircle->testBox(collisionBox)) { if (state == CANDY_STATE_MULTI_JUMP) { if (smh->timePassedSince(lastTimeHitSmiley) > 0.5 * (1.0 / speedMultiplier)) { smh->player->dealDamage(0.25, false); lastTimeHitSmiley = smh->getGameTime(); } smh->setDebugText("Smiley hit by CandyBoss during MultiJump"); } else { if (smh->timePassedSince(lastTimeHitSmiley) > 0.5 * (1.0 / speedMultiplier)) { smh->player->dealDamageAndKnockback(COLLISION_DAMAGE, true, 225.0, x, y); smh->setDebugText("Smiley hit by CandyBoss"); } } } updateLimbs(dt); //Take damage from stuff if (smh->player->getTongue()->testCollision(collisionBox) && smh->timePassedSince(lastTimeHit) > FLASHING_DURATION) { dealDamage(smh->player->getDamage()); } if (smh->player->fireBreathParticle->testCollision(collisionBox)) { //Scale down fire breath a bit otherwise its too strong dealDamage(smh->player->getFireBreathDamage() * 0.8 * dt); } //Immune to frisbees and lightning orbs if (smh->projectileManager->killProjectilesInBox(collisionBox, PROJECTILE_FRISBEE) > 0 || smh->projectileManager->killProjectilesInBox(collisionBox, PROJECTILE_LIGHTNING_ORB) > 0) { smh->soundManager->playSound("snd_HitInvulnerable"); } } updateNovas(dt); updateBartlets(dt); shouldDrawAfterSmiley = (y > smh->player->y); //Do flashing if (smh->timePassedSince(lastTimeHit) < FLASHING_DURATION) { float n = FLASHING_DURATION / 4.0; float x = smh->timePassedSince(lastTimeHit); while (x > n) x -= n; if (x < n/2.0) { flashingAlpha = 100.0 + (310.0 * x) / n; } else { flashingAlpha = 255.0 - 155.0 * (x - n/2.0); } } else { flashingAlpha = 255.0; } //Update mouth if (smh->timePassedSince(timeMouthOpened) > mouthOpenDuration) { smh->resources->GetAnimation("bartli")->SetFrame(0); } if (health < 0.0 && state != CANDY_STATE_FRIENDLY && state != CANDY_STATE_MULTI_JUMP) { numLives--; if (numLives == 0) { health = 0.0; enterState(CANDY_STATE_FRIENDLY); smh->windowManager->openDialogueTextBox(-1, CANDY_DEFEAT_TEXT); smh->saveManager->killBoss(CANDY_BOSS); smh->soundManager->fadeOutMusic(); } else { shrinking = true; spawnedBartletYet = false; timeStartedShrink = smh->getGameTime(); speedMultiplier += .08; health = maxHealth; } } ///////// Death State stuff /////////////// //After being defeated, wait for the text box to be closed if (state == CANDY_STATE_FRIENDLY && !smh->windowManager->isTextBoxOpen()) { enterState(CANDY_STATE_RUNNING_AWAY); fadeOutAlpha = 255.0; } //After defeat and the text box is closed, bartli fades away if (state == CANDY_STATE_RUNNING_AWAY) { fadeOutAlpha -= 255.0 * dt; //When done fading away, drop the loot and return true so this boss is disposed of if (fadeOutAlpha <= 0.0) { fadeOutAlpha = 0.0; smh->soundManager->playMusic("iceMusic"); smh->lootManager->addLoot(LOOT_NEW_ABILITY, x, y, ICE_BREATH, groupID); smh->player->setHealth(smh->player->getMaxHealth()); return true; } } }