You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Character.cs 27 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. namespace GameClass.GameObj
  7. {
  8. public partial class Character : Moveable, ICharacter // 负责人LHR摆烂终了
  9. {
  10. private readonly ReaderWriterLockSlim hpReaderWriterLock = new();
  11. public ReaderWriterLockSlim HPReadWriterLock => hpReaderWriterLock;
  12. #region 装弹、攻击相关的基本属性及方法
  13. /// <summary>
  14. /// 装弹冷却
  15. /// </summary>
  16. protected int cd;
  17. public int CD
  18. {
  19. get
  20. {
  21. lock (actionLock)
  22. {
  23. return cd;
  24. }
  25. }
  26. }
  27. public int OrgCD { get; protected set; }
  28. public readonly BulletType OriBulletOfPlayer;
  29. private BulletType bulletOfPlayer;
  30. public BulletType BulletOfPlayer
  31. {
  32. get
  33. {
  34. lock (actionLock)
  35. {
  36. return bulletOfPlayer;
  37. }
  38. }
  39. set
  40. {
  41. lock (actionLock)
  42. {
  43. bulletOfPlayer = value;
  44. cd = OrgCD = (BulletFactory.BulletCD(value));
  45. Debugger.Output(this, string.Format("'s CD has been set to: {0}.", cd));
  46. maxBulletNum = bulletNum = (BulletFactory.BulletNum(value));
  47. }
  48. }
  49. }
  50. protected int maxBulletNum;
  51. public int MaxBulletNum
  52. {
  53. get
  54. {
  55. lock (actionLock)
  56. {
  57. return maxBulletNum;
  58. }
  59. }
  60. }
  61. private int bulletNum;
  62. private int updateTimeOfBulletNum = 0;
  63. public int UpdateBulletNum(int time)
  64. {
  65. lock (actionLock)
  66. {
  67. if (bulletNum < maxBulletNum)
  68. {
  69. int add = Math.Min(maxBulletNum - bulletNum, (time - updateTimeOfBulletNum) / cd);
  70. updateTimeOfBulletNum += add * cd;
  71. return (bulletNum += add);
  72. }
  73. return maxBulletNum;
  74. }
  75. }
  76. /// <summary>
  77. /// 进行一次攻击
  78. /// </summary>
  79. /// <returns>攻击操作发出的子弹</returns>
  80. public Bullet? Attack(double angle, int time)
  81. {
  82. lock (actionLock)
  83. {
  84. if (bulletOfPlayer == BulletType.Null)
  85. return null;
  86. if (UpdateBulletNum(time) > 0)
  87. {
  88. if (bulletNum == maxBulletNum) updateTimeOfBulletNum = time;
  89. --bulletNum;
  90. XY res = Position + new XY // 子弹紧贴人物生成。
  91. (
  92. (int)(Math.Abs((Radius + BulletFactory.BulletRadius(bulletOfPlayer)) * Math.Cos(angle))) * Math.Sign(Math.Cos(angle)),
  93. (int)(Math.Abs((Radius + BulletFactory.BulletRadius(bulletOfPlayer)) * Math.Sin(angle))) * Math.Sign(Math.Sin(angle))
  94. );
  95. Bullet? bullet = BulletFactory.GetBullet(this, res, this.bulletOfPlayer);
  96. if (bullet == null) return null;
  97. bullet.AP += TryAddAp() ? GameData.ApPropAdd : 0;
  98. facingDirection = new(angle, bullet.AttackDistance);
  99. return bullet;
  100. }
  101. else
  102. return null;
  103. }
  104. }
  105. /*
  106. /// <summary>
  107. /// 攻击被反弹,反弹伤害不会再被反弹
  108. /// </summary>
  109. /// <param name="subHP"></param>
  110. /// <param name="hasSpear"></param>
  111. /// <param name="bouncer">反弹伤害者</param>
  112. /// <returns>是否因反弹伤害而死</returns>
  113. private bool BeBounced(int subHP, bool hasSpear, Character? bouncer)
  114. {
  115. lock (beAttackedLock)
  116. {
  117. if (hp <= 0)
  118. return false;
  119. if (!(bouncer?.TeamID == this.TeamID))
  120. {
  121. if (hasSpear || !HasShield)
  122. _ = TrySubHp(subHP);
  123. if (hp <= 0)
  124. TryActivatingLIFE();
  125. }
  126. return hp <= 0;
  127. }
  128. }*/
  129. #endregion
  130. #region 感知相关的基本属性及方法
  131. private Dictionary<BgmType, double> bgmDictionary = new();
  132. public Dictionary<BgmType, double> BgmDictionary
  133. {
  134. get => bgmDictionary;
  135. private set
  136. {
  137. lock (gameObjLock)
  138. {
  139. bgmDictionary = value;
  140. }
  141. }
  142. }
  143. public void AddBgm(BgmType bgm, double value)
  144. {
  145. if (BgmDictionary.ContainsKey(bgm))
  146. BgmDictionary[bgm] = value;
  147. else BgmDictionary.Add(bgm, value);
  148. }
  149. private int alertnessRadius;
  150. public int AlertnessRadius
  151. {
  152. get => alertnessRadius;
  153. set
  154. {
  155. lock (gameObjLock)
  156. {
  157. alertnessRadius = value;
  158. }
  159. }
  160. }
  161. private double concealment;
  162. public double Concealment
  163. {
  164. get => concealment;
  165. set
  166. {
  167. lock (gameObjLock)
  168. {
  169. concealment = value;
  170. }
  171. }
  172. }
  173. private int viewRange;
  174. public int ViewRange
  175. {
  176. get => viewRange;
  177. set
  178. {
  179. lock (gameObjLock)
  180. {
  181. viewRange = (value > 0) ? value : 0;
  182. }
  183. }
  184. }
  185. #endregion
  186. #region 交互相关的基本属性及方法
  187. private int speedOfOpeningOrLocking;
  188. public int SpeedOfOpeningOrLocking
  189. {
  190. get => speedOfOpeningOrLocking;
  191. set
  192. {
  193. lock (gameObjLock)
  194. {
  195. speedOfOpeningOrLocking = value;
  196. }
  197. }
  198. }
  199. private int speedOfClimbingThroughWindows;
  200. public int SpeedOfClimbingThroughWindows
  201. {
  202. get => speedOfClimbingThroughWindows;
  203. set
  204. {
  205. lock (gameObjLock)
  206. {
  207. speedOfClimbingThroughWindows = value;
  208. }
  209. }
  210. }
  211. private int speedOfOpenChest;
  212. public int SpeedOfOpenChest
  213. {
  214. get => speedOfOpenChest;
  215. set
  216. {
  217. lock (gameObjLock)
  218. {
  219. speedOfOpenChest = value;
  220. }
  221. }
  222. }
  223. #endregion
  224. #region 血量相关的基本属性及方法
  225. private int maxHp;
  226. public int MaxHp
  227. {
  228. get
  229. {
  230. HPReadWriterLock.EnterReadLock();
  231. try
  232. {
  233. return maxHp;
  234. }
  235. finally
  236. {
  237. HPReadWriterLock.ExitReadLock();
  238. }
  239. }
  240. protected set
  241. {
  242. HPReadWriterLock.EnterWriteLock();
  243. try
  244. {
  245. maxHp = value;
  246. if (hp > maxHp) hp = maxHp;
  247. }
  248. finally
  249. {
  250. HPReadWriterLock.ExitWriteLock();
  251. }
  252. }
  253. } // 最大血量
  254. protected int hp;
  255. public int HP
  256. {
  257. get
  258. {
  259. HPReadWriterLock.EnterReadLock();
  260. try
  261. {
  262. return hp;
  263. }
  264. finally
  265. {
  266. HPReadWriterLock.ExitReadLock();
  267. }
  268. }
  269. set
  270. {
  271. HPReadWriterLock.EnterWriteLock();
  272. try
  273. {
  274. if (value > 0)
  275. {
  276. hp = value <= maxHp ? value : maxHp;
  277. }
  278. else
  279. hp = 0;
  280. }
  281. finally
  282. {
  283. HPReadWriterLock.ExitWriteLock();
  284. }
  285. }
  286. }
  287. /// <summary>
  288. /// 尝试减血
  289. /// </summary>
  290. /// <param name="sub">减血量</param>
  291. public int TrySubHp(int sub)
  292. {
  293. HPReadWriterLock.EnterWriteLock();
  294. try
  295. {
  296. int previousHp = hp;
  297. if (hp <= sub)
  298. {
  299. hp = 0;
  300. return hp;
  301. }
  302. else
  303. {
  304. hp -= sub;
  305. return sub;
  306. }
  307. }
  308. finally
  309. {
  310. HPReadWriterLock.ExitWriteLock();
  311. }
  312. }
  313. private double vampire = 0; // 回血率:0-1之间
  314. public double Vampire
  315. {
  316. get
  317. {
  318. HPReadWriterLock.EnterReadLock();
  319. try
  320. {
  321. return vampire;
  322. }
  323. finally
  324. {
  325. HPReadWriterLock.ExitReadLock();
  326. }
  327. }
  328. set
  329. {
  330. HPReadWriterLock.EnterWriteLock();
  331. try
  332. {
  333. if (value > 1)
  334. vampire = 1;
  335. else if (value < 0)
  336. vampire = 0;
  337. else
  338. vampire = value;
  339. }
  340. finally
  341. {
  342. HPReadWriterLock.ExitWriteLock();
  343. }
  344. }
  345. }
  346. public double OriVampire { get; protected set; }
  347. #endregion
  348. #region 状态相关的基本属性与方法
  349. private PlayerStateType playerState = PlayerStateType.Null;
  350. public PlayerStateType PlayerState
  351. {
  352. get
  353. {
  354. lock (actionLock)
  355. {
  356. if (playerState == PlayerStateType.Null && IsMoving) return PlayerStateType.Moving;
  357. return playerState;
  358. }
  359. }
  360. }
  361. public bool NoHp()
  362. {
  363. lock (actionLock)
  364. return (playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped || playerState == PlayerStateType.Addicted || playerState == PlayerStateType.Rescued);
  365. }
  366. public bool Commandable()
  367. {
  368. lock (actionLock)
  369. {
  370. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  371. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  372. && playerState != PlayerStateType.Swinging && playerState != PlayerStateType.TryingToAttack
  373. && playerState != PlayerStateType.ClimbingThroughWindows
  374. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  375. }
  376. }
  377. public bool CanPinDown()
  378. {
  379. lock (actionLock)
  380. {
  381. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  382. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  383. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  384. }
  385. }
  386. public bool InteractingWithMapWithoutMoving()
  387. {
  388. lock (actionLock)
  389. {
  390. return (playerState == PlayerStateType.LockingOrOpeningTheDoor || playerState == PlayerStateType.Fixing || playerState == PlayerStateType.OpeningTheChest);
  391. }
  392. }
  393. public bool NullOrMoving()
  394. {
  395. lock (actionLock)
  396. {
  397. return (playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  398. }
  399. }
  400. public bool CanBeAwed()
  401. {
  402. lock (actionLock)
  403. return !(playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped
  404. || playerState == PlayerStateType.Addicted
  405. || playerState == PlayerStateType.Rescued || playerState == PlayerStateType.Treated
  406. || playerState == PlayerStateType.Stunned || playerState == PlayerStateType.Charmed
  407. || playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  408. }
  409. private GameObj? whatInteractingWith = null;
  410. public GameObj? WhatInteractingWith => whatInteractingWith;
  411. private long ChangePlayerState(PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  412. {
  413. //只能被SetPlayerState引用
  414. whatInteractingWith = gameObj;
  415. if (value != PlayerStateType.Moving)
  416. IsMoving = false;
  417. playerState = (value == PlayerStateType.Moving) ? PlayerStateType.Null : value;
  418. //Debugger.Output(this,playerState.ToString()+" "+IsMoving.ToString());
  419. return ++stateNum;
  420. }
  421. private long ChangePlayerStateInOneThread(PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  422. {
  423. //只能被SetPlayerState引用
  424. whatInteractingWith = gameObj;
  425. if (value != PlayerStateType.Moving)
  426. IsMoving = false;
  427. playerState = (value == PlayerStateType.Moving) ? PlayerStateType.Null : value;
  428. //Debugger.Output(this,playerState.ToString()+" "+IsMoving.ToString());
  429. return stateNum;
  430. }
  431. public long SetPlayerState(PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  432. {
  433. lock (actionLock)
  434. {
  435. PlayerStateType nowPlayerState = PlayerState;
  436. if (nowPlayerState == value) return -1;
  437. switch (nowPlayerState)
  438. {
  439. case PlayerStateType.Escaped:
  440. case PlayerStateType.Deceased:
  441. return -1;
  442. case PlayerStateType.Addicted:
  443. if (value == PlayerStateType.Rescued)
  444. return ChangePlayerStateInOneThread(value, gameObj);
  445. else if (value == PlayerStateType.Null)
  446. return ChangePlayerState(value, gameObj);
  447. else return -1;
  448. case PlayerStateType.Rescued:
  449. if (value == PlayerStateType.Addicted)
  450. return ChangePlayerStateInOneThread(value, gameObj);
  451. else if (value == PlayerStateType.Null)
  452. return ChangePlayerState(value, gameObj);
  453. else return -1;
  454. case PlayerStateType.TryingToAttack:
  455. if (value != PlayerStateType.Moving && value != PlayerStateType.ClimbingThroughWindows)
  456. return ChangePlayerState(value, gameObj);
  457. else return -1;
  458. case PlayerStateType.Stunned:
  459. case PlayerStateType.Charmed:
  460. if (value != PlayerStateType.Moving && value != PlayerStateType.ClimbingThroughWindows && value != PlayerStateType.Swinging)
  461. return ChangePlayerState(value, gameObj);
  462. else return -1;
  463. case PlayerStateType.Swinging:
  464. if (value != PlayerStateType.Moving && value != PlayerStateType.ClimbingThroughWindows)
  465. {
  466. ThreadNum.Release();
  467. return ChangePlayerState(value, gameObj);
  468. }
  469. else return -1;
  470. case PlayerStateType.ClimbingThroughWindows:
  471. if (value != PlayerStateType.Moving)
  472. {
  473. Window window = (Window)WhatInteractingWith!;
  474. window.FinishClimbing();
  475. if (window.Stage.x == 0)
  476. ThreadNum.Release();
  477. else ReSetPos(window.Stage);
  478. return ChangePlayerState(value, gameObj);
  479. }
  480. else return -1;
  481. case PlayerStateType.OpeningTheChest:
  482. ((Chest)WhatInteractingWith!).StopOpen();
  483. return ChangePlayerState(value, gameObj);
  484. case PlayerStateType.OpeningTheDoorway:
  485. Doorway doorway = (Doorway)WhatInteractingWith!;
  486. doorway.StopOpenning();
  487. return ChangePlayerState(value, gameObj);
  488. default:
  489. return ChangePlayerState(value, gameObj);
  490. }
  491. }
  492. }
  493. public long SetPlayerStateNaturally()
  494. {
  495. lock (actionLock)
  496. {
  497. whatInteractingWith = null;
  498. IsMoving = false;
  499. playerState = PlayerStateType.Null;
  500. return ++stateNum;
  501. }
  502. }
  503. public void RemoveFromGame(PlayerStateType playerStateType)
  504. {
  505. lock (actionLock)
  506. {
  507. MoveReaderWriterLock.EnterWriteLock();
  508. try
  509. {
  510. canMove = false;
  511. isRemoved = true;
  512. }
  513. finally
  514. {
  515. MoveReaderWriterLock.ExitWriteLock();
  516. }
  517. playerState = playerStateType;
  518. position = GameData.PosWhoDie;
  519. }
  520. }
  521. #endregion
  522. private int score = 0;
  523. public int Score
  524. {
  525. get => score;
  526. }
  527. /// <summary>
  528. /// 加分
  529. /// </summary>
  530. /// <param name="add">增加量</param>
  531. public virtual void AddScore(int add)
  532. {
  533. lock (gameObjLock)
  534. {
  535. score += add;
  536. //Debugger.Output(this, " 's score has been added to: " + score.ToString());
  537. }
  538. }
  539. /// <summary>
  540. /// 角色所属队伍ID
  541. /// </summary>
  542. private int teamID = int.MaxValue;
  543. public int TeamID
  544. {
  545. get => teamID;
  546. set
  547. {
  548. lock (gameObjLock)
  549. {
  550. teamID = value;
  551. Debugger.Output(this, " joins in the team: " + value.ToString());
  552. }
  553. }
  554. }
  555. private int playerID = int.MaxValue;
  556. public int PlayerID
  557. {
  558. get => playerID;
  559. set
  560. {
  561. lock (gameObjLock)
  562. {
  563. playerID = value;
  564. }
  565. }
  566. }
  567. #region 道具和buff相关属性、方法
  568. private Consumables[] propInventory = new Consumables[GameData.maxNumOfPropInPropInventory]
  569. {new NullProp(), new NullProp(),new NullProp() };
  570. public Consumables[] PropInventory
  571. {
  572. get => propInventory;
  573. set
  574. {
  575. lock (gameObjLock)
  576. {
  577. propInventory = value;
  578. Debugger.Output(this, " prop becomes " + (PropInventory == null ? "null" : PropInventory.ToString()));
  579. }
  580. }
  581. }
  582. /// <summary>
  583. /// 使用物品栏中的道具
  584. /// </summary>
  585. /// <returns>被使用的道具</returns>
  586. public Consumables UseProp(int indexing)
  587. {
  588. if (indexing < 0 || indexing >= GameData.maxNumOfPropInPropInventory)
  589. return new NullProp();
  590. lock (gameObjLock)
  591. {
  592. Consumables prop = propInventory[indexing];
  593. PropInventory[indexing] = new NullProp();
  594. return prop;
  595. }
  596. }
  597. public Consumables UseProp(PropType propType)
  598. {
  599. lock (gameObjLock)
  600. {
  601. if (propType == PropType.Null)
  602. {
  603. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  604. {
  605. if (PropInventory[indexing].GetPropType() != PropType.Null)
  606. {
  607. Consumables prop = PropInventory[indexing];
  608. PropInventory[indexing] = new NullProp();
  609. return prop;
  610. }
  611. }
  612. }
  613. else
  614. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  615. {
  616. if (PropInventory[indexing].GetPropType() == propType)
  617. {
  618. Consumables prop = PropInventory[indexing];
  619. PropInventory[indexing] = new NullProp();
  620. return prop;
  621. }
  622. }
  623. return new NullProp();
  624. }
  625. }
  626. /// <summary>
  627. /// 如果indexing==GameData.maxNumOfPropInPropInventory表明道具栏为满
  628. /// </summary>
  629. public int IndexingOfAddProp()
  630. {
  631. int indexing = 0;
  632. for (; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  633. if (PropInventory[indexing].GetPropType() == PropType.Null)
  634. break;
  635. return indexing;
  636. }
  637. public void AddMoveSpeed(int buffTime, double add = 1.0) => buffManager.AddMoveSpeed(add, buffTime, newVal =>
  638. { MoveSpeed = newVal < GameData.characterMaxSpeed ? newVal : GameData.characterMaxSpeed; },
  639. OrgMoveSpeed);
  640. public bool HasFasterSpeed => buffManager.HasFasterSpeed;
  641. public void AddShield(int shieldTime) => buffManager.AddShield(shieldTime);
  642. public bool HasShield => buffManager.HasShield;
  643. public void AddLife(int LIFETime) => buffManager.AddLife(LIFETime);
  644. public bool HasLIFE => buffManager.HasLIFE;
  645. public void AddAp(int time) => buffManager.AddAp(time);
  646. public bool HasAp => buffManager.HasAp;
  647. public void AddSpear(int spearTime) => buffManager.AddSpear(spearTime);
  648. public bool HasSpear => buffManager.HasSpear;
  649. public void AddClairaudience(int time) => buffManager.AddClairaudience(time);
  650. public bool HasClairaudience => buffManager.HasClairaudience;
  651. public void AddInvisible(int time) => buffManager.AddInvisible(time);
  652. public bool HasInvisible => buffManager.HasInvisible;
  653. private Array buffTypeArray = Enum.GetValues(typeof(BuffType));
  654. public Dictionary<BuffType, bool> Buff
  655. {
  656. get
  657. {
  658. Dictionary<BuffType, bool> buff = new Dictionary<BuffType, bool>();
  659. foreach (BuffType type in buffTypeArray)
  660. {
  661. if (type != BuffType.Null)
  662. buff.Add(type, GetBuffStatus(type));
  663. }
  664. return buff;
  665. }
  666. }
  667. private bool GetBuffStatus(BuffType type)
  668. {
  669. switch (type)
  670. {
  671. case BuffType.Spear:
  672. return this.HasSpear;
  673. case BuffType.AddSpeed:
  674. return this.HasFasterSpeed;
  675. case BuffType.Shield:
  676. return this.HasShield;
  677. case BuffType.AddLife:
  678. return this.HasLIFE;
  679. case BuffType.AddAp:
  680. return this.HasAp;
  681. case BuffType.Clairaudience:
  682. return this.HasClairaudience;
  683. case BuffType.Invisible:
  684. return this.HasInvisible;
  685. default:
  686. return false;
  687. }
  688. }
  689. public void TryActivatingLIFE()
  690. {
  691. if (buffManager.TryActivatingLIFE())
  692. {
  693. AddScore(GameData.ScorePropRemainHp);
  694. hp = GameData.RemainHpWhenAddLife;
  695. }
  696. }
  697. public bool TryAddAp()
  698. {
  699. if (buffManager.TryAddAp())
  700. {
  701. AddScore(GameData.ScorePropAddAp);
  702. return true;
  703. }
  704. return false;
  705. }
  706. public bool TryUseSpear()
  707. {
  708. return buffManager.TryUseSpear();
  709. }
  710. public bool TryUseShield()
  711. {
  712. if (buffManager.TryUseShield())
  713. {
  714. AddScore(GameData.ScorePropUseShield);
  715. return true;
  716. }
  717. return false;
  718. }
  719. #endregion
  720. /* public override void Reset() // 要加锁吗?
  721. {
  722. lock (gameObjLock)
  723. {
  724. // _ = AddDeathCount();
  725. base.Reset();
  726. this.MoveSpeed = OrgMoveSpeed;
  727. HP = MaxHp;
  728. PropInventory = null;
  729. BulletOfPlayer = OriBulletOfPlayer;
  730. lock (gameObjLock)
  731. bulletNum = maxBulletNum;
  732. buffManager.ClearAll();
  733. IsInvisible = false;
  734. this.Vampire = this.OriVampire;
  735. }
  736. }*/
  737. public override bool IsRigid => true;
  738. public override ShapeType Shape => ShapeType.Circle;
  739. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  740. {
  741. if (IsRemoved)
  742. return true;
  743. if (targetObj.Type == GameObjType.Consumables)
  744. {
  745. return true;
  746. }
  747. if (targetObj.Type == GameObjType.Character && XY.DistanceCeil3(targetObj.Position, this.Position) < this.Radius + targetObj.Radius - GameData.adjustLength)
  748. return true;
  749. return false;
  750. }
  751. }
  752. }