diff --git a/Company.cs b/Company.cs index 651fa67..9f45be2 100644 --- a/Company.cs +++ b/Company.cs @@ -65,7 +65,12 @@ public partial class Company : Resource private void EmitCompanyStatusChanged() { - EventBus.CompanyChanged.Invoke(new CompanyStats(Hype, Money, Workers, Runway)); + EventBus.CompanyChanged.Invoke(ToCompanyStats()); + } + + public CompanyStats ToCompanyStats() + { + return new CompanyStats(Hype, Money, Workers, Runway); } public record CompanyStats(float Hype, float Money, float Workers, int Runway); diff --git a/CurrentTimeLine.cs b/CurrentTimeLine.cs index dc5ff31..6463a4a 100644 --- a/CurrentTimeLine.cs +++ b/CurrentTimeLine.cs @@ -4,9 +4,9 @@ using yourareanaiceo; public partial class CurrentTimeLine : Panel { [Export] - private float _speed = 15f; + public float Speed = 15f; - public bool Running { get; set; } + public bool Running { get; private set; } public override void _Process(double delta) { @@ -14,8 +14,13 @@ public partial class CurrentTimeLine : Panel return; var pos = OffsetTransformPosition; - pos.Y += _speed * delta.toFloat(); + pos.Y += Speed * delta.toFloat(); OffsetTransformPosition = pos; } + + public void Start() + { + Running = true; + } } diff --git a/DaySchedule.cs b/DaySchedule.cs index 76d497d..a84ff82 100644 --- a/DaySchedule.cs +++ b/DaySchedule.cs @@ -1,9 +1,12 @@ +using System.Collections.Generic; using System.Linq; using Godot; [SceneTree] public partial class DaySchedule : PanelContainer { + private int _currentSlot; + [Export] private int _hoursInDay = 6; @@ -17,10 +20,35 @@ public partial class DaySchedule : PanelContainer TimeSlotContainer.AddChild(timeSlot); } + + ProgressTimer.Timeout += OnNewMeetingStarts; + + SetupCurrentTimeLine(); + } + + private void SetupCurrentTimeLine() + { + var timeSlot = Instantiator.Instantiate(); + CurrentTimeLine.Speed = (float)(timeSlot.Size.Y / ProgressTimer.WaitTime); + } + + private void OnNewMeetingStarts() + { + GetTimeSlots()[_currentSlot].StartMeeting(); + _currentSlot += 1; } public void StartDay() { - CurrentTimeLine.Running = true; + ProgressTimer.Start(); + CurrentTimeLine.Start(); + + GetTimeSlots().First().StartMeeting(); + _currentSlot += 1; + } + + private List GetTimeSlots() + { + return [.. TimeSlotContainer.GetChildren().OfType()]; } } diff --git a/DaySchedule.tscn b/DaySchedule.tscn index 4ce88b4..c086f02 100644 --- a/DaySchedule.tscn +++ b/DaySchedule.tscn @@ -36,6 +36,10 @@ mouse_filter = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_cm0pq") script = ExtResource("1_b6clr") +[node name="ProgressTimer" type="Timer" parent="." unique_id=131279089] +unique_name_in_owner = true +wait_time = 2.0 + [node name="TimeSlotContainer" type="VBoxContainer" parent="." unique_id=1932322928] unique_name_in_owner = true layout_mode = 2 diff --git a/DropZone.cs b/DropZone.cs index 3dd1b40..96a700f 100644 --- a/DropZone.cs +++ b/DropZone.cs @@ -1,4 +1,5 @@ using Godot; +using yourareanaiceo; public partial class DropZone : Control { @@ -13,8 +14,8 @@ public partial class DropZone : Control var meetingControl = ((MeetingControlDragData)data).MeetingControl; var meetingPhysicsBox = meetingControl.MeetingPhysicsBox; - var main = (Main)FindParent("Main"); - main.AddChild(meetingPhysicsBox); + var game = this.GetGame(); + game.AddChild(meetingPhysicsBox); meetingPhysicsBox.Position = GetGlobalMousePosition(); meetingControl.QueueFree(); diff --git a/DoubleExtensions.cs b/Extensions/DoubleExtensions.cs similarity index 100% rename from DoubleExtensions.cs rename to Extensions/DoubleExtensions.cs diff --git a/DoubleExtensions.cs.uid b/Extensions/DoubleExtensions.cs.uid similarity index 100% rename from DoubleExtensions.cs.uid rename to Extensions/DoubleExtensions.cs.uid diff --git a/Extensions/NodeExtensions.cs b/Extensions/NodeExtensions.cs new file mode 100644 index 0000000..8ccf199 --- /dev/null +++ b/Extensions/NodeExtensions.cs @@ -0,0 +1,11 @@ +using Godot; + +namespace yourareanaiceo; + +public static class NodeExtensions +{ + public static Game GetGame(this Node node) + { + return node.GetTree().CurrentScene as Game; + } +} diff --git a/Extensions/NodeExtensions.cs.uid b/Extensions/NodeExtensions.cs.uid new file mode 100644 index 0000000..771c688 --- /dev/null +++ b/Extensions/NodeExtensions.cs.uid @@ -0,0 +1 @@ +uid://broxfid7ffads diff --git a/Game.cs b/Game.cs new file mode 100644 index 0000000..2360c4b --- /dev/null +++ b/Game.cs @@ -0,0 +1,15 @@ +using Godot; +using yourareanaiceo; + +[SceneTree] +public partial class Game : Node2D +{ + public GameState GameState { get; set; } = new(); + + public override void _Ready() + { + ExecuteButton.Pressed += () => DaySchedule.StartDay(); + + EventBus.CompanyChanged?.Invoke(GameState.Company.ToCompanyStats()); + } +} diff --git a/Main.cs.uid b/Game.cs.uid similarity index 100% rename from Main.cs.uid rename to Game.cs.uid diff --git a/Main.tscn b/Game.tscn similarity index 79% rename from Main.tscn rename to Game.tscn index e3b9f39..ea400ee 100644 --- a/Main.tscn +++ b/Game.tscn @@ -1,13 +1,13 @@ [gd_scene format=3 uid="uid://b2rl7r8oav3hy"] -[ext_resource type="Script" uid="uid://d1h0qvskvk1wu" path="res://Main.cs" id="1_3dxm6"] -[ext_resource type="PackedScene" uid="uid://dciugg77wsy6p" path="res://MeetingPhysicsBox.tscn" id="1_glv2v"] -[ext_resource type="PackedScene" uid="uid://covomnw8s7k1n" path="res://DaySchedule.tscn" id="1_r0du0"] -[ext_resource type="PackedScene" uid="uid://ckdqrg8c0mq8h" path="res://CompanyStatsContainer.tscn" id="2_trn2v"] -[ext_resource type="Resource" uid="uid://mifwco1yj8kc" path="res://resources/meetings/coffee_meeting.tres" id="3_r0du0"] -[ext_resource type="Resource" uid="uid://du72uxjqr0h4a" path="res://resources/meetings/lockin.tres" id="4_cm0pq"] -[ext_resource type="Resource" uid="uid://bcd4qf4i84pwf" path="res://resources/meetings/work_product_1.tres" id="5_fos0i"] -[ext_resource type="Script" uid="uid://bs531c76ivhtf" path="res://DropZone.cs" id="7_lgr22"] +[ext_resource type="Script" uid="uid://d1h0qvskvk1wu" path="res://Game.cs" id="1_joorw"] +[ext_resource type="PackedScene" uid="uid://ckdqrg8c0mq8h" path="res://CompanyStatsContainer.tscn" id="2_2vekm"] +[ext_resource type="PackedScene" uid="uid://covomnw8s7k1n" path="res://DaySchedule.tscn" id="3_yx171"] +[ext_resource type="PackedScene" uid="uid://dciugg77wsy6p" path="res://MeetingPhysicsBox.tscn" id="4_yhmtn"] +[ext_resource type="Resource" uid="uid://mifwco1yj8kc" path="res://resources/meetings/coffee_meeting.tres" id="5_gwjdr"] +[ext_resource type="Resource" uid="uid://du72uxjqr0h4a" path="res://resources/meetings/lockin.tres" id="6_lvtmh"] +[ext_resource type="Resource" uid="uid://bcd4qf4i84pwf" path="res://resources/meetings/work_product_1.tres" id="7_yyih5"] +[ext_resource type="Script" uid="uid://bs531c76ivhtf" path="res://DropZone.cs" id="8_qjyg3"] [sub_resource type="Gradient" id="Gradient_trn2v"] offsets = PackedFloat32Array(0, 0.5518293, 1) @@ -31,12 +31,12 @@ size = Vector2(727.5, 20) [sub_resource type="RectangleShape2D" id="RectangleShape2D_ig7tw"] size = Vector2(21.5, 1920) -[node name="Main" type="Node2D" unique_id=287617203] -script = ExtResource("1_3dxm6") +[node name="Game" type="Node2D" unique_id=287617203] +script = ExtResource("1_joorw") [node name="MeetingSpawn" type="Marker2D" parent="." unique_id=1266113438] unique_name_in_owner = true -position = Vector2(775, 36) +position = Vector2(167, -412) gizmo_extents = 40.0 [node name="TextureRect" type="TextureRect" parent="." unique_id=594808349] @@ -64,12 +64,12 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 -[node name="CompanyStatsContainer" parent="CanvasLayer/Control" unique_id=317328071 instance=ExtResource("2_trn2v")] +[node name="CompanyStatsContainer" parent="CanvasLayer/Control" unique_id=317328071 instance=ExtResource("2_2vekm")] layout_mode = 1 offset_left = -249.53503 offset_right = 0.0 -[node name="DaySchedule" parent="." unique_id=457829015 instance=ExtResource("1_r0du0")] +[node name="DaySchedule" parent="." unique_id=457829015 instance=ExtResource("3_yx171")] unique_name_in_owner = true offset_left = -493.0 offset_top = -277.00006 @@ -105,57 +105,57 @@ shape = SubResource("RectangleShape2D_ig7tw") position = Vector2(1120, -339) shape = SubResource("RectangleShape2D_ig7tw") -[node name="Meeting" parent="." unique_id=796440984 instance=ExtResource("1_glv2v")] +[node name="Meeting" parent="." unique_id=796440984 instance=ExtResource("4_yhmtn")] position = Vector2(35, -776.00006) -MeetingResource = ExtResource("3_r0du0") +MeetingResource = ExtResource("5_gwjdr") -[node name="Meeting4" parent="." unique_id=1960552374 instance=ExtResource("1_glv2v")] +[node name="Meeting4" parent="." unique_id=1960552374 instance=ExtResource("4_yhmtn")] position = Vector2(108, -662.00006) rotation = 0.24779713 -MeetingResource = ExtResource("4_cm0pq") +MeetingResource = ExtResource("6_lvtmh") -[node name="Meeting5" parent="." unique_id=1692042144 instance=ExtResource("1_glv2v")] +[node name="Meeting5" parent="." unique_id=1692042144 instance=ExtResource("4_yhmtn")] position = Vector2(252, -822.00006) rotation = 0.24779713 -MeetingResource = ExtResource("5_fos0i") +MeetingResource = ExtResource("7_yyih5") -[node name="Meeting6" parent="." unique_id=2120697586 instance=ExtResource("1_glv2v")] +[node name="Meeting6" parent="." unique_id=2120697586 instance=ExtResource("4_yhmtn")] position = Vector2(5, -942) rotation = 0.24779713 -MeetingResource = ExtResource("3_r0du0") +MeetingResource = ExtResource("5_gwjdr") -[node name="Meeting7" parent="." unique_id=2144014406 instance=ExtResource("1_glv2v")] +[node name="Meeting7" parent="." unique_id=2144014406 instance=ExtResource("4_yhmtn")] position = Vector2(258, -983.00006) rotation = 0.24779713 -MeetingResource = ExtResource("3_r0du0") +MeetingResource = ExtResource("5_gwjdr") -[node name="Meeting8" parent="." unique_id=1157887697 instance=ExtResource("1_glv2v")] +[node name="Meeting8" parent="." unique_id=1157887697 instance=ExtResource("4_yhmtn")] position = Vector2(365, -877.00006) rotation = 0.24779713 -[node name="Meeting9" parent="." unique_id=1055632102 instance=ExtResource("1_glv2v")] +[node name="Meeting9" parent="." unique_id=1055632102 instance=ExtResource("4_yhmtn")] position = Vector2(15, -1055) rotation = 0.24779713 -MeetingResource = ExtResource("5_fos0i") +MeetingResource = ExtResource("7_yyih5") -[node name="Meeting2" parent="." unique_id=1691479453 instance=ExtResource("1_glv2v")] +[node name="Meeting2" parent="." unique_id=1691479453 instance=ExtResource("4_yhmtn")] position = Vector2(338, -674.00006) rotation = -0.5541229 -MeetingResource = ExtResource("3_r0du0") +MeetingResource = ExtResource("5_gwjdr") -[node name="Meeting3" parent="." unique_id=673551448 instance=ExtResource("1_glv2v")] +[node name="Meeting3" parent="." unique_id=673551448 instance=ExtResource("4_yhmtn")] position = Vector2(163.99982, -503.0002) rotation = -0.18364333 -MeetingResource = ExtResource("3_r0du0") +MeetingResource = ExtResource("5_gwjdr") [node name="DropZone" type="Control" parent="." unique_id=80494692] layout_mode = 3 anchors_preset = 0 -offset_left = 457.0 -offset_top = 9.0 -offset_right = 1080.0 -offset_bottom = 571.0 +offset_left = -173.0 +offset_top = -323.0 +offset_right = 507.0 +offset_bottom = 276.0 mouse_filter = 2 -script = ExtResource("7_lgr22") +script = ExtResource("8_qjyg3") [node name="Camera2D" type="Camera2D" parent="." unique_id=1154975713] diff --git a/GameState.cs b/GameState.cs new file mode 100644 index 0000000..a4a502e --- /dev/null +++ b/GameState.cs @@ -0,0 +1,6 @@ +namespace yourareanaiceo; + +public class GameState +{ + public Company Company { get; set; } = new(); +} diff --git a/GameState.cs.uid b/GameState.cs.uid new file mode 100644 index 0000000..0f319fd --- /dev/null +++ b/GameState.cs.uid @@ -0,0 +1 @@ +uid://ndqbupmafy7v diff --git a/Main.cs b/Main.cs deleted file mode 100644 index 8054d44..0000000 --- a/Main.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Godot; - -[SceneTree] -public partial class Main : Node2D -{ - [Export] - public Company Company; - - public override void _Ready() - { - Company = new Company(); - Company.Hype = 0; - - ExecuteButton.Pressed += () => DaySchedule.StartDay(); - } -} diff --git a/MeetingControl.cs b/MeetingControl.cs index 7997d56..c423eb4 100644 --- a/MeetingControl.cs +++ b/MeetingControl.cs @@ -1,4 +1,5 @@ using Godot; +using yourareanaiceo; public sealed partial class MeetingControlDragData(MeetingControl meetingControl) : GodotObject { @@ -86,9 +87,9 @@ public partial class MeetingControl : Control private void RespawnPhysicsBoxFromSpawn() { - var main = (Main)FindParent("Main"); - main.AddChild(MeetingPhysicsBox); - MeetingPhysicsBox.Position = main.MeetingSpawn.GlobalPosition; + var game = this.GetGame(); + game.AddChild(MeetingPhysicsBox); + MeetingPhysicsBox.Position = game.MeetingSpawn.GlobalPosition; QueueFree(); } @@ -101,4 +102,17 @@ public partial class MeetingControl : Control return preview; } + + public void Animate() + { + var tween = CreateTween(); + + tween.TweenProperty( + this, + new NodePath(Control.PropertyName.Scale), + new Vector2(1.2f, 1.2f), + 0.4f + ); + tween.TweenProperty(this, new NodePath(Control.PropertyName.Scale), Vector2.One, 0.4f); + } } diff --git a/TimeSlot.cs b/TimeSlot.cs index 499a376..60b6190 100644 --- a/TimeSlot.cs +++ b/TimeSlot.cs @@ -1,4 +1,5 @@ using Godot; +using yourareanaiceo; [SceneTree] public partial class TimeSlot : PanelContainer @@ -30,4 +31,14 @@ public partial class TimeSlot : PanelContainer if (what == NotificationDragEnd) MouseFilter = MouseFilterEnum.Ignore; } + + public void StartMeeting() + { + GD.Print("New Meeting starts!"); + var gameState = this.GetGame().GameState; + + // TODO: TimeSlot hat bekommt die MeetingResource on Drop?? oder zumindest nicht über Gfx gehen + MeetingControl?.MeetingControlGfx.MeetingResource.StartMeeting(gameState); + MeetingControl?.Animate(); + } } diff --git a/addons/rider-plugin/bin/windows/~rider-gdextension.windows.editor.x86_64.dll b/addons/rider-plugin/bin/windows/~rider-gdextension.windows.editor.x86_64.dll new file mode 100644 index 0000000..66397c2 Binary files /dev/null and b/addons/rider-plugin/bin/windows/~rider-gdextension.windows.editor.x86_64.dll differ diff --git a/resources/GainHypeAction.cs b/resources/GainHypeAction.cs new file mode 100644 index 0000000..923c57f --- /dev/null +++ b/resources/GainHypeAction.cs @@ -0,0 +1,14 @@ +using Godot; +using yourareanaiceo; + +[GlobalClass] +public partial class GainHypeAction : MeetingActionResource +{ + [Export] + public int Amount; + + public override void Execute(GameState gameState) + { + gameState.Company.Hype += Amount; + } +} diff --git a/resources/GainHypeAction.cs.uid b/resources/GainHypeAction.cs.uid new file mode 100644 index 0000000..f3f4a19 --- /dev/null +++ b/resources/GainHypeAction.cs.uid @@ -0,0 +1 @@ +uid://cduoflv3vjfmg diff --git a/resources/MeetingActionResource.cs b/resources/MeetingActionResource.cs new file mode 100644 index 0000000..fd0b87d --- /dev/null +++ b/resources/MeetingActionResource.cs @@ -0,0 +1,8 @@ +using Godot; +using yourareanaiceo; + +[GlobalClass] +public abstract partial class MeetingActionResource : Resource +{ + public abstract void Execute(GameState gameState); +} diff --git a/resources/MeetingActionResource.cs.uid b/resources/MeetingActionResource.cs.uid new file mode 100644 index 0000000..c436cda --- /dev/null +++ b/resources/MeetingActionResource.cs.uid @@ -0,0 +1 @@ +uid://chl0yv2tsg2va diff --git a/resources/MeetingResource.cs b/resources/MeetingResource.cs index e2d6a27..bae1e2b 100644 --- a/resources/MeetingResource.cs +++ b/resources/MeetingResource.cs @@ -1,13 +1,32 @@ +using System.Linq; using Godot; +using Godot.Collections; +using yourareanaiceo; [GlobalClass] public partial class MeetingResource : Resource { + [Export] + public Array OnMeetingStartActions { get; set; } = []; + + [Export] + public Array OnMeetingEndActions { get; set; } = []; + [Export] public string Title { get; set; } [Export] public Color Color { get; set; } + + public void StartMeeting(GameState gameState) + { + OnMeetingStartActions.ToList().ForEach(m => m.Execute(gameState)); + } + + public void EndMeeting(GameState gameState) + { + OnMeetingEndActions.ToList().ForEach(m => m.Execute(gameState)); + } } public partial class DummyMeetingResource : MeetingResource diff --git a/resources/meetings/lockin.tres b/resources/meetings/lockin.tres index eea9800..6beacbb 100644 --- a/resources/meetings/lockin.tres +++ b/resources/meetings/lockin.tres @@ -1,9 +1,17 @@ [gd_resource type="Resource" script_class="MeetingResource" format=3 uid="uid://du72uxjqr0h4a"] [ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://resources/MeetingResource.cs" id="1_4yd4m"] +[ext_resource type="Script" uid="uid://cduoflv3vjfmg" path="res://resources/GainHypeAction.cs" id="1_qpv0b"] + +[sub_resource type="Resource" id="Resource_7t1gw"] +script = ExtResource("1_qpv0b") +Amount = 20 +metadata/_custom_type_script = "uid://cduoflv3vjfmg" [resource] script = ExtResource("1_4yd4m") +OnMeetingStartActions = Array[Object]([SubResource("Resource_7t1gw")]) +OnMeetingEndActions = null Title = "LOCK IN" Color = Color(0.73206806, 0.22440341, 0.33911285, 1) metadata/_custom_type_script = "uid://cuq38lbfa2v74" diff --git a/resources/meetings/work_product_1.tres b/resources/meetings/work_product_1.tres index 5950a94..c3f2bb6 100644 --- a/resources/meetings/work_product_1.tres +++ b/resources/meetings/work_product_1.tres @@ -1,9 +1,17 @@ [gd_resource type="Resource" script_class="MeetingResource" format=3 uid="uid://bcd4qf4i84pwf"] +[ext_resource type="Script" uid="uid://cduoflv3vjfmg" path="res://resources/GainHypeAction.cs" id="1_7t1gw"] [ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://resources/MeetingResource.cs" id="1_qndny"] +[sub_resource type="Resource" id="Resource_b6clr"] +script = ExtResource("1_7t1gw") +Amount = 10 +metadata/_custom_type_script = "uid://cduoflv3vjfmg" + [resource] script = ExtResource("1_qndny") +OnMeetingStartActions = Array[Object]([SubResource("Resource_b6clr")]) +OnMeetingEndActions = null Title = "Work on your Product" Color = Color(0.4354798, 0.3262509, 0.83488727, 1) metadata/_custom_type_script = "uid://cuq38lbfa2v74"