VehicleModelComp.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { Vec3, v3 } from "cc";
  2. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  3. import { VM } from "../../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
  4. import { VehicleType } from "./VehicleEnum";
  5. import { SingletonModuleComp } from "../../common/SingletonModuleComp";
  6. export enum VehicleState {
  7. Normal,
  8. Wait,
  9. Station,
  10. Leave
  11. }
  12. @ecs.register('VehicleModel')
  13. export class VehicleModelComp extends ecs.Comp {
  14. private vm: any = {};
  15. private _color: string = "";
  16. private _type: string = 'car'
  17. private _path: string = ""
  18. private _capcity: number = 3
  19. private _useSit: number = 0
  20. private _status: number = VehicleState.Normal // 0 正常 1 等待进站 2 站台 3出站
  21. private _ready: boolean = false
  22. get isFull(): boolean {
  23. return this._useSit >= this._capcity
  24. }
  25. get sitPos():Vec3[]{
  26. const vehicle = ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelLevel.rtluCurrent.vehicleType
  27. switch (vehicle) {
  28. case VehicleType.CAR:
  29. return [v3(-0.5,0.2,0),v3(-0.1,0.2,0),v3(0.3,0.2,0)]
  30. case VehicleType.BUS:
  31. return [v3(-0.55,0.2,0),v3(-0.05,0.2,0),v3(0.45,0.2,0)]
  32. case VehicleType.AIRPLANT:
  33. return [v3(-0.9,0.6,0),v3(-0.3,0.6,0),v3(0.5,0.6,0)]
  34. default:
  35. return [v3(-0.5,0.2,0),v3(-0.1,0.2,0),v3(0.3,0.2,0)]
  36. }
  37. }
  38. // 车辆状态
  39. get status(): VehicleState {
  40. return this._status
  41. }
  42. set status(s: VehicleState) {
  43. this._status = s
  44. }
  45. // 车辆状态
  46. get ready(): boolean {
  47. return this._ready
  48. }
  49. set ready(r: boolean) {
  50. this._ready = r
  51. }
  52. /** 颜色 */
  53. get color(): string {
  54. return this._color;
  55. }
  56. set color(value: string) {
  57. this._color = value;
  58. }
  59. /** 模型类型 车-飞机 */
  60. get type(): string {
  61. return this._type;
  62. }
  63. set type(value: string) {
  64. this._type = value;
  65. // this.vm.type = value;
  66. }
  67. /** 模型路径 */
  68. get path(): string {
  69. return this._path;
  70. }
  71. set path(value: string) {
  72. this._path = value;
  73. // this.vm.path = value;
  74. }
  75. /** 容量 */
  76. get capcity(): number {
  77. return this._capcity;
  78. }
  79. set capcity(value: number) {
  80. this._capcity = value;
  81. // this.vm.capcity = value;
  82. }
  83. /** 上车席位 */
  84. get useSit(): number {
  85. return this._useSit;
  86. }
  87. set useSit(value: number) {
  88. this._useSit = value;
  89. // this.vm.useSit = value;
  90. }
  91. // vmAdd() {
  92. // VM.add(this.vm, "Vehicle");
  93. // }
  94. // vmRemove() {
  95. // this.vm.reset();
  96. // VM.remove("Vehicle");
  97. // }
  98. reset() {
  99. // this.vmRemove();
  100. }
  101. }