Ui with timer and army count

This commit is contained in:
Victor Turgeon 2023-10-11 06:19:47 -04:00
parent 5e85af9d00
commit 58f9b64223
12 changed files with 209 additions and 16 deletions

BIN
Assets/16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

34
Assets/16.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://p3scltkq3g87"
path="res://.godot/imported/16.png-5e10eee3c5020f801499e5840ba76f58.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/16.png"
dest_files=["res://.godot/imported/16.png-5e10eee3c5020f801499e5840ba76f58.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://iy5flm8rgj60"
path="res://.godot/imported/Inverted hourglass1.png-ce935ba0e444c66e87f0cdd2111ae4b1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Inverted hourglass1.png"
dest_files=["res://.godot/imported/Inverted hourglass1.png-ce935ba0e444c66e87f0cdd2111ae4b1.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

61
Scenes/Levels/levD443.tmp Normal file
View File

@ -0,0 +1,61 @@
[gd_scene load_steps=9 format=3 uid="uid://uoyiei4wyig3"]
[ext_resource type="Script" path="res://Scripts/level.gd" id="1_0nmok"]
[ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_4n82n"]
[ext_resource type="PackedScene" uid="uid://cl7w6ndvons1a" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"]
[ext_resource type="PackedScene" uid="uid://by2xmwcng01uy" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"]
[ext_resource type="PackedScene" uid="uid://b5lnjonlf4i1b" path="res://Scenes/enemy.tscn" id="4_g0oey"]
[ext_resource type="PackedScene" uid="uid://0onqgygm832d" path="res://Scenes/Player/player.tscn" id="5_ik47y"]
[ext_resource type="AudioStream" uid="uid://c3dy35dv368ft" path="res://Assets/Music/SisNeufPiDoozHuit.mp3" id="7_but47"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1g1r4"]
size = Vector2(930, 384)
[node name="Level1" type="Node2D"]
script = ExtResource("1_0nmok")
[node name="Player" parent="." instance=ExtResource("5_ik47y")]
[node name="TileSet1" parent="." instance=ExtResource("1_4n82n")]
[node name="Decor" type="Node2D" parent="."]
[node name="Candles" parent="Decor" instance=ExtResource("2_o33c4")]
position = Vector2(160, 384)
[node name="Candles2" parent="Decor" instance=ExtResource("2_o33c4")]
position = Vector2(160, 128)
[node name="Candles3" parent="Decor" instance=ExtResource("2_o33c4")]
position = Vector2(800, 128)
[node name="Candles4" parent="Decor" instance=ExtResource("2_o33c4")]
position = Vector2(800, 384)
[node name="Candle" parent="Decor" instance=ExtResource("2_5hdq4")]
position = Vector2(432, 224)
[node name="Candle2" parent="Decor" instance=ExtResource("2_5hdq4")]
position = Vector2(432, 320)
[node name="Candle3" parent="Decor" instance=ExtResource("2_5hdq4")]
position = Vector2(528, 224)
[node name="Candle4" parent="Decor" instance=ExtResource("2_5hdq4")]
position = Vector2(528, 320)
[node name="Enemy" parent="." instance=ExtResource("4_g0oey")]
position = Vector2(481.898, 270.98)
[node name="PlayableArea" type="Area2D" parent="."]
[node name="PlayableRect" type="CollisionShape2D" parent="PlayableArea"]
position = Vector2(479, 272)
shape = SubResource("RectangleShape2D_1g1r4")
[node name="Music" type="AudioStreamPlayer" parent="."]
stream = ExtResource("7_but47")
volume_db = -6.0
autoplay = true
[connection signal="finished" from="Music" to="." method="_on_music_finished"]

View File

@ -58,11 +58,4 @@ stream = ExtResource("7_but47")
volume_db = -6.0
autoplay = true
[node name="Time" type="Label" parent="."]
offset_left = 29.0
offset_top = 18.0
offset_right = 69.0
offset_bottom = 41.0
text = "000"
[connection signal="finished" from="Music" to="." method="_on_music_finished"]

View File

@ -8,6 +8,8 @@ extends Control
@onready var enemyXPLabel : Label = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyXPBar/EnemyXPLabel
@onready var enemyHPBar : ProgressBar = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyHPBar
@onready var enemyHPLabel : Label = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyHPBar/EnemyHPLabel
@onready var timeLabel : Label = $UIRoot/ControlPanel/StatPanel/Middle/Time/HBoxContainer/TimeLabel
@onready var armyCount : Label = $UIRoot/ControlPanel/StatPanel/Middle/ArmySize/HBoxContainer/ArmyCount
signal button_changed(currentButton : Button)
@ -39,3 +41,9 @@ func set_xp(current, min, max, level):
enemyXPBar.min_value = min
enemyXPBar.value = current
enemyXPLabel.text = "Lvl " + str(level) + " (" + str(current) + "/" + str(max) + "xp)"
func set_time(text : String):
timeLabel.text = text + " s"
func set_army_count(count : int):
armyCount.text = str(count)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://dmvukn3rl6gbx"]
[gd_scene load_steps=14 format=3 uid="uid://dmvukn3rl6gbx"]
[ext_resource type="Script" path="res://Scenes/Player/UI/player_ui.gd" id="1_4nwdk"]
[ext_resource type="PackedScene" uid="uid://dl0d1m1gfcd4o" path="res://Scenes/Player/UI/bat_button.tscn" id="1_tnnk6"]
@ -7,6 +7,8 @@
[ext_resource type="Texture2D" uid="uid://kbd5cnmgbqso" path="res://Assets/Sprite-0001.png" id="4_s5lk5"]
[ext_resource type="Texture2D" uid="uid://bof6qeuo2rnso" path="res://Assets/Knight/noBKG_KnightRun_strip.png" id="5_7a8uf"]
[ext_resource type="Texture2D" uid="uid://djjqhipuo3byw" path="res://Assets/Knight/noBKG_KnightShield_strip.png" id="5_t0ay2"]
[ext_resource type="Texture2D" uid="uid://iy5flm8rgj60" path="res://Assets/Inverted hourglass1.png" id="5_vr1sw"]
[ext_resource type="Texture2D" uid="uid://p3scltkq3g87" path="res://Assets/16.png" id="6_id56p"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_v6oad"]
bg_color = Color(0.243137, 0.713726, 0.0627451, 0.301961)
@ -108,7 +110,7 @@ stretch_mode = 5
[node name="Label" type="Label" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = ": "
text = "| "
[node name="VBoxContainer" type="VBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer"]
layout_mode = 2
@ -135,6 +137,61 @@ theme = ExtResource("3_4fgkw")
text = "100"
vertical_alignment = 2
[node name="Middle" type="VBoxContainer" parent="UIRoot/ControlPanel/StatPanel"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.8
[node name="Time" type="Control" parent="UIRoot/ControlPanel/StatPanel/Middle"]
layout_mode = 2
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Middle/Time"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Hourglass" type="TextureRect" parent="UIRoot/ControlPanel/StatPanel/Middle/Time/HBoxContainer"]
layout_mode = 2
texture = ExtResource("5_vr1sw")
expand_mode = 2
stretch_mode = 5
[node name="TimeLabel" type="Label" parent="UIRoot/ControlPanel/StatPanel/Middle/Time/HBoxContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = "240 s"
vertical_alignment = 2
[node name="ArmySize" type="Control" parent="UIRoot/ControlPanel/StatPanel/Middle"]
layout_mode = 2
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Middle/ArmySize"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_bottom = -1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Head" type="TextureRect" parent="UIRoot/ControlPanel/StatPanel/Middle/ArmySize/HBoxContainer"]
layout_mode = 2
texture = ExtResource("6_id56p")
expand_mode = 2
stretch_mode = 5
[node name="ArmyCount" type="Label" parent="UIRoot/ControlPanel/StatPanel/Middle/ArmySize/HBoxContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = "0"
vertical_alignment = 2
[node name="Other" type="Control" parent="UIRoot/ControlPanel/StatPanel"]
layout_mode = 2
size_flags_horizontal = 3

View File

@ -1,3 +1,4 @@
class_name Player
extends Node2D
const BASE_Blud_GEN = 10
@ -38,6 +39,9 @@ func _process(delta):
currentBludAmount += currentBludGen * delta
playerUI.set_blud_total(currentBludAmount)
func set_time(text : String):
playerUI.set_time(text)
func add_monster(monster : TemplateSpawnable):
currentSpawnedMonsters.append(monster)
@ -47,12 +51,15 @@ func add_monster(monster : TemplateSpawnable):
if !allSpawnedMonsters.has(monster.monsterName):
allSpawnedMonsters[monster.monsterName] = 0
allSpawnedMonsters[monster.monsterName] += 1
playerUI.set_army_count(currentSpawnedMonsters.size())
func remove_monster(monster : TemplateSpawnable):
currentSpawnedMonsters.erase(monster)
currentBludGen -= monster.BludGen
playerUI.set_blud_gen(currentBludGen)
playerUI.set_army_count(currentSpawnedMonsters.size())
func entered_playable_area():
cursorState.set_cursor_state("", currentStateIcon)

View File

@ -12,9 +12,10 @@ region = Rect2(0, 0, 64, 64)
maxHp = 10
attackSpeed = 50.0
speed = 4000.0
damage = 1
damage = 2
priority = 1
expReward = 25
BludGen = 0.5
cost = 20
minSpawnRange = 10.0
monsterName = "Bat"

View File

@ -9,7 +9,7 @@ const ATTACK_COOLDOWN : float = 100
@export var damage : int = 0
@export var priority : int = 0
@export var expReward : int = 0
@export var BludGen : int = 0
@export var BludGen : float = 0
@export var cost : int = 0
@export var minSpawnRange : float = 0
@export var canAttack : bool = true

View File

@ -3,13 +3,12 @@ extends Node2D
var length: int = 0
var time: int = 0
var countdown: float = 0
@onready var player: Player = $Player
# Called when the node enters the scene tree for the first time.
func _ready():
length = $Music.stream.get_length()
$Time.text = str(length)
pass # Replace with function body.
player.set_time(str(length))
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
@ -17,8 +16,7 @@ func _process(delta):
if countdown > 1:
countdown -= 1
time = $Music.get_playback_position()
$Time.text = str(length - time - 1)
pass
player.set_time(str(length - time - 1))
func win_screen():
var enemy = $Enemy