123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- using System;
- using System.Collections;
- using DatabaseModel;
- using DG.Tweening;
- using GameWorld;
- using LitJson;
- using OnionSkin;
- using UnityEngine;
- public class DahalFAnim : BaseBehaviour
- {
- private PlayerManager player
- {
- get
- {
- return R.Player;
- }
- }
- private void Start()
- {
- this._eAction = base.GetComponent<DahalFAction>();
- this._eAttr = base.GetComponent<EnemyAttribute>();
- this._atk = base.GetComponentInChildren<EnemyAtk>();
- this._atkData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.达哈尔终极版];
- this._onion = base.GetComponent<OnionCreator>();
- this._baseHurt = base.GetComponent<EnemyBaseHurt>();
- }
- private void Update()
- {
- if (this._eAttr.isDead)
- {
- return;
- }
- this.UpdateFlyToFall();
- this.UpdateHitGround();
- this.UpdatePushDown();
- }
- private void UpdateFlyToFall()
- {
- if (this._eAttr.isFlyingUp)
- {
- bool flag = this.MaxFlyHeight > 0f && this._eAttr.height >= this.MaxFlyHeight;
- if (flag)
- {
- Vector2 currentSpeed = this._eAttr.timeController.GetCurrentSpeed();
- currentSpeed.y = 0f;
- this._eAttr.timeController.SetSpeed(currentSpeed);
- }
- if (this._eAttr.timeController.GetCurrentSpeed().y <= 0f)
- {
- this._eAttr.isFlyingUp = false;
- this._eAction.AnimChangeState("HitToFly3", 1f);
- }
- }
- }
- private void UpdateHitGround()
- {
- if (this._eAttr.checkHitGround && this._eAttr.isOnGround)
- {
- this._eAttr.checkHitGround = false;
- R.Effect.Generate(6, base.transform, default(Vector3), default(Vector3), default(Vector3), true);
- this._eAction.AnimChangeState("HitGround", 1f);
- }
- }
- private void UpdatePushDown()
- {
- if (this._pushDown && this._eAttr.isOnGround)
- {
- this._pushDown = false;
- this._eAttr.timeController.SetGravity(1f);
- Vector2 currentSpeed = this._eAttr.timeController.GetCurrentSpeed();
- currentSpeed.x = (float)(5 * this._eAttr.faceDir);
- this._eAttr.timeController.SetSpeed(currentSpeed);
- this._eAction.AnimChangeState(DahalFAction.StateEnum.AirPushEnd, 1f);
- }
- }
- public void ChangeState_Anim(DahalFAction.StateEnum sta)
- {
- this._eAction.AnimChangeState(sta, 1f);
- }
- public void HitGround()
- {
- this._eAttr.checkHitGround = true;
- this._pushDown = false;
- }
- public void FlyUp()
- {
- this._eAttr.isFlyingUp = true;
- this._pushDown = false;
- }
- public void GetUp()
- {
- this._eAttr.currentActionInterruptPoint = 0;
- this.BackToIdle();
- }
- public void Atk1Over(int move)
- {
- if (move != 1)
- {
- if (move != 2)
- {
- if (move == 3)
- {
- this.GravityScale(1f);
- this.ChangeState_Anim(DahalFAction.StateEnum.Atk1End1);
- }
- }
- else
- {
- this.ChangeState_Anim(DahalFAction.StateEnum.Atk1Move3);
- }
- }
- else
- {
- this.ChangeState_Anim(DahalFAction.StateEnum.Atk1Move2);
- }
- }
- public void StartPabody()
- {
- this._eAttr.paBody = true;
- }
- public void EndPabody()
- {
- this._eAttr.paBody = false;
- }
- public void SetAtkData()
- {
- this._atk.atkData = this._atkData[this._eAction.stateMachine.currentState];
- }
- public void SetAtkId()
- {
- this._atk.atkId = Incrementor.GetNextId();
- }
- public void GravityScale(float scale)
- {
- this._eAttr.timeController.SetGravity(scale);
- }
- public void Speed(string speed)
- {
- JsonData jsonData = JsonMapper.ToObject(speed);
- float num = jsonData.Get<float>("x", 0f);
- float y = jsonData.Get<float>("y", 0f);
- Vector2 speed2 = new Vector2(num * (float)this._eAttr.faceDir, y);
- this._eAttr.timeController.SetSpeed(speed2);
- }
- public void PushDown()
- {
- this._eAttr.isFlyingUp = false;
- this._eAttr.checkHitGround = false;
- this._pushDown = true;
- }
- public void PlaySound(int index)
- {
- R.Audio.PlayEffect(index, new Vector3?(base.transform.position));
- }
- public void PlayAtk2Sound()
- {
- R.Audio.PlayEffect(this.atk2Sound[UnityEngine.Random.Range(0, this.atk2Sound.Length)], new Vector3?(base.transform.position));
- }
- public void OpenOnion()
- {
- this._onion.Open(true, 0.7f, this.onionObj);
- }
- public void BackToIdle()
- {
- if (this._eAction.IsInWeakSta())
- {
- this._eAttr.enterWeakMod = false;
- this._eAction.AnimChangeState(DahalFAction.StateEnum.WeakMod, 1f);
- }
- else
- {
- this._eAction.AnimChangeState(DahalFAction.StateEnum.Idle, 1f);
- }
- }
- public IEnumerator WeakOver()
- {
- for (int i = 0; i < 96; i++)
- {
- if (this._eAction.stateMachine.currentState == "WeakMod" && !this._eAction.IsInWeakSta())
- {
- this._eAction.AnimChangeState(DahalFAction.StateEnum.Idle, 1f);
- }
- yield return new WaitForFixedUpdate();
- }
- yield break;
- }
- public void Shoot(int id = 0)
- {
- this.SparkL.GetComponent<SpriteRenderer>().enabled = true;
- this.SparkR.GetComponent<SpriteRenderer>().enabled = true;
- Vector2 from = (this.SparkL.position - this.SparkLGun.position).normalized;
- Vector2 from2 = (this.SparkR.position - this.SparkRGun.position).normalized;
- if (id == 1)
- {
- Transform transform = R.Effect.Generate(131, this.SparkL, new Vector3(0f, UnityEngine.Random.Range(-0.05f, 0.25f), 0f), default(Vector3), default(Vector3), true);
- Transform transform2 = R.Effect.Generate(131, this.SparkR, new Vector3(0f, UnityEngine.Random.Range(-0.05f, 0.25f), 0f), default(Vector3), default(Vector3), true);
- EnemyBulletLaucher component = transform.GetComponent<EnemyBulletLaucher>();
- component.SetVelocity(20f, Mathf.Sign(from.x) * Vector2.Angle(from, Vector2.up));
- component.damage = this._eAttr.atk;
- component.attacker = base.transform;
- component.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
- EnemyBulletLaucher component2 = transform2.GetComponent<EnemyBulletLaucher>();
- component2.SetVelocity(20f, Mathf.Sign(from2.x) * Vector2.Angle(from2, Vector2.up));
- component2.damage = this._eAttr.atk;
- component2.attacker = base.transform;
- component2.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
- }
- else
- {
- Transform transform3 = R.Effect.Generate(131, this.SparkL, new Vector3(0f, UnityEngine.Random.Range(-0.2f, 0.15f), 0f), default(Vector3), default(Vector3), true);
- Transform transform4 = R.Effect.Generate(131, this.SparkR, new Vector3(0f, UnityEngine.Random.Range(-0.2f, 0.15f), 0f), default(Vector3), default(Vector3), true);
- EnemyBulletLaucher component3 = transform3.GetComponent<EnemyBulletLaucher>();
- component3.SetVelocity(20f, Mathf.Sign(from.x) * Vector2.Angle(from, Vector2.up));
- component3.damage = this._eAttr.atk;
- component3.attacker = base.transform;
- component3.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
- EnemyBulletLaucher component4 = transform4.GetComponent<EnemyBulletLaucher>();
- component4.SetVelocity(20f, Mathf.Sign(from2.x) * Vector2.Angle(from2, Vector2.up));
- component4.damage = this._eAttr.atk;
- component4.attacker = base.transform;
- component4.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
- }
- base.Invoke("StopShoot", 0.28f);
- }
- public void StopShoot()
- {
- this.SparkL.GetComponent<SpriteRenderer>().enabled = false;
- this.SparkR.GetComponent<SpriteRenderer>().enabled = false;
- }
- public void RollOver()
- {
- base.GetComponent<AnimMoveController>().AnimMoveLoopReset();
- }
- public void ShowATK6FallSpark()
- {
- R.Effect.Generate(149, base.transform, new Vector3(0.35f, 0.05f, 0f), default(Vector3), default(Vector3), true);
- }
- public void ShowATK6Effect()
- {
- this.DahalAtk6Effect.rotation = Quaternion.Euler(0f, (float)((base.transform.localScale.x >= 0f) ? 0 : 180), 0f);
- this.DahalAtk6Effect.GetChild(0).localPosition = new Vector3((base.transform.localScale.x >= 0f) ? 0.45f : -0.45f, 0f, 0f);
- this.DahalAtk6Effect.gameObject.SetActive(true);
- }
- public void StopATK6Effect()
- {
- this.DahalAtk6Effect.gameObject.SetActive(false);
- }
- public void ShowChangeStateEffect(int id = 0)
- {
- if (id != 0)
- {
- return;
- }
- R.Effect.Generate(150, this.LBlade, Vector3.zero, new Vector3(0f, 0f, (float)((base.transform.localScale.x >= 0f) ? 0 : 90)), default(Vector3), true);
- R.Effect.Generate(150, this.RBlade, Vector3.zero, new Vector3(0f, 0f, (float)((base.transform.localScale.x >= 0f) ? 0 : 90)), default(Vector3), true);
- }
- public void DahalAngryEffect()
- {
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(CameraEffectProxyPrefabData.GetPrefab(18));
- gameObject.transform.position = this._baseHurt.center.position;
- base.StartCoroutine(this.PlayDahalHaloEffect());
- }
- public IEnumerator PlayDahalHaloEffect()
- {
- for (int i = 0; i < 4; i++)
- {
- R.Effect.Generate(17, null, this._baseHurt.center.position, default(Vector3), default(Vector3), true);
- yield return new WaitForSeconds(0.1f);
- }
- yield break;
- }
- public void DestroySelf()
- {
- this.RealDestroy();
- }
- private void RealDestroy()
- {
- UnityEngine.Object.Destroy(base.gameObject);
- }
- public void QTEHurtPlayerApppear()
- {
- this.player.Transform.position = base.transform.position;
- this.player.Action.ChangeState(PlayerAction.StateEnum.RollEnd, 1f);
- }
- public void QTEFinalHurt()
- {
- EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.QTEHurt);
- EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.GameObject, args);
- }
- public void ExecuteCameraMoveUp()
- {
- R.Camera.Controller.CameraMoveToBySpeed(base.transform.position + Vector3.up * 9f, 25f, false, Ease.Linear);
- R.Camera.Controller.CameraShake(0.166666672f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
- this.ExecuteAirHurt();
- }
- public void ExecuteCameraMoveDown()
- {
- R.Camera.Controller.CameraShake(0.166666672f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
- this._baseHurt.HitEffect(this._baseHurt.center.localPosition, "Atk1");
- R.Camera.Controller.CameraMoveToBySpeed(base.transform.position - Vector3.up * 9f, 25f, false, Ease.Linear);
- }
- public void ExecuteShadeAtk(int dir)
- {
- Transform transform = R.Effect.Generate(177, null, this._baseHurt.center.position + Vector3.down, default(Vector3), default(Vector3), true);
- Vector3 localScale = transform.localScale;
- localScale.x = (float)dir;
- transform.localScale = localScale;
- R.Camera.Controller.CameraShake(0.166666672f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
- }
- public void ExecutePlayerRoll()
- {
- this.player.Transform.position = base.transform.position + Vector3.up * 16f;
- this.player.Action.ChangeState(PlayerAction.StateEnum.DahalRoll, 1f);
- }
- public void ExecuteCameraShake()
- {
- R.Camera.Controller.CameraShake(0.166666672f, 0.3f, CameraController.ShakeTypeEnum.Rect, true);
- }
- public void ExecuteAirHurt()
- {
- this._baseHurt.HitEffect(this._baseHurt.center.localPosition, "Atk1");
- }
- public void ExecuteFinalHurt()
- {
- EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.Execute, string.Empty);
- EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.GameObject, args);
- }
- public void ExecuteCameraRecover()
- {
- R.Camera.Controller.CameraZoomFinished();
- }
- public float MaxFlyHeight;
- private DahalFAction _eAction;
- private EnemyAttribute _eAttr;
- private EnemyAtk _atk;
- private JsonData _atkData;
- private bool _pushDown;
- [SerializeField]
- private Transform SparkL;
- [SerializeField]
- private Transform SparkR;
- [SerializeField]
- private Transform SparkLGun;
- [SerializeField]
- private Transform SparkRGun;
- [SerializeField]
- private Transform LBlade;
- [SerializeField]
- private Transform RBlade;
- [SerializeField]
- private Transform DahalAtk6Effect;
- private OnionCreator _onion;
- [SerializeField]
- private GameObject[] onionObj;
- private EnemyBaseHurt _baseHurt;
- [SerializeField]
- private int[] atk2Sound;
- }
|