import { _decorator, Component, Node, Label, Button, Slider, EventTouch, NodeEventType, Sprite, Color } from 'cc'; import ChessRBSel from '../Game/ChessGame/ChessRBSel'; import ChessMng, { ChessType } from '../Game/DiffSel/ChessMng'; import UIDiffSel from '../Game/DiffSel/UIDiffSel'; import ScenceMng from '../gcommon/ScenceMng'; import { UIButton } from '../gcommon/UIButton'; const { ccclass, property } = _decorator; @ccclass('renjiCreate') export class renjiCreate extends Component { @property(Label) nandu_lab: Label = null; //难度 @property(Label) guoguanlv_lab: Label = null; // 通关率 @property(Label) nandu_lv_lab: Label = null; // 难度等级 @property(Node) btn_hongse: Node = null; //让电脑红色方 @property(Node) btn_heise: Node = null; // 让电脑黑色放 @property(Slider) nandu_sd: Slider = null; // selectSlider:number = 0 old_selectSlider:number = 0 select_index:number = 0; index:number = 0 color:Color = new Color() public static lvArr=['小白','普通','中等','困难','大師']; public static ndArr=['55.6%','31.5%','35.9','40.69%','14.14%']; start() { var self = this; UIButton.BindClick(this.btn_hongse,()=>{ if(ChessRBSel.selIndex!=1){ self.color = self.color.fromHEX("#E70000") self.btn_hongse.getComponent(Sprite).color = self.color self.color = self.color.fromHEX("#EDE4D5") self.btn_heise.getComponent(Sprite).color = self.color self.color = self.color.fromHEX("#000000") self.btn_heise.getChildByName("Label").getComponent(Label).color = self.color self.color = self.color.fromHEX("#FFFFFF") self.btn_hongse.getChildByName("Label").getComponent(Label).color = self.color var index = self.btn_hongse.getSiblingIndex() self.btn_hongse.setSiblingIndex(self.btn_heise.getSiblingIndex()) self.btn_heise.setSiblingIndex(index) ChessRBSel.selIndex = 1; } },this); UIButton.BindClick(this.btn_heise,()=>{ if(ChessRBSel.selIndex!=0){ self.color = self.color.fromHEX("#EDE4D5") self.btn_hongse.getComponent(Sprite).color = self.color self.color = self.color.fromHEX("#4D4C4A") self.btn_heise.getComponent(Sprite).color = self.color self.color = self.color.fromHEX("#000000") self.btn_hongse.getChildByName("Label").getComponent(Label).color = self.color self.color = self.color.fromHEX("#FFFFFF") self.btn_heise.getChildByName("Label").getComponent(Label).color = self.color var index = self.btn_hongse.getSiblingIndex() self.btn_hongse.setSiblingIndex(self.btn_heise.getSiblingIndex()) self.btn_heise.setSiblingIndex(index) ChessRBSel.selIndex = 0; } },this); this.updateInfo(); ChessRBSel.selIndex = 0; //默认自己是红色方 } update(deltaTime: number) { if(this.selectSlider == this.old_selectSlider){ return; } this.old_selectSlider = this.selectSlider; this.updateInfo(); } onSlider(event){ this.selectSlider = event._progress; // console.log("onSlider",event._progress) } updateInfo(){ var index = 0 if(this.old_selectSlider<0.2) { index =0; this.select_index = 0.2 } else if(this.old_selectSlider>0.2&&this.old_selectSlider<0.4){ index = 1; this.select_index = 0.4 }else if(this.old_selectSlider>0.4&&this.old_selectSlider<0.6){ index = 2; this.select_index = 0.6 }else if(this.old_selectSlider>0.6&&this.old_selectSlider<0.8){ index = 3; this.select_index = 0.8 }else if(this.old_selectSlider>0.8){ index = 4; this.select_index = 1 } this.index = index; this.nandu_lab.string = renjiCreate.lvArr[index]; this.guoguanlv_lab.string = renjiCreate.ndArr[index]; this.nandu_lv_lab.string = index.toString(); } onCreateRenji(){ UIDiffSel.selectIndex=this.index; ChessMng.Instance.chesstype=ChessType.renjiboyi; console.log("UIButton onclick") ScenceMng.Instance.load('Chess') } }