123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
- import EventName from "../EventName/EventName";
- import LoadManager from "../LoadManager";
- import LocalData from "../LocalData";
- import Award, { AwardType } from "../Pop/Award";
- export default class RewardMnr {
- private static _instance: RewardMnr = null;
- public static getInstance() {
- if (!this._instance) {
- this._instance = new RewardMnr();
- }
- return this._instance;
- }
- //还原
- Reset() {
- this.HasPropName = []
- }
- HasPropName: string[] = []
- ParabolaCount = 0
- //添加辅助线次数
- addParabola(name: string, Count: number) {
- if (!this.HasPropName.includes(name)) {
- this.HasPropName.push(name)
- this.ParabolaCount += Count
- this.PopAward(AwardType.XuXian)
- }
- }
- addGold(name: string, Count: number) {
- if (!this.HasPropName.includes(name)) {
- this.HasPropName.push(name)
- console.error(this.HasPropName);
-
- LocalData.getInstance().setGold(Count, '+')
- cc.systemEvent.emit(EventName.Tips, `您获得了 ${Count} 枚金币`)
- }
- }
- //#region 使用道具
- //道具使用辅助线次数
- PropUseParabola(Count: number) {
- if (LocalData.getInstance().getParabolaCount() > 0) {
- LocalData.getInstance().setParabolaCount(Count, '-')
- this.ParabolaCount += Count
- cc.systemEvent.emit(EventName.Tips, `您获得了 ${Count} 次完整辅助线机会`)
- } else {
- }
- }
- //道具使用超级跳次数
- PropUseSupjump(Count: number) {
- if (LocalData.getInstance().getSupjumpCount() > 0) {
- LocalData.getInstance().setSupjumpCount(Count, '-')
- cc.systemEvent.emit(EventName.Tips, `超级跳咯~`)
- cc.systemEvent.emit(EventName.UseSupjump)
- } else {
- }
- }
- //道具使用超级跳次数
- PropFlyjump(Count: number) {
- if (LocalData.getInstance().getFlyCount() > 0) {
- LocalData.getInstance().setFlyCount(Count, '-')
- cc.systemEvent.emit(EventName.Tips, `起飞咯~`)
- cc.systemEvent.emit(EventName.UseFly)
- } else {
- }
- }
- //#endregion
- isEnable(name: string) {
- if (!this.HasPropName.includes(name)) {
- return true
- }
- return false
- }
- useOnceParabola() {
- if (this.ParabolaCount > 0) {
- this.ParabolaCount--
- }
- }
- // 1虚线 2超级跳 3 飞
- PopAward(num: AwardType) {
- (async () => {
- const url = "res/Pop/Award"
- let Prefab = await LoadManager.instance.LoadAssets<cc.Prefab>(url);
- if (cc.isValid(Prefab)) {
- let a = cc.instantiate(Prefab);
- a.getComponent(Award).setSp(num)
- cc.Camera.main.node.addChild(a)
- setTimeout(() => {
- a.setPosition(cc.v2(0, 0))
- }, 1);
- }
- })();
- }
- // update (dt) {}
- }
|