future 1 yıl önce
ebeveyn
işleme
ca35963a5c

Dosya farkı çok büyük olduğundan ihmal edildi
+ 217 - 161
assets/resources/ui/home.prefab


+ 15 - 0
assets/script/GameManager.ts

@@ -39,6 +39,21 @@ export class GameManager extends Component {
         sys.localStorage.setItem(config.SETTING_DATA, JSON.stringify(data));
     }
 
+    //获取广播
+    public static requestGuangbo(cb=null) {
+        http.get(config.STATIC_API.msg, (err,d)=>{
+            if(!err){
+                let nd = JSON.parse(d)
+                if(nd.code === config.status.SUCCESS){
+                    // console.log("system_msg", nd.content)
+                    if(cb!=null){
+                        cb(nd.content)
+                    }
+                }   
+            }
+        })
+    }
+
     //获取用户车列表
     public static requestUserCarList(cb=null) {
         http.post(config.API.user_car_list,null,(err,d)=>{

+ 1 - 0
assets/script/config.ts

@@ -24,6 +24,7 @@ export class config  {
         levels : "/snakestatic/levels.json",
         regions : "/snakestatic/regions.json",
         car_list : "/snakestatic/car_list.json",
+        msg: "/snakestatic/msg.json",
         rankings: (region_id)=>{
             return `/snakestatic/rankings/${region_id}.json`
         }

+ 4 - 0
assets/script/data.ts

@@ -77,6 +77,10 @@ export class rankData{
     public nationwide_badge_status:number = 0 //全国徽章状态 1展示 0不展示
 }
 
+export class guangboData{
+    public title:string = ""
+}
+
 export class user_car_list{
     public car_list:number[] = [] //汽车列表
     public default_car_id:number = 0 //	默认车辆

+ 1 - 0
assets/script/ui/home/home.ts

@@ -62,6 +62,7 @@ export class home extends Component {
         this.unscheduleAllCallbacks()
         this.schedule(()=>{
             this.bottom.getComponent(home_bottom).reloadCountryRankData()
+            this.top.getComponent(home_top).reloadGuangboData()
         },600)
     }
 }

+ 17 - 16
assets/script/ui/home/home_guangbo.ts

@@ -1,4 +1,5 @@
 import { _decorator, Component, Label, Node, Tween, tween, UITransform, Vec3 } from 'cc';
+import { guangboData } from '../../data';
 const { ccclass, property } = _decorator;
 
 @ccclass('home_guangbo')
@@ -6,23 +7,24 @@ export class home_guangbo extends Component {
     @property(Node) lab_1:Node = null
     @property(Node) lab_2:Node = null
     private cur_index = 0
-    private data_list:string[] = ['1','2','3','4']
-
-    init() {
-        // this.setText(this.lab_1, this.data_list[this.cur_index])
-        // this.schedule(()=>{
-        //     this.cur_index++
-        //     if(this.cur_index>=this.data_list.length) {
-        //         this.cur_index = 0
-        //     }
-        //     this.setText(this.lab_1, this.data_list[this.cur_index])
-            
-        // },2)
+    private data_list:guangboData[] = []
+
+    init(data_list:guangboData[]) {
+        this.data_list = data_list
+        this.lab_1.getComponent(Label).string = this.data_list[this.cur_index].title
+        this.unscheduleAllCallbacks()
+        this.schedule(()=>{
+            this.cur_index++
+            if(this.cur_index>=this.data_list.length) {
+                this.cur_index = 0
+            }
+            this.lab_1.getComponent(Label).string = this.data_list[this.cur_index].title
+        },2.5)
     }
 
     private startSchedule() {
         // this.lab_2.active = false
-        this.setText(this.lab_1, this.data_list[this.cur_index])
+        this.setText(this.lab_1, this.data_list[this.cur_index].title)
         this.schedule(()=>{
             this.cur_index ++
             this.runFrame(this.lab_1)
@@ -31,7 +33,7 @@ export class home_guangbo extends Component {
                 this.cur_index = 0
             }
 
-        },2)
+        },2.5)
     }
 
     private stopSchedule() {
@@ -47,7 +49,7 @@ export class home_guangbo extends Component {
                 // current_node.active = false
                 current_node.setPosition(new Vec3(0,-50,0))
             } else if(later_y==0) {
-                this.setText(current_node, this.data_list[this.cur_index])
+                this.setText(current_node, this.data_list[this.cur_index].title)
                 current_node.active = true
             } else if(later_y==-50) {
                 current_node.active = false
@@ -57,7 +59,6 @@ export class home_guangbo extends Component {
 
     private setText(current_node:Node, str:string) {
         current_node.getComponent(Label).string = '恭喜广州吴彦祖-' + str
-
     }
 }
 

+ 8 - 1
assets/script/ui/home/home_top.ts

@@ -4,6 +4,7 @@ import { config } from '../../config';
 import { userDataManager } from '../../manager/userDataManager';
 import { home_guangbo } from './home_guangbo';
 import { tools } from '../../tools';
+import { GameManager } from '../../GameManager';
 const { ccclass, property } = _decorator;
 
 @ccclass('home_top')
@@ -38,7 +39,13 @@ export class home_top extends Component {
         })
         this.lab_nickname.getComponent(Label).string = user_data.nickName
         this.lab_car_pai.getComponent(Label).string = user_data.license_code
-        this.guangbo.getComponent(home_guangbo).init()
+        this.reloadGuangboData()
+    }
+
+    public reloadGuangboData() {
+        GameManager.requestGuangbo((d_content)=>{
+            this.guangbo.getComponent(home_guangbo).init(d_content)
+        })
     }
     
 }

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor