diff --git a/packages/wolf_3d_dart/lib/src/engine/player/player.dart b/packages/wolf_3d_dart/lib/src/engine/player/player.dart index 09bddd0..46a931e 100644 --- a/packages/wolf_3d_dart/lib/src/engine/player/player.dart +++ b/packages/wolf_3d_dart/lib/src/engine/player/player.dart @@ -102,6 +102,8 @@ class Player { pendingWeaponType = weaponType; switchState = WeaponSwitchState.lowering; + + print("[PLAYER] Requesting weapon switch to ${weaponType.name}."); } // --- Health & Damage --- @@ -114,16 +116,16 @@ class Player { damageFlash = math.min(1.0, damageFlash + (damage * 0.05)); if (health <= 0) { - print("YOU DIED!"); + print("[PLAYER] Died! Final Score: $score"); } else { - print("Ouch! ($health)"); + print("[PLAYER] Took $damage damage ($health)"); } } void heal(int amount) { final int newHealth = math.min(100, health + amount); if (health < 100) { - print("Feelin' better. ($newHealth)"); + print("[PLAYER] Healed for $amount ($health -> $newHealth)"); } health = newHealth; } @@ -131,13 +133,14 @@ class Player { void addAmmo(int amount) { final int newAmmo = math.min(99, ammo + amount); if (ammo < 99) { - print("Hell yeah. ($newAmmo)"); + print("[PLAYER] Picked up ammo $amount ($ammo -> $newAmmo)"); } ammo = newAmmo; } void addLives(int amount) { lives = math.min(9, lives + amount); + print("[PLAYER] Adding $amount extra lives (Total Lives: $lives)"); } /// Attempts to collect [item] and returns the SFX to play. @@ -157,6 +160,8 @@ class Player { ); if (effect == null) return null; + print("[PLAYER] Collected ${item.runtimeType} - Effect: $effect"); + if (effect.healthToRestore > 0) { heal(effect.healthToRestore); } @@ -166,6 +171,8 @@ class Player { } if (effect.scoreToAdd > 0) { + print("[PLAYER] Adding ${effect.scoreToAdd} score."); + score += effect.scoreToAdd; } @@ -174,10 +181,12 @@ class Player { } if (effect.grantGoldKey) { + print("[PLAYER] Collected Gold Key."); hasGoldKey = true; } if (effect.grantSilverKey) { + print("[PLAYER] Collected Silver Key."); hasSilverKey = true; } @@ -193,6 +202,8 @@ class Player { if (weaponType == WeaponType.machineGun) hasMachineGun = true; if (weaponType == WeaponType.chainGun) hasChainGun = true; + + print("[PLAYER] Collected ${weaponType.name}."); } if (effect.requestWeaponSwitch case final weaponType?) { @@ -242,7 +253,7 @@ class Player { onEnemyKilled: (Enemy killedEnemy) { score += killedEnemy.scoreValue; print( - "Killed ${killedEnemy.runtimeType}! +${killedEnemy.scoreValue} (Score: $score)", + "[PLAYER] Killed ${killedEnemy.runtimeType}! +${killedEnemy.scoreValue} (Score: $score)", ); }, ); @@ -251,6 +262,7 @@ class Player { if (currentWeapon.state == WeaponState.idle && ammo <= 0 && currentWeapon.type != WeaponType.knife) { + print("[PLAYER] Out of ammo, switching to knife."); requestWeaponSwitch(WeaponType.knife); } } diff --git a/packages/wolf_3d_dart/lib/src/entities/entities/collectible.dart b/packages/wolf_3d_dart/lib/src/entities/entities/collectible.dart index 5432565..13af19c 100644 --- a/packages/wolf_3d_dart/lib/src/entities/entities/collectible.dart +++ b/packages/wolf_3d_dart/lib/src/entities/entities/collectible.dart @@ -46,6 +46,11 @@ class CollectiblePickupEffect { this.grantWeapon, this.requestWeaponSwitch, }); + + @override + String toString() { + return 'CollectiblePickupEffect(healthToRestore: $healthToRestore, ammoToAdd: $ammoToAdd, scoreToAdd: $scoreToAdd, extraLivesToAdd: $extraLivesToAdd, pickupSfxId: $pickupSfxId, grantGoldKey: $grantGoldKey, grantSilverKey: $grantSilverKey, grantWeapon: $grantWeapon, requestWeaponSwitch: $requestWeaponSwitch)'; + } } abstract class Collectible extends Entity { diff --git a/packages/wolf_3d_dart/lib/src/entities/entities/weapon/weapon.dart b/packages/wolf_3d_dart/lib/src/entities/entities/weapon/weapon.dart index 9a191c3..21add95 100644 --- a/packages/wolf_3d_dart/lib/src/entities/entities/weapon/weapon.dart +++ b/packages/wolf_3d_dart/lib/src/entities/entities/weapon/weapon.dart @@ -1,8 +1,8 @@ import 'dart:math' as math; -import 'package:wolf_3d_dart/wolf_3d_data_types.dart'; import 'package:wolf_3d_dart/src/entities/entities/enemies/enemy.dart'; import 'package:wolf_3d_dart/src/entities/entity.dart'; +import 'package:wolf_3d_dart/wolf_3d_data_types.dart'; enum WeaponState { idle, firing } @@ -55,14 +55,20 @@ abstract class Weapon { bool fire(int currentTime, {required int currentAmmo}) { if (state == WeaponState.idle && currentAmmo > 0) { - if (!isAutomatic && !_triggerReleased) return false; + if (!isAutomatic && !_triggerReleased) { + return false; + } state = WeaponState.firing; frameIndex = 0; lastFrameTime = currentTime; _triggerReleased = false; + + print("[WEAPON] $type fired."); + return true; } + return false; }