This commit is contained in:
Victor Turgeon 2023-10-11 04:32:53 -04:00
parent 1b15fc10a6
commit 1297c1e76a
9 changed files with 159 additions and 15 deletions

BIN
Assets/Sprite-0001.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

View File

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

View File

@ -6,3 +6,6 @@ extends Node2D
func set_cursor_state(info : String, image: Texture2D):
infoLabel.text = info
imageTexture.texture = image
func set_cursor_state_info(info : String):
infoLabel.text = info

View File

@ -1,7 +1,8 @@
extends Control
@onready var menuZone : Control = $MenuZone
@export var buttonGroup : ButtonGroup
@onready var bludGen : Label = $UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludGenContainer/BludGen
@onready var bludTotal : Label = $UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludTotalContainer/BludTotal
signal button_changed(currentButton : Button)
@ -11,3 +12,13 @@ func _ready():
func on_button_changed():
button_changed.emit(buttonGroup.get_pressed_button())
func set_blud(gen, total):
bludGen.text = str(floor(gen))
bludTotal.text = str(floor(total))
func set_blud_gen(gen):
bludGen.text = str(floor(gen))
func set_blud_total(total):
bludTotal.text = str(floor(total))

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://dmvukn3rl6gbx"]
[gd_scene load_steps=6 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"]
[ext_resource type="Theme" uid="uid://dr1h7to56a2pv" path="res://Themes/base_theme.tres" id="3_4fgkw"]
[ext_resource type="ButtonGroup" uid="uid://gjbbywsr8n8b" path="res://Scenes/Player/UI/spawnables_button_group.tres" id="3_7a133"]
[ext_resource type="Texture2D" uid="uid://kbd5cnmgbqso" path="res://Assets/Sprite-0001.png" id="4_s5lk5"]
[node name="PlayerUI" type="Control"]
layout_mode = 3
@ -39,6 +41,16 @@ grow_horizontal = 2
grow_vertical = 0
mouse_filter = 2
[node name="ColorRect" type="ColorRect" parent="UIRoot"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_4fgkw")
color = Color(0.0156863, 0.207843, 0.341176, 0.12549)
[node name="ControlPanel" type="HBoxContainer" parent="UIRoot"]
layout_mode = 1
anchors_preset = 15
@ -47,19 +59,69 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme_override_constants/separation = 2
alignment = 1
[node name="StatPanel" type="Control" parent="UIRoot/ControlPanel"]
[node name="StatPanel" type="HBoxContainer" parent="UIRoot/ControlPanel"]
layout_mode = 2
size_flags_horizontal = 3
mouse_filter = 2
[node name="Blud" type="Control" parent="UIRoot/ControlPanel/StatPanel"]
layout_mode = 2
size_flags_horizontal = 3
[node name="HBoxContainer" type="HBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Blud"]
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_top = -20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="BludIcon" type="TextureRect" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer"]
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
texture = ExtResource("4_s5lk5")
expand_mode = 1
stretch_mode = 5
[node name="Label" type="Label" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = ": "
[node name="VBoxContainer" type="VBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer"]
layout_mode = 2
[node name="BludGenContainer" type="HBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer"]
layout_mode = 2
[node name="BludGen" type="Label" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludGenContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = "10"
[node name="suffix" type="Label" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludGenContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = "/s"
[node name="BludTotalContainer" type="HBoxContainer" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer"]
layout_mode = 2
[node name="BludTotal" type="Label" parent="UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludTotalContainer"]
layout_mode = 2
theme = ExtResource("3_4fgkw")
text = "100"
vertical_alignment = 2
[node name="ButtonPanel" type="HBoxContainer" parent="UIRoot/ControlPanel"]
layout_mode = 2
size_flags_horizontal = 3
mouse_filter = 2
theme_override_constants/separation = 4
[node name="SpawnableButton" parent="UIRoot/ControlPanel/ButtonPanel" instance=ExtResource("1_tnnk6")]
layout_mode = 2

View File

@ -4,6 +4,16 @@ extends Button
@export var spawnableScene : PackedScene = null
@onready var animationPlayer : AnimationPlayer = $AnimationPlayer
@onready var label : Label = $Label
func _ready():
if spawnableScene == null:
return
var temp : TemplateSpawnable = spawnableScene.instantiate()
label.text = str(temp.monsterName) + " (" + str(temp.cost) + ")"
temp.queue_free()
func _on_mouse_entered():
animationPlayer.play("AnimateTextureRect")

View File

@ -1,16 +1,18 @@
extends Node2D
const BASE_BLOOD_GEN = 10
const STARTING_BLOOD_AMOUNT = 100
const BASE_Blud_GEN = 10
const STARTING_Blud_AMOUNT = 100
var currentBloodAmount : int = 0
var currentBloodGen : float = 0
var currentBludAmount : float = 0
var currentBludGen : float = 0
var currentSpawnableScene : PackedScene = null
var currentRefInstance : TemplateSpawnable = null
var currentCost : float = 0
var currentStateIcon : Texture2D = null
var allSpawnedMonsters : Dictionary = {}
var currentSpawnedMonsters : Array = []
@onready var menuZone : Control = $Camera2D/CanvasLayer/PlayerUI.menuZone
@onready var menuZone : Control = $Camera2D/CanvasLayer/PlayerUI/MenuZone
@onready var playerUI : Control = $Camera2D/CanvasLayer/PlayerUI
@onready var enemy : CharacterBody2D = $"../Enemy"
@onready var playableArea : Area2D = $"../PlayableArea"
@onready var cursorState : Node2D = $CursorState
@ -18,8 +20,10 @@ var currentSpawnedMonsters : Array = []
var isInPlayableArea : bool = false
func _ready():
currentBloodAmount = STARTING_BLOOD_AMOUNT
currentBloodGen = BASE_BLOOD_GEN
currentBludAmount = STARTING_Blud_AMOUNT
currentBludGen = BASE_Blud_GEN
playerUI.set_blud(currentBludGen, currentBludAmount)
playableArea.mouse_entered.connect(entered_playable_area)
playableArea.mouse_exited.connect(exited_playable_area)
@ -28,10 +32,15 @@ func _process(delta):
handle_menu_inputs()
handle_spawn()
handle_cursor_state()
currentBludAmount += currentBludGen * delta
playerUI.set_blud_total(currentBludAmount)
func add_monster(monster : TemplateSpawnable):
currentSpawnedMonsters.append(monster)
currentBludGen += monster.BludGen
playerUI.set_blud_gen(currentBludGen)
if !allSpawnedMonsters.has(monster.monsterName):
allSpawnedMonsters[monster.monsterName] = 0
allSpawnedMonsters[monster.monsterName] += 1
@ -39,6 +48,9 @@ func add_monster(monster : TemplateSpawnable):
func remove_monster(monster : TemplateSpawnable):
currentSpawnedMonsters.erase(monster)
currentBludGen -= monster.BludGen
playerUI.set_blud_gen(currentBludGen)
func entered_playable_area():
cursorState.set_cursor_state("", currentStateIcon)
isInPlayableArea = true
@ -62,12 +74,24 @@ func handle_spawn():
spawn_current()
func handle_cursor_state():
if cursorState.infoLabel.text != "out of bounds":
if currentBludAmount < currentCost:
cursorState.set_cursor_state_info("not enough blud")
else:
cursorState.set_cursor_state_info("")
cursorState.visible = !is_in_menu()
cursorState.global_position = get_global_mouse_position()
func spawn_current():
if !isInPlayableArea || is_in_menu() || currentSpawnableScene == null:
return
if currentBludAmount < currentCost:
if cursorState.infoLabel.text == "":
cursorState.set_cursor_state_info("not enough blud")
return
currentBludAmount -= currentCost
var spawnable = currentSpawnableScene.instantiate()
spawnable.global_position = get_global_mouse_position()
$"..".add_child(spawnable)
@ -97,5 +121,6 @@ func _on_player_ui_button_changed(currentButton):
currentSpawnableScene = currentButton.spawnableScene
currentRefInstance = currentSpawnableScene.instantiate()
currentStateIcon = currentRefInstance.monsterIcon
currentCost = currentRefInstance.cost
cursorState.set_cursor_state("", currentStateIcon)

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 bloodGen : int = 0
@export var BludGen : int = 0
@export var cost : int = 0
@export var minSpawnRange : float = 0
@export var canAttack : bool = true

View File

@ -9,7 +9,6 @@ bg_color = Color(0.403922, 0.0117647, 0.0627451, 0.188235)
bg_color = Color(0.803922, 0.152941, 0.188235, 1)
[resource]
default_font = ExtResource("1_i16b1")
Label/fonts/font = ExtResource("1_i16b1")
ProgressBar/styles/background = SubResource("StyleBoxFlat_hf10d")
ProgressBar/styles/fill = SubResource("StyleBoxFlat_jy7e3")