RewardMnr.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName from "../EventName/EventName";
  8. import LocalData from "../LocalData";
  9. export default class RewardMnr {
  10. private static _instance: RewardMnr = null;
  11. public static getInstance() {
  12. if (!this._instance) {
  13. this._instance = new RewardMnr();
  14. }
  15. return this._instance;
  16. }
  17. //还原
  18. Reset() {
  19. this.HasPropName = []
  20. }
  21. HasPropName: string[] = []
  22. ParabolaCount = 0
  23. //添加辅助线次数
  24. addParabola(name: string, Count: number) {
  25. if (!this.HasPropName.includes(name)) {
  26. this.HasPropName.push(name)
  27. this.ParabolaCount += Count
  28. cc.systemEvent.emit(EventName.Tips, `您获得了 ${Count} 次完整辅助线机会`)
  29. }
  30. }
  31. addGold(name: string, Count: number) {
  32. if (!this.HasPropName.includes(name)) {
  33. this.HasPropName.push(name)
  34. LocalData.getInstance().setGold(Count, '+')
  35. cc.systemEvent.emit(EventName.Tips, `您获得了 ${Count} 枚金币`)
  36. }
  37. }
  38. isEnable(name: string) {
  39. if (!this.HasPropName.includes(name)) {
  40. return true
  41. }
  42. return false
  43. }
  44. useOnceParabola() {
  45. if (this.ParabolaCount > 0) {
  46. this.ParabolaCount--
  47. }
  48. }
  49. // update (dt) {}
  50. }