Weapon System
Description
The Weapon System is responsible for handling player-controlled turret firing, including input processing, fire rate control, ammo consumption, projectile spawning, and audiovisual feedback.
The system is built around the IShooter interface, allowing different weapon implementations to be easily swapped or extended.
IShooter Interface
IShooter Interfacepublic interface IShooter
{
void ShotUpdate();
void Subscribe();
void Unsubscribe();
}Turret Weapon Implementation (TurretShooting.cs)
TurretShooting is a concrete implementation of IShooter designed for tap-and-hold shooting on mobile devices.
Key Features
Tap-based input (press and hold to shoot)
Fire rate controlled by player stats
Ammo validation and consumption
Sequential or simultaneous fire points
Projectile object pooling
Upgrade-level–based sound effects
UI and physics-based input filtering
Input Handling
Shooting starts on
OnButtonDownShooting stops on
OnButtonUpUI interactions are automatically ignored
Physics raycasting is used to prevent accidental input blocking by the player object
This ensures reliable shooting behavior on touch devices with UI overlays.
Shooting Logic
Shooting is processed in
ShotUpdate()Fire interval is defined by
PlayerStats.FireIntervalEach shot:
Validates turret level
Consumes ammo
Spawns projectiles from pooled instances
Triggers visual effects and animations
Plays a level-based firing sound
Fire Modes
The system supports two firing modes:
Sequential Fire Fires from one fire point per shot, cycling through available fire points.
All Points Fire Fires from all fire points simultaneously.
Fire mode behavior is configured via the player’s TurretPart settings.

Ammo Tracker
AmmoTracker is responsible for managing the player’s ammunition and synchronizing its state with the UI. Upon initialization, it retrieves the initial ammo count from PlayerStats, immediately updates the UI, and stores callbacks for UI updates and handling the out-of-ammo state.
The OnShoot method decreases the current ammo, notifies the UI, and triggers the OutOfAmmo event if ammo reaches zero.
The AmmoTracker component is attached to the PlayerContext GameObject.

Swipe-Based Turret Rotation (TurretRotator.cs)
The TurretRotator handles horizontal turret aiming using swipe input.
Key Features
Horizontal rotation only (Y-axis)
Configurable rotation sensitivity
Optional inverted controls
Min/max rotation angle clamping
Input-based, no per-frame polling
Input
Uses
IInputService.OnSwipeReceives delta X from swipe gestures
Rotation Logic
Swipe delta is converted into angular rotation
Rotation is clamped between configurable limits
Rotation is applied in local space, ensuring predictable behavior
Lifecycle
Subscribe()— enables swipe inputUnsubscribe()— disables swipe input
Last updated