Files

67 lines
1.8 KiB
C#
Raw Permalink Normal View History

2021-11-22 00:52:19 +01:00
using UnityEngine;
2023-04-24 17:18:13 +03:00
public class Assist : DemonicsAnimator
2021-11-22 00:52:19 +01:00
{
2022-09-18 16:22:36 +03:00
[SerializeField] private AssistStatsSO _assistStatsSO = default;
[SerializeField] private GameObject _smokePrefab = default;
private Audio _audio;
private Transform _player;
private GameObject _hitEffect;
2021-11-22 00:52:19 +01:00
2022-09-18 16:22:36 +03:00
public AssistStatsSO AssistStats { get { return _assistStatsSO; } private set { } }
2021-11-22 00:52:19 +01:00
2022-09-18 16:22:36 +03:00
private void Awake()
{
_player = transform.root;
_audio = GetComponent<Audio>();
2023-01-14 19:39:35 +02:00
transform.SetParent(null);
2022-09-18 16:22:36 +03:00
}
2021-11-22 03:51:45 +01:00
2022-09-18 16:22:36 +03:00
public void SetAssist(AssistStatsSO assistStats)
{
_assistStatsSO = assistStats;
}
2022-01-15 10:40:44 +01:00
2023-01-12 19:12:56 +02:00
public void Attack(int frame)
2022-09-18 16:22:36 +03:00
{
2022-10-15 23:52:35 +02:00
gameObject.SetActive(true);
2022-09-18 16:22:36 +03:00
_audio.Sound("Attack").Play();
transform.SetParent(_player);
transform.localPosition = AssistStats.assistPosition;
transform.localScale = _player.localScale;
}
2023-01-23 18:31:58 +02:00
public void Simulate(PlayerNetwork player)
2023-01-14 19:39:35 +02:00
{
2023-01-23 18:31:58 +02:00
gameObject.SetActive(player.shadow.isOnScreen);
SetAnimation("Attack", player.shadow.animationFrames);
transform.position = new Vector2((float)player.shadow.position.x, (float)player.shadow.position.y);
transform.localScale = new Vector2(player.shadow.flip, 1);
2023-01-14 19:39:35 +02:00
}
2023-01-12 19:12:56 +02:00
public bool GetProjectile(string name, int frame)
2022-10-15 23:52:35 +02:00
{
2023-01-23 18:31:58 +02:00
return GetEvent(name, frame, out _).projectile;
2022-10-15 23:52:35 +02:00
}
protected override void AnimationEnded()
{
base.AnimationEnded();
gameObject.SetActive(false);
}
2022-09-18 16:22:36 +03:00
public void Recall()
{
2023-01-12 19:12:56 +02:00
if (_hitEffect != null)
2022-09-18 16:22:36 +03:00
{
2023-01-12 19:12:56 +02:00
_hitEffect.SetActive(false);
2022-09-18 16:22:36 +03:00
}
2022-10-17 10:53:16 +02:00
gameObject.SetActive(false);
2022-09-18 16:22:36 +03:00
}
2022-06-01 06:54:09 +02:00
2022-09-18 16:22:36 +03:00
public void HitboxCollidedGround(RaycastHit2D hit)
{
_audio.Sound("Destroyed").Play();
GameObject effect = Instantiate(_smokePrefab);
effect.transform.localPosition = hit.point;
}
2021-11-22 00:52:19 +01:00
}