Ver Fonte

取名随机

woso_javan há 2 meses atrás
pai
commit
db12afc20c

+ 33 - 0
assets/module_storm_sunder/Script/HomeUI.ts

@@ -14,8 +14,12 @@ export class HomeUI extends Component {
     lbUserMoney: Label = null;
     lbUserName: Label = null;
 
+    btRandom: Node = null;
+
     protected onLoad(): void {
         this.lbUserMoney = this.node.getChildByPath('TopLeft/UserInfo/LbMoney').getComponent(Label)!;
+        this.lbUserName = this.node.getChildByPath('UserName/lbUserName').getComponent(Label)!;
+        this.btRandom = this.node.getChildByPath('UserName/BtRandom')!;
         this.rigisterEvent();
     }
 
@@ -25,6 +29,7 @@ export class HomeUI extends Component {
 
     private rigisterEvent() {
         EventDispatcher.instance.on(GameEvent.EVENT_UPDATE_USER_MONEY, this.upadteUserInfo, this);
+        this.btRandom.on(NodeEventType.TOUCH_END, this.onClickRandom, this);
     }
 
     private upadteUserInfo() {
@@ -32,4 +37,32 @@ export class HomeUI extends Component {
         this.lbUserMoney.string = money.toString();
     }
 
+    private onClickRandom() {
+        const idMax: number = 20;
+        this.lbUserName.string = this.generateUniqueName(idMax);
+        AttributeBonusMgr.inst.userModel.nickName = this.lbUserName.string;
+    }
+
+    generateUniqueName(idMax: number): string {
+        const uniqueNames = AttributeBonusMgr.inst.userModel.uniqueNames;
+        const randomId = Math.floor(Math.random() * idMax) + 1; // 随机获取 1 到 idMax 之间的值
+        const config = AttributeBonusMgr.inst.nameModelConfig.getPramById(randomId);
+
+        if (config) {
+            let newName = `${config.text_1}${config.text_2}`;
+            let counter = 1;
+
+            // 确保名称唯一
+            while (uniqueNames.has(newName)) {
+                newName = `${config.text_1}${config.text_2}_${counter}`;
+                counter++;
+            }
+
+            uniqueNames.add(newName);
+            return newName; // 直接返回拼接好的名字
+        }
+
+        return ""; // 若无有效名称,返回空字符串
+    }
+
 }

+ 3 - 0
assets/module_storm_sunder/Script/Manager/AttributeBonusMgr.ts

@@ -5,6 +5,7 @@ import { MainConfigModel } from "../Model/MainConfigModel";
 import { AiConfigModel } from "../Model/AiConfigModel";
 import { EventDispatcher } from "db://assets/core_tgx/easy_ui_framework/EventDispatcher";
 import { GameEvent } from "../Enum/GameEvent";
+import { NameConfigModel } from "../Model/NameConfigModel";
 
 /** 属性加成管理器*/
 export class AttributeBonusMgr {
@@ -17,12 +18,14 @@ export class AttributeBonusMgr {
     }
 
     userModel: UserModel;
+    nameModelConfig: NameConfigModel;
     developConfig: DevelopConfigModel;
     aiConfig: AiConfigModel;
     mainConfig: MainConfigModel;
 
     initilize() {
         this.userModel = new UserModel();
+        this.nameModelConfig = new NameConfigModel();
         this.mainConfig = new MainConfigModel();
         this.developConfig = new DevelopConfigModel();
         this.aiConfig = new AiConfigModel();

+ 24 - 0
assets/module_storm_sunder/Script/Model/NameConfigModel.ts

@@ -0,0 +1,24 @@
+import { Tablename_config } from "db://assets/module_basic/table/Tablename_config";
+
+/**main 配置表模型 */
+export class NameConfigModel {
+
+    config: Tablename_config = null!;
+
+    constructor() {
+        this.config = new Tablename_config();
+    }
+
+    getPramById(id: number) {
+        this.config.init(id);
+        return this.config;
+    }
+
+    getText1() {
+        return this.config.text_1;
+    }
+
+    getText2() {
+        return this.config.text_2;
+    }
+}

+ 9 - 0
assets/module_storm_sunder/Script/Model/NameConfigModel.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "c7cb4745-0534-45fa-a8a9-b496fd55d41b",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 3 - 1
assets/module_storm_sunder/Script/Model/UserModel.ts

@@ -7,7 +7,7 @@ import { AttributeBonusMgr, BonusType } from "../Manager/AttributeBonusMgr";
 */
 export class UserModel {
     money: number = 999999;
-    nickName: string = '爸爸在此'; //昵称
+    nickName: string = 'player'; //昵称
     // userTornadoLevel: number = 1; //玩家风暴等级
 
     /** 游戏内基础攻击*/
@@ -47,6 +47,8 @@ export class UserModel {
 
     bonusData: Record<BonusType, BonusItem> = null;
 
+    uniqueNames: Set<string> = new Set<string>();
+
     constructor() {
     }
 

+ 2 - 2
assets/module_storm_sunder/Textures/MinZiLanKuang.png.meta

@@ -52,8 +52,8 @@
         "rawHeight": 60,
         "borderTop": 0,
         "borderBottom": 0,
-        "borderLeft": 0,
-        "borderRight": 0,
+        "borderLeft": 50,
+        "borderRight": 50,
         "packable": true,
         "pixelsToUnit": 100,
         "pivotX": 0.5,

BIN
assets/module_storm_sunder/Textures/ShaiZi.png


+ 134 - 0
assets/module_storm_sunder/Textures/ShaiZi.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.26",
+  "importer": "image",
+  "imported": true,
+  "uuid": "99a750de-9b1f-464d-a909-e36936d16cf3",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "99a750de-9b1f-464d-a909-e36936d16cf3@6c48a",
+      "displayName": "ShaiZi",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "99a750de-9b1f-464d-a909-e36936d16cf3",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "nearest",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "99a750de-9b1f-464d-a909-e36936d16cf3@f9941",
+      "displayName": "ShaiZi",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimType": "auto",
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 83,
+        "height": 55,
+        "rawWidth": 83,
+        "rawHeight": 55,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -41.5,
+            -27.5,
+            0,
+            41.5,
+            -27.5,
+            0,
+            -41.5,
+            27.5,
+            0,
+            41.5,
+            27.5,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            55,
+            83,
+            55,
+            0,
+            0,
+            83,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -41.5,
+            -27.5,
+            0
+          ],
+          "maxPos": [
+            41.5,
+            27.5,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "99a750de-9b1f-464d-a909-e36936d16cf3@6c48a",
+        "atlasUuid": ""
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "99a750de-9b1f-464d-a909-e36936d16cf3@f9941"
+  }
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 575 - 145
assets/module_storm_sunder/rooster_stormsunder.scene


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff