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.

Doorway.cs 1.1 kB

12345678910111213141516171819202122232425262728293031323334
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. /// <summary>
  7. /// 出口
  8. /// </summary>
  9. public class Doorway : Immovable, IDoorway
  10. {
  11. public Doorway(XY initPos) :
  12. base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Doorway)
  13. {
  14. }
  15. public override bool IsRigid => true;
  16. public override ShapeType Shape => ShapeType.Square;
  17. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  18. {
  19. if (!ProgressOfDoorway.IsFinished()) return false;
  20. if (targetObj.Type != GameObjType.Character)
  21. return true; // 非玩家不碰撞
  22. return false;
  23. }
  24. public AtomicBool PowerSupply { get; } = new(false);
  25. public TimeBasedProgressAtVariableSpeed ProgressOfDoorway { get; } = new(GameData.degreeOfOpenedDoorway, 1);
  26. public bool TryToOpen()
  27. {
  28. if (!PowerSupply) return false;
  29. return ProgressOfDoorway.Start();
  30. }
  31. }
  32. }