|
|
@@ -6,11 +6,13 @@ const { ccclass, property } = cc._decorator;
|
|
|
@ccclass
|
|
|
export class FarmCountDown extends cc.Component {
|
|
|
@property({ type: cc.Component.EventHandler, tooltip: "成熟回调" }) onRiped: cc.Component.EventHandler = null;
|
|
|
+ @property({ type: cc.Component.EventHandler, tooltip: "生虫回调" }) onSick: cc.Component.EventHandler = null;
|
|
|
@property({ type: cc.Component.EventHandler, tooltip: "加速按钮回调" }) onSpeedButton: cc.Component.EventHandler = null;
|
|
|
@property({ type: cc.Node, tooltip: "常驻计时器组" }) normalGroup: cc.Node = null;
|
|
|
@property({ type: cc.ProgressBar, tooltip: "常驻进度条" }) normalProgress: cc.ProgressBar = null;
|
|
|
@property({ type: BitmapFontC, tooltip: "常驻计时" }) normalCount: BitmapFontC = null;
|
|
|
@property({ type: cc.Node, tooltip: "可收获图标" }) ripedIcon: cc.Node = null;
|
|
|
+ @property({ type: cc.Node, tooltip: "生病图标" }) sickIcon: cc.Node = null;
|
|
|
|
|
|
private counting = false;
|
|
|
/**成熟时间戳 */
|
|
|
@@ -25,6 +27,7 @@ export class FarmCountDown extends cc.Component {
|
|
|
this.ripeTime = data.growSpan;
|
|
|
this.totleTime = producting.time;
|
|
|
this.normalGroup.active = true;
|
|
|
+ this.sickIcon.active = false;
|
|
|
this.counting = true;
|
|
|
this.normalCount.string = '';
|
|
|
this.normalProgress.progress = 0;
|
|
|
@@ -45,6 +48,7 @@ export class FarmCountDown extends cc.Component {
|
|
|
public cleanRiped(): void {
|
|
|
this.isDataed = false;
|
|
|
this.ripedIcon.active = false;
|
|
|
+ this.sickIcon.active = false;
|
|
|
}
|
|
|
|
|
|
public async onSpeed() {
|
|
|
@@ -66,8 +70,14 @@ export class FarmCountDown extends cc.Component {
|
|
|
private riped(): void {
|
|
|
this.counting = false;
|
|
|
this.normalGroup.active = false;
|
|
|
- this.ripedIcon.active = true;
|
|
|
- this.onRiped && this.onRiped.emit(null);
|
|
|
+ if (Math.random() < 0.4) {
|
|
|
+ this.sickIcon.active = true;
|
|
|
+ this.onSick && this.onSick.emit(null);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.ripedIcon.active = true;
|
|
|
+ this.onRiped && this.onRiped.emit(null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|