zc hace 2 años
padre
commit
e1b5bacfab
Se han modificado 2 ficheros con 29 adiciones y 44 borrados
  1. 28 38
      assets/scripts/OptionsCtr.ts
  2. 1 6
      assets/scripts/gameCtr.ts

+ 28 - 38
assets/scripts/OptionsCtr.ts

@@ -16,58 +16,48 @@ export class OptionsCtr extends Component {
     @property({ type: Sprite })
     notSelectedSprite: Sprite = null // 设置你想要的选中背景图
 
-    private votesOrgPos_x:number = -894
+    private votesOrgPos_x: number = -894
     private votesWidth = 890
-    start() {
-
-    }
-    resetVotes()
-    {
-        for(let i=0;i<4;i++)
-        {
+    start() {}
+    resetVotes() {
+        for (let i = 0; i < 4; i++) {
             const vote: Node = this.optionNodes[i].getChildByName("votes").getChildByName("toupiaojindu")
             vote.active = false
-            vote.getChildByName('votePannel_particle').active = false
-            vote.setPosition(this.votesOrgPos_x,0,0)
+            vote.getChildByName("votePannel_particle").active = false
+            vote.setPosition(this.votesOrgPos_x, 0, 0)
         }
     }
 
-
-    showVotes(num: number[] , processCtr: processCtr) {
+    showVotes(num: number[], processCtr: processCtr) {
         let index = 0
 
         //获取投票范围,修改合适步长
-        let scope:number = 10
+        let scope: number = 10
 
         const maxValue = Math.max(...num)
-            if(maxValue > 10 && maxValue < 100)
-            {
-                scope = 100
-            }
-            else if(maxValue > 99)
-            {
-                scope = 1000
-            }
+        if (maxValue > 10 && maxValue < 100) {
+            scope = 100
+        } else if (maxValue > 99) {
+            scope = 1000
+        }
 
-        for(let i=0;i<4;i++)
-        {
+        for (let i = 0; i < 4; i++) {
             const vote: Node = this.optionNodes[i].getChildByName("votes").getChildByName("toupiaojindu")
-            if(!vote.active || !vote.getChildByName('votePannel_particle').active )
-            {
+            if (!vote.active || !vote.getChildByName("votePannel_particle").active) {
                 vote.active = true
-                vote.getChildByName('votePannel_particle').active = true
+                vote.getChildByName("votePannel_particle").active = true
             }
-            tween(vote).to(1, {
-                position: new Vec3(this.votesOrgPos_x + (this.votesWidth / scope) * num[i], 0, 0)
-            })
-            .call(()=>{
-                if(index ===3)
-                {
-                    processCtr.doneProcessing()
-                }
-                index++
-            })
-            .start()
+            tween(vote)
+                .to(1, {
+                    position: new Vec3(this.votesOrgPos_x + (this.votesWidth / scope) * num[i], 0, 0)
+                })
+                .call(() => {
+                    if (index === 3) {
+                        processCtr.doneProcessing()
+                    }
+                    index++
+                })
+                .start()
         }
     }
 
@@ -81,6 +71,7 @@ export class OptionsCtr extends Component {
         for (let i = 0; i < 4; i++) {
             const nodeLabel = this.optionNodes[i].getChildByName("text_option").getComponent(Label)
             nodeLabel.string = ""
+            this.optionNodes[i].getComponent(UIOpacity).opacity = 255
         }
 
         tween(this.node.getComponent(UIOpacity))
@@ -126,7 +117,6 @@ export class OptionsCtr extends Component {
                     spriteComponent.spriteFrame = this.selectedSprite.spriteFrame
                 }
 
-               
                 this.selectedAction(optionNode)
             } else {
                 // 这是未被选中的选项

+ 1 - 6
assets/scripts/gameCtr.ts

@@ -580,12 +580,7 @@ export class GameCtr extends Component {
                     if (spriteComponent) {
                         spriteComponent.spriteFrame = this.optionsCtr.notSelectedSprite.spriteFrame
                     }
-                    for (let i = 0; i < 4; i++) {
-                        this.optionsCtr.optionNodes[i].getComponent(UIOpacity).opacity = 255
-                        const vote:Node = this.optionsCtr.optionNodes[i].getChildByName("votes").getChildByName("toupiaojindu")
-                        console.log("vote info!!!!!!!!!!!!!!"+vote.active+"   "+vote.getPosition+"   "+vote.getComponent(UIOpacity).opacity)
-                    }
-
+                   
                     //剧情上移开始展示
                     tween(this.storyPannelCtr.node)
                         .to(0.2, { position: new Vec3(0, 0, 0) })