Can now open secret walls and pick up machine gun

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 15:34:27 +01:00
parent 9f5f29100b
commit 001c7c3131
13 changed files with 545 additions and 120 deletions

View File

@@ -2,6 +2,7 @@ import 'dart:math' as math;
import 'package:wolf_dart/classes/coordinate_2d.dart';
import 'package:wolf_dart/features/entities/collectible.dart';
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
import 'package:wolf_dart/features/entities/entity.dart';
import 'package:wolf_dart/features/weapon/weapon.dart';
import 'package:wolf_dart/features/weapon/weapons/chain_gun.dart';
@@ -162,15 +163,20 @@ class Player {
case CollectibleType.weapon:
if (item.mapId == 50) {
if (!weapons.containsKey(WeaponType.machineGun)) {
// Machine Gun Pickup
if (weapons[WeaponType.machineGun] == null) {
weapons[WeaponType.machineGun] = MachineGun();
hasMachineGun = true;
}
// The original game ALWAYS switches to a superior weapon on pickup
requestWeaponSwitch(WeaponType.machineGun);
pickedUp = true;
}
if (item.mapId == 51) {
if (!weapons.containsKey(WeaponType.chainGun)) {
// Chain Gun Pickup
if (weapons[WeaponType.chainGun] == null) {
weapons[WeaponType.chainGun] = ChainGun();
hasChainGun = true;
}
requestWeaponSwitch(WeaponType.chainGun);
pickedUp = true;
@@ -199,6 +205,10 @@ class Player {
}
}
void releaseTrigger() {
currentWeapon.releaseTrigger();
}
/// Returns true only on the specific frame where the hit should be calculated
void updateWeapon({
required int currentTime,
@@ -212,7 +222,6 @@ class Player {
if (currentWeapon.state == WeaponState.firing &&
oldFrame == 0 &&
currentWeapon.frameIndex == 1) {
// The weapon handles everything itself!
currentWeapon.performHitscan(
playerX: x,
playerY: y,
@@ -220,8 +229,28 @@ class Player {
entities: entities,
isWalkable: isWalkable,
currentTime: currentTime,
onEnemyKilled: (int pointsToAdd) {
onEnemyKilled: (Enemy killedEnemy) {
// Dynamic scoring based on the enemy type!
int pointsToAdd = 0;
switch (killedEnemy.runtimeType.toString()) {
case 'BrownGuard':
pointsToAdd = 100;
break;
case 'Dog':
pointsToAdd = 200;
break;
// You can easily plug in future enemies here!
// case 'SSOfficer': pointsToAdd = 500; break;
default:
pointsToAdd = 100; // Fallback
}
score += pointsToAdd;
// Optional: Print to console so you can see it working
print(
"Killed ${killedEnemy.runtimeType}! +$pointsToAdd (Score: $score)",
);
},
);
}