mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-30 16:01:53 +08:00
feat: Enhance game mechanics and structure
- Added `ColorBar` class for visual representation of values. - Expanded `EntityBase` with new properties: `isBoss` and `weapons`, and implemented damage handling and entity generation methods. - Updated `EntityStateBar` to use `ColorBar` for health representation. - Introduced `BulletBase` scene and script for bullet mechanics, including damage handling and generation. - Created `WorldTool` for managing the game world and root node. - Implemented `EntityTool` for retrieving entities from hurtboxes. - Added `GameRule` for managing game rules like friendly fire. - Updated scene files to reflect new structures and added necessary resources.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
extends Area2D
|
||||
class_name BulletBase
|
||||
|
||||
@export var speed: float = 1
|
||||
@export var damage: float = 10
|
||||
|
||||
var launcher: EntityBase = null
|
||||
|
||||
func _ready():
|
||||
area_entered.connect(hit)
|
||||
|
||||
func hit(target: Node):
|
||||
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
||||
if !entity || !launcher: return
|
||||
if entity == launcher: return
|
||||
if GameRule.allowFriendlyFire:
|
||||
if entity.isPlayer() == launcher.isPlayer(): return
|
||||
entity.takeDamage(self)
|
||||
|
||||
static func generate(
|
||||
bullet: PackedScene,
|
||||
launchBy: EntityBase,
|
||||
spawnPosition: Vector2,
|
||||
spawnRotation: float,
|
||||
addToWorld: bool = true
|
||||
):
|
||||
var instance: BulletBase = bullet.instantiate()
|
||||
instance.launcher = launchBy
|
||||
instance.position = spawnPosition
|
||||
instance.rotation = spawnRotation
|
||||
if addToWorld:
|
||||
WorldTool.rootNode.add_child(instance)
|
||||
return instance
|
||||
Reference in New Issue
Block a user