public override void Update(GameTime gameTime) { // TIMER FOR NEXT ATTACK if (!currentAnimation.IsPlayingAnimation) { timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; // Damage damageSpriteAlpha = Math.Max(0, damageSpriteAlpha - FADE_OUT_SPEED); } // ATTACKING if (timer >= ATTACK_INTERVAL) { timer = 0; if (!character.IsDead && !enemyCharacter.IsDead && !isHealing) { myAttackTurn = !myAttackTurn; Attack(); } else { EndFight(); } } // UPDATE WEAPON ANIMATION currentAnimation.Update(gameTime); hitEffect.Update(gameTime); // HIT MOMENT if (currentAnimation.Time >= hitInterval && currentAnimation.IsPlayingAnimation && !isFlickering) { // Play the right hit sound PlayHitSound(); // Lose HP if (myAttackTurn) { enemyCharacter.hp -= MathHelper.Clamp(damage, enemyCharacter.hp - enemyCharacter.maxHP, enemyCharacter.hp); } else { character.hp -= MathHelper.Clamp(damage, character.hp - character.maxHP, character.hp); } if (currentAnimation != specialAnimations[Character.Special.Healer]) { // Set flickering values isFlickering = true; flickerAmount = 0; show = false; // Set visual damage damageSprite.position = myAttackTurn ? MyDamagePosition : EnemyDamagePosition; damageSpriteAlpha = 1f; damageSprite.CurrentFrame = Math.Min(damage, 3); //hitEffect = currentAnimation != specialAnimations[Character.Special.Spy] ? AnimationAssets.HitEffect : AnimationAssets.SpySpecialHitEffect; hitEffect.Position = myAttackTurn ? MyHitEffectPosition : EnemyHitEffectPosition; hitEffect.Play(); hitEffect.FlipX = !myAttackTurn; } else { // Set visual heal damageSprite.position = myAttackTurn ? MyDamagePosition : EnemyDamagePosition; damageSpriteAlpha = 1f; damageSprite.CurrentFrame = Math.Min(-damage + 3, 5); isFlickering = true; } } damageSprite.position.Y -= DAMAGE_SPEED; // FLICKER EFFECT if (flickerAmount < FLICKER_LIMIT && isFlickering) { flickerTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (flickerTimer >= FLICKER_INTERVAL) { show = !show; if (show) { flickerAmount++; } flickerTimer = 0; } } // UPDATE CHARACTER ANIMATION character.UpdateSpineAnimation(gameTime); enemyCharacter.UpdateSpineAnimation(gameTime); // UPDATE HEALTH myHealthBar.hp = character.hp; enemyHealthbar.hp = enemyCharacter.hp; }
public override void Update(GameTime gameTime) { Globals.multiplayerConnection.Update(gameTime); searchMatchAnimation.Update(gameTime); }