67 lines
1.9 KiB
GDScript
67 lines
1.9 KiB
GDScript
extends Camera2D
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(_delta: float) -> void:
|
|
if UserContext.game_paused or UserContext.is_inspecting:
|
|
return
|
|
var mouse: = get_viewport().get_mouse_position()
|
|
var size: = get_viewport().get_visible_rect().size
|
|
if (mouse.x < (0.10*size.x)):
|
|
position.x -= 3
|
|
elif (mouse.x > (0.90*size.x)):
|
|
position.x += 3
|
|
|
|
if (mouse.y < (0.10*size.y)):
|
|
position.y -= 3
|
|
elif (mouse.y > (0.90*size.y)):
|
|
position.y += 3
|
|
|
|
func _unhandled_input(event: InputEvent):
|
|
if UserContext.game_paused or UserContext.is_inspecting or UserContext.zoom_off:
|
|
return
|
|
if event is InputEventMouseButton:
|
|
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
|
|
zoom.x +=1
|
|
zoom.y +=1
|
|
|
|
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
|
|
if zoom.x - 1 < 1:
|
|
zoom.x = 1
|
|
else:
|
|
zoom.x -= 1
|
|
if zoom.y - 1 < 1:
|
|
zoom.y = 1
|
|
else:
|
|
zoom.y -= 1
|
|
if UserContext.modal_command is MoveCommand and event.button_index == MOUSE_BUTTON_LEFT and UserContext.selected_member != null:
|
|
var loc = get_global_mouse_position()
|
|
var node := Node2D.new()
|
|
node.name = "targetNode"
|
|
node.top_level = true
|
|
node.position = loc
|
|
self.add_child(node)
|
|
UserContext.select_point(node)
|
|
|
|
|
|
func _on_enemy_gates_body_entered(body: Node2D) -> void:
|
|
if (body.get_class()== "CharacterBody2D"):
|
|
if body.get_node("MemberSprite").get_allegiance() == "You":
|
|
var event = preload("res://random events/invaded_win.tres")
|
|
event.probability = 1.0
|
|
|
|
# Replace with function body.
|
|
|
|
|
|
func _on_player_gates_body_entered(body: Node2D) -> void:
|
|
if (body.get_class()== "CharacterBody2D"):
|
|
if body.get_node("MemberSprite").get_allegiance() == "Rivaldom":
|
|
var event = preload("res://random events/invaded_loss.tres")
|
|
event.probability = 1.0
|