Compare commits
2 commits
9fc559ffd0
...
6863a8a387
Author | SHA1 | Date | |
---|---|---|---|
6863a8a387 | |||
6309bce63f |
13 changed files with 104 additions and 6 deletions
|
@ -1 +0,0 @@
|
||||||
uid://0jlvid7baag0
|
|
|
@ -1 +0,0 @@
|
||||||
uid://c3wn7vy5wqvyv
|
|
4
autoloads/levels.gd
Normal file
4
autoloads/levels.gd
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
@export var level_sets: Array[LevelSet] = []
|
6
autoloads/levels.tscn
Normal file
6
autoloads/levels.tscn
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://dbqsgks307bto"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://autoloads/levels.gd" id="1_b8434"]
|
||||||
|
|
||||||
|
[node name="Levels" type="Node"]
|
||||||
|
script = ExtResource("1_b8434")
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://bbnq7ptk8hhxa"]
|
[gd_scene load_steps=11 format=3 uid="uid://bbnq7ptk8hhxa"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://d13tqqx8ygak4" path="res://assets/textures/backgrounds/hell.png" id="1_bxdo5"]
|
[ext_resource type="Texture2D" uid="uid://d13tqqx8ygak4" path="res://assets/textures/backgrounds/hell.png" id="1_bxdo5"]
|
||||||
[ext_resource type="Shader" path="res://noise/noise.gdshader" id="1_j2mm6"]
|
[ext_resource type="Shader" path="res://assets/shaders/noise.gdshader" id="1_j2mm6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://mh2gfm7iqqsm" path="res://objects/player/player.tscn" id="2_kip56"]
|
[ext_resource type="PackedScene" uid="uid://mh2gfm7iqqsm" path="res://objects/player/player.tscn" id="2_kip56"]
|
||||||
[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="3_4td23"]
|
[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="3_4td23"]
|
||||||
[ext_resource type="PackedScene" uid="uid://68lav5rke5ag" path="res://objects/spring/spring.tscn" id="4_a3xei"]
|
[ext_resource type="PackedScene" uid="uid://68lav5rke5ag" path="res://objects/spring/spring.tscn" id="4_a3xei"]
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
[gd_scene load_steps=5 format=4 uid="uid://cccb8wltupasj"]
|
[gd_scene load_steps=6 format=4 uid="uid://cccb8wltupasj"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_h5jcm"]
|
[ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_h5jcm"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/level/level.gd" id="1_hcs1r"]
|
||||||
[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="2_dj7w1"]
|
[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="2_dj7w1"]
|
||||||
[ext_resource type="PackedScene" uid="uid://mh2gfm7iqqsm" path="res://objects/player/player.tscn" id="3_kyrxg"]
|
[ext_resource type="PackedScene" uid="uid://mh2gfm7iqqsm" path="res://objects/player/player.tscn" id="3_kyrxg"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c8r040r4glui4" path="res://objects/enemies/lashy/lashy.tscn" id="4_gykx6"]
|
[ext_resource type="PackedScene" uid="uid://c8r040r4glui4" path="res://objects/enemies/lashy/lashy.tscn" id="4_gykx6"]
|
||||||
|
|
||||||
[node name="LevelZ" type="Node2D"]
|
[node name="LevelZ" type="Node2D"]
|
||||||
|
script = ExtResource("1_hcs1r")
|
||||||
|
title = "Test Level Z"
|
||||||
|
id = "z-level"
|
||||||
|
order = 2
|
||||||
|
|
||||||
[node name="Background" type="Sprite2D" parent="."]
|
[node name="Background" type="Sprite2D" parent="."]
|
||||||
modulate = Color(0.996924, 0.421436, 0, 1)
|
modulate = Color(0.996924, 0.421436, 0, 1)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
uid://b855r6rw5a08e
|
|
|
@ -18,6 +18,7 @@ config/icon="res://icon.svg"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
SceneManager="*res://autoloads/scene_manager.tscn"
|
SceneManager="*res://autoloads/scene_manager.tscn"
|
||||||
|
Levels="*res://autoloads/levels.tscn"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|
7
scripts/level/level.gd
Normal file
7
scripts/level/level.gd
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class_name Level
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
@export var title: String
|
||||||
|
@export var id: String
|
||||||
|
@export_range(0,1,1,"or_greater") var order: int
|
20
scripts/level/level_info.gd
Normal file
20
scripts/level/level_info.gd
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
@tool
|
||||||
|
class_name LevelInfo
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
|
||||||
|
@export var title: String:
|
||||||
|
set(value):
|
||||||
|
title = value
|
||||||
|
resource_name = title
|
||||||
|
@export var id: String
|
||||||
|
@export var order: int = 0
|
||||||
|
@export_file("*.tscn", "*.scn") var scene_path: String
|
||||||
|
|
||||||
|
|
||||||
|
static func from_level(level: Level) -> LevelInfo:
|
||||||
|
var info = LevelInfo.new()
|
||||||
|
info.title = level.title
|
||||||
|
info.id = level.id
|
||||||
|
info.order = level.order
|
||||||
|
return info
|
59
scripts/level/level_set.gd
Normal file
59
scripts/level/level_set.gd
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
@tool
|
||||||
|
class_name LevelSet
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
|
||||||
|
@export var title: String:
|
||||||
|
set(value):
|
||||||
|
title = value
|
||||||
|
resource_name = title
|
||||||
|
@export var id: String
|
||||||
|
@export_dir var levels_dir: String:
|
||||||
|
set(value):
|
||||||
|
levels_dir = value
|
||||||
|
if Engine.is_editor_hint():
|
||||||
|
update_levels()
|
||||||
|
|
||||||
|
@export var levels: Array[LevelInfo] = []
|
||||||
|
|
||||||
|
|
||||||
|
func has_id(id: String) -> bool:
|
||||||
|
for info in levels:
|
||||||
|
if info.id == id:
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
func has_level(level: Level) -> bool:
|
||||||
|
for info in levels:
|
||||||
|
if info.scene_path == level.scene_file_path:
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
func update_levels() -> void:
|
||||||
|
levels.clear()
|
||||||
|
var dir = DirAccess.open(levels_dir)
|
||||||
|
if dir:
|
||||||
|
dir.list_dir_begin()
|
||||||
|
var file = dir.get_next()
|
||||||
|
while file != "":
|
||||||
|
if not dir.current_is_dir() and file.ends_with(".tscn") or file.ends_with(".scn"):
|
||||||
|
var scene := load(levels_dir + "/" + file) as PackedScene
|
||||||
|
if scene and scene.can_instantiate():
|
||||||
|
var level = scene.instantiate()
|
||||||
|
if level is Level:
|
||||||
|
if has_id(level.id):
|
||||||
|
_popup_alert("Duplicate level ID: %s" % level.id)
|
||||||
|
else:
|
||||||
|
levels.append(LevelInfo.from_level(level))
|
||||||
|
level.free()
|
||||||
|
file = dir.get_next()
|
||||||
|
# sort levels by level order
|
||||||
|
levels.sort_custom(func(a, b): return a.order < b.order)
|
||||||
|
|
||||||
|
|
||||||
|
func _popup_alert(message: String) -> void:
|
||||||
|
var popup = AcceptDialog.new()
|
||||||
|
popup.dialog_text = message
|
||||||
|
EditorInterface.popup_dialog_centered(popup)
|
|
@ -1 +0,0 @@
|
||||||
uid://cv55s54clajw5
|
|
Loading…
Add table
Add a link
Reference in a new issue