cursor gun card inject scene
This commit is contained in:
6
growth/CardInjects/CursorGunCardInject.tscn
Normal file
6
growth/CardInjects/CursorGunCardInject.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bf1241le7dwfs"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c0jwjfs64x5tm" path="res://CardInjects/cursor_gun_card_inject.gd" id="1_25dn0"]
|
||||
|
||||
[node name="CursorGunCardInject" type="Node"]
|
||||
script = ExtResource("1_25dn0")
|
||||
25
growth/CardInjects/cursor_gun_card_inject.gd
Normal file
25
growth/CardInjects/cursor_gun_card_inject.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Node
|
||||
|
||||
@export var CursorBullet: PackedScene
|
||||
@export var max_ammo = 10
|
||||
var ammo = 10
|
||||
|
||||
func activate(world, activator):
|
||||
var target: Vector2 = activator.get_target_pos()
|
||||
var bullet = CursorBullet.instantiate()
|
||||
world.add_child(bullet)
|
||||
bullet.position = activator.position
|
||||
bullet.look_at(target)
|
||||
if activator.get_collision_layer_bit(1): # player object
|
||||
bullet.set_collision_layer_bit(1, false)
|
||||
bullet.set_collision_layer_bit(2, true)
|
||||
elif activator.get_collision_layer_bit(2): # enemy object
|
||||
bullet.set_collision_layer_bit(1, true)
|
||||
bullet.set_collision_layer_bit(2, false)
|
||||
else:
|
||||
assert(false, "who are you, activator?")
|
||||
ammo -= 1
|
||||
# TODO: handle ammo for player and virus
|
||||
|
||||
func discard(world, activator):
|
||||
pass
|
||||
1
growth/CardInjects/cursor_gun_card_inject.gd.uid
Normal file
1
growth/CardInjects/cursor_gun_card_inject.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c0jwjfs64x5tm
|
||||
@@ -25,6 +25,7 @@ metadata/_edit_group_ = true
|
||||
sprite_frames = SubResource("SpriteFrames_i3pqv")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
collision_layer = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("RectangleShape2D_onrkg")
|
||||
|
||||
Reference in New Issue
Block a user