Files
blackhole-escape/Assets/Scripts/Scripts/AsteroidBlackHoleForce.cs
iDunnoDev 0360907df1 Added Main menu Changes to UI
Added Rules Menu Changes to UI
Added Cutscenes to the rules scene
Reorganised Files
2022-06-22 13:30:58 +01:00

46 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Class to handle the Asteroids Blackhole forces
/// </summary>
public class AsteroidBlackHoleForce : BlackHoleForce
{
public float gravityForceOffsetPercent;
private BlackHoleManager _currentBlackHoleManager;
protected override void DoAwakeTasks()
{
// Get the current blackhole
_currentBlackHoleManager = GameObject.Find("BlackHole").GetComponent<BlackHoleManager>();
base.DoAwakeTasks();
}
public override void ApplyBlackHoleForce(float appliedForce)
{
if (!blackHolePullImmunue)
{
_objectRigidBody.AddForce((-_objectRigidBody.transform.up * appliedForce) * gravityForceOffsetPercent);
}
}
/// <summary>
/// Method for dealing with what happens when this object hits the blackhole
/// </summary>
public override void HitBlackHole()
{
// Call a special function for growing the black hole, this is because it takes multiple asteroids to grow it
_currentBlackHoleManager.AsteroidGrow();
ObjectSpawning attachedShared = gameObject.GetComponent<AsteroidObjectShared>().Spawner;
if (attachedShared)
{
attachedShared.ReduceSpawnedCount();
}
Destroy(gameObject);
base.HitBlackHole();
}
}