diff --git a/Gameplay/Actor.cs b/Gameplay/Actor.cs index 2a4bbfa..26181ae 100644 --- a/Gameplay/Actor.cs +++ b/Gameplay/Actor.cs @@ -3,9 +3,10 @@ using System; using System.Collections.Generic; using System.Linq; -public partial class Actor : Node +public partial class Actor : Sprite2D { - public bool _available, _hovered, _selected; + public bool _available = false, _hovered = false, _selected = false; + public int _health, _healthMax; public CollisionShape2D _startArea; public List _cues = new(); public Cue _selectedCue = null; @@ -17,34 +18,40 @@ public partial class Actor : Node public Sprite2D _tempBallSprite = new(); - public static Actor Create(string SCENENAME) + public static Actor _Create() { - PackedScene scene = ResourceLoader.Load("res://Gameplay/" + SCENENAME + ".tscn"); + PackedScene scene = ResourceLoader.Load("res://Gameplay/actor.tscn"); Actor newActor = scene.Instantiate(); - return newActor; - } + + newActor.Texture = GD.Load("res://art/ness.png"); - public override void _Ready() - { - Ball newBall = Ball.Create("ball", 0); - _balls.Add(newBall); - newBall = Ball.Create("ball", 1); - _balls.Add(newBall); + Ball newBall = Ball._Create(0); + newActor._balls.Add(newBall); + newBall = Ball._Create(0); + newActor._balls.Add(newBall); - Cue newCue = Cue.Create("cue"); - AddChild(newCue); - _cues.Add(newCue); - for (int i = 0; i < _cues.Count; i++) + Cue newCue = Cue._Create(); + newActor.AddChild(newCue); + newActor._cues.Add(newCue); + for (int i = 0; i < newActor._cues.Count; i++) { - _cues[i].Shoot += OnCueShoot; + newActor._cues[i].Shoot += newActor.OnCueShoot; } - _ballBag = new(_balls); + newActor._ballBag = new(newActor._balls); + + newActor._health = 10; + newActor._healthMax = newActor._health; + + ActorPanel newActorPanel = ActorPanel._Create(newActor); + newActor.AddChild(newActorPanel); + + return newActor; } public override void _Process(double DELTA_) { - if (_ballBag.Count > 0) + if (_ballBag.Count > 0 && _selected) { if (_heldBall == null) { @@ -71,7 +78,7 @@ public partial class Actor : Node { _startArea = Globals.Instance._currentBattle.GetNode("Table").GetNode("PlayerStartArea").GetNode("CollisionShape2D"); } - + _tempBallSprite.Position = new Vector2(Math.Min(Math.Max(mousePosition.X, _startArea.GlobalPosition.X - ((RectangleShape2D)(_startArea.Shape)).Size.X / 2), _startArea.GlobalPosition.X + ((RectangleShape2D)(_startArea.Shape)).Size.X / 2), Math.Min(Math.Max(mousePosition.Y, _startArea.GlobalPosition.Y - ((RectangleShape2D)(_startArea.Shape)).Size.Y / 2), _startArea.GlobalPosition.Y + ((RectangleShape2D)(_startArea.Shape)).Size.Y / 2)); if (Input.IsActionJustReleased("left_click")) { @@ -133,7 +140,7 @@ public partial class Actor : Node //public void ResetCueBall() //{ - //_cueBall = Ball.Create("ball", 0, _startPosition); + //_cueBall = Ball._Create("ball", 0, _startPosition); //_cueBall.SetName("CueBall"); //AddChild(_cueBall); //Texture2D image = GD.Load("res://art/cue_ball.png"); diff --git a/Gameplay/ActorPanel.cs b/Gameplay/ActorPanel.cs new file mode 100644 index 0000000..915bf0d --- /dev/null +++ b/Gameplay/ActorPanel.cs @@ -0,0 +1,36 @@ +using Godot; +using System; + +public partial class ActorPanel : Panel +{ + public static ActorPanel _Create(Actor ACTOR) + { + PackedScene scene = ResourceLoader.Load("res://Gameplay/actor_panel.tscn"); + ActorPanel newActorPanel = scene.Instantiate(); + + newActorPanel.SetSprite(ACTOR.Texture); + newActorPanel.SetMax(ACTOR._healthMax); + newActorPanel.SetValue(ACTOR._health); + newActorPanel.SetPosition(new Vector2(1500, 0)); + + return newActorPanel; + } + public void SetPosition(Vector2 POSITION) + { + Position = POSITION; + } + public void SetSprite(Texture2D TEXTURE) + { + GetNode("Image").Texture = TEXTURE; + } + public void SetValue(int VALUE) + { + GetNode("Health").GetNode("Value").Text = VALUE.ToString(); + GetNode("Health").GetNode("Bar").Value = VALUE; + } + public void SetMax(int MAX) + { + GetNode("Health").GetNode("Max").Text = MAX.ToString(); + GetNode("Health").GetNode("Bar").MaxValue = MAX; + } +} diff --git a/Gameplay/ActorPanel.cs.uid b/Gameplay/ActorPanel.cs.uid new file mode 100644 index 0000000..5d90958 --- /dev/null +++ b/Gameplay/ActorPanel.cs.uid @@ -0,0 +1 @@ +uid://c4ekvurl6q7jn diff --git a/Gameplay/Ball.cs b/Gameplay/Ball.cs index f78d6fc..f2d013c 100644 --- a/Gameplay/Ball.cs +++ b/Gameplay/Ball.cs @@ -4,12 +4,13 @@ using System.Data; public partial class Ball : RigidBody2D { - public bool _placed, _potted, _available, _hovered, _selected, _aimed, _moving; + public bool _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _moving = false; + public int _defense, _defenseMax; public float _moveThreshold = 5.0f; - public static Ball Create(string SCENENAME, int NUMBER) + public static Ball _Create(int NUMBER) { - PackedScene scene = ResourceLoader.Load("res://Gameplay/"+SCENENAME+".tscn"); + PackedScene scene = ResourceLoader.Load("res://Gameplay/ball.tscn"); Ball newBall = scene.Instantiate(); string fileName; if (NUMBER == 0) @@ -25,15 +26,6 @@ public partial class Ball : RigidBody2D return newBall; } - public override void _Ready() - { - _available = true; - _hovered = false; - _selected = false; - _aimed = false; - _moving = false; - } - public override void _Process(double DELTA_) { if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold) diff --git a/Gameplay/Battle.cs b/Gameplay/Battle.cs index 6762496..6cc4a73 100644 --- a/Gameplay/Battle.cs +++ b/Gameplay/Battle.cs @@ -9,24 +9,41 @@ public partial class Battle : Node public bool _current; public Vector2 _startPosition = new Vector2(890, 340); public Player _player; + public Player _computer; + public Player _turn; public List _potted = new(); - public List _balls; - - - public override void _Ready() + public List _balls = new(); + public Table _table; + + public static Battle _Create() { - _player = GetNode("Player"); - Start(); - - List pockets = GetNode
("Table").GetChildren() + PackedScene scene = ResourceLoader.Load("res://Gameplay/battle.tscn"); + Battle newBattle = scene.Instantiate(); + + Player newPlayer = Player._Create(); + newBattle._player = newPlayer; + newBattle.AddChild(newPlayer); + + Table newTable = Table._Create(); + newTable.Position = Globals.Instance._screenCenter; + newBattle._table = newTable; + + List pockets = newBattle._table.GetChildren() .Where(n => n.GetName().ToString().ToLower().Contains("pocket")) .Select(n => (Area2D)n) .ToList(); for (int i = 0; i < pockets.Count; i++) { - pockets[i].BodyEntered += PottedBall; + pockets[i].BodyEntered += newBattle.PottedBall; } + newBattle.AddChild(newTable); + + return newBattle; + } + public override void _Ready() + { _balls = GetTree().GetNodesInGroup("balls").Select(b => (Ball)b).ToList(); + Start(); } public override void _Process(double DELTA_) @@ -37,21 +54,22 @@ public partial class Battle : Node public void GenerateBalls() { int count = 1; - int rows = 5; + int columns = 0; int diameter = 36; + Table table = GetNode
("Table"); for (int i = 0; i < 5; i++) { - for (int j = 0; j < rows; j++) + for (int j = 0; j <= columns; j++) { - Vector2 position = new Vector2(250 + (i*(diameter)), 267 + (j*(diameter)) + (i*(diameter / 2))); - Ball ball = Ball.Create("ball", count); + Vector2 position = new Vector2(table.GlobalPosition.X - (i * (diameter / 2)) + (j * (diameter)), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (i * diameter)); + Ball ball = Ball._Create(count); ball.Place(position); AddChild(ball); - + count += 1; } - rows -= 1; - + columns += 1; + } } @@ -83,10 +101,10 @@ public partial class Battle : Node { return; } - if (BODY == _player._actor._selectedBall) + if (BODY == _player._selectedActor._selectedBall) { - _player._actor._selectedBall._potted = true; - _player._actor._selectedBall._placed = false; + _player._selectedActor._selectedBall._potted = true; + _player._selectedActor._selectedBall._placed = false; } else { diff --git a/Gameplay/Cue.cs b/Gameplay/Cue.cs index 5e87459..a236a67 100644 --- a/Gameplay/Cue.cs +++ b/Gameplay/Cue.cs @@ -11,9 +11,9 @@ public partial class Cue : Sprite2D Vector2 _direction; public ProgressBar _progressBar; - public static Cue Create(string SCENENAME) + public static Cue _Create() { - PackedScene scene = ResourceLoader.Load("res://Gameplay/"+SCENENAME+".tscn"); + PackedScene scene = ResourceLoader.Load("res://Gameplay/cue.tscn"); Cue newCue = scene.Instantiate(); Texture2D image = GD.Load("res://art/cue.png"); newCue.Texture = image; diff --git a/Gameplay/Globals.cs b/Gameplay/Globals.cs index 277afad..13b262c 100644 --- a/Gameplay/Globals.cs +++ b/Gameplay/Globals.cs @@ -6,7 +6,10 @@ public partial class Globals : Node public static Globals Instance; public bool _anyMovement; + public Vector2 _screenSize; + public Vector2 _screenCenter; public Battle _currentBattle; + public override void _Ready() { diff --git a/Gameplay/Main.cs b/Gameplay/Main.cs index cea42f4..12c0644 100644 --- a/Gameplay/Main.cs +++ b/Gameplay/Main.cs @@ -5,7 +5,11 @@ public partial class Main : Node { public override void _Ready() { - + Globals.Instance._screenSize = GetViewport().GetVisibleRect().Size; + Globals.Instance._screenCenter = new Vector2(Globals.Instance._screenSize.X / 2, Globals.Instance._screenSize.Y / 2); + Battle newBattle = Battle._Create(); + Globals.Instance._currentBattle = newBattle; + AddChild(newBattle); } public override void _Process(double DELTA_) diff --git a/Gameplay/Player.cs b/Gameplay/Player.cs index 686974e..77eb6a1 100644 --- a/Gameplay/Player.cs +++ b/Gameplay/Player.cs @@ -1,23 +1,28 @@ using Godot; using System; +using System.Collections.Generic; public partial class Player : Node { public bool _available, _selected; - public Actor _actor; - public Battle _currentBattle; - - public override void _Ready() - { - _actor = Actor.Create("actor"); - AddChild(_actor); - } - - public override void _Process(double DELTA_) - { - - } - + public Actor _selectedActor; + public List _actors = new(); + public static Player _Create() + { + PackedScene scene = ResourceLoader.Load("res://Gameplay/player.tscn"); + Player newPlayer = scene.Instantiate(); + + Actor newActor = Actor._Create(); + newPlayer._actors.Add(newActor); + newPlayer.AddChild(newActor); + + return newPlayer; + } + + public override void _Process(double DELTA_) + { + + } } diff --git a/Gameplay/PowerBar.cs b/Gameplay/PowerBar.cs index 19b6e8f..575f29f 100644 --- a/Gameplay/PowerBar.cs +++ b/Gameplay/PowerBar.cs @@ -3,10 +3,7 @@ using System; public partial class PowerBar : ProgressBar { - public override void _Ready() - { - - } + public override void _Process(double DELTA_) { diff --git a/Gameplay/Table.cs b/Gameplay/Table.cs index 1c141ec..7763897 100644 --- a/Gameplay/Table.cs +++ b/Gameplay/Table.cs @@ -4,5 +4,11 @@ using System; public partial class Table : Sprite2D { - + public static Table _Create() + { + PackedScene scene = ResourceLoader.Load("res://Gameplay/table.tscn"); + Table newTable = scene.Instantiate
(); + + return newTable; + } } diff --git a/Gameplay/actor.tscn b/Gameplay/actor.tscn index 844bd18..873f669 100644 --- a/Gameplay/actor.tscn +++ b/Gameplay/actor.tscn @@ -2,7 +2,5 @@ [ext_resource type="Script" uid="uid://b4mr2vn8mw6r4" path="res://Gameplay/Actor.cs" id="1_hr3hk"] -[node name="Actor" type="Node"] +[node name="Actor" type="Sprite2D"] script = ExtResource("1_hr3hk") - -[node name="StartPosition" type="Marker2D" parent="."] diff --git a/Gameplay/actor_panel.tscn b/Gameplay/actor_panel.tscn new file mode 100644 index 0000000..0db6556 --- /dev/null +++ b/Gameplay/actor_panel.tscn @@ -0,0 +1,89 @@ +[gd_scene load_steps=5 format=3 uid="uid://8kv00jc35dma"] + +[ext_resource type="Script" uid="uid://c4ekvurl6q7jn" path="res://Gameplay/ActorPanel.cs" id="1_dg1wx"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e1ofl"] +bg_color = Color(1, 1, 1, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mmnuv"] +bg_color = Color(0.259294, 0.259294, 0.259294, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dg1wx"] +bg_color = Color(0.6, 1, 0.6, 1) + +[node name="ActorPanel" type="Panel"] +anchors_preset = -1 +offset_left = -100.0 +offset_top = -150.0 +offset_right = 100.0 +offset_bottom = 150.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_e1ofl") +script = ExtResource("1_dg1wx") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 0 +offset_right = 207.0 +offset_bottom = 40.0 +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "Actor Name" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Image" type="Sprite2D" parent="."] +position = Vector2(100, 75) + +[node name="Health" type="Node2D" parent="."] +position = Vector2(100, 150) + +[node name="Name" type="RichTextLabel" parent="Health"] +offset_left = -80.0 +offset_top = -26.0 +offset_bottom = -1.0 +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "Health" +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="Max" type="RichTextLabel" parent="Health"] +offset_top = -26.0 +offset_right = 80.0 +offset_bottom = -1.0 +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "000" +horizontal_alignment = 2 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="Separator" type="RichTextLabel" parent="Health"] +offset_top = -26.0 +offset_right = 50.0 +offset_bottom = -1.0 +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "/ +" +horizontal_alignment = 2 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="Value" type="RichTextLabel" parent="Health"] +offset_top = -26.0 +offset_right = 40.0 +offset_bottom = -1.0 +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "000" +horizontal_alignment = 2 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="Bar" type="ProgressBar" parent="Health"] +offset_left = -80.0 +offset_top = -3.0 +offset_right = 81.0 +offset_bottom = 4.0 +theme_override_styles/background = SubResource("StyleBoxFlat_mmnuv") +theme_override_styles/fill = SubResource("StyleBoxFlat_dg1wx") +step = 1.0 +show_percentage = false +metadata/_edit_use_anchors_ = true diff --git a/Gameplay/battle.tscn b/Gameplay/battle.tscn index 1476f51..150e8fd 100644 --- a/Gameplay/battle.tscn +++ b/Gameplay/battle.tscn @@ -1,27 +1,6 @@ -[gd_scene load_steps=5 format=3 uid="uid://5ymxo45j4ryt"] +[gd_scene load_steps=2 format=3 uid="uid://5ymxo45j4ryt"] [ext_resource type="Script" uid="uid://0c1u4l8lu07h" path="res://Gameplay/Battle.cs" id="1_i431l"] -[ext_resource type="PackedScene" uid="uid://dsprg4uahkylm" path="res://Gameplay/table.tscn" id="2_6t8i5"] -[ext_resource type="PackedScene" uid="uid://cdaxqopr35lll" path="res://Gameplay/player.tscn" id="2_ogveh"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tivnh"] -bg_color = Color(0.111197, 0.111197, 0.111197, 1) -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 [node name="Battle" type="Node" groups=["battles"]] script = ExtResource("1_i431l") - -[node name="Table" parent="." instance=ExtResource("2_6t8i5")] -position = Vector2(357, 539) - -[node name="Player" parent="." instance=ExtResource("2_ogveh")] - -[node name="PottedPanel" type="Panel" parent="."] -offset_left = 694.0 -offset_top = 123.0 -offset_right = 815.0 -offset_bottom = 1003.0 -theme_override_styles/panel = SubResource("StyleBoxFlat_tivnh") diff --git a/Gameplay/main.tscn b/Gameplay/main.tscn index 9b7bce3..94d2917 100644 --- a/Gameplay/main.tscn +++ b/Gameplay/main.tscn @@ -1,9 +1,6 @@ -[gd_scene load_steps=3 format=3 uid="uid://yqtgkxjjexag"] +[gd_scene load_steps=2 format=3 uid="uid://yqtgkxjjexag"] [ext_resource type="Script" uid="uid://v6ovq4snxruc" path="res://Gameplay/Main.cs" id="1_0xm2m"] -[ext_resource type="PackedScene" uid="uid://5ymxo45j4ryt" path="res://Gameplay/battle.tscn" id="3_vkc8e"] [node name="Main" type="Node"] script = ExtResource("1_0xm2m") - -[node name="Battle" parent="." instance=ExtResource("3_vkc8e")] diff --git a/art/jeff.png b/art/jeff.png new file mode 100644 index 0000000..35faad6 Binary files /dev/null and b/art/jeff.png differ diff --git a/art/jeff.png.import b/art/jeff.png.import new file mode 100644 index 0000000..d4e0305 --- /dev/null +++ b/art/jeff.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c6eui3f3rgcd7" +path="res://.godot/imported/jeff.png-5d89b47d50f05d86f96544842e596d2b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/jeff.png" +dest_files=["res://.godot/imported/jeff.png-5d89b47d50f05d86f96544842e596d2b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/art/ness.png b/art/ness.png new file mode 100644 index 0000000..aa9a6b5 Binary files /dev/null and b/art/ness.png differ diff --git a/art/ness.png.import b/art/ness.png.import new file mode 100644 index 0000000..08f6e1d --- /dev/null +++ b/art/ness.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://djf4xoheoxq8j" +path="res://.godot/imported/ness.png-a622ea535e2011d0b2b7179ab9a56990.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/ness.png" +dest_files=["res://.godot/imported/ness.png-a622ea535e2011d0b2b7179ab9a56990.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/art/paula.png b/art/paula.png new file mode 100644 index 0000000..27b7add Binary files /dev/null and b/art/paula.png differ diff --git a/art/paula.png.import b/art/paula.png.import new file mode 100644 index 0000000..c29b969 --- /dev/null +++ b/art/paula.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcjfn7km102yj" +path="res://.godot/imported/paula.png-1324567e16dda0b6556a8cda98993e45.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/paula.png" +dest_files=["res://.godot/imported/paula.png-1324567e16dda0b6556a8cda98993e45.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/art/poo.png b/art/poo.png new file mode 100644 index 0000000..3f554e1 Binary files /dev/null and b/art/poo.png differ diff --git a/art/poo.png.import b/art/poo.png.import new file mode 100644 index 0000000..bf7e27c --- /dev/null +++ b/art/poo.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bjfe0tmumvsmi" +path="res://.godot/imported/poo.png-53bba34069cd30827409c19e31039eb5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/poo.png" +dest_files=["res://.godot/imported/poo.png-53bba34069cd30827409c19e31039eb5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1