void Player::Jump() { if (m_bCanJump == false) { return; } if (m_jumpTimer >= 0.0f) { return; } m_bCanJump = false; m_jumpTimer = 0.3f; m_velocity += m_up * 14.0f; // Change to jump animation if (CanAttackLeft() && CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, false, AnimationSections_FullBody, "Jump", 0.01f); } if (m_bCanInteruptCombatAnim) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Legs_Feet, false, AnimationSections_Legs_Feet, "Jump", 0.01f); } }
// Combat void Player::PressAttack() { if (CanAttackRight()) { 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 = true; } 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 = true; } else if (randomAttack == 3) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, false, AnimationSections_FullBody, "SwordAttack3", 0.01f); m_bCanInteruptCombatAnim = false; } m_bCanAttackRight = false; } }
void Player::StopMoving() { if (m_bIsIdle == false) { m_bIsIdle = true; if (CanAttackLeft() && CanAttackRight()) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, false, AnimationSections_FullBody, "BindPose", 0.15f); } if (m_bCanInteruptCombatAnim) { m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Legs_Feet, false, AnimationSections_Legs_Feet, "BindPose", 0.15f); } } }
// 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()) { } }