7-19-25 @ 1:16 AM
This commit is contained in:
@@ -3,7 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Actor : Sprite2D
|
||||
public partial class Actor : Node2D
|
||||
{
|
||||
public bool _available = false, _hovered = false, _selected = false;
|
||||
public int _health, _healthMax;
|
||||
@@ -15,6 +15,7 @@ public partial class Actor : Sprite2D
|
||||
public Ball _hoveredBall = null;
|
||||
public Ball _selectedBall = null;
|
||||
public Ball _heldBall = null;
|
||||
public ActorPanel _panel;
|
||||
|
||||
public Sprite2D _tempBallSprite = new();
|
||||
|
||||
@@ -23,7 +24,7 @@ public partial class Actor : Sprite2D
|
||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/actor.tscn");
|
||||
Actor newActor = scene.Instantiate<Actor>();
|
||||
|
||||
newActor.Texture = GD.Load<Texture2D>("res://art/ness.png");
|
||||
newActor.GetNode<Sprite2D>("Sprite").Texture = GD.Load<Texture2D>("res://art/ness.png");
|
||||
|
||||
Ball newBall = Ball._Create(0);
|
||||
newActor._balls.Add(newBall);
|
||||
@@ -44,6 +45,7 @@ public partial class Actor : Sprite2D
|
||||
newActor._healthMax = newActor._health;
|
||||
|
||||
ActorPanel newActorPanel = ActorPanel._Create(newActor);
|
||||
newActor._panel = newActorPanel;
|
||||
newActor.AddChild(newActorPanel);
|
||||
|
||||
return newActor;
|
||||
@@ -51,6 +53,13 @@ public partial class Actor : Sprite2D
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
if (_panel._hovered)
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_selected = true;
|
||||
}
|
||||
}
|
||||
if (_ballBag.Count > 0 && _selected)
|
||||
{
|
||||
if (_heldBall == null)
|
||||
@@ -65,6 +74,7 @@ public partial class Actor : Sprite2D
|
||||
{
|
||||
_heldBall = _ballBag[(_ballBag.IndexOf(_heldBall) - 1) < 0 ? ^1 : (_ballBag.IndexOf(_heldBall) - 1)];
|
||||
}
|
||||
|
||||
Vector2 mousePosition = GetViewport().GetMousePosition();
|
||||
if (_tempBallSprite.Texture == null)
|
||||
{
|
||||
@@ -73,28 +83,49 @@ public partial class Actor : Sprite2D
|
||||
AddChild(_tempBallSprite);
|
||||
}
|
||||
_tempBallSprite.Texture = _heldBall.GetNode<Sprite2D>("Image").Texture;
|
||||
_tempBallSprite.ZIndex = 1;
|
||||
}
|
||||
if (_startArea == null)
|
||||
{
|
||||
_startArea = Globals.Instance._currentBattle.GetNode<Table>("Table").GetNode<Area2D>("PlayerStartArea").GetNode<CollisionShape2D>("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"))
|
||||
_tempBallSprite.Position = mousePosition;
|
||||
if (_tempBallSprite.Position.X >= _startArea.GlobalPosition.X - ((RectangleShape2D)(_startArea.Shape)).Size.X / 2 && _tempBallSprite.Position.X <= _startArea.GlobalPosition.X + ((RectangleShape2D)(_startArea.Shape)).Size.X / 2 && _tempBallSprite.Position.Y >= _startArea.GlobalPosition.Y - ((RectangleShape2D)(_startArea.Shape)).Size.Y / 2 && _tempBallSprite.Position.Y <= _startArea.GlobalPosition.Y + ((RectangleShape2D)(_startArea.Shape)).Size.Y / 2)
|
||||
{
|
||||
_heldBall.Place(_tempBallSprite.Position);
|
||||
AddChild(_heldBall);
|
||||
int ballIndex = _ballBag.IndexOf(_heldBall);
|
||||
_ballBag.Remove(_heldBall);
|
||||
_tempBallSprite.Texture = null;
|
||||
if (_ballBag.Count > 0)
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_heldBall = _ballBag[ballIndex - (ballIndex > _ballBag.Count ? 1 : 0)];
|
||||
_heldBall.Place(_tempBallSprite.Position);
|
||||
int ballIndex = _ballBag.IndexOf(_heldBall);
|
||||
|
||||
AddChild(_heldBall);
|
||||
|
||||
_ballBag.Remove(_heldBall);
|
||||
_tempBallSprite.Texture = null;
|
||||
if (_ballBag.Count > 0)
|
||||
{
|
||||
_heldBall = _ballBag[ballIndex - (ballIndex > _ballBag.Count ? 1 : 0)];
|
||||
}
|
||||
else
|
||||
{
|
||||
_heldBall = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _balls.Count; i++)
|
||||
{
|
||||
if (_balls[i]._potted)
|
||||
{
|
||||
_balls[i]._potted = false;
|
||||
_balls[i].Sleeping = true;
|
||||
_ballBag.Add(_balls[i]);
|
||||
RemoveChild(_balls[i]);
|
||||
|
||||
}
|
||||
}
|
||||
if (_balls.Any(b => b._hovered))
|
||||
{
|
||||
_hoveredBall = _balls.Single(b => b._hovered);
|
||||
|
||||
Reference in New Issue
Block a user