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 28 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. #region 装弹、攻击相关的基本属性及方法
  11. private readonly object attackLock = new();
  12. public IntNumUpdateEachCD BulletNum { get; } = new IntNumUpdateEachCD();
  13. private int orgCD;
  14. public int OrgCD
  15. {
  16. get
  17. {
  18. lock (attackLock)
  19. return orgCD;
  20. }
  21. }
  22. public readonly BulletType OriBulletOfPlayer;
  23. private BulletType bulletOfPlayer;
  24. public BulletType BulletOfPlayer
  25. {
  26. get
  27. {
  28. lock (attackLock)
  29. {
  30. return bulletOfPlayer;
  31. }
  32. }
  33. set
  34. {
  35. lock (attackLock)
  36. {
  37. bulletOfPlayer = value;
  38. orgCD = (BulletFactory.BulletCD(value));
  39. BulletNum.SetCD(orgCD);
  40. Debugger.Output(this, string.Format("'s CD has been set to: {0}.", orgCD));
  41. BulletNum.SetPositiveMaxNumAndNum(BulletFactory.BulletNum(value));
  42. }
  43. }
  44. }
  45. /// <summary>
  46. /// 进行一次攻击
  47. /// </summary>
  48. /// <returns>攻击操作发出的子弹</returns>
  49. public Bullet? Attack(double angle)
  50. {
  51. lock (attackLock)
  52. {
  53. if (bulletOfPlayer == BulletType.Null)
  54. return null;
  55. if (BulletNum.TrySub(1) == 1)
  56. {
  57. XY res = Position + new XY // 子弹紧贴人物生成。
  58. (
  59. (int)(Math.Abs((Radius + BulletFactory.BulletRadius(bulletOfPlayer)) * Math.Cos(angle))) * Math.Sign(Math.Cos(angle)),
  60. (int)(Math.Abs((Radius + BulletFactory.BulletRadius(bulletOfPlayer)) * Math.Sin(angle))) * Math.Sign(Math.Sin(angle))
  61. );
  62. Bullet? bullet = BulletFactory.GetBullet(this, res, this.bulletOfPlayer);
  63. if (bullet == null) return null;
  64. if (TryAddAp()) bullet.AP.Add(GameData.ApPropAdd);
  65. FacingDirection = new(angle, bullet.AttackDistance);
  66. return bullet;
  67. }
  68. else
  69. return null;
  70. }
  71. }
  72. #endregion
  73. #region 感知相关的基本属性及方法
  74. private readonly object bgmLock = new();
  75. private Dictionary<BgmType, double> bgmDictionary = new() { { BgmType.GhostIsComing, 0 }, { BgmType.StudentIsApproaching, 0 }, { BgmType.GeneratorIsBeingFixed, 0 } };
  76. public Dictionary<BgmType, double> BgmDictionary
  77. {
  78. get
  79. {
  80. lock (bgmLock)
  81. return bgmDictionary;
  82. }
  83. }
  84. public void AddBgm(BgmType bgm, double value)
  85. {
  86. lock (bgmLock)
  87. bgmDictionary[bgm] = value;
  88. }
  89. private readonly int alertnessRadius;
  90. public int AlertnessRadius => alertnessRadius;
  91. private readonly double concealment;
  92. public double Concealment => concealment;
  93. private readonly int viewRange;
  94. public int ViewRange => viewRange;
  95. #endregion
  96. #region 交互相关的基本属性及方法
  97. private readonly int speedOfOpeningOrLocking;
  98. public int SpeedOfOpeningOrLocking => speedOfOpeningOrLocking;
  99. private readonly int speedOfClimbingThroughWindows;
  100. public int SpeedOfClimbingThroughWindows => speedOfClimbingThroughWindows;
  101. private readonly int speedOfOpenChest;
  102. public int SpeedOfOpenChest => speedOfOpenChest;
  103. #endregion
  104. #region 血量相关的基本属性及方法
  105. public LongInTheVariableRange HP { get; }
  106. public DoubleInTheVariableRange Vampire { get; } = new DoubleInTheVariableRange(0, 1);
  107. public double OriVampire { get; protected set; }
  108. private readonly object treatLock = new();
  109. private int degreeOfTreatment = 0;
  110. public int DegreeOfTreatment
  111. {
  112. get
  113. {
  114. lock (treatLock)
  115. return degreeOfTreatment;
  116. }
  117. }
  118. public void SetDegreeOfTreatment0()
  119. {
  120. lock (treatLock)
  121. degreeOfTreatment = 0;
  122. }
  123. public bool AddDegreeOfTreatment(int value, Student whoTreatYou)
  124. {
  125. lock (treatLock)
  126. {
  127. degreeOfTreatment += value;
  128. long addV = HP.TryAddToMaxV(degreeOfTreatment);
  129. if (addV == 0)
  130. {
  131. degreeOfTreatment = 0;
  132. return false;
  133. }
  134. if (addV > 0)
  135. {
  136. whoTreatYou.AddScore(GameData.StudentScoreTreat(addV));
  137. degreeOfTreatment = 0;
  138. return true;
  139. }
  140. if (degreeOfTreatment >= GameData.basicTreatmentDegree)
  141. {
  142. whoTreatYou.AddScore(GameData.StudentScoreTreat(GameData.basicTreatmentDegree));
  143. HP.AddPositiveV(GameData.basicTreatmentDegree);
  144. degreeOfTreatment = 0;
  145. return true;
  146. }
  147. return false;
  148. }
  149. }
  150. #endregion
  151. #region 查询状态相关的基本属性与方法
  152. private PlayerStateType playerState = PlayerStateType.Null;
  153. public PlayerStateType PlayerState
  154. {
  155. get
  156. {
  157. lock (actionLock)
  158. {
  159. if (playerState == PlayerStateType.Moving)
  160. return (IsMoving) ? PlayerStateType.Moving : PlayerStateType.Null;
  161. return playerState;
  162. }
  163. }
  164. }
  165. public bool NoHp()
  166. {
  167. lock (actionLock)
  168. return (playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped || playerState == PlayerStateType.Addicted || playerState == PlayerStateType.Rescued);
  169. }
  170. public bool Commandable()
  171. {
  172. lock (actionLock)
  173. {
  174. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  175. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  176. && playerState != PlayerStateType.Swinging && playerState != PlayerStateType.TryingToAttack
  177. && playerState != PlayerStateType.ClimbingThroughWindows
  178. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  179. }
  180. }
  181. public bool CanPinDown()
  182. {
  183. lock (actionLock)
  184. {
  185. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  186. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  187. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  188. }
  189. }
  190. public bool InteractingWithMapWithoutMoving()
  191. {
  192. lock (actionLock)
  193. {
  194. return (playerState == PlayerStateType.LockingTheDoor || playerState == PlayerStateType.OpeningTheDoor
  195. || playerState == PlayerStateType.Fixing || playerState == PlayerStateType.OpeningTheChest);
  196. }
  197. }
  198. public bool NullOrMoving()
  199. {
  200. lock (actionLock)
  201. {
  202. return (playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  203. }
  204. }
  205. public bool CanBeAwed()
  206. {
  207. lock (actionLock)
  208. return !(playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped
  209. || playerState == PlayerStateType.Addicted
  210. || playerState == PlayerStateType.Rescued || playerState == PlayerStateType.Treated
  211. || playerState == PlayerStateType.Stunned || playerState == PlayerStateType.Charmed
  212. || playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  213. }
  214. #endregion
  215. #region 更改状态相关的属性和方法
  216. private GameObj? whatInteractingWith = null;
  217. public GameObj? WhatInteractingWith
  218. {
  219. get
  220. {
  221. lock (actionLock)
  222. {
  223. return whatInteractingWith;
  224. }
  225. }
  226. }
  227. private long ChangePlayerState(RunningStateType running, PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  228. {
  229. //只能被SetPlayerState引用
  230. if (runningState == RunningStateType.RunningSleepily)
  231. {
  232. ThreadNum.Release();
  233. }
  234. runningState = running;
  235. whatInteractingWith = gameObj;
  236. playerState = value;
  237. return ++stateNum;
  238. }
  239. private long ChangePlayerStateInOneThread(RunningStateType running, PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  240. {
  241. if (runningState == RunningStateType.RunningSleepily)
  242. {
  243. ThreadNum.Release();
  244. }
  245. runningState = running;
  246. //只能被SetPlayerState引用
  247. whatInteractingWith = gameObj;
  248. playerState = value;
  249. return stateNum;
  250. }
  251. public long SetPlayerState(RunningStateType runningState, PlayerStateType value = PlayerStateType.Null, IGameObj? obj = null)
  252. {
  253. GameObj? gameObj = (GameObj?)obj;
  254. lock (actionLock)
  255. {
  256. PlayerStateType nowPlayerState = PlayerState;
  257. if (nowPlayerState == value && value != PlayerStateType.UsingSkill) return -1;
  258. GameObj? lastObj = whatInteractingWith;
  259. switch (nowPlayerState)
  260. {
  261. case PlayerStateType.Escaped:
  262. case PlayerStateType.Deceased:
  263. return -1;
  264. case PlayerStateType.Addicted:
  265. if (value == PlayerStateType.Rescued)
  266. return ChangePlayerStateInOneThread(runningState, value, gameObj);
  267. else if (value == PlayerStateType.Null || value == PlayerStateType.Deceased)
  268. return ChangePlayerState(runningState, value, gameObj);
  269. else return -1;
  270. case PlayerStateType.Rescued:
  271. if (value == PlayerStateType.Addicted)
  272. return ChangePlayerStateInOneThread(runningState, value, gameObj);
  273. else if (value == PlayerStateType.Null || value == PlayerStateType.Deceased)
  274. return ChangePlayerState(runningState, value, gameObj);
  275. else return -1;
  276. case PlayerStateType.TryingToAttack:
  277. if (value == PlayerStateType.Addicted || value == PlayerStateType.Swinging
  278. || value == PlayerStateType.Deceased || value == PlayerStateType.Stunned
  279. || value == PlayerStateType.Charmed || value == PlayerStateType.Null)
  280. return ChangePlayerState(runningState, value, gameObj);
  281. else return -1;
  282. case PlayerStateType.Stunned:
  283. case PlayerStateType.Charmed:
  284. if (value == PlayerStateType.Addicted || value == PlayerStateType.Deceased
  285. || value == PlayerStateType.Null)
  286. return ChangePlayerState(runningState, value, gameObj);
  287. else return -1;
  288. case PlayerStateType.Swinging:
  289. if (value == PlayerStateType.Addicted
  290. || value == PlayerStateType.Deceased || value == PlayerStateType.Stunned
  291. || value == PlayerStateType.Charmed || value == PlayerStateType.Null)
  292. return ChangePlayerState(runningState, value, gameObj);
  293. else return -1;
  294. case PlayerStateType.ClimbingThroughWindows:
  295. if (value == PlayerStateType.Addicted
  296. || value == PlayerStateType.Deceased || value == PlayerStateType.Stunned
  297. || value == PlayerStateType.Charmed || value == PlayerStateType.Null)
  298. {
  299. Window window = (Window)lastObj!;
  300. if (window.Stage.x != 0) ReSetPos(window.Stage);
  301. window.FinishClimbing();
  302. return ChangePlayerState(runningState, value, gameObj);
  303. }
  304. else return -1;
  305. case PlayerStateType.OpeningTheChest:
  306. if (value == PlayerStateType.Rescued) return -1;
  307. ((Chest)lastObj!).OpenProgress.Set0();
  308. return ChangePlayerState(runningState, value, gameObj);
  309. case PlayerStateType.OpeningTheDoorway:
  310. if (value == PlayerStateType.Rescued) return -1;
  311. Doorway doorway = (Doorway)lastObj!;
  312. doorway.ProgressOfDoorway.TryStop();
  313. return ChangePlayerState(runningState, value, gameObj);
  314. case PlayerStateType.OpeningTheDoor:
  315. if (value == PlayerStateType.Rescued) return -1;
  316. Door door = (Door)lastObj!;
  317. door.StopOpen();
  318. ReleaseTool(door.KeyType);
  319. return ChangePlayerState(runningState, value, gameObj);
  320. case PlayerStateType.UsingSkill:
  321. {
  322. if (value == PlayerStateType.Rescued) return -1;
  323. switch (CharacterType)
  324. {
  325. case CharacterType.TechOtaku:
  326. {
  327. if (typeof(CraftingBench).IsInstanceOfType(lastObj))
  328. {
  329. ((CraftingBench)lastObj!).StopSkill();
  330. return ChangePlayerState(runningState, value, gameObj);
  331. }
  332. else
  333. {
  334. if (value != PlayerStateType.UsingSkill)
  335. ((UseRobot)FindActiveSkill(ActiveSkillType.UseRobot)).NowPlayerID = (int)PlayerID;
  336. return ChangePlayerState(runningState, value, gameObj);
  337. }
  338. }
  339. case CharacterType.Assassin:
  340. if (value == PlayerStateType.Moving) return StateNum;
  341. else
  342. {
  343. TryDeleteInvisible();
  344. return ChangePlayerState(runningState, value, gameObj);
  345. }
  346. default:
  347. return ChangePlayerState(runningState, value, gameObj);
  348. }
  349. }
  350. default:
  351. if (value == PlayerStateType.Rescued) return -1;
  352. return ChangePlayerState(runningState, value, gameObj);
  353. }
  354. }
  355. }
  356. public long SetPlayerStateNaturally()
  357. {
  358. lock (actionLock)
  359. {
  360. runningState = RunningStateType.Null;
  361. whatInteractingWith = null;
  362. playerState = PlayerStateType.Null;
  363. return ++stateNum;
  364. }
  365. }
  366. public bool ResetPlayerState(long state, RunningStateType running = RunningStateType.Null, PlayerStateType value = PlayerStateType.Null, IGameObj? obj = null)
  367. {
  368. lock (actionLock)
  369. {
  370. if (state != stateNum) return false;
  371. this.runningState = running;
  372. whatInteractingWith = (GameObj?)obj;
  373. playerState = value;
  374. ++stateNum;
  375. return true;
  376. }
  377. }
  378. public bool ResetPlayerStateInOneThread(long state, RunningStateType running = RunningStateType.Null, PlayerStateType value = PlayerStateType.Null, IGameObj? obj = null)
  379. {
  380. lock (actionLock)
  381. {
  382. if (state != stateNum) return false;
  383. this.runningState = running;
  384. whatInteractingWith = (GameObj?)obj;
  385. playerState = value;
  386. return true;
  387. }
  388. }
  389. public bool StartThread(long stateNum, RunningStateType runningState)
  390. {
  391. lock (ActionLock)
  392. {
  393. if (this.StateNum == stateNum)
  394. {
  395. this.runningState = runningState;
  396. return true;
  397. }
  398. }
  399. return false;
  400. }
  401. public bool TryToRemoveFromGame(PlayerStateType playerStateType)
  402. {
  403. lock (actionLock)
  404. {
  405. if (SetPlayerState(RunningStateType.RunningForcibly, playerStateType) == -1) return false;
  406. TryToRemove();
  407. CanMove.SetReturnOri(false);
  408. position = GameData.PosWhoDie;
  409. }
  410. return true;
  411. }
  412. #endregion
  413. private long score = 0;
  414. public long Score
  415. {
  416. get => Interlocked.Read(ref score);
  417. }
  418. /// <summary>
  419. /// 加分
  420. /// </summary>
  421. /// <param name="add">增加量</param>
  422. public virtual void AddScore(long add)
  423. {
  424. Interlocked.Add(ref score, add);
  425. //Debugger.Output(this, " 's score has been added to: " + score.ToString());
  426. }
  427. /// <summary>
  428. /// 角色所属队伍ID
  429. /// </summary>
  430. public AtomicLong TeamID { get; } = new AtomicLong(long.MaxValue);
  431. public AtomicLong PlayerID { get; } = new AtomicLong(long.MaxValue);
  432. #region 道具和buff相关属性、方法
  433. private readonly object inventoryLock = new();
  434. public object InventoryLock => inventoryLock;
  435. private Gadget[] propInventory = new Gadget[GameData.maxNumOfPropInPropInventory]
  436. {new NullProp(), new NullProp(),new NullProp() };
  437. public Gadget[] PropInventory
  438. {
  439. get
  440. {
  441. lock (inventoryLock)
  442. return propInventory;
  443. }
  444. set
  445. {
  446. lock (inventoryLock)
  447. propInventory = value;
  448. }
  449. }
  450. /// <summary>
  451. /// 使用物品栏中的道具
  452. /// </summary>
  453. /// <returns>被使用的道具</returns>
  454. public Gadget ConsumeProp(int indexing)
  455. {
  456. if (indexing < 0 || indexing >= GameData.maxNumOfPropInPropInventory)
  457. return new NullProp();
  458. lock (inventoryLock)
  459. {
  460. Gadget prop = propInventory[indexing];
  461. if (!prop.IsUsable()) return new NullProp();
  462. PropInventory[indexing] = new NullProp();
  463. return prop;
  464. }
  465. }
  466. public Gadget ConsumeProp(PropType propType)
  467. {
  468. if (propType == PropType.Null)
  469. {
  470. lock (inventoryLock)
  471. {
  472. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  473. {
  474. if (PropInventory[indexing].IsUsable())
  475. {
  476. Gadget prop = PropInventory[indexing];
  477. PropInventory[indexing] = new NullProp();
  478. return prop;
  479. }
  480. }
  481. }
  482. }
  483. else
  484. {
  485. lock (inventoryLock)
  486. {
  487. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  488. {
  489. if (PropInventory[indexing].GetPropType() == propType && PropInventory[indexing].IsUsable())
  490. {
  491. Gadget prop = PropInventory[indexing];
  492. PropInventory[indexing] = new NullProp();
  493. return prop;
  494. }
  495. }
  496. }
  497. }
  498. return new NullProp();
  499. }
  500. public bool UseTool(PropType propType)//占用道具,使其不能重复使用和被消耗
  501. {
  502. lock (inventoryLock)
  503. {
  504. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  505. {
  506. if (PropInventory[indexing].GetPropType() == propType && PropInventory[indexing].IsUsable())
  507. {
  508. return ((Tool)PropInventory[indexing]).IsUsed = true;
  509. }
  510. }
  511. }
  512. return false;
  513. }
  514. public void ReleaseTool(PropType propType)
  515. {
  516. lock (inventoryLock)
  517. {
  518. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  519. {
  520. if (PropInventory[indexing].GetPropType() == propType && ((Tool)PropInventory[indexing]).IsUsed)
  521. {
  522. ((Tool)PropInventory[indexing]).IsUsed = false;
  523. break;
  524. }
  525. }
  526. }
  527. }
  528. /// <summary>
  529. /// 如果indexing==GameData.maxNumOfPropInPropInventory表明道具栏为满
  530. /// </summary>
  531. public int IndexingOfAddProp()
  532. {
  533. int indexing = 0;
  534. lock (inventoryLock)
  535. for (; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  536. if (propInventory[indexing].GetPropType() == PropType.Null)
  537. break;
  538. return indexing;
  539. }
  540. public void AddMoveSpeed(int buffTime, double add = 1.0) => buffManager.AddMoveSpeed(add, buffTime, newVal =>
  541. { MoveSpeed.SetReturnOri(newVal < GameData.characterMaxSpeed ? newVal : GameData.characterMaxSpeed); },
  542. OrgMoveSpeed);
  543. public bool HasFasterSpeed => buffManager.HasFasterSpeed;
  544. public void AddShield(int shieldTime) => buffManager.AddShield(shieldTime);
  545. public bool HasShield => buffManager.HasShield;
  546. public void AddLife(int LIFETime) => buffManager.AddLife(LIFETime);
  547. public bool HasLIFE => buffManager.HasLIFE;
  548. public void AddAp(int time) => buffManager.AddAp(time);
  549. public bool HasAp => buffManager.HasAp;
  550. public void AddSpear(int spearTime) => buffManager.AddSpear(spearTime);
  551. public bool HasSpear => buffManager.HasSpear;
  552. public void AddClairaudience(int time) => buffManager.AddClairaudience(time);
  553. public bool HasClairaudience => buffManager.HasClairaudience;
  554. public void AddInvisible(int time) => buffManager.AddInvisible(time);
  555. public bool HasInvisible => buffManager.HasInvisible;
  556. private Array buffTypeArray = Enum.GetValues(typeof(BuffType));
  557. public Dictionary<BuffType, bool> Buff
  558. {
  559. get
  560. {
  561. Dictionary<BuffType, bool> buff = new Dictionary<BuffType, bool>();
  562. foreach (BuffType type in buffTypeArray)
  563. {
  564. if (type != BuffType.Null)
  565. buff.Add(type, GetBuffStatus(type));
  566. }
  567. return buff;
  568. }
  569. }
  570. private bool GetBuffStatus(BuffType type)
  571. {
  572. switch (type)
  573. {
  574. case BuffType.Spear:
  575. return this.HasSpear;
  576. case BuffType.AddSpeed:
  577. return this.HasFasterSpeed;
  578. case BuffType.Shield:
  579. return this.HasShield;
  580. case BuffType.AddLife:
  581. return this.HasLIFE;
  582. case BuffType.AddAp:
  583. return this.HasAp;
  584. case BuffType.Clairaudience:
  585. return this.HasClairaudience;
  586. case BuffType.Invisible:
  587. return this.HasInvisible;
  588. default:
  589. return false;
  590. }
  591. }
  592. public void TryActivatingLIFE()
  593. {
  594. if (buffManager.TryActivatingLIFE())
  595. {
  596. AddScore(GameData.ScorePropRemainHp);
  597. HP.SetPositiveV(GameData.RemainHpWhenAddLife);
  598. }
  599. }
  600. public bool TryAddAp()
  601. {
  602. if (buffManager.TryAddAp())
  603. {
  604. AddScore(GameData.ScorePropAddAp);
  605. return true;
  606. }
  607. return false;
  608. }
  609. public bool TryUseSpear()
  610. {
  611. return buffManager.TryUseSpear();
  612. }
  613. public bool TryDeleteInvisible()
  614. {
  615. return buffManager.TryDeleteInvisible();
  616. }
  617. public bool TryUseShield()
  618. {
  619. if (buffManager.TryUseShield())
  620. {
  621. AddScore(GameData.ScorePropUseShield);
  622. return true;
  623. }
  624. return false;
  625. }
  626. #endregion
  627. /* public override void Reset() // 要加锁吗?
  628. {
  629. lock (gameObjLock)
  630. {
  631. // _ = AddDeathCount();
  632. base.Reset();
  633. this.MoveSpeed = OrgMoveSpeed;
  634. HP = MaxHp;
  635. PropInventory = null;
  636. BulletOfPlayer = OriBulletOfPlayer;
  637. lock (gameObjLock)
  638. bulletNum = maxBulletNum;
  639. buffManager.ClearAll();
  640. IsInvisible = false;
  641. this.Vampire = this.OriVampire;
  642. }
  643. }*/
  644. public override bool IsRigid => true;
  645. public override ShapeType Shape => ShapeType.Circle;
  646. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  647. {
  648. if (IsRemoved)
  649. return true;
  650. if (targetObj.Type == GameObjType.Gadget)
  651. {
  652. return true;
  653. }
  654. if (targetObj.Type == GameObjType.Character && XY.DistanceCeil3(targetObj.Position, this.Position) < this.Radius + targetObj.Radius - GameData.adjustLength)
  655. return true;
  656. return false;
  657. }
  658. }
  659. }