|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Component, Node, ButtonComponent, EventTouch, director, SkeletalAnimationComponent, Prefab, instantiate, LayoutComponent, LabelComponent, ProgressBarComponent } from 'cc';
|
|
|
+import { _decorator, Component, Node, ButtonComponent, EventTouch, director, SkeletalAnimationComponent, Prefab, instantiate, LayoutComponent, LabelComponent, ProgressBarComponent, loader } from 'cc';
|
|
|
import { GUIMediator } from '../../../engines/gui/GUIMediator';
|
|
|
import { GUIManager } from '../../../engines/gui/GUIManager';
|
|
|
import { UIConst } from '../UIConst';
|
|
@@ -10,6 +10,7 @@ import { SceneManager } from '../../../engines/scenes/SceneManager';
|
|
|
import { DataModel } from '../../../engines/models/DataModel';
|
|
|
import { DataModelEventType } from '../../../engines/models/DataModelEventType';
|
|
|
import { GamePropertys } from '../../models/GamePropertys';
|
|
|
+import { LoadingView } from '../../../engines/loadingView/LoadingView';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('FightingMediator')
|
|
@@ -126,19 +127,78 @@ export class FightingMediator extends GUIMediator {
|
|
|
* 弹夹子弹池
|
|
|
*/
|
|
|
bulletPool:Node[]=[];
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 资源引用
|
|
|
+ */
|
|
|
+ private assetsRef:Prefab[];
|
|
|
|
|
|
+ /**
|
|
|
+ * 显示状态
|
|
|
+ */
|
|
|
+ private onShowed:boolean=false;
|
|
|
start () {
|
|
|
// Your initialization goes here.
|
|
|
}
|
|
|
|
|
|
OnShow():void{
|
|
|
+ this.onShowed=false;
|
|
|
+ this.LoadAssets();
|
|
|
+ }
|
|
|
+
|
|
|
+ private __OnShow():void{
|
|
|
GameController.single.monsterHPUILayer=this.monsterHPUILayer;
|
|
|
GameController.single.Init(this);
|
|
|
this.AddEvents();
|
|
|
this.RefreshView();
|
|
|
+ this.onShowed=true;
|
|
|
}
|
|
|
|
|
|
+ private LoadAssets():void{
|
|
|
+ let urls:string[]=[];
|
|
|
+ //武器
|
|
|
+ let weaponConfig:any=GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
|
|
|
+ urls.push(weaponConfig.prefab);
|
|
|
+
|
|
|
+ //栅栏
|
|
|
+ let fenceConfig:any=GameConfigManager.GetFenceConfig(GameModel.single.currentFenceId);
|
|
|
+ urls.push(fenceConfig.prefab);
|
|
|
+
|
|
|
+ //本关用到的怪物资源
|
|
|
+ let levelConfig:any=GameConfigManager.GetLevelConfig(GameModel.single.currentLevel);
|
|
|
+ let monsterConfig:any;
|
|
|
+ levelConfig.monsters.forEach(element => {
|
|
|
+ monsterConfig=GameConfigManager.GetMonsterConfig(element.monsterId);
|
|
|
+ if(urls.indexOf(monsterConfig.prefab)<0){
|
|
|
+ urls.push(monsterConfig.prefab);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //枪口火焰
|
|
|
+ urls.push("d3d/gunFire/GunFire");
|
|
|
+
|
|
|
+ //怪物血条
|
|
|
+ urls.push("ui/components/MonsterHPUI");
|
|
|
+
|
|
|
+ //加载
|
|
|
+ loader.loadResArray(urls,Prefab,this.LoadAssetsProgress.bind(this),this.LoadAssetsComplete.bind(this));
|
|
|
+ }
|
|
|
+
|
|
|
+ private LoadAssetsProgress(index:number,total:number,item):void{
|
|
|
+ LoadingView.single.UpdateProgress(index/total);
|
|
|
+ }
|
|
|
+
|
|
|
+ private LoadAssetsComplete(error:Error,assets):void{
|
|
|
+ if(error){
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ this.assetsRef=assets;
|
|
|
+ this.__OnShow();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
OnHide():void{
|
|
|
+ this.onShowed=false;
|
|
|
this.RemoveEvents();
|
|
|
}
|
|
|
|
|
@@ -266,6 +326,9 @@ export class FightingMediator extends GUIMediator {
|
|
|
|
|
|
private fenceHp:number=0;
|
|
|
update (deltaTime: number) {
|
|
|
+ if(this.onShowed==false){
|
|
|
+ return;
|
|
|
+ }
|
|
|
super.update(deltaTime);
|
|
|
if(GameController.single.fence.hp!=this.fenceHp){
|
|
|
this.RefreshFenceHp();
|