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

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