123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- using System;
- using System.Collections;
- using GameWorld;
- using LitJson;
- using UnityEngine;
- public class RiderGunAnimEvent : BaseBehaviour
- {
- private Transform player
- {
- get
- {
- return R.Player.Transform;
- }
- }
- private void Start()
- {
- this._action = base.GetComponent<RiderGunAction>();
- this._eAttr = base.GetComponent<EnemyAttribute>();
- this._atk = base.GetComponentInChildren<EnemyAtk>();
- this._atkData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.骑兵改];
- this._atk2LoopTimes = 2;
- }
- public void ChangeState(RiderGunAction.StateEnum sta)
- {
- this._action.AnimChangeState(sta, 1f);
- }
- public void Atk2End()
- {
- this._atk2LoopTimes--;
- if (this._atk2LoopTimes <= 0)
- {
- this._atk2LoopTimes = 2;
- this._action.AnimChangeState(RiderGunAction.StateEnum.Atk2End, 1f);
- }
- }
- public void StartPabody()
- {
- this._eAttr.paBody = true;
- }
- public void EndPabody()
- {
- this._eAttr.paBody = false;
- }
- public void SetAtkData()
- {
- this._atk.atkData = this._atkData[this._action.stateMachine.currentState];
- }
- public void LunchBullet()
- {
- float num = Vector2.Angle(this.gunLunch.position - this.gun.position, Vector2.up);
- Transform transform = UnityEngine.Object.Instantiate<Transform>(this.bulletPrefab, this.gunLunch.position, Quaternion.identity);
- transform.localRotation = Quaternion.Euler(0f, 0f, (float)this._eAttr.faceDir * -num);
- transform.GetComponent<Rigidbody2D>().velocity = (this.gunLunch.position - this.gun.position).normalized * 20f;
- EnemyBullet component = transform.GetComponent<EnemyBullet>();
- component.damage = this._eAttr.atk;
- component.origin = base.gameObject;
- component.SetAtkData(this._atkData["GunAtk2Ready"]);
- }
- public void SpwanEffect()
- {
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.atkEffect, base.transform.position + Vector3.back * 0.01f, Quaternion.identity);
- gameObject.GetComponent<SkeletonAnimation>().state.SetAnimation(0, this._action.stateMachine.currentState, false);
- gameObject.transform.localScale = base.transform.localScale;
- gameObject.AddComponent<AutoDestroy>();
- UnityEngine.Object.Destroy(gameObject.GetComponent<EnemyEffectSync>());
- }
- public void PlaySound(int index)
- {
- R.Audio.PlayEffect(index, new Vector3?(base.transform.position));
- }
- public void PlayMoveSound()
- {
- R.Audio.PlayEffect(this.moveSound[UnityEngine.Random.Range(0, this.moveSound.Length)], new Vector3?(base.transform.position));
- }
- public void DestroySelf()
- {
- base.Invoke("RealDestroy", 2f);
- base.gameObject.SetActive(false);
- }
- private void RealDestroy()
- {
- UnityEngine.Object.Destroy(base.gameObject);
- }
- public void BackToIdle()
- {
- if (this._action.IsInWeakSta())
- {
- this._eAttr.enterWeakMod = false;
- this._action.AnimChangeState(RiderAction.StateEnum.WeakMod, 1f);
- }
- else
- {
- this._action.AnimChangeState(RiderAction.StateEnum.Ready, 1f);
- }
- }
- public IEnumerator WeakOver()
- {
- for (int i = 0; i < 116; i++)
- {
- if (this._action.stateMachine.currentState == "WeakMod" && !this._action.IsInWeakSta())
- {
- this._action.AnimChangeState(RiderAction.StateEnum.Ready, 1f);
- }
- yield return new WaitForFixedUpdate();
- }
- yield break;
- }
- public void QTECameraZoomIn()
- {
- R.Camera.Controller.CameraZoom(base.transform.position + Vector3.up * 3f, 0.2f, 3f);
- R.Camera.Controller.CameraShake(0.2f, 0.4f, CameraController.ShakeTypeEnum.Rect, false);
- R.Camera.Controller.OpenMotionBlur(0.13333334f, 1f, base.transform.position);
- }
- public void QTEFinalHurt()
- {
- EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.QTEHurt);
- EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.gameObject, args);
- }
- public void QTEPlyerAttack()
- {
- R.Player.Action.ChangeState(PlayerAction.StateEnum.RiderQTEHurt_2, 1f);
- }
- public void QTEPlayerBack()
- {
- R.Player.Action.ChangeState(PlayerAction.StateEnum.EndAtk, 1f);
- }
- public void ExecuteEffect()
- {
- EnemyBaseHurt component = base.GetComponent<EnemyBaseHurt>();
- component.HitEffect(component.center.localPosition, "Atk1");
- }
- public void ExecuteShadeAttack()
- {
- R.Effect.Generate(180, null, base.transform.position, default(Vector3), default(Vector3), true);
- }
- public void ExecutePlyerAttack()
- {
- Vector3 position = base.transform.position + Vector3.up * 2.1f;
- position.z = LayerManager.ZNum.MMiddle_P;
- this.player.position = position;
- R.Player.Action.ChangeState(PlayerAction.StateEnum.RiderQTEHurt_3, 2f);
- }
- public void ExecuteFinalHurt()
- {
- EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.Execute, string.Empty);
- EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.gameObject, args);
- }
- private RiderGunAction _action;
- private EnemyAttribute _eAttr;
- private int _atk2LoopTimes;
- private EnemyAtk _atk;
- private JsonData _atkData;
- [SerializeField]
- private Transform gun;
- [SerializeField]
- private Transform gunLunch;
- [SerializeField]
- private Transform bulletPrefab;
- [SerializeField]
- private GameObject atkEffect;
- [SerializeField]
- private int[] moveSound;
- }
|