Merge branch 'Rycarus_ScaleAbility' into dev
This commit is contained in:
commit
b9a25206ab
3 changed files with 41 additions and 47 deletions
|
@ -169,9 +169,10 @@ position = Vector2(582, -317)
|
||||||
[node name="MirrorOrb" parent="." index="8" instance=ExtResource("7_dyi0e")]
|
[node name="MirrorOrb" parent="." index="8" instance=ExtResource("7_dyi0e")]
|
||||||
position = Vector2(-431, -212)
|
position = Vector2(-431, -212)
|
||||||
|
|
||||||
[node name="Block" parent="." index="9" instance=ExtResource("8_ec71m")]
|
[node name="Block" parent="." index="9" node_paths=PackedStringArray("ui_actions") instance=ExtResource("8_ec71m")]
|
||||||
position = Vector2(476, 253)
|
position = Vector2(476, 253)
|
||||||
collision_layer = 1
|
collision_layer = 1
|
||||||
|
|
||||||
[node name="EnemyMover" parent="." index="10" instance=ExtResource("8_16072")]
|
[node name="EnemyMover" parent="." index="10" instance=ExtResource("8_16072")]
|
||||||
position = Vector2(-132, 311)
|
position = Vector2(-132, 311)
|
||||||
|
ui_actions = NodePath("../UILayer/UI")
|
||||||
|
|
|
@ -1,24 +1,28 @@
|
||||||
extends StaticBody2D
|
extends StaticBody2D
|
||||||
|
|
||||||
@export var scale_up_target: Vector2 = Vector2(3.0, 3.0)
|
@export var scale_up_target: Vector2 = Vector2(3.0, 3.0)
|
||||||
@export var scale_down_target: Vector2 = Vector2(0.5, 0.5)
|
@export var scale_down_target: Vector2 = Vector2(0.5, 0.5)
|
||||||
@export var scale_duration: float = 0.5
|
@export var scale_duration: float = 0.5
|
||||||
|
@export var ui_actions: Node
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
if ui_actions == null:
|
||||||
|
ui_actions = get_parent().get_node("Path/To/UiActionsNode")
|
||||||
|
|
||||||
|
func _on_input_event(viewport, event, shape_idx):
|
||||||
|
if event is InputEventMouseButton and event.pressed:
|
||||||
|
if event.is_action_pressed("click"):
|
||||||
|
if ui_actions.current_selected == "scale_up":
|
||||||
|
scale_up()
|
||||||
|
ui_actions.scale_up_player()
|
||||||
|
elif ui_actions.current_selected == "scale_down":
|
||||||
|
scale_down()
|
||||||
|
ui_actions.scale_down_player()
|
||||||
|
|
||||||
func scale_up():
|
func scale_up():
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(self, "scale", scale_up_target, scale_duration)
|
tween.tween_property(self, "scale", scale_up_target, scale_duration)
|
||||||
# TODO: scale the player
|
|
||||||
|
|
||||||
func scale_down():
|
func scale_down():
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(self, "scale", scale_down_target, scale_duration)
|
tween.tween_property(self, "scale", scale_down_target, scale_duration)
|
||||||
# TODO: scale the player
|
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
|
||||||
print("works")
|
|
||||||
if event is InputEventMouseButton and event.pressed:
|
|
||||||
if Input.is_action_just_pressed("click"):
|
|
||||||
scale_up()
|
|
||||||
elif Input.is_action_just_pressed("clickR"):
|
|
||||||
scale_down()
|
|
||||||
|
|
|
@ -1,52 +1,41 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export var player : CharacterBody2D;
|
@export var player: CharacterBody2D
|
||||||
|
|
||||||
var current_selected = "none";
|
var current_selected = "none"
|
||||||
|
@export var scale_duration: float = 0.5
|
||||||
@export var scale_duration: float = 0.5
|
var target_scale_player: Vector2 = Vector2(1, 1)
|
||||||
var target_scale: Vector2 = Vector2(1, 1)
|
var target_scale_block: Vector2 = Vector2(1, 1)
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("click"):
|
if event.is_action_pressed("click"):
|
||||||
if current_selected == "scale_up":
|
if current_selected == "scale_up":
|
||||||
scale_up()
|
current_selected = "scale_up"
|
||||||
elif current_selected == "scale_down":
|
elif current_selected == "scale_down":
|
||||||
scale_down()
|
current_selected = "scale_down"
|
||||||
elif current_selected == "mirror":
|
elif current_selected == "mirror":
|
||||||
mirror();
|
mirror()
|
||||||
|
|
||||||
|
|
||||||
func select_up():
|
func select_up():
|
||||||
current_selected = "scale_up"
|
current_selected = "scale_up"
|
||||||
|
|
||||||
func select_down():
|
func select_down():
|
||||||
current_selected = "scale_down"
|
current_selected = "scale_down"
|
||||||
|
|
||||||
|
|
||||||
func select_mirror():
|
func select_mirror():
|
||||||
current_selected = "mirror"
|
current_selected = "mirror"
|
||||||
|
|
||||||
|
|
||||||
func scale_up():
|
|
||||||
var pPos = player.position
|
|
||||||
pPos.x += 1280/2
|
|
||||||
pPos.y += 720/2
|
|
||||||
if player.scale.x < 2 and get_viewport().get_mouse_position().distance_to(pPos) < 12:
|
|
||||||
target_scale = Vector2(2.0, 2.0)
|
|
||||||
start_scaling()
|
|
||||||
|
|
||||||
func scale_down():
|
|
||||||
var pPos = player.position
|
|
||||||
pPos.x += 1280/2
|
|
||||||
pPos.y += 720/2
|
|
||||||
if player.scale.x > 1 and get_viewport().get_mouse_position().distance_to(pPos) < 12:
|
|
||||||
target_scale = Vector2(1, 1)
|
|
||||||
start_scaling()
|
|
||||||
|
|
||||||
func start_scaling():
|
func start_scaling(target_node: Node2D, scale_value: Vector2):
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(player, "scale", target_scale, scale_duration)
|
tween.tween_property(target_node, "scale", scale_value, scale_duration)
|
||||||
|
|
||||||
|
func scale_up_player():
|
||||||
|
target_scale_player = Vector2(0.5, 0.5)
|
||||||
|
start_scaling(player, target_scale_player)
|
||||||
|
|
||||||
|
func scale_down_player():
|
||||||
|
target_scale_player = Vector2(2.0, 2.0)
|
||||||
|
start_scaling(player, target_scale_player)
|
||||||
|
|
||||||
func mirror():
|
func mirror():
|
||||||
pass #Hir mirror einbauen einbauen
|
pass # Mirror-Funktionalität hier einfügen
|
||||||
|
|
Loading…
Add table
Reference in a new issue