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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  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. }
  247. finally
  248. {
  249. HPReadWriterLock.ExitWriteLock();
  250. }
  251. }
  252. } // 最大血量
  253. protected int hp;
  254. public int HP
  255. {
  256. get
  257. {
  258. HPReadWriterLock.EnterReadLock();
  259. try
  260. {
  261. return hp;
  262. }
  263. finally
  264. {
  265. HPReadWriterLock.ExitReadLock();
  266. }
  267. }
  268. set
  269. {
  270. HPReadWriterLock.EnterWriteLock();
  271. try
  272. {
  273. if (value > 0)
  274. {
  275. hp = value <= MaxHp ? value : MaxHp;
  276. }
  277. else
  278. hp = 0;
  279. }
  280. finally
  281. {
  282. HPReadWriterLock.ExitWriteLock();
  283. }
  284. }
  285. }
  286. /// <summary>
  287. /// 尝试减血
  288. /// </summary>
  289. /// <param name="sub">减血量</param>
  290. /// <returns>减操作是否成功</returns>
  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. private double oriVampire = 0;
  347. public double OriVampire { get; protected set; }
  348. #endregion
  349. #region 状态相关的基本属性与方法
  350. private PlayerStateType playerState = PlayerStateType.Null;
  351. public PlayerStateType PlayerState
  352. {
  353. get
  354. {
  355. lock (actionLock)
  356. {
  357. if (playerState == PlayerStateType.Null && IsMoving) return PlayerStateType.Moving;
  358. return playerState;
  359. }
  360. }
  361. }
  362. public bool NoHp()
  363. {
  364. lock (actionLock)
  365. return (playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped || playerState == PlayerStateType.Addicted || playerState == PlayerStateType.Rescued);
  366. }
  367. public bool Commandable()
  368. {
  369. lock (actionLock)
  370. {
  371. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  372. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  373. && playerState != PlayerStateType.Swinging && playerState != PlayerStateType.TryingToAttack
  374. && playerState != PlayerStateType.ClimbingThroughWindows
  375. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  376. }
  377. }
  378. public bool CanPinDown()
  379. {
  380. lock (actionLock)
  381. {
  382. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  383. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  384. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  385. }
  386. }
  387. public bool InteractingWithMapWithoutMoving()
  388. {
  389. lock (actionLock)
  390. {
  391. return (playerState == PlayerStateType.LockingOrOpeningTheDoor || playerState == PlayerStateType.Fixing || playerState == PlayerStateType.OpeningTheChest);
  392. }
  393. }
  394. public bool NullOrMoving()
  395. {
  396. lock (actionLock)
  397. {
  398. return (playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  399. }
  400. }
  401. public bool CanBeAwed()
  402. {
  403. lock (actionLock)
  404. return !(playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped
  405. || playerState == PlayerStateType.Addicted
  406. || playerState == PlayerStateType.Rescued || playerState == PlayerStateType.Treated
  407. || playerState == PlayerStateType.Stunned || playerState == PlayerStateType.Charmed
  408. || playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  409. }
  410. private GameObj? whatInteractingWith = null;
  411. public GameObj? WhatInteractingWith => whatInteractingWith;
  412. private long ChangePlayerState(PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  413. {
  414. //只能被SetPlayerState引用
  415. whatInteractingWith = gameObj;
  416. if (value != PlayerStateType.Moving)
  417. IsMoving = false;
  418. playerState = (value == PlayerStateType.Moving) ? PlayerStateType.Null : value;
  419. //Debugger.Output(this,playerState.ToString()+" "+IsMoving.ToString());
  420. return ++stateNum;
  421. }
  422. private long ChangePlayerStateInOneThread(PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  423. {
  424. //只能被SetPlayerState引用
  425. whatInteractingWith = gameObj;
  426. if (value != PlayerStateType.Moving)
  427. IsMoving = false;
  428. playerState = (value == PlayerStateType.Moving) ? PlayerStateType.Null : value;
  429. //Debugger.Output(this,playerState.ToString()+" "+IsMoving.ToString());
  430. return stateNum;
  431. }
  432. public long SetPlayerState(PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  433. {
  434. lock (actionLock)
  435. {
  436. PlayerStateType nowPlayerState = PlayerState;
  437. if (nowPlayerState == value) return -1;
  438. switch (nowPlayerState)
  439. {
  440. case PlayerStateType.Escaped:
  441. case PlayerStateType.Deceased:
  442. return -1;
  443. case PlayerStateType.Addicted:
  444. if (value == PlayerStateType.Rescued)
  445. return ChangePlayerStateInOneThread(value, gameObj);
  446. else if (value == PlayerStateType.Null)
  447. return ChangePlayerState(value, gameObj);
  448. else return -1;
  449. case PlayerStateType.Rescued:
  450. if (value == PlayerStateType.Addicted)
  451. return ChangePlayerStateInOneThread(value, gameObj);
  452. else if (value == PlayerStateType.Null)
  453. return ChangePlayerState(value, gameObj);
  454. else return -1;
  455. case PlayerStateType.TryingToAttack:
  456. if (value != PlayerStateType.Moving && value != PlayerStateType.ClimbingThroughWindows)
  457. return ChangePlayerState(value, gameObj);
  458. else return -1;
  459. case PlayerStateType.Stunned:
  460. case PlayerStateType.Charmed:
  461. if (value != PlayerStateType.Moving && value != PlayerStateType.ClimbingThroughWindows && value != PlayerStateType.Swinging)
  462. return ChangePlayerState(value, gameObj);
  463. else return -1;
  464. case PlayerStateType.Swinging:
  465. if (value != PlayerStateType.Moving && value != PlayerStateType.ClimbingThroughWindows)
  466. {
  467. ThreadNum.Release();
  468. return ChangePlayerState(value, gameObj);
  469. }
  470. else return -1;
  471. case PlayerStateType.ClimbingThroughWindows:
  472. if (value != PlayerStateType.Moving)
  473. {
  474. Window window = (Window)WhatInteractingWith!;
  475. window.FinishClimbing();
  476. if (window.Stage.x == 0)
  477. ThreadNum.Release();
  478. else ReSetPos(window.Stage);
  479. return ChangePlayerState(value, gameObj);
  480. }
  481. else return -1;
  482. case PlayerStateType.OpeningTheChest:
  483. ((Chest)WhatInteractingWith!).StopOpen();
  484. return ChangePlayerState(value, gameObj);
  485. case PlayerStateType.OpeningTheDoorway:
  486. Doorway doorway = (Doorway)WhatInteractingWith!;
  487. doorway.StopOpenning();
  488. return ChangePlayerState(value, gameObj);
  489. default:
  490. return ChangePlayerState(value, gameObj);
  491. }
  492. }
  493. }
  494. public long SetPlayerStateNaturally()
  495. {
  496. lock (actionLock)
  497. {
  498. whatInteractingWith = null;
  499. IsMoving = false;
  500. playerState = PlayerStateType.Null;
  501. return ++stateNum;
  502. }
  503. }
  504. public void RemoveFromGame(PlayerStateType playerStateType)
  505. {
  506. lock (actionLock)
  507. {
  508. MoveReaderWriterLock.EnterWriteLock();
  509. try
  510. {
  511. canMove = false;
  512. isRemoved = true;
  513. }
  514. finally
  515. {
  516. MoveReaderWriterLock.ExitWriteLock();
  517. }
  518. playerState = playerStateType;
  519. position = GameData.PosWhoDie;
  520. }
  521. }
  522. #endregion
  523. private int score = 0;
  524. public int Score
  525. {
  526. get => score;
  527. }
  528. /// <summary>
  529. /// 加分
  530. /// </summary>
  531. /// <param name="add">增加量</param>
  532. public virtual void AddScore(int add)
  533. {
  534. lock (gameObjLock)
  535. {
  536. score += add;
  537. //Debugger.Output(this, " 's score has been added to: " + score.ToString());
  538. }
  539. }
  540. /// <summary>
  541. /// 角色所属队伍ID
  542. /// </summary>
  543. private int teamID = int.MaxValue;
  544. public int TeamID
  545. {
  546. get => teamID;
  547. set
  548. {
  549. lock (gameObjLock)
  550. {
  551. teamID = value;
  552. Debugger.Output(this, " joins in the team: " + value.ToString());
  553. }
  554. }
  555. }
  556. private int playerID = int.MaxValue;
  557. public int PlayerID
  558. {
  559. get => playerID;
  560. set
  561. {
  562. lock (gameObjLock)
  563. {
  564. playerID = value;
  565. }
  566. }
  567. }
  568. #region 道具和buff相关属性、方法
  569. private Prop[] propInventory = new Prop[GameData.maxNumOfPropInPropInventory]
  570. {new NullProp(), new NullProp(),new NullProp() };
  571. public Prop[] PropInventory
  572. {
  573. get => propInventory;
  574. set
  575. {
  576. lock (gameObjLock)
  577. {
  578. propInventory = value;
  579. Debugger.Output(this, " prop becomes " + (PropInventory == null ? "null" : PropInventory.ToString()));
  580. }
  581. }
  582. }
  583. /// <summary>
  584. /// 使用物品栏中的道具
  585. /// </summary>
  586. /// <returns>被使用的道具</returns>
  587. public Prop UseProp(int indexing)
  588. {
  589. if (indexing < 0 || indexing >= GameData.maxNumOfPropInPropInventory)
  590. return new NullProp();
  591. lock (gameObjLock)
  592. {
  593. Prop prop = propInventory[indexing];
  594. PropInventory[indexing] = new NullProp();
  595. return prop;
  596. }
  597. }
  598. public Prop UseProp(PropType propType)
  599. {
  600. lock (gameObjLock)
  601. {
  602. if (propType == PropType.Null)
  603. {
  604. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  605. {
  606. if (PropInventory[indexing].GetPropType() != PropType.Null)
  607. {
  608. Prop prop = PropInventory[indexing];
  609. PropInventory[indexing] = new NullProp();
  610. return prop;
  611. }
  612. }
  613. }
  614. else
  615. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  616. {
  617. if (PropInventory[indexing].GetPropType() == propType)
  618. {
  619. Prop prop = PropInventory[indexing];
  620. PropInventory[indexing] = new NullProp();
  621. return prop;
  622. }
  623. }
  624. return new NullProp();
  625. }
  626. }
  627. /// <summary>
  628. /// 如果indexing==GameData.maxNumOfPropInPropInventory表明道具栏为满
  629. /// </summary>
  630. public int IndexingOfAddProp()
  631. {
  632. int indexing = 0;
  633. for (; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  634. if (PropInventory[indexing].GetPropType() == PropType.Null)
  635. break;
  636. return indexing;
  637. }
  638. public void AddMoveSpeed(int buffTime, double add = 1.0) => buffManager.AddMoveSpeed(add, buffTime, newVal =>
  639. { MoveSpeed = newVal < GameData.characterMaxSpeed ? newVal : GameData.characterMaxSpeed; },
  640. OrgMoveSpeed);
  641. public bool HasFasterSpeed => buffManager.HasFasterSpeed;
  642. public void AddShield(int shieldTime) => buffManager.AddShield(shieldTime);
  643. public bool HasShield => buffManager.HasShield;
  644. public void AddLife(int LIFETime) => buffManager.AddLife(LIFETime);
  645. public bool HasLIFE => buffManager.HasLIFE;
  646. public void AddAp(int time) => buffManager.AddAp(time);
  647. public bool HasAp => buffManager.HasAp;
  648. public void AddSpear(int spearTime) => buffManager.AddSpear(spearTime);
  649. public bool HasSpear => buffManager.HasSpear;
  650. public void AddClairaudience(int time) => buffManager.AddClairaudience(time);
  651. public bool HasClairaudience => buffManager.HasClairaudience;
  652. public void AddInvisible(int time) => buffManager.AddInvisible(time);
  653. public bool HasInvisible => buffManager.HasInvisible;
  654. private Array buffTypeArray = Enum.GetValues(typeof(BuffType));
  655. public Dictionary<BuffType, bool> Buff
  656. {
  657. get
  658. {
  659. Dictionary<BuffType, bool> buff = new Dictionary<BuffType, bool>();
  660. foreach (BuffType type in buffTypeArray)
  661. {
  662. if (type != BuffType.Null)
  663. buff.Add(type, GetBuffStatus(type));
  664. }
  665. return buff;
  666. }
  667. }
  668. private bool GetBuffStatus(BuffType type)
  669. {
  670. switch (type)
  671. {
  672. case BuffType.Spear:
  673. return this.HasSpear;
  674. case BuffType.AddSpeed:
  675. return this.HasFasterSpeed;
  676. case BuffType.Shield:
  677. return this.HasShield;
  678. case BuffType.AddLife:
  679. return this.HasLIFE;
  680. case BuffType.AddAp:
  681. return this.HasAp;
  682. case BuffType.Clairaudience:
  683. return this.HasClairaudience;
  684. case BuffType.Invisible:
  685. return this.HasInvisible;
  686. default:
  687. return false;
  688. }
  689. }
  690. public void TryActivatingLIFE()
  691. {
  692. if (buffManager.TryActivatingLIFE())
  693. {
  694. AddScore(GameData.ScorePropRemainHp);
  695. hp = GameData.RemainHpWhenAddLife;
  696. }
  697. }
  698. public bool TryAddAp()
  699. {
  700. if (buffManager.TryAddAp())
  701. {
  702. AddScore(GameData.ScorePropAddAp);
  703. return true;
  704. }
  705. return false;
  706. }
  707. public bool TryUseSpear()
  708. {
  709. return buffManager.TryUseSpear();
  710. }
  711. public bool TryUseShield()
  712. {
  713. if (buffManager.TryUseShield())
  714. {
  715. AddScore(GameData.ScorePropUseShield);
  716. return true;
  717. }
  718. return false;
  719. }
  720. #endregion
  721. /* public override void Reset() // 要加锁吗?
  722. {
  723. lock (gameObjLock)
  724. {
  725. // _ = AddDeathCount();
  726. base.Reset();
  727. this.MoveSpeed = OrgMoveSpeed;
  728. HP = MaxHp;
  729. PropInventory = null;
  730. BulletOfPlayer = OriBulletOfPlayer;
  731. lock (gameObjLock)
  732. bulletNum = maxBulletNum;
  733. buffManager.ClearAll();
  734. IsInvisible = false;
  735. this.Vampire = this.OriVampire;
  736. }
  737. }*/
  738. public override bool IsRigid => true;
  739. public override ShapeType Shape => ShapeType.Circle;
  740. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  741. {
  742. if (IsRemoved)
  743. return true;
  744. if (targetObj.Type == GameObjType.Prop)
  745. {
  746. return true;
  747. }
  748. if (targetObj.Type == GameObjType.Character && XY.DistanceCeil3(targetObj.Position, this.Position) < this.Radius + targetObj.Radius - GameData.adjustLength)
  749. return true;
  750. return false;
  751. }
  752. }
  753. }