74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Abstract class to handle the blackhole forces of the game
|
|
/// </summary>
|
|
public class BlackHoleForce : MonoBehaviour
|
|
{
|
|
// Bool to set the GO to ignore the blackholes pull
|
|
public bool blackHolePullImmunue;
|
|
|
|
protected Rigidbody _objectRigidBody;
|
|
protected Transform _currentTransform;
|
|
protected HoverMovement _movement;
|
|
|
|
private void Awake()
|
|
{
|
|
// Get the rigidbody and movement script attached to the GO for use
|
|
_objectRigidBody = gameObject.GetComponent<Rigidbody>();
|
|
_movement = gameObject.GetComponent<HoverMovement>();
|
|
DoAwakeTasks();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Virtual method to allow a child script to do tasks during the Awake call
|
|
/// </summary>
|
|
protected virtual void DoAwakeTasks()
|
|
{
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
// Stop using the rigidbody default rotation and gravity settings
|
|
_objectRigidBody.constraints = RigidbodyConstraints.FreezeRotation;
|
|
_objectRigidBody.useGravity = false;
|
|
_currentTransform = transform;
|
|
|
|
// Add the BHF to the black holes list of GO's with blackhole physics
|
|
BlackHoleManager.blackHoleForceObjects.Add(this);
|
|
|
|
DoStartTasks();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method for letting a child script do start tasks during the start call
|
|
/// </summary>
|
|
protected virtual void DoStartTasks()
|
|
{
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
// Remove us from the blackhole force list on the blackhole
|
|
BlackHoleManager.blackHoleForceObjects.Remove(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Virtual method to Apply the actual blackhole force to the attached gameobject, this allows for each GO type to react differently
|
|
/// </summary>
|
|
/// <param name="appliedForce">Amount of force applied to the object from the blackhole</param>
|
|
public virtual void ApplyBlackHoleForce(float appliedForce)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Virtual method to call when an object has hit the blackhole
|
|
/// </summary>
|
|
public virtual void HitBlackHole()
|
|
{
|
|
}
|
|
}
|