| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import { _decorator, Button, Component, Node } from 'cc';
- import { button_sound, GameLink, notify } from '../../game/GameLink';
- import { week_data_type } from '../../game/Player';
- import { gui } from '../../../core/ui/ui';
- import { UI_lsbx } from './UI_lsbx';
- import { UINotify } from '../../../module_basic/ui_notify/UINotify';
- import ch_util from '../../../ch/ch_util';
- const { ccclass, property } = _decorator;
- @ccclass('UI_item')
- export class UI_item extends Component {
- @property(Button)
- private btn: Button = null;
- @property(Node)
- private wdl: Node = null;
- @property(Node)
- private have: Node = null;
- @property(Node)
- private mask: Node = null;
- @property({type:Number})
- public index:number;
- start() {
- }
- private onClick() {
- button_sound();
- GameLink.getInst().player.set_ylq_ls(1);
- this.get_reward();
- console.log(GameLink.getInst().player.get_ylq_ls());
- this.show_Have();
- }
- public show_Have() {
- this.have.active = true;
- this.btn.node.off(Button.EventType.CLICK, this.onClick, this);
- }
- public hide_Mask() {
- this.wdl.active = false;
- this.mask.active = false;
- }
- public unlock() {
- this.btn.node.on(Button.EventType.CLICK, this.onClick, this);
- }
- private get_reward(){
- if (gui.get(UI_lsbx).items_value[this.index][0] == 1) {
- GameLink.getInst().player.add_item(3, gui.get(UI_lsbx).items_value[this.index][1]);
- UINotify.show("提示道具+3");
- }
- else if (gui.get(UI_lsbx).items_value[this.index][0] == 2) {
- for (let i = 0; i < gui.get(UI_lsbx).items_value[this.index][1]; i++) {
-
- GameLink.getInst().player.lottery_random_add_skin_block(ch_util.getRandomInt(2,5));
- }
- UINotify.show("砖块+"+gui.get(UI_lsbx).items_value[this.index][1]);
- }
- else {
- GameLink.getInst().player.set_coin(GameLink.getInst().player.get_coin() + gui.get(UI_lsbx).items_value[this.index][1]);
- UINotify.show("金币+" + gui.get(UI_lsbx).items_value[this.index][1]);
- }
- GameLink.getInst().player.setDirty();
- GameLink.getInst().player.save();
- }
- }
|