WeaponBlockExample.ts 919 B

123456789101112131415161718192021222324252627282930313233
  1. import { _decorator, Component } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. /**
  4. * 武器方块示例脚本
  5. * 展示如何使用ConfigManager来创建带有武器配置的方块
  6. */
  7. @ccclass('WeaponBlockExample')
  8. export class WeaponBlockExample extends Component {
  9. private static _instance: WeaponBlockExample = null;
  10. // 全局子弹速度(BulletController 会读取)
  11. @property({ tooltip: '全局子弹速度(覆盖子弹预制体上的默认值)' })
  12. public bulletSpeed: number = 300;
  13. onLoad() {
  14. WeaponBlockExample._instance = this;
  15. }
  16. onDestroy() {
  17. if (WeaponBlockExample._instance === this) {
  18. WeaponBlockExample._instance = null;
  19. }
  20. }
  21. public static getInstance(): WeaponBlockExample {
  22. return WeaponBlockExample._instance;
  23. }
  24. public getCurrentBulletSpeed(): number {
  25. return this.bulletSpeed;
  26. }
  27. }