Spawn chests randomly and also mark according tiles as non-walkable.
parent
e759d6d3d5
commit
5b6efaebe9
|
@ -1,11 +1,10 @@
|
||||||
[gd_scene load_steps=14 format=2]
|
[gd_scene load_steps=13 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/StreamContainer.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://scenes/StreamContainer.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://entities/Player.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://entities/Player.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://scenes/Camera.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://scenes/Camera.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://ui/EditorUI.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://ui/EditorUI.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://utils/TileHighlight.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://utils/TileHighlight.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://entities/Chest.tscn" type="PackedScene" id=7]
|
|
||||||
[ext_resource path="res://scenes/TileWorld.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://scenes/TileWorld.tscn" type="PackedScene" id=8]
|
||||||
[ext_resource path="res://scenes/Game.cs" type="Script" id=9]
|
[ext_resource path="res://scenes/Game.cs" type="Script" id=9]
|
||||||
[ext_resource path="res://ui/WorldGeneratorUI.gd" type="Script" id=12]
|
[ext_resource path="res://ui/WorldGeneratorUI.gd" type="Script" id=12]
|
||||||
|
@ -42,7 +41,6 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0 )
|
||||||
|
|
||||||
[node name="TileWorld" parent="." instance=ExtResource( 8 )]
|
[node name="TileWorld" parent="." instance=ExtResource( 8 )]
|
||||||
GenerationMapType = 0
|
GenerationMapType = 0
|
||||||
Size = 64
|
|
||||||
|
|
||||||
[node name="GameUI" type="HBoxContainer" parent="."]
|
[node name="GameUI" type="HBoxContainer" parent="."]
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
|
@ -260,7 +258,7 @@ text = "Textures"
|
||||||
|
|
||||||
[node name="WorldTextureRect" type="TextureRect" parent="Generator Container/WorldGeneratorContainer"]
|
[node name="WorldTextureRect" type="TextureRect" parent="Generator Container/WorldGeneratorContainer"]
|
||||||
margin_top = 88.0
|
margin_top = 88.0
|
||||||
margin_right = 100.0
|
margin_right = 135.0
|
||||||
margin_bottom = 188.0
|
margin_bottom = 188.0
|
||||||
rect_min_size = Vector2( 100, 100 )
|
rect_min_size = Vector2( 100, 100 )
|
||||||
expand = true
|
expand = true
|
||||||
|
@ -269,7 +267,7 @@ flip_v = true
|
||||||
|
|
||||||
[node name="HeightTextureRect" type="TextureRect" parent="Generator Container/WorldGeneratorContainer"]
|
[node name="HeightTextureRect" type="TextureRect" parent="Generator Container/WorldGeneratorContainer"]
|
||||||
margin_top = 192.0
|
margin_top = 192.0
|
||||||
margin_right = 100.0
|
margin_right = 135.0
|
||||||
margin_bottom = 292.0
|
margin_bottom = 292.0
|
||||||
rect_min_size = Vector2( 100, 100 )
|
rect_min_size = Vector2( 100, 100 )
|
||||||
expand = true
|
expand = true
|
||||||
|
@ -298,15 +296,6 @@ parameters/playback = SubResource( 26 )
|
||||||
|
|
||||||
[node name="Entities" type="Spatial" parent="."]
|
[node name="Entities" type="Spatial" parent="."]
|
||||||
|
|
||||||
[node name="Chest" parent="Entities" instance=ExtResource( 7 )]
|
|
||||||
transform = Transform( -0.534471, 0, -0.845187, 0, 1, 0, 0.845187, 0, -0.534471, 2.68689, 0, 2.60865 )
|
|
||||||
|
|
||||||
[node name="Chest3" parent="Entities" instance=ExtResource( 7 )]
|
|
||||||
transform = Transform( 0.550568, 0, -0.83479, 0, 1, 0, 0.83479, 0, 0.550568, 4.88275, 0, -1.70504 )
|
|
||||||
|
|
||||||
[node name="Chest2" parent="Entities" instance=ExtResource( 7 )]
|
|
||||||
transform = Transform( 0.793576, 0, -0.608471, 0, 1, 0, 0.608471, 0, 0.793576, 2.79265, 0, -5.36551 )
|
|
||||||
|
|
||||||
[node name="Axe" parent="Entities" instance=ExtResource( 14 )]
|
[node name="Axe" parent="Entities" instance=ExtResource( 14 )]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.79762, 0, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.79762, 0, 0 )
|
||||||
input_ray_pickable = false
|
input_ray_pickable = false
|
||||||
|
@ -317,4 +306,3 @@ input_ray_pickable = false
|
||||||
[editable path="TileWorld"]
|
[editable path="TileWorld"]
|
||||||
[editable path="Player"]
|
[editable path="Player"]
|
||||||
[editable path="Player/Geometry"]
|
[editable path="Player/Geometry"]
|
||||||
[editable path="Entities/Chest"]
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class TileWorld : Spatial
|
||||||
private Array<Spatial> _rockAssets = new();
|
private Array<Spatial> _rockAssets = new();
|
||||||
private Array<Spatial> _grassAssets = new();
|
private Array<Spatial> _grassAssets = new();
|
||||||
private Array<Spatial> _treeAssets = new();
|
private Array<Spatial> _treeAssets = new();
|
||||||
|
private PackedScene _chestScene = GD.Load<PackedScene>("res://entities/Chest.tscn");
|
||||||
private Spatial _environmentNode;
|
private Spatial _environmentNode;
|
||||||
private bool _resizeTriggered;
|
private bool _resizeTriggered;
|
||||||
private int _resizeExtraFrameCount = 0;
|
private int _resizeExtraFrameCount = 0;
|
||||||
|
@ -98,6 +99,8 @@ public class TileWorld : Spatial
|
||||||
_treeAssets.Add(asset);
|
_treeAssets.Add(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_chestScene = GD.Load<PackedScene>("res://entities/Chest.tscn");
|
||||||
|
|
||||||
_environmentNode = GetNode<Spatial>("Environment");
|
_environmentNode = GetNode<Spatial>("Environment");
|
||||||
Entities = GetNode<Spatial>("Entities");
|
Entities = GetNode<Spatial>("Entities");
|
||||||
|
|
||||||
|
@ -350,6 +353,16 @@ public class TileWorld : Spatial
|
||||||
Entities.AddChild(treeAsset);
|
Entities.AddChild(treeAsset);
|
||||||
HexGrid.AddObstacle(cell);
|
HexGrid.AddObstacle(cell);
|
||||||
}
|
}
|
||||||
|
else if (environmentRandom.NextDouble() < 0.01)
|
||||||
|
{
|
||||||
|
Chest chestAsset = (Chest)_chestScene.Instance();
|
||||||
|
Transform assetTransform = Transform.Identity;
|
||||||
|
assetTransform.origin = GetHexCenterFromOffset(offsetCoord);
|
||||||
|
assetTransform.origin.y += 1.2f;
|
||||||
|
chestAsset.Transform = assetTransform;
|
||||||
|
Entities.AddChild(chestAsset);
|
||||||
|
HexGrid.AddObstacle(cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (IsColorWater(colorValue))
|
else if (IsColorWater(colorValue))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue