70 lines
1.2 KiB
C#
70 lines
1.2 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Data;
|
|
|
|
public partial class Ball : RigidBody2D
|
|
{
|
|
public bool _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _moving = false, _isCue = false;
|
|
public int _defense, _defenseMax;
|
|
public float _moveThreshold = 5.0f;
|
|
|
|
public static Ball _Create()
|
|
{
|
|
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/ball.tscn");
|
|
Ball newBall = scene.Instantiate<Ball>();
|
|
|
|
return newBall;
|
|
}
|
|
|
|
public override void _Process(double DELTA_)
|
|
{
|
|
if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold)
|
|
{
|
|
Sleeping = true;
|
|
if (_moving)
|
|
{
|
|
_moving = false;
|
|
}
|
|
}
|
|
else if (LinearVelocity.Length() >= _moveThreshold)
|
|
{
|
|
if (!_moving)
|
|
{
|
|
_moving = true;
|
|
}
|
|
}
|
|
|
|
if (Globals.Instance._anyMovement)
|
|
{
|
|
if (_available)
|
|
{
|
|
_available = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!_available)
|
|
{
|
|
_available = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Place(Vector2 POSITION)
|
|
{
|
|
_placed = true;
|
|
Position = POSITION;
|
|
}
|
|
|
|
private void OnMouseEntered()
|
|
{
|
|
_hovered = true;
|
|
}
|
|
|
|
private void OnMouseExited()
|
|
{
|
|
_hovered = false;
|
|
}
|
|
|
|
}
|