
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
95 lines
2.7 KiB
C#
95 lines
2.7 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|