Added a class to map object ids so they can be called by name
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ 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/entities/map_objects.dart';
|
||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
||||
import 'package:wolf_dart/features/weapon/weapons/chain_gun.dart';
|
||||
import 'package:wolf_dart/features/weapon/weapons/knife.dart';
|
||||
@@ -131,18 +132,14 @@ class Player {
|
||||
switch (item.type) {
|
||||
case CollectibleType.health:
|
||||
if (health >= 100) return false;
|
||||
// Map IDs 47 (Dog Food) and 48 (Medkit)
|
||||
heal(item.mapId == 47 ? 4 : 25);
|
||||
heal(item.mapId == MapObjectId.dogFood ? 4 : 25);
|
||||
pickedUp = true;
|
||||
break;
|
||||
|
||||
case CollectibleType.ammo:
|
||||
if (ammo >= 99) return false;
|
||||
|
||||
int previousAmmo = ammo;
|
||||
addAmmo(8);
|
||||
|
||||
// Auto-switch back to Pistol if holding Knife and just got ammo
|
||||
if (currentWeapon is Knife && previousAmmo <= 0) {
|
||||
requestWeaponSwitch(WeaponType.pistol);
|
||||
}
|
||||
@@ -150,11 +147,11 @@ class Player {
|
||||
break;
|
||||
|
||||
case CollectibleType.treasure:
|
||||
if (item.mapId == 52) score += 100;
|
||||
if (item.mapId == 53) score += 500;
|
||||
if (item.mapId == 54) score += 1000;
|
||||
if (item.mapId == 55) score += 5000;
|
||||
if (item.mapId == 56) {
|
||||
if (item.mapId == MapObjectId.cross) score += 100;
|
||||
if (item.mapId == MapObjectId.chalice) score += 500;
|
||||
if (item.mapId == MapObjectId.chest) score += 1000;
|
||||
if (item.mapId == MapObjectId.crown) score += 5000;
|
||||
if (item.mapId == MapObjectId.extraLife) {
|
||||
heal(100);
|
||||
addAmmo(25);
|
||||
}
|
||||
@@ -162,31 +159,29 @@ class Player {
|
||||
break;
|
||||
|
||||
case CollectibleType.weapon:
|
||||
addAmmo(8);
|
||||
if (item.mapId == 50) {
|
||||
// Machine Gun Pickup
|
||||
if (item.mapId == MapObjectId.machineGun) {
|
||||
if (weapons[WeaponType.machineGun] == null) {
|
||||
weapons[WeaponType.machineGun] = MachineGun();
|
||||
hasMachineGun = true;
|
||||
}
|
||||
// The original game ALWAYS switches to a superior weapon on pickup
|
||||
addAmmo(8);
|
||||
requestWeaponSwitch(WeaponType.machineGun);
|
||||
pickedUp = true;
|
||||
}
|
||||
if (item.mapId == 51) {
|
||||
// Chain Gun Pickup
|
||||
if (item.mapId == MapObjectId.chainGun) {
|
||||
if (weapons[WeaponType.chainGun] == null) {
|
||||
weapons[WeaponType.chainGun] = ChainGun();
|
||||
hasChainGun = true;
|
||||
}
|
||||
addAmmo(8);
|
||||
requestWeaponSwitch(WeaponType.chainGun);
|
||||
pickedUp = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CollectibleType.key:
|
||||
if (item.mapId == 43) hasGoldKey = true;
|
||||
if (item.mapId == 44) hasSilverKey = true;
|
||||
if (item.mapId == MapObjectId.goldKey) hasGoldKey = true;
|
||||
if (item.mapId == MapObjectId.silverKey) hasSilverKey = true;
|
||||
pickedUp = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user