Fighter.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using System.Collections.Generic;
  5. using System;
  6. namespace YLBattle
  7. {
  8. /// <summary>
  9. /// 战斗中角色
  10. /// </summary>
  11. public class Fighter : MonoBehaviour
  12. {
  13. #region 操作
  14. /// <summary>
  15. /// 外部交互
  16. /// </summary>
  17. private IBattleGlobalOper mGlobalOper = null;
  18. /// <summary>
  19. /// 战场数据交互
  20. /// </summary>
  21. public IBattleGlobalOper GlobalOper
  22. {
  23. get { return mGlobalOper; }
  24. }
  25. /// <summary>
  26. ///
  27. /// </summary>
  28. private DragonBones.UnityArmatureComponent pmDragonBone = null;
  29. /// <summary>
  30. /// 状态机
  31. /// </summary>
  32. public DragonBones.UnityArmatureComponent mDragonBone
  33. {
  34. get { return pmDragonBone; }
  35. }
  36. #endregion
  37. #region FighterData
  38. /// <summary>
  39. /// 是否死亡
  40. /// </summary>
  41. public bool IsDead = false;
  42. /// <summary>
  43. /// 编号ID
  44. /// </summary>
  45. private string pmID = string.Empty;
  46. /// <summary>
  47. /// 编号ID
  48. /// </summary>
  49. public string mID
  50. {
  51. get
  52. {
  53. return pmID;
  54. }
  55. set
  56. {
  57. pmID = value;
  58. }
  59. }
  60. /// <summary>
  61. /// 模版ID
  62. /// </summary>
  63. private string pmTID = string.Empty;
  64. /// <summary>
  65. /// 模版ID
  66. /// </summary>
  67. public string mTID
  68. {
  69. get
  70. {
  71. return pmTID;
  72. }
  73. set
  74. {
  75. pmTID = value;
  76. }
  77. }
  78. /// <summary>
  79. /// 等级
  80. /// </summary>
  81. private int pmLevel = 0;
  82. /// <summary>
  83. /// 等级
  84. /// </summary>
  85. public int mLevel
  86. {
  87. get { return pmLevel; }
  88. }
  89. /// <summary>
  90. ///
  91. /// </summary>
  92. private string pmDragonName = "";
  93. /// <summary>
  94. ///
  95. /// </summary>
  96. public string mDragonName
  97. {
  98. get { return pmDragonName; }
  99. }
  100. /// <summary>
  101. /// 所属阵营
  102. /// </summary>
  103. private EBattleTeam pmTeam = EBattleTeam.NONE;
  104. /// <summary>
  105. /// 所属阵营
  106. /// </summary>
  107. public EBattleTeam mTeam
  108. {
  109. get
  110. {
  111. return pmTeam;
  112. }
  113. set
  114. {
  115. pmTeam = value;
  116. }
  117. }
  118. /// <summary>
  119. ///
  120. /// </summary>
  121. private int pmSeat = 0;
  122. /// <summary>
  123. /// 占位
  124. /// </summary>
  125. public int mSeat
  126. {
  127. get { return pmSeat; }
  128. }
  129. private int pmHeight = 0;
  130. /// <summary>
  131. /// 身高
  132. /// </summary>
  133. public int mHeight
  134. {
  135. get { return pmHeight; }
  136. }
  137. /// <summary>
  138. ///
  139. /// </summary>
  140. private Vector3 pmbodyCenterPos = Vector3.zero;
  141. /// <summary>
  142. ///
  143. /// </summary>
  144. public Vector3 mBodyCenterPos
  145. {
  146. get
  147. {
  148. if (mTeam == EBattleTeam.REDTEAM)
  149. {
  150. this.pmbodyCenterPos = GetScreenVector3(this.pmbodyCenterPoint.position);
  151. this.pmbodyCenterPos.z = 0;
  152. }
  153. if (mTeam == EBattleTeam.BLUETEAM)
  154. {
  155. float posX = this.mGlobalOper.GetFighterProperty(mID, EBattleProperty.POSX);
  156. float posY = this.mGlobalOper.GetFighterProperty(mID, EBattleProperty.POSY);
  157. pmbodyCenterPos = new Vector3(posX, posY, 0);
  158. }
  159. return pmbodyCenterPos;
  160. }
  161. }
  162. /// <summary>
  163. ///
  164. /// </summary>
  165. private Vector3 pmbodyRootPos = Vector3.zero;
  166. /// <summary>
  167. ///
  168. /// </summary>
  169. public Vector3 mBodyRootPos
  170. {
  171. get
  172. {
  173. if (mTeam == EBattleTeam.REDTEAM)
  174. {
  175. this.pmbodyRootPos = GetScreenVector3(this.pmbodyRootPoint.position);
  176. this.pmbodyRootPos.z = 0;
  177. }
  178. if (mTeam == EBattleTeam.BLUETEAM)
  179. {
  180. float posX = this.mGlobalOper.GetFighterProperty(mID, EBattleProperty.POSX);
  181. float posY = this.mGlobalOper.GetFighterProperty(mID, EBattleProperty.POSY);
  182. pmbodyRootPos = new Vector3(posX, posY, 0);
  183. }
  184. return pmbodyRootPos;
  185. }
  186. }
  187. /// <summary>
  188. ///
  189. /// </summary>
  190. private Transform pmbodyCenterPoint = null;
  191. /// <summary>
  192. ///
  193. /// </summary>
  194. public Transform mBodyCenterPoint
  195. {
  196. get
  197. {
  198. if (pmbodyCenterPoint == null)
  199. {
  200. LogHelper.LogError("没有找到发射点 TID=" + pmTID);
  201. pmbodyCenterPoint = transform;
  202. }
  203. return pmbodyCenterPoint;
  204. }
  205. }
  206. /// <summary>
  207. ///
  208. /// </summary>
  209. private Transform pmbodyRootPoint = null;
  210. /// <summary>
  211. ///
  212. /// </summary>
  213. public string mNormalSound { get; set; }
  214. /// <summary>
  215. ///
  216. /// </summary>
  217. public string mSkillSound { get; set; }
  218. /// <summary>
  219. ///
  220. /// </summary>
  221. public string mBeattackSound { get; set; }
  222. /// <summary>
  223. ///
  224. /// </summary>
  225. private RenderTexture pmBodyImage = null;
  226. /// <summary>
  227. /// 红队
  228. /// </summary>
  229. private MeshRenderer pmRedBody;
  230. /// <summary>
  231. /// 红队
  232. /// </summary>
  233. private MeshRenderer pmRedBodyGray;
  234. /// <summary>
  235. /// 蓝队
  236. /// </summary>
  237. private RawImage pmBlueBody;
  238. /// <summary>
  239. ///
  240. /// </summary>
  241. //private GameObject pmRedSelectFlag = null;
  242. /// <summary>
  243. /// 动画机
  244. /// </summary>
  245. private Animator pmAnimator = null;
  246. /// <summary>
  247. ///
  248. /// </summary>
  249. public Animator mBodyAnimator
  250. {
  251. get
  252. {
  253. if (this.pmAnimator == null)
  254. {
  255. pmAnimator = this.pmRedBody.GetComponent<Animator>();
  256. }
  257. return pmAnimator;
  258. }
  259. }
  260. /// <summary>
  261. /// 动画机
  262. /// </summary>
  263. private Animator pmGrayAnimator = null;
  264. /// <summary>
  265. ///
  266. /// </summary>
  267. public Animator mGrayAnimator
  268. {
  269. get
  270. {
  271. if (this.pmGrayAnimator == null)
  272. {
  273. pmGrayAnimator = this.pmRedBodyGray.GetComponent<Animator>();
  274. }
  275. return pmGrayAnimator;
  276. }
  277. }
  278. /// <summary>
  279. /// 是否外部调用龙骨动画(暴击状态时,tip调用了龙骨动画,所以不能随意修改(如被攻击恢复....)
  280. /// </summary>
  281. private bool IsOutInvokeDragon = false;
  282. /// <summary>
  283. /// 外部调用订阅事件
  284. /// </summary>
  285. private Action mOutInvokeCallBack = null;
  286. /// <summary>
  287. ///
  288. /// </summary>
  289. private GameObject mLianjiEffect = null;
  290. /// <summary>
  291. /// 当前连击点击状态
  292. /// </summary>
  293. private bool mLianjiState = false;
  294. #endregion
  295. /// <summary>
  296. /// 获取属性
  297. /// </summary>
  298. /// <param name="tp">属性</param>
  299. /// <returns>属性值</returns>
  300. public float GetProperty(EBattleProperty tp)
  301. {
  302. return this.mGlobalOper.GetFighterProperty(mID, tp);
  303. }
  304. /// <summary>
  305. /// 设置实例信息
  306. /// </summary>
  307. /// <param name="_id">实例ID</param>
  308. /// <param name="_strTid">模板ID</param>
  309. /// <param name="_eTeam">队列</param>
  310. /// <param name="_intSeat">占位(敌方和己方不同,注意场景中的实际占位)</param>
  311. /// <param name="mBFM">战场交换器</param>
  312. internal void SetInfo(string _id, string _strTid, EBattleTeam _eTeam, int _intSeat, IBattleGlobalOper mBFM, string _sounds, string _dragonName)
  313. {
  314. this.pmID = _id;
  315. this.pmTeam = _eTeam;
  316. this.pmTID = _strTid;
  317. this.pmSeat = _intSeat;
  318. this.mGlobalOper = mBFM;
  319. this.pmLevel = (int)mBFM.GetFighterProperty(_id, EBattleProperty.LEVEL);
  320. this.pmHeight = (int)mBFM.GetFighterProperty(_id, EBattleProperty.HEIGHT);
  321. string[] sounds = _sounds.Split(',');
  322. this.mNormalSound = sounds[0];
  323. this.mSkillSound = sounds[1];
  324. this.mBeattackSound = sounds[2];
  325. this.pmDragonName = _dragonName;
  326. this.gameObject.AddComponent<BUI_LookAtTarget>();
  327. ///蓝队位置
  328. if (this.mTeam == EBattleTeam.BLUETEAM)
  329. {
  330. this.transform.localPosition = new Vector3(this.transform.localPosition.x,
  331. this.transform.localPosition.y + 1500 / 2 - pmHeight / 2 / 2,
  332. this.transform.localPosition.z);
  333. }
  334. ///被攻击位置
  335. if (this.mTeam == EBattleTeam.BLUETEAM)
  336. {
  337. this.pmbodyCenterPoint = this.transform.Find("BeAttackCenter");
  338. this.pmbodyCenterPoint.localPosition = new Vector3(0, -1500 / 2 + pmHeight * 1.0f / 7.1f, 0);
  339. this.pmbodyRootPoint = this.transform.Find("BeAttackRoot");
  340. this.pmbodyRootPoint.localPosition = new Vector3(0, -1500 / 2 + pmHeight * 1.0f / 7.1f, 0); ;
  341. }
  342. else
  343. {
  344. this.pmbodyCenterPoint = this.transform.Find("BeAttackCenter");
  345. this.pmbodyCenterPoint.localPosition = new Vector3(0, -1500 / 100 / 3.5f + pmHeight / 100 / 7.1f, 0);
  346. this.pmbodyRootPoint = this.transform.Find("BeAttackRoot");
  347. ///红队存在于3D场景中,摄像机有Y轴的倾斜,所以Y轴偏上,这里做一个修正
  348. float offsetY = 0f;
  349. this.pmbodyRootPoint.localPosition = new Vector3(0, -1500 / 100 / 2 - offsetY, 0);
  350. //this.pmRedSelectFlag = this.transform.Find("SelectFlag").gameObject;
  351. //this.pmRedSelectFlag.SetActive(false);
  352. }
  353. ///初始化位置(蓝队以UI位置为最终点,但是出场时UI为出现,因此在这里初始第一版位置)
  354. //if (_eTeam == EBattleTeam.BLUETEAM)
  355. //{
  356. // Vector3 pos = GetScreenVector3(pmbodyRootPoint.position);
  357. // this.mGlobalOper.ModifyFighterPosition(mID, pos.x, pos.y);
  358. // Debug.Log(this.pmID + "/" + pos.ToString());
  359. //}
  360. }
  361. /// <summary>
  362. ///
  363. /// </summary>
  364. /// <param name="_dragonboneCont"></param>
  365. /// <param name="rt"></param>
  366. public void SetDragonBone(DragonBones.UnityArmatureComponent _dragonboneCont, RenderTexture rt)
  367. {
  368. this.pmDragonBone = _dragonboneCont;
  369. this.pmBodyImage = rt;
  370. if (this.pmTeam == EBattleTeam.BLUETEAM)
  371. {
  372. this.pmBlueBody = transform.Find("RawImageBody").GetComponent<RawImage>();
  373. this.pmBlueBody.texture = this.pmBodyImage;
  374. this.pmBlueBody.enabled = false;
  375. this.pmDragonBone.gameObject.SetActive(false);
  376. this.pmDragonBone.enabled = false;
  377. }
  378. if (this.pmTeam == EBattleTeam.REDTEAM)
  379. {
  380. this.pmRedBody = transform.Find("PlaneBody").GetComponent<MeshRenderer>();
  381. this.pmRedBody.material.mainTexture = this.pmBodyImage;
  382. this.pmRedBodyGray = transform.Find("PlaneBodyGray").GetComponent<MeshRenderer>();
  383. this.pmRedBodyGray.material.mainTexture = this.pmBodyImage;
  384. this.pmRedBodyGray.transform.localPosition = new Vector3(0, 0, -0.01f);
  385. this.pmRedBodyGray.gameObject.SetActive(false);
  386. }
  387. if (!this.pmDragonBone.HasEventListener(DragonBones.EventObject.COMPLETE))
  388. {
  389. ////监听动画完成事件
  390. this.pmDragonBone.AddEventListener(DragonBones.EventObject.COMPLETE, OnDragonBoneAnimation_COMPLETE);
  391. }
  392. ///循环事件别删除,部分动画是循环的,比如攻击,程序这强制执行修正
  393. if (!this.pmDragonBone.HasEventListener(DragonBones.EventObject.LOOP_COMPLETE))
  394. {
  395. ////监听动画完成事件
  396. this.pmDragonBone.AddEventListener(DragonBones.EventObject.LOOP_COMPLETE, OnDragonBoneAnimation_LOOP_COMPLETE);
  397. }
  398. if (this.mTeam == EBattleTeam.REDTEAM)
  399. {
  400. this.pmDragonBone.animation.Play("Idle", 0);
  401. }
  402. }
  403. /// <summary>
  404. /// sence坐标转屏幕坐标(red转ui)
  405. /// </summary>
  406. /// <param name="orgPos"></param>
  407. /// <returns></returns>
  408. private Vector3 GetScreenVector3(Vector3 orgPos)
  409. {
  410. Vector3 trgPos = Vector3.zero;
  411. Vector3 sencePos = CameraManager.Instance.SenceCamara.WorldToScreenPoint(orgPos);
  412. trgPos = CameraManager.Instance.SenceUICamera.ScreenToWorldPoint(sencePos);
  413. return trgPos;
  414. }
  415. ///// <summary>
  416. ///// 参考2
  417. ///// </summary>
  418. ///// <returns></returns>
  419. //Vector2 MonoWorldToUGUI(Vector3 orgPos)
  420. //{
  421. // Vector2 pos;
  422. // Vector3 screenPos = CameraManager.Instance.SenceCamara.WorldToScreenPoint(orgPos);
  423. // RectTransformUtility.ScreenPointToLocalPointInRectangle(mMng.MeCanvas.GetComponent<RectTransform>(),
  424. // screenPos, CameraManager.Instance.SenceUICamera, out pos);
  425. // return pos;
  426. //}
  427. /// <summary>
  428. ///
  429. /// </summary>
  430. /// <param name="_bol"></param>
  431. /// <param name="_strAniName"></param>
  432. /// <param name="ac"></param>
  433. public void SetActiveBodyTexture(bool _bol, string _strAniName = "", Action ac = null)
  434. {
  435. this.IsOutInvokeDragon = _bol;
  436. if (mTeam == EBattleTeam.BLUETEAM)
  437. {
  438. this.pmDragonBone.gameObject.SetActive(_bol);
  439. this.pmDragonBone.enabled = _bol;
  440. //this.pmBlueBody.enabled = _bol;
  441. }
  442. if (_bol && _strAniName.Length > 0)
  443. {
  444. this.mOutInvokeCallBack = ac;
  445. this.PlayDragonAnimation(_strAniName, true);
  446. }
  447. }
  448. /// <summary>
  449. /// 播放动画
  450. /// </summary>
  451. /// <param name="aniName">动画名称</param>
  452. /// <param name="isForce">是否强制播放</param>
  453. /// <param name="_loop">是否循环播放</param>
  454. private void PlayDragonAnimation(string aniName, bool isForce, int _loop = 1)
  455. {
  456. if (isForce)
  457. {
  458. this.mDragonBone.animation.Play(aniName, aniName == "Idle" ? 0 : 1);
  459. return;
  460. }
  461. if (this.mDragonBone.animation.lastAnimationName == aniName)
  462. {
  463. return;
  464. }
  465. this.mDragonBone.animation.Play(aniName, aniName == "Idle" ? 0 : _loop);
  466. }
  467. /// <summary>
  468. ///
  469. /// </summary>
  470. /// <param name="type"></param>
  471. /// <param name="eventObject"></param>
  472. public void OnDragonBoneAnimation_LOOP_COMPLETE(string type, DragonBones.EventObject eventObject)
  473. {
  474. switch (eventObject.animationState.name)
  475. {
  476. case "Attack":
  477. if (mTeam == EBattleTeam.REDTEAM)
  478. {
  479. this.PlayDragonAnimation("Idle", false);
  480. }
  481. break;
  482. case "Beattack":
  483. if (mTeam == EBattleTeam.REDTEAM)
  484. {
  485. this.PlayDragonAnimation("Idle", false);
  486. }
  487. break;
  488. }
  489. }
  490. /// <summary>
  491. ///
  492. /// </summary>
  493. /// <param name="type"></param>
  494. /// <param name="eventObject"></param>
  495. public void OnDragonBoneAnimation_COMPLETE(string type, DragonBones.EventObject eventObject)
  496. {
  497. switch (eventObject.animationState.name)
  498. {
  499. case "Attack":
  500. if (mTeam == EBattleTeam.REDTEAM)
  501. {
  502. this.PlayDragonAnimation("Idle", false);
  503. }
  504. if (mOutInvokeCallBack != null)
  505. {
  506. this.mOutInvokeCallBack.Invoke();
  507. this.mOutInvokeCallBack = null;
  508. this.PlayDragonAnimation("Idle", false);
  509. }
  510. /// SetActiveBodyTexture关闭触发会让IsOutInvokeDragon=false,使动画归位
  511. //if (this.IsOutInvokeDragon)
  512. //{
  513. // ///如果是蓝队正对一下情况,会影响必杀全身像的显示
  514. // return;
  515. //}
  516. //this.pmDragonBone.gameObject.SetActive(false);
  517. //this.pmDragonBone.enabled = false;
  518. break;
  519. case "Beattack":
  520. if (mTeam == EBattleTeam.REDTEAM)
  521. {
  522. this.PlayDragonAnimation("Idle", false);
  523. }
  524. break;
  525. }
  526. }
  527. /// <summary>
  528. /// 攻击
  529. /// </summary>
  530. /// <param name="skill">技能ID</param>
  531. /// <param name="_atkactiontype">技能攻击动作 0=无动作 1=攻击动作</param>
  532. internal void SetAttack(string skill, int _atkactiontype)
  533. {
  534. /**
  535. * 音效
  536. */
  537. //Debug.Log("##################################普通攻击动作播放时加音效(跟着人属性走)#########################");
  538. ////AudioManager.Instance.PlayHeroSound(mTID, this.mAttackSound, ESoundType.HERO_ATTACK);
  539. if (_atkactiontype != 0)
  540. {
  541. if (this.mTeam == EBattleTeam.BLUETEAM)
  542. {
  543. //this.pmDragonBone.gameObject.SetActive(true);
  544. //this.pmDragonBone.enabled = true;
  545. //this.PlayDragonAnimation("Attack", true);
  546. }
  547. else
  548. {
  549. this.PlayDragonAnimation("Attack", true);
  550. }
  551. }
  552. this.mGlobalOper.OnCastBullet(mID, skill);
  553. }
  554. private bool isLianjiEffectLoad = false;
  555. /// <summary>
  556. ///
  557. /// </summary>
  558. /// <param name="_bol"></param>
  559. public void SetLianjiEffect(bool _bol)
  560. {
  561. if (isLianjiEffectLoad == false)
  562. {
  563. isLianjiEffectLoad = true;
  564. SkillControl.Instance.createPosEffect("UI_SKILL_LianjiFiger", this.mBodyCenterPos, (obj) =>
  565. {
  566. this.mLianjiEffect = obj;
  567. this.mLianjiEffect.SetActive(true);
  568. this.mLianjiEffect.transform.position = this.mBodyCenterPos;
  569. });
  570. return;
  571. }
  572. if (this.mLianjiEffect == null)
  573. {
  574. return;
  575. }
  576. if (_bol)
  577. {
  578. this.mLianjiEffect.SetActive(true);
  579. this.mLianjiEffect.transform.position = this.mBodyCenterPos;
  580. }
  581. else
  582. {
  583. this.mLianjiEffect.SetActive(false);
  584. }
  585. }
  586. /// <summary>
  587. /// 清理特效
  588. /// </summary>
  589. public void ClearLianjiEffect()
  590. {
  591. if (this.mLianjiEffect != null)
  592. {
  593. Destroy(this.mLianjiEffect);
  594. this.mLianjiEffect = null;
  595. }
  596. }
  597. public void SetBeSelect()
  598. {
  599. //this.pmRedSelectFlag.SetActive(true);
  600. }
  601. public void SetBeForget()
  602. {
  603. //this.pmRedSelectFlag.SetActive(false);
  604. }
  605. /// <summary>
  606. /// 受伤
  607. /// </summary>
  608. internal void SetHit()
  609. {
  610. string strId = this.mTID.Substring(0, 3);
  611. /**
  612. * 101开头是角色,202开头是boss
  613. * 只有这两类有被攻击动画
  614. * 其他小怪,用闪动Animator攻击动画
  615. */
  616. if (strId == "101" || strId == "202")
  617. {
  618. this.PlayDragonAnimation("Beattack", true, 1);
  619. }
  620. //else
  621. {
  622. this.mBodyAnimator.Play("BeAttack");
  623. Invoke("RetsetHitColor", 0.4f);
  624. }
  625. }
  626. /// <summary>
  627. ///
  628. /// </summary>
  629. void RetsetHitColor()
  630. {
  631. //Debug.Log(mID+ " RetsetHitColor");
  632. if (this.IsOutInvokeDragon)
  633. {
  634. ///如果是蓝队正对一下情况,会影响必杀全身像的显示
  635. return;
  636. }
  637. this.mBodyAnimator.Play("Idle");
  638. }
  639. /// <summary>
  640. ///
  641. /// </summary>
  642. /// <param name="_force"></param>
  643. internal void SetIdle(bool _force)
  644. {
  645. if (this.IsOutInvokeDragon)
  646. {
  647. ///如果是蓝队正对一下情况,会影响必杀全身像的显示
  648. return;
  649. }
  650. ///攻击状态,则不强制转化Idle,完整播放,待攻击动画播放完毕后,再由事件返回idle
  651. if (_force)
  652. {
  653. this.PlayDragonAnimation("Idle", true);
  654. }
  655. else
  656. {
  657. if (this.mTeam == EBattleTeam.BLUETEAM)
  658. {
  659. this.pmDragonBone.gameObject.SetActive(false);
  660. this.pmDragonBone.enabled = false;
  661. }
  662. }
  663. }
  664. /// <summary>
  665. /// 死亡
  666. /// </summary>
  667. internal void SetDead()
  668. {
  669. this.IsDead = true;
  670. this.ClearLianjiEffect();
  671. this.pmDragonBone.RemoveEventListener(DragonBones.EventObject.COMPLETE, OnDragonBoneAnimation_COMPLETE);
  672. }
  673. /// <summary>
  674. /// 出场
  675. /// </summary>
  676. internal void SetArrival()
  677. {
  678. if (this.mTeam == EBattleTeam.REDTEAM)
  679. {
  680. this.pmDragonBone.gameObject.SetActive(true);
  681. this.pmDragonBone.enabled = true;
  682. gameObject.SetActive(true);
  683. }
  684. else
  685. {
  686. this.pmDragonBone.gameObject.SetActive(false);
  687. this.pmDragonBone.enabled = false;
  688. }
  689. }
  690. /// <summary>
  691. /// 隐身~
  692. /// </summary>
  693. internal void SetHidden()
  694. {
  695. this.pmDragonBone.gameObject.SetActive(false);
  696. gameObject.SetActive(false);
  697. }
  698. /// <summary>
  699. /// (红队)隐身
  700. /// </summary>
  701. internal void SetDisapper()
  702. {
  703. this.pmRedBody.gameObject.SetActive(false);
  704. this.pmRedBodyGray.gameObject.SetActive(true);
  705. this.mGrayAnimator.Play("Die");
  706. Invoke("LateDisapper", 0.5f);
  707. }
  708. /// <summary>
  709. /// 延迟删除
  710. /// </summary>
  711. void LateDisapper()
  712. {
  713. FightingManager.Instance.DeleteOneFighter(mID);
  714. }
  715. /// <summary>
  716. /// 变亮
  717. /// </summary>
  718. internal void SetLight()
  719. {
  720. //this.pmRedBody.gameObject.SetActive(true);
  721. this.mGrayAnimator.Play("Show");
  722. this.pmRedBodyGray.gameObject.SetActive(false);
  723. }
  724. /// <summary>
  725. /// 变暗
  726. /// </summary>
  727. internal void SetDark()
  728. {
  729. //this.pmRedBody.gameObject.SetActive(false);
  730. this.pmRedBodyGray.gameObject.SetActive(true);
  731. this.mGrayAnimator.Play("Dark");
  732. }
  733. /// <summary>
  734. /// 查找Transform
  735. /// </summary>
  736. /// <param name="name">名称</param>
  737. /// <returns>Transform</returns>
  738. public Transform FindTransform(string name)
  739. {
  740. Transform[] trans = this.transform.GetComponentsInChildren<Transform>();
  741. for (int i = 0; i < trans.Length; i++)
  742. {
  743. if (trans[i].name == name)
  744. {
  745. return trans[i];
  746. }
  747. }
  748. return null;
  749. }
  750. }
  751. }