import { _decorator, Component, Node } from "cc";
import BaseUI from "../base/BaseUI";
import { Sprite } from "cc";
import { AB } from "../base/AB";
const { ccclass, property } = _decorator;

@ccclass("UIGameResultPlayerItem")
export class UIGameResultPlayerItem extends BaseUI {
  init(data: any) {
    this.setText("lbl_kill", data.kill + "");
    this.setText("lbl_score", data.score + "");
    this.setText("lbl_rank", data.rank + "");
    this.setText("lbl_name", data.name);
  }

  private _liked = false;

  async like() {
    if (this._liked) {
      return;
    }
    this._liked = true;
    let btnLike = this.FindAs("btn_like", Sprite);
    AB.inst.setBundleBallImage("textures/result/like_1", btnLike);
  }

  protected simpleOnBtnClick(name: string): void {
    switch (name) {
      case "btn_like":
        this.like();
        break;
    }
  }
}
