diff --git a/levels/test_level.tscn b/levels/test_level.tscn index 99dac84..42ea0ef 100644 --- a/levels/test_level.tscn +++ b/levels/test_level.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=6 format=3 uid="uid://cbs0x36e3ranm"] +[gd_scene load_steps=8 format=3 uid="uid://cbs0x36e3ranm"] [ext_resource type="MeshLibrary" uid="uid://dwo1m72yajrb1" path="res://assets/tilesets/tileset.tres" id="1_l447d"] [ext_resource type="PackedScene" uid="uid://b5gb5paiupum" path="res://player/player.tscn" id="2_ojnju"] +[ext_resource type="PackedScene" uid="uid://2pw0p13lcklv" path="res://buildings/kash_buildings/factory.tscn" id="3_08gdj"] +[ext_resource type="AudioStream" uid="uid://byo1w5vecks0m" path="res://music/jazz.ogg" id="3_brvx4"] [ext_resource type="PackedScene" uid="uid://c2casdi4d2o3j" path="res://shaders/water_plane.tscn" id="3_ga7wg"] -[sub_resource type="Environment" id="Environment_i4emf"] +[sub_resource type="Environment" id="Environment_lo4sd"] ambient_light_source = 3 ambient_light_color = Color(0.54902, 0.815686, 0.964706, 1) ssao_radius = 11.01 @@ -29,7 +31,7 @@ adjustment_brightness = 1.1 adjustment_contrast = 1.25 adjustment_saturation = 0.8 -[sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_rja1c"] +[sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_5s8jn"] [node name="test_level" type="Node3D"] @@ -44,8 +46,16 @@ data = { metadata/_editor_floor_ = Vector3(0, 0, 0) [node name="player" parent="." instance=ExtResource("2_ojnju")] -transform = Transform3D(1, 0, 0, 0, 0.494109, 0.8694, 0, -0.8694, 0.494109, -3.70665, 40.1006, 20.9216) +transform = Transform3D(1, 0, 0, 0, 0.388867, 0.921294, 0, -0.921294, 0.388867, -1.19974, 40.1006, 13.3341) +attributes = null current = true +fov = 37.8493 +near = 0.032 +_test_building = ExtResource("3_08gdj") + +[node name="Music" type="AudioStreamPlayer" parent="."] +stream = ExtResource("3_brvx4") +autoplay = true [node name="water_plane" parent="." instance=ExtResource("3_ga7wg")] transform = Transform3D(227.061, 0, -196.07, 0, 300, 0, 196.07, 0, 227.061, 0, 0.257405, 0) @@ -58,5 +68,5 @@ light_volumetric_fog_energy = 1.74 light_angular_distance = 5.2 [node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource("Environment_i4emf") -camera_attributes = SubResource("CameraAttributesPhysical_rja1c") +environment = SubResource("Environment_lo4sd") +camera_attributes = SubResource("CameraAttributesPhysical_5s8jn") diff --git a/menu/start_game_menu.tscn b/menu/start_game_menu.tscn index 93f2034..20c508a 100644 --- a/menu/start_game_menu.tscn +++ b/menu/start_game_menu.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://4tym1auav4yv"] +[gd_scene load_steps=7 format=3 uid="uid://4tym1auav4yv"] [ext_resource type="Script" path="res://menu/start_game_menu.cs" id="1_0k2xm"] +[ext_resource type="AudioStream" uid="uid://ckg5eypyrhidg" path="res://music/I Feel Grunge (Slow).wav" id="2_yw57x"] [sub_resource type="LabelSettings" id="LabelSettings_n38oc"] font_size = 290 @@ -143,3 +144,7 @@ offset_bottom = -461.0 grow_horizontal = 2 grow_vertical = 2 horizontal_alignment = 1 + +[node name="Music" type="AudioStreamPlayer" parent="."] +stream = ExtResource("2_yw57x") +autoplay = true diff --git a/music/I Feel Grunge (Slow).wav b/music/I Feel Grunge (Slow).wav new file mode 100644 index 0000000..770d0e4 Binary files /dev/null and b/music/I Feel Grunge (Slow).wav differ diff --git a/music/jazz.ogg b/music/jazz.ogg new file mode 100644 index 0000000..48db11d Binary files /dev/null and b/music/jazz.ogg differ diff --git a/player/player.cs b/player/player.cs index fb22d47..f3226f4 100644 --- a/player/player.cs +++ b/player/player.cs @@ -3,140 +3,140 @@ using System; public partial class player : Camera3D { - private const string _path = "/root/player/"; - //private Camera3D _cam; - [Export] - private Label _con; - [Export] - private Label _mousePosLabel; - [Export] - private Label _cursorPosLabel; - [Export] - private RayCast3D _cursor; - [Export] - private Node3D _cursorPoint; - private bool _mUp, _mDown, _mLeft, _mRight, _wIn, _wOut; + private const string _path = "/root/player/"; + //private Camera3D _cam; + [Export] + private Label _con; + [Export] + private Label _mousePosLabel; + [Export] + private Label _cursorPosLabel; + [Export] + private RayCast3D _cursor; + [Export] + private Node3D _cursorPoint; + private bool _mUp, _mDown, _mLeft, _mRight, _wIn, _wOut; - [Export] - private PackedScene _test_building; + [Export] + private PackedScene _test_building; - [Export] - private TextureProgressBar _nuke, _pr, _kash; + [Export] + private TextureProgressBar _nuke, _pr, _kash; - private float Nuke { get => (float)_nuke.Value; set => _nuke.Value = value; } - private float PR { get => (float)_pr.Value; set => _pr.Value = value; } - private float Kash { get => (float)_kash.Value; set => _kash.Value = value; } + private float Nuke { get => (float)_nuke.Value; set => _nuke.Value = value; } + private float PR { get => (float)_pr.Value; set => _pr.Value = value; } + private float Kash { get => (float)_kash.Value; set => _kash.Value = value; } - public Node3D CurrentBuilding { get; set; } + public Node3D CurrentBuilding { get; set; } - public override void _Ready() - { - //for debugging TODO: Remove - game_manager.CurrentState = game_manager.State.Building; - if (_test_building != null) - { - CurrentBuilding = _test_building.Instantiate(); - GD.Print(CurrentBuilding); + public override void _Ready() + { + //for debugging TODO: Remove + game_manager.CurrentState = game_manager.State.Building; + if (_test_building != null) + { + CurrentBuilding = _test_building.Instantiate(); + GD.Print(CurrentBuilding); - GetTree().Root.CallDeferred("add_child", CurrentBuilding); - } - } + GetTree().Root.CallDeferred("add_child", CurrentBuilding); + } + } - public override void _Process(double delta) - { - Vector3 rot = this.Rotation; - bool zin = true, zout = true; + public override void _Process(double delta) + { + Vector3 rot = this.Rotation; + bool zin = true, zout = true; - if (Input.IsActionPressed("CamNorth")) - _mUp = true; - if (Input.IsActionPressed("CamSouth")) - _mDown = true; - if (Input.IsActionPressed("CamEast")) - _mRight = true; - if (Input.IsActionPressed("CamWest")) - _mLeft = true; + if (Input.IsActionPressed("CamNorth")) + _mUp = true; + if (Input.IsActionPressed("CamSouth")) + _mDown = true; + if (Input.IsActionPressed("CamEast")) + _mRight = true; + if (Input.IsActionPressed("CamWest")) + _mLeft = true; - this.Rotation -= rot; - if (this.Position.Y < 5) - zin = false; - else if (this.Position.Y > 45) - zout = false; - if (_mLeft && this.Position.X > -30) - this.Translate(new Vector3((float)-delta * 10, 0, 0)); - if (_mRight && this.Position.X < 30) - this.Translate(new Vector3((float)delta * 10, 0, 0)); - if (_mUp && this.Position.Z > -25) - this.Translate(new Vector3(0, 0, (float)-delta * 10)); - if (_mDown && this.Position.Z < 25) - this.Translate(new Vector3(0, 0, (float)delta * 10)); - this.Rotation += rot; + this.Rotation -= rot; + if (this.Position.Y < 5) + zin = false; + else if (this.Position.Y > 45) + zout = false; + if (_mLeft && this.Position.X > -30) + this.Translate(new Vector3((float)-delta * 10, 0, 0)); + if (_mRight && this.Position.X < 30) + this.Translate(new Vector3((float)delta * 10, 0, 0)); + if (_mUp && this.Position.Z > -25) + this.Translate(new Vector3(0, 0, (float)-delta * 10)); + if (_mDown && this.Position.Z < 25) + this.Translate(new Vector3(0, 0, (float)delta * 10)); + this.Rotation += rot; - if (_wIn && zin) - this.Translate(new Vector3(0, 0, (float)-delta * 10)); - if (_wOut && zout) - this.Translate(new Vector3(0, 0, (float)delta * 10)); + if (_wIn && zin) + this.Translate(new Vector3(0, 0, (float)-delta * 10)); + if (_wOut && zout) + this.Translate(new Vector3(0, 0, (float)delta * 10)); - _con.Set("text", this.Position); + _con.Set("text", this.Position); - if (_cursor != null && _cursorPoint != null) - { - //Get the collision with map and change its X and Z value to always be in the center of a tile - Vector3I collisionVector = (Vector3I)_cursor.GetCollisionPoint(); - _cursorPosLabel.Text = "Virtual Cursor Postion" + collisionVector.ToString(); - _cursorPoint.GlobalPosition = new Vector3(collisionVector.X - collisionVector.X % 2, collisionVector.Y + 0.1f, collisionVector.Z - collisionVector.Z % 2); + if (_cursor != null && _cursorPoint != null) + { + //Get the collision with map and change its X and Z value to always be in the center of a tile + Vector3I collisionVector = (Vector3I)_cursor.GetCollisionPoint(); + _cursorPosLabel.Text = "Virtual Cursor Postion" + collisionVector.ToString(); + _cursorPoint.GlobalPosition = new Vector3(collisionVector.X - collisionVector.X % 2, collisionVector.Y + 0.1f, collisionVector.Z - collisionVector.Z % 2); - if (game_manager.CurrentState == game_manager.State.Building) - HandleBuilding(); - } - } + if (game_manager.CurrentState == game_manager.State.Building) + HandleBuilding(); + } + } - public override void _Input(InputEvent @event) - { - _mLeft = _mRight = _mUp = _mDown = _wIn = _wOut = false; + public override void _Input(InputEvent @event) + { + _mLeft = _mRight = _mUp = _mDown = _wIn = _wOut = false; - if (@event is InputEventMouseMotion mouse) - { - Vector2 vec = mouse.Position; - if (vec.X < 5) - _mLeft = true; - else if (vec.X > 1915) - _mRight = true; - if (vec.Y < 20) - _mUp = true; - else if (vec.Y > 1060) - _mDown = true; + if (@event is InputEventMouseMotion mouse) + { + Vector2 vec = mouse.Position; + if (vec.X < 5) + _mLeft = true; + else if (vec.X > 1915) + _mRight = true; + if (vec.Y < 20) + _mUp = true; + else if (vec.Y > 1060) + _mDown = true; - _mousePosLabel.Text = "Mouse position: " + vec.ToString(); + _mousePosLabel.Text = "Mouse position: " + vec.ToString(); - _cursor.Position = new Vector3( - (vec.X - GetViewport().GetVisibleRect().Size.X / 2) * this.Position.Y / 700, - -((vec.Y - GetViewport().GetVisibleRect().Size.Y / 2) * this.Position.Y / 700) - , 0 - ); - } - else if (@event is InputEventMouseButton mousebtn) - { - if (mousebtn.ButtonIndex == MouseButton.WheelUp) - _wIn = true; - else if (mousebtn.ButtonIndex == MouseButton.WheelDown) - _wOut = true; - } + _cursor.Position = new Vector3( + (vec.X - GetViewport().GetVisibleRect().Size.X / 2) * this.Position.Y / 700, + -((vec.Y - GetViewport().GetVisibleRect().Size.Y / 2) * this.Position.Y / 700) + , 0 + ); + } + else if (@event is InputEventMouseButton mousebtn) + { + if (mousebtn.ButtonIndex == MouseButton.WheelUp) + _wIn = true; + else if (mousebtn.ButtonIndex == MouseButton.WheelDown) + _wOut = true; + } - } + } - public void HandleBuilding() - { - if (CurrentBuilding != null) - { - CurrentBuilding.GlobalPosition = _cursorPoint.GlobalPosition; + public void HandleBuilding() + { + if (CurrentBuilding != null) + { + CurrentBuilding.GlobalPosition = _cursorPoint.GlobalPosition; - if (Input.IsActionJustPressed("build")) - { - Node3D tempBuilding = (Node3D)CurrentBuilding.Duplicate(); - GetTree().Root.CallDeferred("add_child", tempBuilding); - } - } - } + if (Input.IsActionJustPressed("build")) + { + Node3D tempBuilding = (Node3D)CurrentBuilding.Duplicate(); + GetTree().Root.CallDeferred("add_child", tempBuilding); + } + } + } } diff --git a/player/player.tscn b/player/player.tscn index 2c97cd1..feec5c2 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -1,7 +1,6 @@ -[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="PackedScene" uid="uid://2pw0p13lcklv" path="res://buildings/kash_buildings/factory.tscn" id="2_mspwe"] [sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_1ejpb"] frustum_near = 0.032 @@ -72,7 +71,6 @@ _mousePosLabel = NodePath("Debug info/mousePos") _cursorPosLabel = NodePath("Debug info/cursorPointPos") _cursor = NodePath("cursor") _cursorPoint = NodePath("cursorPoint") -_test_building = ExtResource("2_mspwe") _nuke = NodePath("NukeBar") _pr = NodePath("PrBar") _kash = NodePath("KashBar")