void BombsGame::Unhide(int x, int y, bool b_selected) { if (!IsHidden(x,y)) { return; } if (b_selected) m_field[x+y*m_width] |= BG_SELECTED; m_field[x+y*m_width] &= ~BG_HIDDEN; if (!IsBomb(x,y)) { m_numRemainingCells--; } }
void Player::AttackAnimationTimerFinished() { if (IsBow()) { } else if (IsBoomerang()) { vec3 boomerangSpawnPosition = GetCenter() + (m_forward*0.75f) + (GetRightVector()*-0.4f) + (GetUpVector()*0.5f); float cameraModification = (m_cameraForward.y*17.5f); if (m_cameraForward.y < 0.0f) { cameraModification = (m_cameraForward.y*5.0f); } vec3 boomerangTarget = boomerangSpawnPosition + m_forward*15.0f + (vec3(0.0f, 1.0f, 0.0f) * cameraModification); if (m_pTargetEnemy != NULL) { boomerangTarget = m_pTargetEnemy->GetProjectileHitboxCenter(); if (m_pTargetEnemy->IsMoving()) { boomerangTarget += m_pTargetEnemy->GetForwardVector() * (m_pTargetEnemy->GetMovementSpeed() / 3.0f); } } float curveTime = length(boomerangTarget - boomerangSpawnPosition) / 15.0f; if (curveTime <= 0.4f) curveTime = 0.4f; Projectile* pProjectile = m_pProjectileManager->CreateProjectile(boomerangSpawnPosition, vec3(0.0f, 0.0f, 0.0f), 0.0f, "media/gamedata/weapons/Boomerang/BoomerangThrown.weapon", 0.05f); pProjectile->SetProjectileType(true, false, false); pProjectile->SetOwner(this, NULL, NULL); pProjectile->SetGravityMultiplier(0.0f); pProjectile->SetReturnToPlayer(true); pProjectile->SetProjectileCurveParams(m_forward, boomerangTarget, curveTime); pProjectile->SetWorldCollisionEnabled(true); m_pVoxelCharacter->SetRenderRightWeapon(false); } else if (IsStaff()) { float powerAmount = 25.0f; float cameraMultiplier = 25.0f; vec3 spellSpawnPosition = GetCenter() + (m_forward*1.25f) + (GetUpVector()*0.25f); if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson) { cameraMultiplier = 30.0f; spellSpawnPosition.y += 0.75f; } vec3 spellSpawnVelocity = m_forward * powerAmount + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier); if (m_pTargetEnemy != NULL) { vec3 toTarget = m_pTargetEnemy->GetProjectileHitboxCenter() - GetCenter(); spellSpawnVelocity = (normalize(toTarget) * powerAmount); } Projectile* pProjectile = m_pProjectileManager->CreateProjectile(spellSpawnPosition, spellSpawnVelocity, 0.0f, "media/gamedata/items/Fireball/Fireball.item", 0.05f); pProjectile->SetProjectileType(true, false, false); pProjectile->SetOwner(this, NULL, NULL); pProjectile->SetGravityMultiplier(0.0f); } else if (IsWand()) { } else if (IsBomb()) { vec3 bombSpawnPosition = GetCenter() + (m_forward*0.75f) + (GetUpVector()*0.5f); float liftAmount = 8.0f; float powerAmount = 30.0f; float cameraMultiplier = 25.0f; if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson) { cameraMultiplier = 30.0f; } vec3 bombSpawnVelocity; if (m_pTargetEnemy) { // Enemy target vec3 toTarget = m_pTargetEnemy->GetCenter() - GetCenter(); float toTargetDistance = length(toTarget); liftAmount += toTargetDistance * 0.04f; bombSpawnVelocity = (normalize(toTarget) * powerAmount) + vec3(0.0f, liftAmount, 0.0f); } else { bombSpawnVelocity = (m_forward * powerAmount) + (GetUpVector() * liftAmount) + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier); } Projectile* pProjectile = m_pProjectileManager->CreateProjectile(bombSpawnPosition, bombSpawnVelocity, 0.0f, "media/gamedata/items/Bomb/BombThrown.item", 0.05f); pProjectile->SetProjectileType(true, false, false); pProjectile->SetOwner(this, NULL, NULL); pProjectile->SetGravityMultiplier(3.5f); float explodeRadius = 3.5f - (GetRandomNumber(-150, 0, 2) * 0.01f); pProjectile->SetExplodingProjectile(true, explodeRadius); //m_pVoxelCharacter->SetRenderRightWeapon(false); InventoryItem* pItem = m_pInventoryManager->GetInventoryItemForEquipSlot(EquipSlot_RightHand); if (pItem != NULL) { if (pItem->m_quantity != -1) { pItem->m_quantity -= 1; } if (pItem->m_quantity == 0) { // Remove this item from the manager, and remove it from the inventory and GUI UnequipItem(EquipSlot_RightHand, false, false); m_pInventoryManager->RemoveInventoryItem(EquipSlot_RightHand); m_pActionBar->RemoveInventoryItemFromActionBar(pItem->m_title); } } } else if (IsConsumable()) { } else if (IsDagger()) { } else if (IsHammer()) { } else if (IsMace()) { } else if (IsSickle()) { } else if (IsPickaxe()) { Item* pInteractItem = VoxGame::GetInstance()->GetInteractItem(); if (pInteractItem != NULL) { pInteractItem->Interact(); } else { DestroyBlock(); } } else if (IsAxe()) { } else if (Is2HandedSword()) { } else if (IsSword()) { } else if (IsBlockPlacing()) { } else if (IsItemPlacing()) { } else if (IsSceneryPlacing()) { } else if (IsSpellHands()) { float powerAmount = 25.0f; float cameraMultiplier = 25.0f; vec3 spellSpawnPosition = GetCenter() + (m_forward*0.5f) + (GetUpVector()*0.0f); // For right hand spellSpawnPosition += -(GetRightVector()*0.4f); if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson) { cameraMultiplier = 30.0f; spellSpawnPosition.y += 0.75f; } vec3 spellSpawnVelocity = m_forward * powerAmount + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier); if (m_pTargetEnemy != NULL) { vec3 toTarget = m_pTargetEnemy->GetProjectileHitboxCenter() - GetCenter(); spellSpawnVelocity = (normalize(toTarget) * powerAmount); } Projectile* pProjectile = m_pProjectileManager->CreateProjectile(spellSpawnPosition, spellSpawnVelocity, 0.0f, "media/gamedata/items/Fireball/FireballBlue.item", 0.05f); pProjectile->SetProjectileType(true, false, false); pProjectile->SetOwner(this, NULL, NULL); pProjectile->SetGravityMultiplier(0.0f); } else if (IsShield()) { } else if (IsTorch()) { } }
// Combat void Player::PressAttack() { if (IsDead()) { return; } if (IsBow()) { if (m_bowAttackDelay <= 0.0f) { if (m_bIsChargingAttack == false) { m_bIsChargingAttack = true; m_chargeAmount = 0.0f; LoadWeapon(false, "media/gamedata/items/Arrow/ArrowHold.item"); if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson) { // Make sure we set arrow alpha if we are in first person mode m_pVoxelCharacter->SetMeshAlpha(0.45f, true); } if (m_bIsIdle) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, false, AnimationSections_FullBody, "BowCharge", 0.2f); } else { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Head_Body, false, AnimationSections_Head_Body, "BowCharge", 0.2f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "BowCharge", 0.2f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "BowCharge", 0.2f); } VoxGame::GetInstance()->PlaySoundEffect(eSoundEffect_BowDraw); } } } else if (IsBoomerang()) { if (CanAttackRight()) { if (m_bCanThrowWeapon) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, true, AnimationSections_FullBody, "SwordAttack1", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "SwordAttack1", 0.01f); Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.22f, 0.22f, 0.0f, NULL, _AttackAnimationTimerFinished, this); m_bCanAttackRight = false; m_bCanThrowWeapon = false; // Start weapon trails if (m_pVoxelCharacter->GetRightWeapon()) { if (m_pVoxelCharacter->IsRightWeaponLoaded()) { m_pVoxelCharacter->GetRightWeapon()->StartWeaponTrails(); } } } } } else if (IsStaff()) { if (m_magic >= 10.0f) { if (CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "StaffAttack", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "StaffAttack", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Head_Body, false, AnimationSections_Head_Body, "StaffAttack", 0.01f); m_bCanInteruptCombatAnim = false; Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.2f, 0.2f, 0.0f, NULL, _AttackAnimationTimerFinished, this); m_magic -= 10.0f; VoxGame::GetInstance()->GetHUD()->UpdatePlayerData(); m_bCanAttackRight = false; } VoxGame::GetInstance()->PlaySoundEffect(eSoundEffect_FireballCast, 0.5f); } } else if (IsWand()) { } else if (IsBomb()) { if (CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, true, AnimationSections_FullBody, "SwordAttack2", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "SwordAttack2", 0.01f); Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.25f, 0.25f, 0.0f, NULL, _AttackAnimationTimerFinished, this); m_bCanAttackRight = false; } } else if (IsConsumable()) { } else if (IsDagger()) { InventoryItem* pRightHand = m_pInventoryManager->GetInventoryItemForEquipSlot(EquipSlot_RightHand); InventoryItem* pLeftHand = m_pInventoryManager->GetInventoryItemForEquipSlot(EquipSlot_LeftHand); if (pRightHand != NULL && pRightHand->m_itemType == InventoryType_Weapon_Dagger && CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "SwordAttack2", 0.01f); Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.3f, 0.3f, 0.0f, NULL, _AttackAnimationTimerFinished, this); m_bCanInteruptCombatAnim = true; m_attackEnabledDelayTimer = 0.0f; m_attackSegmentAngle = 0.75f; float attackTime = 0.4f; float startRotation = -10.0f; float endRotation = -10.0f; float easingRotation = 0.0f; m_attackEnabled = true; m_attackEnabledTimer = 0.0f; m_attackRotation = startRotation; Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledTimer, 0.0f, attackTime, attackTime, 0.0f, NULL, _AttackEnabledTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledDelayTimer, m_attackEnabledDelayTimer, 0.0f, m_attackEnabledDelayTimer, 0.0f, NULL, _AttackEnabledDelayTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackRotation, startRotation, endRotation, attackTime, easingRotation); m_bCanAttackRight = false; } else if (pLeftHand != NULL && pLeftHand->m_itemType == InventoryType_Weapon_Dagger && CanAttackLeft()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "SwordAttack2", 0.01f); Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.3f, 0.3f, 0.0f, NULL, _AttackAnimationTimerFinished_Alternative, this); m_bCanInteruptCombatAnim = true; m_attackEnabledDelayTimer = 0.0f; m_attackSegmentAngle = 0.75f; float attackTime = 0.4f; float startRotation = -10.0f; float endRotation = -10.0f; float easingRotation = 0.0f; m_attackEnabled = true; m_attackEnabledTimer = 0.0f; m_attackRotation = startRotation; Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledTimer, 0.0f, attackTime, attackTime, 0.0f, NULL, _AttackEnabledTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledDelayTimer, m_attackEnabledDelayTimer, 0.0f, m_attackEnabledDelayTimer, 0.0f, NULL, _AttackEnabledDelayTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackRotation, startRotation, endRotation, attackTime, easingRotation); m_bCanAttackLeft = false; } } else if (IsHammer()) { } else if (IsMace()) { } else if (IsSickle()) { } else if (IsPickaxe()) { if (CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, true, AnimationSections_FullBody, "Mine", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "Mine", 0.01f); m_bCanInteruptCombatAnim = false; Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.4f, 0.4f, 0.0f, NULL, _AttackAnimationTimerFinished, this); m_bCanAttackRight = false; } } else if (IsAxe()) { } else if (Is2HandedSword()) { if (CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, true, AnimationSections_FullBody, "2HandedSwordAttack", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "2HandedSwordAttack", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "2HandedSwordAttack", 0.01f); m_bCanInteruptCombatAnim = false; m_attackEnabledDelayTimer = 0.175f; m_attackSegmentAngle = 0.60f; float attackTime = 0.6f; float startRotation = 240.0f; float endRotation = -60.0f; float easingRotation = -50.0f; m_attackEnabled = true; m_attackEnabledTimer = 0.0f; m_attackRotation = startRotation; Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledTimer, 0.0f, attackTime, attackTime, 0.0f, NULL, _AttackEnabledTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledDelayTimer, m_attackEnabledDelayTimer, 0.0f, m_attackEnabledDelayTimer, 0.0f, NULL, _AttackEnabledDelayTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackRotation, startRotation, endRotation, attackTime, easingRotation); m_bCanAttackRight = false; } } else if (IsSword()) { if (CanAttackRight()) { float attackTime = 0.0f; float startRotation = 0.0f; float endRotation = 0.0f; float easingRotation = 0.0f; int randomAttack = GetRandomNumber(1, 3); if (randomAttack == 1) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, true, AnimationSections_FullBody, "SwordAttack1", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Head_Body, false, AnimationSections_Head_Body, "SwordAttack1", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "SwordAttack1", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "SwordAttack1", 0.01f); m_bCanInteruptCombatAnim = false; m_attackEnabledDelayTimer = 0.1f; m_attackSegmentAngle = 0.75f; attackTime = 0.4f; startRotation = -20.0f; endRotation = -20.0f; easingRotation = 0.0f; } else if (randomAttack == 2) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, true, AnimationSections_FullBody, "SwordAttack2", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Head_Body, false, AnimationSections_Head_Body, "SwordAttack2", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "SwordAttack2", 0.01f); m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "SwordAttack1", 0.01f); m_bCanInteruptCombatAnim = false; m_attackEnabledDelayTimer = 0.2f; m_attackSegmentAngle = 0.75f; attackTime = 0.4f; startRotation = -10.0f; endRotation = -10.0f; easingRotation = 0.0f; } else if (randomAttack == 3) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, false, AnimationSections_FullBody, "SwordAttack3", 0.01f); m_bCanInteruptCombatAnim = false; m_attackEnabledDelayTimer = 0.0f; m_attackSegmentAngle = 0.60f; attackTime = 0.6f; startRotation = 360.0f; endRotation = -45.0f; easingRotation = -75.0f; } m_bCanAttackRight = false; m_attackEnabled = true; m_attackEnabledTimer = 0.0f; m_attackRotation = startRotation; Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledTimer, 0.0f, attackTime, attackTime, 0.0f, NULL, _AttackEnabledTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackEnabledDelayTimer, m_attackEnabledDelayTimer, 0.0f, m_attackEnabledDelayTimer, 0.0f, NULL, _AttackEnabledDelayTimerFinished, this); Interpolator::GetInstance()->AddFloatInterpolation(&m_attackRotation, startRotation, endRotation, attackTime, easingRotation); } } else if (IsBlockPlacing()) { } else if (IsItemPlacing()) { } else if (IsSceneryPlacing()) { } else if (IsSpellHands()) { if (m_magic >= 5.0f) { InventoryItem* pRightHand = m_pInventoryManager->GetInventoryItemForEquipSlot(EquipSlot_RightHand); InventoryItem* pLeftHand = m_pInventoryManager->GetInventoryItemForEquipSlot(EquipSlot_LeftHand); if (pRightHand != NULL && pRightHand->m_itemType == InventoryType_Weapon_SpellHands && CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "HandSpellCastRight", 0.01f); Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.3f, 0.3f, 0.0f, NULL, _AttackAnimationTimerFinished, this); m_magic -= 5.0f; VoxGame::GetInstance()->GetHUD()->UpdatePlayerData(); m_bCanAttackRight = false; } else if (pLeftHand != NULL && pLeftHand->m_itemType == InventoryType_Weapon_SpellHands && CanAttackLeft()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "HandSpellCastLeft", 0.01f); Interpolator::GetInstance()->AddFloatInterpolation(&m_animationTimer, 0.0f, 0.3f, 0.3f, 0.0f, NULL, _AttackAnimationTimerFinished_Alternative, this); m_magic -= 5.0f; VoxGame::GetInstance()->GetHUD()->UpdatePlayerData(); m_bCanAttackLeft = false; } VoxGame::GetInstance()->PlaySoundEffect(eSoundEffect_FireballCast, 0.5f); } } else if (IsShield()) { } else if (IsTorch()) { } }
void Player::AttackAnimationTimerFinished_Alternative() { if (IsBow()) { } else if (IsBoomerang()) { } else if (IsStaff()) { } else if (IsWand()) { } else if (IsBomb()) { } else if (IsConsumable()) { } else if (IsDagger()) { } else if (IsHammer()) { } else if (IsMace()) { } else if (IsSickle()) { } else if (IsPickaxe()) { } else if (IsAxe()) { } else if (Is2HandedSword()) { } else if (IsSword()) { } else if (IsBlockPlacing()) { } else if (IsItemPlacing()) { } else if (IsSceneryPlacing()) { } else if (IsSpellHands()) { float powerAmount = 25.0f; float cameraMultiplier = 25.0f; vec3 spellSpawnPosition = GetCenter() + (m_forward*0.5f) + (GetUpVector()*0.0f); // For left hand spellSpawnPosition += (GetRightVector()*0.4f); if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson) { cameraMultiplier = 30.0f; spellSpawnPosition.y += 0.75f; } vec3 spellSpawnVelocity = m_forward * powerAmount + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier); if (m_pTargetEnemy != NULL) { vec3 toTarget = m_pTargetEnemy->GetProjectileHitboxCenter() - GetCenter(); spellSpawnVelocity = (normalize(toTarget) * powerAmount); } Projectile* pProjectile = m_pProjectileManager->CreateProjectile(spellSpawnPosition, spellSpawnVelocity, 0.0f, "media/gamedata/items/Fireball/FireballBlue.item", 0.05f); pProjectile->SetProjectileType(true, false, false); pProjectile->SetOwner(this, NULL, NULL); pProjectile->SetGravityMultiplier(0.0f); } else if (IsShield()) { } else if (IsTorch()) { } }