Merge branch 'master' of https://gitlab.hexaquo.at/Light/fhwikijam
This commit is contained in:
commit
23755f7970
@ -55,6 +55,10 @@ func _process(_delta):
|
|||||||
|
|
||||||
|
|
||||||
func _process_input():
|
func _process_input():
|
||||||
|
#exit
|
||||||
|
if Input.is_action_pressed("ui_cancel"):
|
||||||
|
_interface.gameOver()
|
||||||
|
|
||||||
# Walking
|
# Walking
|
||||||
var input_movement_vector = Vector2()
|
var input_movement_vector = Vector2()
|
||||||
if Input.is_action_pressed("move_fwrd"):
|
if Input.is_action_pressed("move_fwrd"):
|
||||||
@ -65,7 +69,7 @@ func _process_input():
|
|||||||
input_movement_vector.x -= 1
|
input_movement_vector.x -= 1
|
||||||
if Input.is_action_pressed("move_right"):
|
if Input.is_action_pressed("move_right"):
|
||||||
input_movement_vector.x += 1
|
input_movement_vector.x += 1
|
||||||
|
|
||||||
# look around with mouse
|
# look around with mouse
|
||||||
_dir = Vector3()
|
_dir = Vector3()
|
||||||
var camera_transform = _camera.get_global_transform()
|
var camera_transform = _camera.get_global_transform()
|
||||||
|
@ -74,10 +74,58 @@ pitch_scale = 1.5
|
|||||||
[node name="HUD" parent="." instance=ExtResource( 4 )]
|
[node name="HUD" parent="." instance=ExtResource( 4 )]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
label_nodepath = NodePath("LabelScore")
|
label_nodepath = NodePath("LabelScore")
|
||||||
|
popup_nodepath = NodePath("PopupWon")
|
||||||
|
|
||||||
[node name="LabelScore" type="Label" parent="HUD"]
|
[node name="LabelScore" type="Label" parent="HUD"]
|
||||||
margin_left = 15.0
|
margin_left = 15.0
|
||||||
margin_top = 15.0
|
margin_top = 15.0
|
||||||
margin_right = 115.0
|
margin_right = 115.0
|
||||||
margin_bottom = 30.0
|
margin_bottom = 30.0
|
||||||
text = "Score: %score%"
|
text = "Score: 0"
|
||||||
|
|
||||||
|
[node name="PopupWon" type="Popup" parent="HUD"]
|
||||||
|
visible = true
|
||||||
|
margin_left = 383.0
|
||||||
|
margin_top = 187.0
|
||||||
|
margin_right = 530.0
|
||||||
|
margin_bottom = 289.0
|
||||||
|
|
||||||
|
[node name="PanelFail" type="Panel" parent="HUD/PopupWon"]
|
||||||
|
modulate = Color( 0.996078, 0, 0, 1 )
|
||||||
|
margin_left = -383.0
|
||||||
|
margin_top = -187.36
|
||||||
|
margin_right = 641.0
|
||||||
|
margin_bottom = 412.64
|
||||||
|
|
||||||
|
[node name="PanelWon" type="Panel" parent="HUD/PopupWon"]
|
||||||
|
modulate = Color( 0.0313726, 0, 0.996078, 1 )
|
||||||
|
margin_left = -383.0
|
||||||
|
margin_top = -187.36
|
||||||
|
margin_right = 641.0
|
||||||
|
margin_bottom = 412.64
|
||||||
|
|
||||||
|
[node name="LabelWon" type="Label" parent="HUD/PopupWon"]
|
||||||
|
margin_left = 87.064
|
||||||
|
margin_top = 24.4867
|
||||||
|
margin_right = 169.064
|
||||||
|
margin_bottom = 72.4867
|
||||||
|
text = "Gratulations!
|
||||||
|
|
||||||
|
You Won!"
|
||||||
|
|
||||||
|
[node name="LabelFail" type="Label" parent="HUD/PopupWon"]
|
||||||
|
margin_left = 88.9828
|
||||||
|
margin_top = 28.0094
|
||||||
|
margin_right = 168.983
|
||||||
|
margin_bottom = 76.0094
|
||||||
|
text = " You died!
|
||||||
|
|
||||||
|
Game over"
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="HUD/PopupWon"]
|
||||||
|
margin_left = 86.5054
|
||||||
|
margin_top = 144.902
|
||||||
|
margin_right = 179.505
|
||||||
|
margin_bottom = 181.902
|
||||||
|
text = "play again"
|
||||||
|
[connection signal="pressed" from="HUD/PopupWon/Button" to="HUD" method="_on_Button_pressed"]
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
export(NodePath) var label_nodepath
|
export(NodePath) var label_nodepath
|
||||||
|
export(NodePath) var popup_nodepath
|
||||||
|
|
||||||
const SCORE = 100
|
const SCORE = 100
|
||||||
|
|
||||||
var _labelScore: Label
|
var _labelScore: Label
|
||||||
|
var _popup: Popup
|
||||||
var _score: int = 0
|
var _score: int = 0
|
||||||
|
|
||||||
|
|
||||||
@ -12,10 +14,39 @@ func _ready():
|
|||||||
_labelScore = get_node(label_nodepath) as Label
|
_labelScore = get_node(label_nodepath) as Label
|
||||||
assert(null != _labelScore)
|
assert(null != _labelScore)
|
||||||
|
|
||||||
|
_popup = get_node(popup_nodepath) as Popup
|
||||||
|
assert(null != _popup)
|
||||||
|
|
||||||
|
|
||||||
func increaseScore():
|
func increaseScore():
|
||||||
_score += SCORE
|
_score += SCORE
|
||||||
_labelScore.text = "Score: " + String(_score)
|
_labelScore.text = "Score: " + String(_score)
|
||||||
if (_score / SCORE == Collector.getCount()):
|
Logger.info(String(_score) + " of " + String(Collector.getCount() * SCORE) + " possible points")
|
||||||
|
if (_score >= (Collector.getCount() * SCORE)):
|
||||||
Logger.info("YOU WON!")
|
Logger.info("YOU WON!")
|
||||||
|
success()
|
||||||
|
|
||||||
|
|
||||||
|
func gameOver():
|
||||||
|
_endGame(false)
|
||||||
|
|
||||||
|
|
||||||
|
func success():
|
||||||
|
_endGame(true)
|
||||||
|
|
||||||
|
|
||||||
|
func _endGame (value):
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
|
|
||||||
|
Collector.Clear()
|
||||||
|
|
||||||
|
_popup.get_node("LabelWon").visible = value
|
||||||
|
_popup.get_node("LabelFail").visible = !value
|
||||||
|
|
||||||
|
_popup.get_node("PanelWon").visible = value
|
||||||
|
_popup.get_node("PanelFail").visible = !value
|
||||||
|
_popup.show()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_pressed():
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
@ -5,9 +5,13 @@ var _collectibles: Array
|
|||||||
|
|
||||||
func addCollectible (coll):
|
func addCollectible (coll):
|
||||||
Logger.info("appending new collectible: " + String(coll.get_instance_id()))
|
Logger.info("appending new collectible: " + String(coll.get_instance_id()))
|
||||||
Logger.info("current collection count: " + String(Collector.getCount()))
|
|
||||||
_collectibles.append(coll)
|
_collectibles.append(coll)
|
||||||
|
Logger.info("current collection count: " + String(Collector.getCount()))
|
||||||
|
|
||||||
|
|
||||||
func getCount ():
|
func getCount ():
|
||||||
return _collectibles.size()
|
return _collectibles.size()
|
||||||
|
|
||||||
|
|
||||||
|
func Clear ():
|
||||||
|
return _collectibles.clear()
|
Loading…
x
Reference in New Issue
Block a user