-
Notifications
You must be signed in to change notification settings - Fork 3
/
Parryable.cs
72 lines (67 loc) · 2.41 KB
/
Parryable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.Collections;
using UnityEngine;
using Logger = Modding.Logger;
namespace Fennel
{
internal class Parryable : MonoBehaviour
{
public static bool doingOne = false;
private void OnTriggerEnter2D(Collider2D col)
{
if (doingOne || col.gameObject.layer != 16) return;
doingOne = true;
//GameManager.instance.FreezeMoment(1);
StartCoroutine(GameManager.instance.FreezeMoment(0.04f, 0.15f, 0.04f, 0f));
HeroController.instance.NailParry();
GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
Fennel.preloadedGO["ClashTink"].transform.SetPosition2D(transform.position);
Fennel.preloadedGO["ClashTink"].GetComponent<AudioSource>().Play();
GameObject slash = col.transform.parent.gameObject;
float degrees = 0f;
PlayMakerFSM damagesEnemy = PlayMakerFSM.FindFsmOnGameObject(slash, "damages_enemy");
if (damagesEnemy != null)
{
degrees = damagesEnemy.FsmVariables.FindFsmFloat("direction").Value;
}
else return;
Vector3 pos = new Vector3();
if (degrees < 45f)
{
HeroController.instance.RecoilLeft();
pos = new Vector2(1.5f, 0f);
}
else if (degrees < 135f)
{
HeroController.instance.RecoilDown();
pos = new Vector2(0f, 1.5f);
}
else if (degrees < 225f)
{
HeroController.instance.RecoilRight();
pos = new Vector2(-1.5f, 0f);
}
else
{
HeroController.instance.Bounce();
pos = new Vector2(0f, -1.5f);
}
GameObject fx = Instantiate(Fennel.preloadedGO["parryFX"]);
fx.transform.SetPosition2D(HeroController.instance.transform.position);
fx.transform.position += pos;
fx.SetActive(true);
StartCoroutine(EndParry());
}
IEnumerator EndParry()
{
yield return null;
HeroController.instance.NailParryRecover();
yield return new WaitForSeconds(0.2f);
doingOne = false;
Log("No Error2");
}
private void Log(object ob)
{
Logger.Log("[Parryable] " + ob);
}
}
}