Reworked weapons and projectiles
This commit is contained in:
@@ -2,38 +2,27 @@ class_name AbstractWeapon
|
||||
extends Node2D
|
||||
|
||||
|
||||
enum Belonging { PLAYER, ENEMY }
|
||||
enum Type { NONE, SHORT_RANGE, MEDIUM_RANGE, LONG_RANGE, HOMING, MINES }
|
||||
|
||||
|
||||
const PREFIXES := {
|
||||
Belonging.PLAYER: "player",
|
||||
Belonging.ENEMY: "enemy",
|
||||
}
|
||||
|
||||
const SHOT_POSTFIX = "_shot"
|
||||
const IDLE_POSTFIX = "_idle"
|
||||
const RELOAD_POSTFIX = "_reloading"
|
||||
const IDLE_ANIMATION = "idle"
|
||||
const SHOT_ANIMATION = "shot"
|
||||
const RELOAD_ANIMATION = "reloading"
|
||||
|
||||
|
||||
@export_range(1, 100) var bullet_per_shot : int = 1
|
||||
@export_range(0, 360) var sector_angle : int = 0
|
||||
|
||||
@export var Projectile : PackedScene
|
||||
@export var projectile_scene : PackedScene
|
||||
@export var type := Type.NONE
|
||||
|
||||
|
||||
var _belonging: Belonging
|
||||
var _can_shoot := true
|
||||
|
||||
|
||||
@onready var muzzle : Node2D = $Muzzle
|
||||
|
||||
|
||||
func set_belonging(belonging: Belonging) -> void:
|
||||
_belonging = belonging
|
||||
|
||||
|
||||
func shoot(ship_velocity: Vector2) -> bool:
|
||||
if not _can_shoot: return false
|
||||
|
||||
@@ -52,18 +41,10 @@ func _get_projectile_position() -> Vector2:
|
||||
|
||||
|
||||
func _create_projectile(ship_velocity: Vector2) -> AbstractProjectile:
|
||||
var projectile : AbstractProjectile = Projectile.instantiate()
|
||||
var projectile : AbstractProjectile = projectile_scene.instantiate()
|
||||
projectile.global_position = global_position
|
||||
projectile.ship_velocity = ship_velocity
|
||||
|
||||
match _belonging:
|
||||
Belonging.PLAYER:
|
||||
projectile.direction = Vector2.RIGHT
|
||||
projectile.collide_enemies = true
|
||||
Belonging.ENEMY:
|
||||
projectile.direction = Vector2.LEFT
|
||||
projectile.collide_players = true
|
||||
|
||||
if sector_angle > 0:
|
||||
var sector_rad := deg_to_rad(sector_angle)
|
||||
var random_angle := randfn(0.0, sector_rad / 6.0)
|
||||
|
||||
Reference in New Issue
Block a user