1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import { _decorator, Color, Component, instantiate, Node, Prefab, Sprite, sys, Vec2, Vec3 } from 'cc';
- import { SkinItem } from './SkinItem';
- import EventMgr from '../../script/Manager/EventMgr';
- import { allSkinList, Skin, SuperFind } from '../../script/Manager/LocalDataMgr';
- import { mainscene } from '../../script/mainscene';
- import PlatformService from '../../script/Platform/PlatformService';
- const { ccclass, property } = _decorator;
- @ccclass('SkinItem2')
- export class SkinItem2 extends SkinItem {
- @property({type:Node})
- lock:Node = null
- @property({type:Node})
- usingLabel:Node = null
- @property(Sprite)
- bgSprite:Sprite = null
- @property({type:Node})
- btnUse:Node = null
- private unlockColor = "C16D51"
- private lockColor = "FFFFFF"
- private key:number = -1
- private isUnlock:boolean = false
- protected override start(): void {
- super.start()
- this.btnUse.on(Node.EventType.TOUCH_END,this.onBtnUseClick,this)
- }
- override init(key: number,spine:Prefab,animName:string = "idle",spineOffset:Vec2 = new Vec2(0,0),isUnlock:boolean = false)
- {
- let skin = instantiate(spine)
- this.skinRoot.addChild(skin)
- skin.active = true
- skin.setPosition(Vec3.ZERO)
- skin.position = skin.position.clone().add3f(spineOffset.x,spineOffset.y,0)
- this.lock.active = !isUnlock
- this.key = key
- this.setBgColor(isUnlock)
- this.isUnlock = isUnlock
- }
- override onClick()
- {
- if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
- mainscene.instance.ge.track(
- "ad_show", //追踪事件的名称
- {
- version: "123",
- ad_position: "小熊解锁皮肤",
- level_id: SuperFind.superFindData.currentBgKey
- } //需要上传的事件属性
- );
- }
- PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => {
- // PlatformService.getInstance().platformApi.reportAnalytics("tips", {
- // level: this.data.title
- // })
- if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
- mainscene.instance.ge.track(
- "ad_showend", //追踪事件的名称
- {
- version: "123",
- ad_position: "小熊解锁皮肤",
- level_id: SuperFind.superFindData.currentBgKey
- } //需要上传的事件属性
- );
- this.isUnlock = true
- this.setBgColor(this.isUnlock)
- this.lock.active = !this.isUnlock
- Skin.addSelectSkin(this.key)
- }
- })
- }
- onBtnUseClick()
- {
- Skin.setCurrentSelSingleSkin(this.key)
- Skin.setSelectStatu(true)
- EventMgr.ins.dispatchEvent("showUsingLabel",[this.node,this.isUnlock])
- EventMgr.ins.dispatchEvent("regenerate")
- // console.log("当前被选中的皮肤",allSkinList[this.key])
- }
- setBgColor(isUnlock)
- {
- let color = new Color()
- this.bgSprite.color = isUnlock ? Color.fromHEX(color, this.unlockColor) : Color.fromHEX(color, this.lockColor);
- }
- override getKey(): number {
- return this.key
- }
- }
|