Added new sounds needed for game
Added blackhole swirl texture and materials Added Magnet, Hunter and Drop core powerups and script overhaul for powerups in general Added Scenes and Cinematic changes for the game, win and death screens Added a score Changed the way enemy spawns work Removed unused scripts
This commit is contained in:
60
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs
Normal file
60
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AttachablePowerUpEffect : PowerUpEffect
|
||||
{
|
||||
public string uiReadyText;
|
||||
[TextArea]
|
||||
public string uiDescText;
|
||||
|
||||
public AudioClip onUseSFX;
|
||||
public AudioClip onAltSFX;
|
||||
|
||||
public float abilityCooldown;
|
||||
protected bool _abilityCooldown;
|
||||
protected TimerHelper _abilityCooldownTimer;
|
||||
|
||||
public bool CooldownStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return _abilityCooldown;
|
||||
}
|
||||
}
|
||||
|
||||
public float CooldownTimePercent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _abilityCooldownTimer.Position;
|
||||
}
|
||||
}
|
||||
|
||||
public float CooldownTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _abilityCooldownTimer.CurrentTick;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool OnAltUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual T GetStatChangesValue<T>(string statName, T currentValue)
|
||||
{
|
||||
switch(statName)
|
||||
{
|
||||
default:
|
||||
return currentValue;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2d66670f3ff6264c8f188a9ed6812a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
207
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs
Normal file
207
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs
Normal file
@ -0,0 +1,207 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
public class ChaseAttachedPowerUpEffect : AttachablePowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private Rigidbody _playerRigidBody;
|
||||
|
||||
public float chargeForce;
|
||||
public float targetRange;
|
||||
public GameObject selectorGO;
|
||||
|
||||
private GameObject _currentTarget;
|
||||
|
||||
public float scanCooldown;
|
||||
private bool _scanCooldown;
|
||||
private TimerHelper _scanTimer;
|
||||
|
||||
private Queue<GameObject> _scannedObjects = new Queue<GameObject>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_playerRigidBody = _player.GetComponent<Rigidbody>();
|
||||
_abilityCooldown = false;
|
||||
_abilityCooldownTimer = new TimerHelper(abilityCooldown, false);
|
||||
_scanCooldown = false;
|
||||
_scanTimer = new TimerHelper(scanCooldown, false);
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
PlayerColliderManager playerCM = _player.GetComponent<PlayerColliderManager>();
|
||||
if (playerCM != null)
|
||||
{
|
||||
playerCM.SetImmune(2.0f);
|
||||
}
|
||||
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Vector3 directionToTarget = _currentTarget.transform.position - _player.transform.position;
|
||||
_playerRigidBody.AddForce(directionToTarget.normalized * chargeForce, ForceMode.VelocityChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerRigidBody.AddForce(_player.transform.forward * chargeForce, ForceMode.VelocityChange);
|
||||
}
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("PowerUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onUseSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onUseSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnAltUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
if (!_scanCooldown)
|
||||
{
|
||||
bool result = false;
|
||||
Queue<GameObject> currentScan = new Queue<GameObject>();
|
||||
RaycastHit[] raycastHits = Physics.SphereCastAll(_player.transform.position, 30.0f, _player.transform.forward, targetRange, LayerMask.GetMask("Enemies"));
|
||||
if (raycastHits.Length > 0)
|
||||
{
|
||||
foreach (RaycastHit currentHit in raycastHits)
|
||||
{
|
||||
GameObject currentGO = currentHit.transform.gameObject;
|
||||
if (currentGO.tag != "Asteroid")
|
||||
{
|
||||
if (!currentScan.Contains(currentGO))
|
||||
{
|
||||
currentScan.Enqueue(currentGO);
|
||||
if (!_scannedObjects.Contains(currentGO))
|
||||
{
|
||||
_scannedObjects.Enqueue(currentGO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_scannedObjects = new Queue<GameObject>(_scannedObjects.Where(s => currentScan.Any(c => c == s)));
|
||||
|
||||
if (_scannedObjects.Count > 0)
|
||||
{
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform lastTargetGO = _currentTarget.transform.Find("ShipModel/Target");
|
||||
if (lastTargetGO != null)
|
||||
{
|
||||
Destroy(lastTargetGO.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
_currentTarget = _scannedObjects.Dequeue();
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform shipModel = _currentTarget.transform.Find("ShipModel");
|
||||
if (shipModel != null)
|
||||
{
|
||||
GameObject newTarget = Instantiate(selectorGO, shipModel);
|
||||
newTarget.name = "Target";
|
||||
}
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform lastTargetGO = _currentTarget.transform.Find("ShipModel/Target");
|
||||
if (lastTargetGO != null)
|
||||
{
|
||||
Destroy(lastTargetGO.gameObject);
|
||||
}
|
||||
}
|
||||
_currentTarget = null;
|
||||
}
|
||||
|
||||
if (onAltSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onAltSFX);
|
||||
}
|
||||
|
||||
_scanTimer.RestartTimer();
|
||||
_scanCooldown = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform lastTargetGO = _currentTarget.transform.Find("ShipModel/Target");
|
||||
if (lastTargetGO != null)
|
||||
{
|
||||
Destroy(lastTargetGO.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_abilityCooldown)
|
||||
{
|
||||
if (_abilityCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_abilityCooldown = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_scanCooldown)
|
||||
{
|
||||
if (_scanTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_scanCooldown = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
uiReadyText = "Target Locked!";
|
||||
}
|
||||
else
|
||||
{
|
||||
uiReadyText = "Charge Ready";
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76658df4e112a4242933ce765ec32517
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs
Normal file
39
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChasePowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
public GameObject coredVersionGO;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
}
|
||||
|
||||
public override void OnPickUp()
|
||||
{
|
||||
Transform coreHolder = _player.transform.Find("PlayerModel/CoreHolder");
|
||||
for (int i = 0; i < coreHolder.transform.childCount; i++)
|
||||
{
|
||||
Destroy(coreHolder.GetChild(i).gameObject);
|
||||
}
|
||||
GameObject newSpecialCore = Instantiate(coredVersionGO, coreHolder);
|
||||
AttachablePowerUpEffect newDropEffect = newSpecialCore.GetComponent<ChaseAttachedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newDropEffect);
|
||||
|
||||
if (_currentGameEngine != null)
|
||||
{
|
||||
_currentGameEngine.QueueDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0acb9ef365b6ca64f9de242050419158
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
94
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs
Normal file
94
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DropAttachedPowerUpEffect : AttachablePowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private PlayerColliderManager _playerColliderManager;
|
||||
private Rigidbody _playerRigidBody;
|
||||
|
||||
public float dropPowerForce;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_playerRigidBody = _player.GetComponent<Rigidbody>();
|
||||
_playerColliderManager = _player.GetComponent<PlayerColliderManager>();
|
||||
_abilityCooldown = false;
|
||||
_abilityCooldownTimer = new TimerHelper(abilityCooldown, false);
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
_playerRigidBody.AddForce(-_player.transform.up * dropPowerForce, ForceMode.VelocityChange);
|
||||
_playerColliderManager.SetDeadly();
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("PowerUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onUseSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onUseSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnAltUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
_playerRigidBody.AddForce(_player.transform.up * dropPowerForce, ForceMode.VelocityChange);
|
||||
_playerColliderManager.SetDeadly();
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("AltUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onAltSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onAltSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_abilityCooldown)
|
||||
{
|
||||
if (_abilityCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_abilityCooldown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 454df0da5160bf04ba9d3c2b668abb15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Assets/Scripts/PowerUps/DropPowerUpEffect.cs
Normal file
39
Assets/Scripts/PowerUps/DropPowerUpEffect.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DropPowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
public GameObject coredVersionGO;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
}
|
||||
|
||||
public override void OnPickUp()
|
||||
{
|
||||
Transform coreHolder = _player.transform.Find("PlayerModel/CoreHolder");
|
||||
for (int i = 0; i < coreHolder.transform.childCount; i++)
|
||||
{
|
||||
Destroy(coreHolder.GetChild(i).gameObject);
|
||||
}
|
||||
GameObject newSpecialCore = Instantiate(coredVersionGO, coreHolder);
|
||||
AttachablePowerUpEffect newDropEffect = newSpecialCore.GetComponent<DropAttachedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newDropEffect);
|
||||
|
||||
if (_currentGameEngine != null)
|
||||
{
|
||||
_currentGameEngine.QueueDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/DropPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/DropPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23358c3666402094fb34adca754e8461
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
147
Assets/Scripts/PowerUps/MagnetAttachedPowerUpEffect.cs
Normal file
147
Assets/Scripts/PowerUps/MagnetAttachedPowerUpEffect.cs
Normal file
@ -0,0 +1,147 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MagnetAttachedPowerUpEffect : AttachablePowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
|
||||
public float magnetPowerForce;
|
||||
public float magnetPowerRange;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_abilityCooldown = false;
|
||||
_abilityCooldownTimer = new TimerHelper(abilityCooldown, false);
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
foreach (BlackHoleForce currentBHF in BlackHoleManager.blackHoleForceObjects)
|
||||
{
|
||||
GameObject currentObject = currentBHF.gameObject;
|
||||
if (currentObject.tag != "Player")
|
||||
{
|
||||
Vector3 directionToObject = gameObject.transform.position - currentObject.transform.position;
|
||||
float distanceToObject = directionToObject.magnitude;
|
||||
if (distanceToObject <= magnetPowerRange)
|
||||
{
|
||||
Rigidbody currentRigidBody = currentObject.GetComponent<Rigidbody>();
|
||||
if (currentRigidBody != null)
|
||||
{
|
||||
currentRigidBody.AddForce(directionToObject.normalized * magnetPowerForce, ForceMode.VelocityChange);
|
||||
}
|
||||
if (currentObject.tag == "Enemy")
|
||||
{
|
||||
EnemyColliderManager enemyColliderManager = currentObject.GetComponent<EnemyColliderManager>();
|
||||
enemyColliderManager.MagnetizeEnemy();
|
||||
}
|
||||
else if (currentObject.tag == "Mine")
|
||||
{
|
||||
MineColliderManager mineCM = currentObject.GetComponent<MineColliderManager>();
|
||||
if (mineCM != null)
|
||||
{
|
||||
mineCM.magnetizeMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("PowerUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onUseSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onUseSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnAltUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
foreach (BlackHoleForce currentBHF in BlackHoleManager.blackHoleForceObjects)
|
||||
{
|
||||
GameObject currentObject = currentBHF.gameObject;
|
||||
if (currentObject.tag != "Player")
|
||||
{
|
||||
Vector3 directionToObject = gameObject.transform.position - currentObject.transform.position;
|
||||
float distanceToObject = directionToObject.magnitude;
|
||||
if (distanceToObject <= magnetPowerRange)
|
||||
{
|
||||
Rigidbody currentRigidBody = currentObject.GetComponent<Rigidbody>();
|
||||
if (currentRigidBody != null)
|
||||
{
|
||||
currentRigidBody.AddForce(-directionToObject.normalized * magnetPowerForce, ForceMode.VelocityChange);
|
||||
}
|
||||
if (currentObject.tag == "Enemy")
|
||||
{
|
||||
EnemyColliderManager enemyColliderManager = currentObject.GetComponent<EnemyColliderManager>();
|
||||
enemyColliderManager.MagnetizeEnemy();
|
||||
}
|
||||
else if (currentObject.tag == "Mine")
|
||||
{
|
||||
MineColliderManager mineCM = currentObject.GetComponent<MineColliderManager>();
|
||||
if (mineCM != null)
|
||||
{
|
||||
mineCM.magnetizeMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("AltUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onAltSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onAltSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_abilityCooldown)
|
||||
{
|
||||
if (_abilityCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_abilityCooldown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MagnetEmbedPowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
|
||||
public float magnetPowerForce;
|
||||
public float magnetPowerRange;
|
||||
|
||||
public float magnetPowerCooldown;
|
||||
private bool _magnetPowerCooldown;
|
||||
private TimerHelper _magnetPowerCooldownTimer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_magnetPowerCooldown = false;
|
||||
_magnetPowerCooldownTimer = new TimerHelper(magnetPowerCooldown, false);
|
||||
}
|
||||
|
||||
public override void OnPickUp()
|
||||
{
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_magnetPowerCooldown)
|
||||
{
|
||||
foreach (BlackHoleForce currentBHF in BlackHoleManager.blackHoleForceObjects)
|
||||
{
|
||||
GameObject currentObject = currentBHF.gameObject;
|
||||
if (currentObject.tag != "Player")
|
||||
{
|
||||
Vector3 directionToObject = gameObject.transform.position - currentObject.transform.position;
|
||||
float distanceToObject = directionToObject.magnitude;
|
||||
if (distanceToObject <= magnetPowerRange)
|
||||
{
|
||||
Rigidbody currentRigidBody = currentObject.GetComponent<Rigidbody>();
|
||||
if (currentRigidBody != null)
|
||||
{
|
||||
currentRigidBody.AddForce(directionToObject * magnetPowerForce, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_magnetPowerCooldown = true;
|
||||
_magnetPowerCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override float CooldownStatus()
|
||||
{
|
||||
return _magnetPowerCooldownTimer.Position;
|
||||
}
|
||||
|
||||
public override bool PowerUpReady()
|
||||
{
|
||||
if (_magnetPowerCooldown)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_magnetPowerCooldown)
|
||||
{
|
||||
if (_magnetPowerCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_magnetPowerCooldown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ public class MagnetPowerUpEffect : PowerUpEffect
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
}
|
||||
@ -23,26 +24,16 @@ public class MagnetPowerUpEffect : PowerUpEffect
|
||||
Destroy(coreHolder.GetChild(i).gameObject);
|
||||
}
|
||||
GameObject newSpecialCore = Instantiate(coredVersionGO, coreHolder);
|
||||
PowerUpEffect newMagnetEffect = newSpecialCore.GetComponent<MagnetEmbedPowerUpEffect>();
|
||||
AttachablePowerUpEffect newMagnetEffect = newSpecialCore.GetComponent<MagnetAttachedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newMagnetEffect);
|
||||
|
||||
if (_currentGameEngine != null)
|
||||
{
|
||||
_currentGameEngine.QueueDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override float CooldownStatus()
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public override bool PowerUpReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,12 @@ using UnityEngine;
|
||||
public class PowerUpEffect : MonoBehaviour
|
||||
{
|
||||
public string powerUpName;
|
||||
public string powerUpDesc;
|
||||
public string powerUpDesc;
|
||||
public GameObject powerUpModel;
|
||||
|
||||
protected GameEngine _currentGameEngine;
|
||||
public int dialogIndex;
|
||||
|
||||
public virtual void OnPickUp()
|
||||
{
|
||||
ApplyEffect();
|
||||
@ -16,20 +19,4 @@ public class PowerUpEffect : MonoBehaviour
|
||||
public virtual void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual float CooldownStatus()
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public virtual bool PowerUpReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user