瀏覽代碼

开局 扩大碰撞size

woso_javan 2 月之前
父節點
當前提交
6dbf034a68

+ 9 - 6
assets/module_storm_sunder/Prefabs/UI/Gambit/UI_BattleGambit_Impl.ts

@@ -3,14 +3,16 @@ import { GameUILayers } from "../../../../scripts/GameUILayers";
 import { UI_BattleGambit, UI_BattleRevive } from "../../../../scripts/UIDef";
 import { GameMgr, GameStatus } from '../../../Script/Manager/GameMgr';
 import { tgxModuleContext } from 'db://assets/core_tgx/tgx';
-import { Layout_BattleRevive } from '../Revive/Layout_BattleRevive';
+import { Layout_BattleGambit } from './Layout_BattleGambit';
+import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
+import { GameEvent } from '../../../Script/Enum/GameEvent';
 const { ccclass, property } = _decorator;
 
 @ccclass('UI_BattleGambit_Impl')
 export class UI_BattleGambit_Impl extends UI_BattleRevive {
 
     constructor() {
-        super('Prefabs/UI/Revive/UI_BattleRevive', GameUILayers.POPUP, Layout_BattleRevive);
+        super('Prefabs/UI/Gambit/UI_BattleGambit', GameUILayers.POPUP, Layout_BattleGambit);
     }
 
     public getRes(): [] {
@@ -18,14 +20,15 @@ export class UI_BattleGambit_Impl extends UI_BattleRevive {
     }
 
     protected onCreated(): void {
-        let layout = this.layout as Layout_BattleRevive;
-        this.onButtonEvent(layout.btn_revive, () => {
+        let layout = this.layout as Layout_BattleGambit;
+        this.onButtonEvent(layout.btn_get, () => {
             this.changeGameStatus(GameStatus.Playing);
+            EventDispatcher.instance.emit(GameEvent.EVENT_GAME_START_EFFECT);
         });
         this.onButtonEvent(layout.btn_back, () => {
-            // this.changeGameStatus(GameStatus.None);
             GameMgr.inst.isWin = false;
-            GameMgr.inst.setGameStatus(GameStatus.End);
+            GameMgr.inst.setGameStatus(GameStatus.Playing);
+            EventDispatcher.instance.emit(GameEvent.EVENT_GAME_START);
             this.hide();
         });
     }

+ 8 - 2
assets/module_storm_sunder/Script/Component/TornadoAIComponent.ts

@@ -7,6 +7,8 @@ import { GameMgr, GameStatus } from '../Manager/GameMgr';
 import { PlayerMgr } from '../Manager/PlayerMgr';
 import { tgxUIMgr } from 'db://assets/core_tgx/tgx';
 import { UI_BattleRevive } from 'db://assets/scripts/UIDef';
+import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
+import { GameEvent } from '../Enum/GameEvent';
 
 const { ccclass, property } = _decorator;
 
@@ -38,10 +40,15 @@ export class TornadoAIComponent extends TornadoComponent {
 
         this.initAIPlayer();
         this.onPlayerInfoHandler();
-        this.decideAction(); // 进入行为循环
+        // this.decideAction(); // 进入行为循环
 
         this.tigger.on('onTriggerEnter', this.onTriggerEnter, this);
         this.radiusTigger.on('onTriggerEnter', this.onRadiusTriggerEnter, this);
+        this.registerEvent();
+    }
+
+    protected registerEvent(): void {
+        EventDispatcher.instance.on(GameEvent.EVENT_GAME_START, this.decideAction, this);
     }
 
     private initAIPlayer() {
@@ -120,7 +127,6 @@ export class TornadoAIComponent extends TornadoComponent {
     }
 
     protected override onTriggerEnter(event: ITriggerEvent): void {
-
         if (event.otherCollider.getGroup() === 1 << 2) {
             this.unscheduleAllCallbacks();
             this.isChasing = false;

+ 14 - 4
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -25,8 +25,8 @@ export class TornadoComponent extends Component {
     points: Node[] = [];
     tornado: Node = null!;
     rigidBody: RigidBody = null!;
-    tigger: Collider = null!; //龙卷风触发器
-    radiusTigger: Collider = null!;     //龙卷风半径检测触发器
+    tigger: BoxCollider = null!; //龙卷风触发器
+    radiusTigger: CylinderCollider = null!;     //龙卷风半径检测触发器
 
     ai: boolean = false;
     attack: number = 20;
@@ -58,8 +58,8 @@ export class TornadoComponent extends Component {
 
         this.tornado = this.node.getChildByName('RigibodyStorm')!;
         this.rigidBody = this.tornado.getComponent(RigidBody)!;
-        this.tigger = this.tornado.getComponent(Collider)!;
-        this.radiusTigger = this.node.getChildByName('radiusTigger').getComponent(Collider)!;
+        this.tigger = this.tornado.getComponent(BoxCollider)!;
+        this.radiusTigger = this.node.getChildByName('radiusTigger').getComponent(CylinderCollider)!;
 
         this.tigger.on('onTriggerEnter', this.onTriggerEnter, this);
         this.tigger.on('onTriggerStay', this.onTriggerStay, this);
@@ -92,6 +92,7 @@ export class TornadoComponent extends Component {
 
     protected registerEvent() {
         EventDispatcher.instance.on(GameEvent.EVENT_STORM_LEVEL_UP, this.stormLevelUp, this);
+        EventDispatcher.instance.on(GameEvent.EVENT_GAME_START_EFFECT, this.onGambitEffect, this);
     }
 
     protected onTriggerEnter(event: ITriggerEvent): void {
@@ -317,6 +318,15 @@ export class TornadoComponent extends Component {
         this.updateCameraView();
     }
 
+    //开局特效
+    private onGambitEffect() {
+        const multiple: number = AttributeBonusMgr.inst.userModel.game_tornado_damage;
+        const scaleFactor = multiple / 100;
+        const size = this.tigger.size;
+        this.tigger.size = new Vec3(size.x + size.x * scaleFactor, size.y + size.y * scaleFactor, size.z + size.z * scaleFactor);
+        console.log(`龙卷风碰撞 开局特效启动 最新size:${this.tigger.size}}`);
+    }
+
     private updateCameraView() {
         const sence = director.getScene();
         const view = 50 + this.currentLv * 2;

+ 3 - 0
assets/module_storm_sunder/Script/Enum/GameEvent.ts

@@ -4,6 +4,9 @@ export class GameEvent {
     /** 游戏开始*/
     static readonly EVENT_GAME_START = 'EVENT_GAME_START';
 
+    /** 开局特效*/
+    static readonly EVENT_GAME_START_EFFECT = 'EVENT_GAME_START_EFFECT';
+
     /** 刷新排行榜*/
     static readonly EVENT_REFRESH_RANK = 'EVENT_REFRESH_RANK';
 

+ 19 - 4
assets/module_storm_sunder/Script/Manager/GameMgr.ts

@@ -4,7 +4,7 @@ import { tgxUIMgr } from "db://assets/core_tgx/tgx";
 import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
 import { PropMgr } from "./PropMgr";
 import { TimerMgr } from "./TimerMgr";
-import { UI_BattleResult, UI_BattleRevive } from "db://assets/scripts/UIDef";
+import { UI_BattleGambit, UI_BattleResult, UI_BattleRevive } from "db://assets/scripts/UIDef";
 import { PlayerMgr } from "./PlayerMgr";
 import { assetManager, instantiate, Prefab } from "cc";
 import { resLoader } from "db://assets/core_tgx/base/ResLoader";
@@ -52,12 +52,24 @@ export class GameMgr {
                 PlayerMgr.inst.reset();
                 MapMgr.Instance.setMapInfo(1);
                 break;
-            case GameStatus.Playing:
+            case GameStatus.Gambit:
                 await MapMgr.Instance.addMapNode();
                 await PlayerMgr.inst.setPlayerVisible(true);
                 await PlayerMgr.inst.setPlayerPosition();
                 homeUI.active = false;
                 battleUI.active = true;
+
+                const gambit = tgxUIMgr.inst.isShowing(UI_BattleGambit);
+                if (!gambit) {
+                    tgxUIMgr.inst.showUI(UI_BattleGambit);
+                }
+                break;
+            case GameStatus.Playing:
+                // await MapMgr.Instance.addMapNode();
+                // await PlayerMgr.inst.setPlayerVisible(true);
+                // await PlayerMgr.inst.setPlayerPosition();
+                // homeUI.active = false;
+                // battleUI.active = true;
                 break;
             case GameStatus.Revive:
                 const revive = tgxUIMgr.inst.isShowing(UI_BattleRevive);
@@ -77,11 +89,12 @@ export class GameMgr {
     }
 
     public async startGame() {
-        GameMgr.inst.setGameStatus(GameStatus.Playing);
         await PropMgr.inst.genatorProp();
         await PlayerMgr.inst.playerAddComponent();
         await PlayerMgr.inst.genareatorAIPlayer();
-        TimerMgr.inst.startCountdown();
+        GameMgr.inst.setGameStatus(GameStatus.Gambit);
+
+        // TimerMgr.inst.startCountdown();
     }
 }
 
@@ -90,6 +103,8 @@ export enum GameStatus {
     None,
     /** 游戏进行中 */
     Playing,
+    /** 开局*/
+    Gambit,
     /** 复活中*/
     Revive,
     /** 游戏结束 */

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

@@ -71,7 +71,7 @@ export class UserModel {
         this.game_modleVolume_base = mainConfig.getPramById(12);
         this.game_lv_modleVolume_up = mainConfig.getPramById(13);
 
-        this.game_tornado_damage = mainConfig.getPramById(14);
+        this.game_tornado_damage = mainConfig.getPramById(14); //开局扩大范围
         this.game_ai_range = mainConfig.getPramById(15);
         this.game_base_pass_reward = mainConfig.getPramById(16);
         this.game_reward_develop = mainConfig.getPramById(17);