|
|
@@ -0,0 +1,85 @@
|
|
|
+import { ProductType } from "../data/GameData";
|
|
|
+
|
|
|
+const { ccclass, property } = cc._decorator;
|
|
|
+
|
|
|
+@ccclass
|
|
|
+export class RedPointControl extends cc.Component {
|
|
|
+
|
|
|
+ @property({type: cc.Node, displayName: '红点节点'})
|
|
|
+ private node_redPoint: cc.Node = null;
|
|
|
+
|
|
|
+ start()
|
|
|
+ {
|
|
|
+ this.changeStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ update(dt)
|
|
|
+ {
|
|
|
+ if(gData.farmMapData.isStateChange)
|
|
|
+ {
|
|
|
+ this.changeStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private changeStatus()
|
|
|
+ {
|
|
|
+ for (let key in ProductType) {
|
|
|
+ let max = gData.gameData.getMaxProduct(ProductType[key]);
|
|
|
+ if (max) {
|
|
|
+ let list_data = gData.gameData.getProductArrByType(ProductType[key]);
|
|
|
+ for (let i = 0; i != list_data.length; ++i) {
|
|
|
+ if (list_data[i].picture <= max) {
|
|
|
+ let state = gData.gameData.getFarmMapRewardState(this.getIndex(list_data[i]));
|
|
|
+ if (state == 0) {
|
|
|
+ this.node_redPoint.active = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.node_redPoint.active = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ getIndex(data) {
|
|
|
+ let index: any = {};
|
|
|
+ index.i = 0;
|
|
|
+ index.j = 0;
|
|
|
+ switch (data.tab) {
|
|
|
+ case '农作物':
|
|
|
+ index.i = 0;
|
|
|
+ index.j = data.picture - 10001;
|
|
|
+ break;
|
|
|
+ case '动物':
|
|
|
+ index.i = 1;
|
|
|
+ index.j = data.picture - 20001;
|
|
|
+ break;
|
|
|
+ case '爆米花厂':
|
|
|
+ index.i = 2;
|
|
|
+ index.j = data.picture - 20004;
|
|
|
+ break;
|
|
|
+ case '糕点铺':
|
|
|
+ index.i = 3;
|
|
|
+ index.j = data.picture - 20013;
|
|
|
+ break;
|
|
|
+ case '制糖厂':
|
|
|
+ index.i = 4;
|
|
|
+ index.j = data.picture - 20010;
|
|
|
+ break;
|
|
|
+ case '炼乳厂':
|
|
|
+ index.i = 5;
|
|
|
+ index.j = data.picture - 20007;
|
|
|
+ break;
|
|
|
+ case '功夫面馆':
|
|
|
+ index.i = 6;
|
|
|
+ index.j = data.picture - 20025;
|
|
|
+ break;
|
|
|
+ case '快餐店':
|
|
|
+ index.i = 7;
|
|
|
+ index.j = data.picture - 20019;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return index;
|
|
|
+ }
|
|
|
+}
|