chore: add tower hitbox + change selector icons
This commit is contained in:
parent
d4c62243d8
commit
1e08ddb279
6 changed files with 81 additions and 13 deletions
BIN
Assets/Icones/IconsFlat-32.png
Normal file
BIN
Assets/Icones/IconsFlat-32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
34
Assets/Icones/IconsFlat-32.png.import
Normal file
34
Assets/Icones/IconsFlat-32.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://7v37noapccnc"
|
||||||
|
path="res://.godot/imported/IconsFlat-32.png-cbb60368a49eb8516061cb2084e62d5b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/Icones/IconsFlat-32.png"
|
||||||
|
dest_files=["res://.godot/imported/IconsFlat-32.png-cbb60368a49eb8516061cb2084e62d5b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
|
@ -80,3 +80,18 @@ static func showConfirmPopup(
|
||||||
confirmPopup.label.text = text
|
confirmPopup.label.text = text
|
||||||
confirmPopup.confirmed.connect(confirmCallback)
|
confirmPopup.confirmed.connect(confirmCallback)
|
||||||
confirmPopup.canceled.connect(cancelCallback)
|
confirmPopup.canceled.connect(cancelCallback)
|
||||||
|
|
||||||
|
|
||||||
|
static func getTopOfHitBox(body : CollisionObject3D) -> float:
|
||||||
|
if body is GameTile:
|
||||||
|
return .2
|
||||||
|
|
||||||
|
if body.has_node("CollisionShape3D"):
|
||||||
|
var shape : Shape3D = body.shape_owner_get_shape(0, 0)
|
||||||
|
var transform : Transform3D = body.shape_owner_get_transform(0)
|
||||||
|
if shape is CapsuleShape3D:
|
||||||
|
return shape.height + shape.radius + transform.origin.y
|
||||||
|
if shape is SphereShape3D:
|
||||||
|
return shape.radius + transform.origin.y
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,23 @@ func _process(_delta: float) -> void:
|
||||||
var tower : Tower
|
var tower : Tower
|
||||||
if collider is GameTile:
|
if collider is GameTile:
|
||||||
tower = usedLocations.get(collider.global_position.round())
|
tower = usedLocations.get(collider.global_position.round())
|
||||||
|
selection_icon.frame = 5
|
||||||
if Input.is_action_just_pressed("build"):
|
selection_icon.axis = Vector3.Axis.AXIS_Y
|
||||||
if not collider is GameTile || tower == selected_tower:
|
selection_icon.pixel_size = .03
|
||||||
|
else:
|
||||||
|
selection_icon.frame = 68
|
||||||
|
selection_icon.pixel_size = .02 if collider is Tower else .01
|
||||||
|
selection_icon.axis = Vector3.Axis.AXIS_Z
|
||||||
|
if collider is Tower:
|
||||||
|
tower = collider
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if isTileFree(collider):
|
if Input.is_action_just_pressed("build"):
|
||||||
|
if tower == selected_tower:
|
||||||
|
return
|
||||||
|
|
||||||
|
if isTileAndFree(collider):
|
||||||
placeTower()
|
placeTower()
|
||||||
elif tower:
|
elif tower:
|
||||||
selectTower(tower.type)
|
selectTower(tower.type)
|
||||||
|
|
@ -53,7 +64,7 @@ func _input(event: InputEvent) -> void:
|
||||||
handleTowerShortCuts(event)
|
handleTowerShortCuts(event)
|
||||||
|
|
||||||
|
|
||||||
func handle_player_controls() -> Node3D:
|
func handle_player_controls() -> CollisionObject3D:
|
||||||
#If the player has the mouse on the GUI, player can't place tower
|
#If the player has the mouse on the GUI, player can't place tower
|
||||||
if is_on_gui:
|
if is_on_gui:
|
||||||
return
|
return
|
||||||
|
|
@ -71,15 +82,16 @@ func handle_player_controls() -> Node3D:
|
||||||
visible = false
|
visible = false
|
||||||
return null
|
return null
|
||||||
|
|
||||||
var collider : Node3D = ray_result.get("collider")
|
var collider : CollisionObject3D = ray_result.get("collider")
|
||||||
visible = true
|
visible = true
|
||||||
selection_icon.visible = true
|
selection_icon.visible = true
|
||||||
global_position = collider.global_position + Vector3(0.0, 0.21, 0.0)
|
global_position = collider.global_position
|
||||||
|
global_position.y += Helper.getTopOfHitBox(collider) + .01
|
||||||
|
|
||||||
if selected_tower && selected_tower.state == Tower.STATE.BLUEPRINT:
|
if selected_tower && selected_tower.state == Tower.STATE.BLUEPRINT:
|
||||||
selected_tower.sprite.modulate = "ff4545c8" # If the tower can't be placed he is red
|
selected_tower.sprite.modulate = "ff4545c8" # If the tower can't be placed he is red
|
||||||
selection_icon.visible = false # If we are placing a tower, hide the selector model
|
selection_icon.visible = false # If we are placing a tower, hide the selector model
|
||||||
if collider is GameTile && isTileFree(collider):
|
if isTileAndFree(collider):
|
||||||
selected_tower.sprite.modulate = "61ff45c8" # If the tower can be placed he is green
|
selected_tower.sprite.modulate = "61ff45c8" # If the tower can be placed he is green
|
||||||
|
|
||||||
return collider
|
return collider
|
||||||
|
|
@ -100,9 +112,10 @@ func placeTower() -> void:
|
||||||
moveTower(selected_tower, global_position)
|
moveTower(selected_tower, global_position)
|
||||||
|
|
||||||
|
|
||||||
func isTileFree(tile: GameTile) -> bool:
|
func isTileAndFree(collider: CollisionObject3D) -> bool:
|
||||||
return not usedLocations.has(tile.global_position.round()) \
|
return collider is GameTile && collider.type == GameTile.TYPE.TOWER \
|
||||||
&& tile.type == GameTile.TYPE.TOWER
|
&& not usedLocations.has(collider.global_position.round())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Set [param toPosition] with [Vector3.INF] to make the tower rest
|
## Set [param toPosition] with [Vector3.INF] to make the tower rest
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://trg7ag3dqr2l"]
|
[gd_scene load_steps=9 format=3 uid="uid://trg7ag3dqr2l"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://8kpvuurr5h5n" path="res://Towers/Tower.gd" id="1_egfuc"]
|
[ext_resource type="Script" uid="uid://8kpvuurr5h5n" path="res://Towers/Tower.gd" id="1_egfuc"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bn6ikwol6x8r0" path="res://Assets/Characters/Male1.png" id="2_egfuc"]
|
[ext_resource type="Texture2D" uid="uid://bn6ikwol6x8r0" path="res://Assets/Characters/Male1.png" id="2_egfuc"]
|
||||||
[ext_resource type="Texture2D" uid="uid://uptdcefxlv4c" path="res://Assets/Icones/ppdf_bio_image_placeholder_2.png" id="2_mnaic"]
|
[ext_resource type="Texture2D" uid="uid://uptdcefxlv4c" path="res://Assets/Icones/ppdf_bio_image_placeholder_2.png" id="2_mnaic"]
|
||||||
[ext_resource type="Script" uid="uid://blnmjxmusrsa7" path="res://UI/GameStyleBoxFlat.gd" id="8_5dr1v"]
|
[ext_resource type="Script" uid="uid://blnmjxmusrsa7" path="res://UI/GameStyleBoxFlat.gd" id="8_5dr1v"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ynmsb"]
|
||||||
|
radius = 0.15
|
||||||
|
height = 0.5
|
||||||
|
|
||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_jv31o"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_jv31o"]
|
||||||
viewport_path = NodePath("EnergyBar3D/SubViewport")
|
viewport_path = NodePath("EnergyBar3D/SubViewport")
|
||||||
|
|
||||||
|
|
@ -28,6 +32,8 @@ icone = ExtResource("2_mnaic")
|
||||||
bio = "Aime se promener dans l'herbe et manger des framboises. Sa petite bouille la rend trop mignonne."
|
bio = "Aime se promener dans l'herbe et manger des framboises. Sa petite bouille la rend trop mignonne."
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
|
||||||
|
shape = SubResource("CapsuleShape3D_ynmsb")
|
||||||
|
|
||||||
[node name="Range" type="Area3D" parent="."]
|
[node name="Range" type="Area3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0)
|
||||||
|
|
|
||||||
|
|
@ -55,5 +55,5 @@ func getNextValue(oldValue, baseValue, scaleType : SCALE_TYPE):
|
||||||
match scaleType:
|
match scaleType:
|
||||||
SCALE_TYPE.LINEAR: return oldValue + baseValue
|
SCALE_TYPE.LINEAR: return oldValue + baseValue
|
||||||
_:
|
_:
|
||||||
push_warning("Upgrade scale type not defined !")
|
push_error("Upgrade scale type not defined !")
|
||||||
return oldValue
|
return oldValue
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue