7-14-25 1:27PM
This commit is contained in:
@@ -3,57 +3,61 @@ using System;
|
||||
|
||||
public partial class Ball : RigidBody2D
|
||||
{
|
||||
|
||||
public bool _placed, _available, _hovered, _selected, _aimed, _moving;
|
||||
public bool _placed, _potted, _available, _hovered, _selected, _aimed, _moving;
|
||||
public float _moveThreshold = 5.0f;
|
||||
|
||||
public static Ball Create(int number, Vector2 position)
|
||||
public static Ball Create(string SCENENAME, int NUMBER)
|
||||
{
|
||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/ball.tscn");
|
||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/"+SCENENAME+".tscn");
|
||||
Ball newBall = scene.Instantiate<Ball>();
|
||||
string fileName;
|
||||
if (number == 0)
|
||||
if (NUMBER == 0)
|
||||
{
|
||||
fileName = "res://art/cue_ball.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = "res://art/ball_"+number+".png";
|
||||
fileName = "res://art/ball_"+NUMBER+".png";
|
||||
}
|
||||
Texture2D image = GD.Load<Texture2D>(fileName);
|
||||
newBall.GetNode<Sprite2D>("Image").Texture = image;
|
||||
newBall.Position = position;
|
||||
return newBall;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
SetProcess(false);
|
||||
_placed = false;
|
||||
_available = false;
|
||||
_hovered = false;
|
||||
_selected = false;
|
||||
_aimed = false;
|
||||
_moving = false;
|
||||
_available = false;
|
||||
}
|
||||
|
||||
public override void _Process(double delta_)
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
_moving = false;
|
||||
if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold)
|
||||
{
|
||||
Sleeping = true;
|
||||
if (_moving)
|
||||
{
|
||||
_moving = false;
|
||||
}
|
||||
}
|
||||
else if (LinearVelocity.Length() >= _moveThreshold)
|
||||
{
|
||||
_moving = true;
|
||||
if (!_moving)
|
||||
{
|
||||
_moving = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!((Battle)GetParent()).CheckMovement())
|
||||
if (!Globals.Instance._anyMovement)
|
||||
{
|
||||
if (!_available)
|
||||
{
|
||||
_available = true;
|
||||
GetParent().GetNode<Cue>("Cue").ShowCue();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -61,9 +65,26 @@ public partial class Ball : RigidBody2D
|
||||
if (_available)
|
||||
{
|
||||
_available = false;
|
||||
GetParent().GetNode<Cue>("Cue").HideCue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Place(Vector2 POSITION)
|
||||
{
|
||||
_placed = true;
|
||||
Position = POSITION;
|
||||
SetProcess(true);
|
||||
}
|
||||
|
||||
private void OnMouseEntered()
|
||||
{
|
||||
_hovered = true;
|
||||
}
|
||||
|
||||
private void OnMouseExited()
|
||||
{
|
||||
_hovered = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user