| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 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();
- gData.farmMapData.isStateChange = false;
- }
- update(dt)
- {
- if(gData.farmMapData.isStateChange)
- {
- this.changeStatus();
- mk.event.emit("initFarmMapUi");
- }
- if(gData.farmMapData.isInit)
- {
- gData.farmMapData.isInit = false;
- this.changeStatus();
- }
- }
- lateUpdate()
- {
- gData.farmMapData.isStateChange = false;
- }
- private changeStatus()
- {
- for (let key in ProductType) {
- let max = gData.gameData.getMaxProductExtra(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;
- }
- }
|