VehicleModelComp.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. export enum VehicleState {
  5. Normal,
  6. Wait,
  7. Station,
  8. Leave
  9. }
  10. @ecs.register('VehicleModel')
  11. export class VehicleModelComp extends ecs.Comp {
  12. private vm: any = {};
  13. private _color: string = "";
  14. private _type: string = 'car'
  15. private _path: string = ""
  16. private _capcity: number = 3
  17. private _useSit: number = 0
  18. private _status: number = VehicleState.Normal // 0 正常 1 等待进站 2 站台 3出站
  19. private _ready: boolean = false
  20. get isFull(): boolean {
  21. return this._useSit >= this._capcity
  22. }
  23. get sitPos():Vec3[]{
  24. return [v3(-0.5,0,0),v3(0,0,0),v3(0.5,0,0)]
  25. }
  26. // 车辆状态
  27. get status(): VehicleState {
  28. return this._status
  29. }
  30. set status(s: VehicleState) {
  31. this._status = s
  32. }
  33. // 车辆状态
  34. get ready(): boolean {
  35. return this._ready
  36. }
  37. set ready(r: boolean) {
  38. this._ready = r
  39. }
  40. /** 颜色 */
  41. get color(): string {
  42. return this._color;
  43. }
  44. set color(value: string) {
  45. this._color = value;
  46. }
  47. /** 模型类型 车-飞机 */
  48. get type(): string {
  49. return this._type;
  50. }
  51. set type(value: string) {
  52. this._type = value;
  53. // this.vm.type = value;
  54. }
  55. /** 模型路径 */
  56. get path(): string {
  57. return this._path;
  58. }
  59. set path(value: string) {
  60. this._path = value;
  61. // this.vm.path = value;
  62. }
  63. /** 容量 */
  64. get capcity(): number {
  65. return this._capcity;
  66. }
  67. set capcity(value: number) {
  68. this._capcity = value;
  69. // this.vm.capcity = value;
  70. }
  71. /** 上车席位 */
  72. get useSit(): number {
  73. return this._useSit;
  74. }
  75. set useSit(value: number) {
  76. this._useSit = value;
  77. // this.vm.useSit = value;
  78. }
  79. // vmAdd() {
  80. // VM.add(this.vm, "Vehicle");
  81. // }
  82. // vmRemove() {
  83. // this.vm.reset();
  84. // VM.remove("Vehicle");
  85. // }
  86. reset() {
  87. // this.vmRemove();
  88. }
  89. }