implement different kinds of power ups (two bullet types not implemented yet)
This commit is contained in:
parent
a5a3ca3013
commit
21f7d1d5f4
5 changed files with 65 additions and 11 deletions
|
@ -1,3 +1,5 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class CollectPowerUp(
|
||||
|
@ -22,14 +24,31 @@ internal sealed class CollectPowerUp(
|
|||
|
||||
// now the tank overlaps the power up by at least 0.5 tiles
|
||||
|
||||
tank.Magazine = tank.Magazine with
|
||||
switch (obj.Type)
|
||||
{
|
||||
UsedBullets = 0,
|
||||
Type = tank.Magazine.Type | MagazineType.Explosive
|
||||
};
|
||||
case PowerUpType.MagazineTypeUpgrade:
|
||||
if (obj.MagazineType == null)
|
||||
throw new UnreachableException();
|
||||
|
||||
if (tank.ReloadingUntil >= DateTime.Now)
|
||||
tank.ReloadingUntil = DateTime.Now;
|
||||
tank.Magazine = tank.Magazine with
|
||||
{
|
||||
Type = tank.Magazine.Type | obj.MagazineType.Value,
|
||||
UsedBullets = 0
|
||||
};
|
||||
|
||||
if (tank.ReloadingUntil >= DateTime.Now)
|
||||
tank.ReloadingUntil = DateTime.Now;
|
||||
|
||||
break;
|
||||
case PowerUpType.MagazineSizeUpgrade:
|
||||
tank.Magazine = tank.Magazine with
|
||||
{
|
||||
MaxBullets = (byte)int.Clamp(tank.Magazine.MaxBullets + 1, 1, 32)
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
tank.Owner.Scores.PowerUpsCollected++;
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue