Browse Source

feat: 优化

chenjixiang 1 year ago
parent
commit
37ef4489f8
2 changed files with 19 additions and 2 deletions
  1. 17 0
      assets/Script/Main/MainHome.ts
  2. 2 2
      assets/resources/Prefab/Main/MainHomePrefab.prefab

+ 17 - 0
assets/Script/Main/MainHome.ts

@@ -1,6 +1,7 @@
 import { EventType, ObserverManager } from '../Manager/core/EventManager';
 import PrefabManager from '../Manager/core/PrefabManager';
 import { UIID } from '../Manager/core/UIID';
+import { gameModel } from '../Module/Module';
 import CCUtils from '../Utiles/CCUtils';
 
 const { ccclass, property } = cc._decorator;
@@ -35,6 +36,22 @@ export default class MainHome extends cc.Component {
             this.selectPrefab = node;
             this.setZindex();
         });
+        // 总分数 gameModel.historyScores数组内所有分数相加
+        let  totalScore: number = 0;
+        console.log('gameModel.historyScores.', gameModel.historyScores)
+        if (gameModel.historyScores.length) {
+            totalScore = gameModel.historyScores.reduce((a, b) => a + b, 0);
+        }
+        CCUtils.getLabel(this.node, 'headLayer/noteNumBg/value').string = totalScore.toString();
+        let starNum: number = Math.floor(totalScore / 2000);
+        if (starNum > 4) starNum = 4;
+        const node: cc.Node = CCUtils.findChild(this.node, 'headLayer/liveNumBg/starNode');
+        for (let i: number = 0; i < starNum; i++) {
+            // liveNumBg
+            CCUtils.findChild(node.children[i], 'light').active = true;
+            console.log('i', i);
+        }
+        // 适配
         this.setAdaptation();
     }
 

+ 2 - 2
assets/resources/Prefab/Main/MainHomePrefab.prefab

@@ -2078,7 +2078,7 @@
       "__id__": 48
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 53
@@ -2370,7 +2370,7 @@
       "__id__": 56
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 61