Come collision stuff and stuff aand stuff hahahah
This commit is contained in:
parent
004ba54cc0
commit
5ccf6a12ea
@ -1,31 +1,57 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public partial class base_building : Node3D
|
public partial class base_building : Node3D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public Node3D BlocksNode { get; set; } = null;
|
public Node3D BlocksNode { get; set; } = null;
|
||||||
private building_block[] _blocks = null;
|
private List<building_block> _blocks = null;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public string DisplayName { get; set; } = "base_building";
|
public string DisplayName { get; set; } = "base_building";
|
||||||
[Export]
|
[Export]
|
||||||
public int KashCost { get; set; } = 1;
|
public int KashCost { get; set; } = 1;
|
||||||
|
public bool IsPlaced { get; set; } = false;
|
||||||
|
|
||||||
public bool IsPlaceable
|
public bool IsPlaceable
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (_blocks == null || _blocks.Count < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
foreach (building_block block in _blocks)
|
||||||
|
if (!block.IsPlaceable)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
if (BlocksNode != null)
|
if (BlocksNode != null)
|
||||||
{
|
{
|
||||||
|
_blocks = new List<building_block>();
|
||||||
|
foreach (Node child in BlocksNode.GetChildren())
|
||||||
|
{
|
||||||
|
_blocks.Add((building_block)child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
// if (!IsPlaced)
|
||||||
|
//{
|
||||||
|
//if (IsPlaceable)
|
||||||
|
//{
|
||||||
|
////show green highlight
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
////show red highlight
|
||||||
|
//}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,18 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
public enum TileTypes
|
|
||||||
{
|
|
||||||
NONE,
|
|
||||||
Grass,
|
|
||||||
Sand,
|
|
||||||
Water,
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class building_block : Node3D
|
public partial class building_block : Node3D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public RayCast3D _ray = null;
|
private RayCast3D _ground_ray;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private TileTypes _compatible_tile = TileTypes.NONE;
|
private RayCast3D _collision_ray;
|
||||||
|
|
||||||
public bool IsPlaceable
|
public bool IsPlaceable
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_ray == null || _compatible_tile == TileTypes.NONE)
|
return _collision_ray.GetCollider() == null && _ground_ray.GetCollider() != null && _ground_ray.GetCollider().GetType() == typeof(GridMap);
|
||||||
return false;
|
|
||||||
|
|
||||||
GodotObject collider = _ray.GetCollider();
|
|
||||||
GD.Print(collider);
|
|
||||||
|
|
||||||
if (collider == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,34 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://m3lrwoup4i4r"]
|
[gd_scene load_steps=4 format=3 uid="uid://m3lrwoup4i4r"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_3ht4p"]
|
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_3ht4p"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cdakee12nn8un" path="res://assets/meshes/highlights_grass.tscn" id="2_m6bs4"]
|
[ext_resource type="PackedScene" uid="uid://cdakee12nn8un" path="res://assets/meshes/highlights_grass.tscn" id="2_m6bs4"]
|
||||||
|
|
||||||
[node name="grass_block" type="Node3D" node_paths=PackedStringArray("_ray")]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_gr51o"]
|
||||||
|
size = Vector3(1.8, 2, 1.8)
|
||||||
|
|
||||||
|
[node name="grass_block" type="Node3D" node_paths=PackedStringArray("_ground_ray", "_collision_ray")]
|
||||||
script = ExtResource("1_3ht4p")
|
script = ExtResource("1_3ht4p")
|
||||||
_ray = NodePath("RayCast3D")
|
_ground_ray = NodePath("Area3D/GroundCheck")
|
||||||
_compatible_tile = 1
|
_collision_ray = NodePath("Area3D/AreaCast")
|
||||||
|
|
||||||
[node name="highlights-grass" parent="." instance=ExtResource("2_m6bs4")]
|
[node name="highlights-grass" parent="." instance=ExtResource("2_m6bs4")]
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
[node name="Area3D" type="Area3D" parent="."]
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 0
|
||||||
|
monitoring = false
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
|
shape = SubResource("BoxShape3D_gr51o")
|
||||||
|
|
||||||
|
[node name="GroundCheck" type="RayCast3D" parent="Area3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.693845, 0)
|
||||||
|
|
||||||
|
[node name="AreaCast" type="RayCast3D" parent="Area3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.23187, 0)
|
||||||
|
collision_mask = 2
|
||||||
|
hit_from_inside = true
|
||||||
|
collide_with_areas = true
|
||||||
|
collide_with_bodies = false
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://dffhktks7ro6y"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_xuxw4"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bea5tpiqs0m4b" path="res://assets/meshes/highlights_sand.tscn" id="2_pmjbb"]
|
|
||||||
|
|
||||||
[node name="sand_block" type="Node3D" node_paths=PackedStringArray("_ray")]
|
|
||||||
script = ExtResource("1_xuxw4")
|
|
||||||
_ray = NodePath("RayCast3D")
|
|
||||||
_compatible_tile = 2
|
|
||||||
|
|
||||||
[node name="highlights-sand" parent="." instance=ExtResource("2_pmjbb")]
|
|
||||||
|
|
||||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
|
@ -1,13 +0,0 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://b3jpnuj1suvcj"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_p3ylt"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://ds0lxspxtnkcp" path="res://assets/meshes/highlights-water.glb" id="2_53d7w"]
|
|
||||||
|
|
||||||
[node name="water_block" type="Node3D" node_paths=PackedStringArray("_ray")]
|
|
||||||
script = ExtResource("1_p3ylt")
|
|
||||||
_ray = NodePath("RayCast3D")
|
|
||||||
_compatible_tile = 3
|
|
||||||
|
|
||||||
[node name="highlights-water" parent="." instance=ExtResource("2_53d7w")]
|
|
||||||
|
|
||||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
|
@ -47,7 +47,7 @@ public partial class player : Camera3D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node3D CurrentBuilding { get; set; }
|
public base_building CurrentBuilding { get; set; }
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@ -55,8 +55,7 @@ public partial class player : Camera3D
|
|||||||
game_manager.CurrentState = game_manager.State.Building;
|
game_manager.CurrentState = game_manager.State.Building;
|
||||||
if (_test_building != null)
|
if (_test_building != null)
|
||||||
{
|
{
|
||||||
CurrentBuilding = _test_building.Instantiate<Node3D>();
|
CurrentBuilding = _test_building.Instantiate<base_building>();
|
||||||
GD.Print(CurrentBuilding);
|
|
||||||
|
|
||||||
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
|
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
|
||||||
}
|
}
|
||||||
@ -156,9 +155,12 @@ public partial class player : Camera3D
|
|||||||
|
|
||||||
if (Input.IsActionJustPressed("build"))
|
if (Input.IsActionJustPressed("build"))
|
||||||
{
|
{
|
||||||
Node3D tempBuilding = (Node3D)CurrentBuilding.Duplicate();
|
if (CurrentBuilding.IsPlaceable)
|
||||||
|
{
|
||||||
|
base_building tempBuilding = (base_building)CurrentBuilding.Duplicate();
|
||||||
GetTree().Root.CallDeferred("add_child", tempBuilding);
|
GetTree().Root.CallDeferred("add_child", tempBuilding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=19 format=3 uid="uid://b5gb5paiupum"]
|
[gd_scene load_steps=18 format=3 uid="uid://b5gb5paiupum"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://player/player.cs" id="1_of2l4"]
|
[ext_resource type="Script" path="res://player/player.cs" id="1_of2l4"]
|
||||||
|
|
||||||
@ -63,10 +63,7 @@ height = 255
|
|||||||
|
|
||||||
[sub_resource type="SphereMesh" id="SphereMesh_mtv4x"]
|
[sub_resource type="SphereMesh" id="SphereMesh_mtv4x"]
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_pws5q"]
|
[node name="player" type="Camera3D" node_paths=PackedStringArray("_con", "_mousePosLabel", "_cursorPosLabel", "_cursor", "_cursorPoint", "_nuke", "_pr", "_kash")]
|
||||||
font_size = 28
|
|
||||||
|
|
||||||
[node name="player" type="Camera3D" node_paths=PackedStringArray("_con", "_mousePosLabel", "_cursorPosLabel", "_cursor", "_cursorPoint", "_nuke", "_pr", "_kash", "_chatter", "_sndChtr", "_sndBtn", "_tmrChtr")]
|
|
||||||
attributes = SubResource("CameraAttributesPhysical_1ejpb")
|
attributes = SubResource("CameraAttributesPhysical_1ejpb")
|
||||||
script = ExtResource("1_of2l4")
|
script = ExtResource("1_of2l4")
|
||||||
_con = NodePath("Debug info/Label")
|
_con = NodePath("Debug info/Label")
|
||||||
@ -77,13 +74,8 @@ _cursorPoint = NodePath("cursorPoint")
|
|||||||
_nuke = NodePath("NukeBar")
|
_nuke = NodePath("NukeBar")
|
||||||
_pr = NodePath("PrBar")
|
_pr = NodePath("PrBar")
|
||||||
_kash = NodePath("KashBar")
|
_kash = NodePath("KashBar")
|
||||||
_chatter = NodePath("lbl_Chatter")
|
|
||||||
_sndChtr = NodePath("snd_Chatter")
|
|
||||||
_sndBtn = NodePath("snd_Button")
|
|
||||||
_tmrChtr = NodePath("tmr_Chatter")
|
|
||||||
|
|
||||||
[node name="Debug info" type="Control" parent="."]
|
[node name="Debug info" type="Control" parent="."]
|
||||||
visible = false
|
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
@ -194,19 +186,3 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2)
|
|||||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
|
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
|
||||||
mesh = SubResource("SphereMesh_mtv4x")
|
mesh = SubResource("SphereMesh_mtv4x")
|
||||||
skeleton = NodePath("../..")
|
skeleton = NodePath("../..")
|
||||||
|
|
||||||
[node name="lbl_Chatter" type="Label" parent="."]
|
|
||||||
offset_left = 314.0
|
|
||||||
offset_top = 270.0
|
|
||||||
offset_right = 756.0
|
|
||||||
offset_bottom = 513.0
|
|
||||||
text = "CHATTER"
|
|
||||||
label_settings = SubResource("LabelSettings_pws5q")
|
|
||||||
autowrap_mode = 3
|
|
||||||
|
|
||||||
[node name="snd_Chatter" type="AudioStreamPlayer" parent="."]
|
|
||||||
|
|
||||||
[node name="snd_Button" type="AudioStreamPlayer" parent="."]
|
|
||||||
|
|
||||||
[node name="tmr_Chatter" type="Timer" parent="."]
|
|
||||||
wait_time = 3.0
|
|
||||||
|
@ -15,12 +15,6 @@ run/main_scene="res://menu/start_game_menu.tscn"
|
|||||||
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[display]
|
|
||||||
|
|
||||||
window/size/viewport_width=1920
|
|
||||||
window/size/viewport_height=1080
|
|
||||||
window/size/mode=3
|
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
project/assembly_name="Mad"
|
project/assembly_name="Mad"
|
||||||
@ -57,6 +51,12 @@ build={
|
|||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":98,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":98,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
rotate={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"echo":false,"script":null)
|
||||||
|
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user