Kaynağa Gözat

Merge branch 'master' of http://120.92.132.192:23541/TDGame/TDGameClient3D

w405651948 4 yıl önce
ebeveyn
işleme
cb894bde86

+ 7 - 4
assets/resources/ui/FightingUI.prefab

@@ -3100,7 +3100,7 @@
       "__id__": 61
     },
     "_children": [],
-    "_active": false,
+    "_active": true,
     "_components": [
       {
         "__id__": 98
@@ -3208,7 +3208,7 @@
       "__id__": 97
     },
     "_enabled": true,
-    "playOnLoad": false,
+    "playOnLoad": true,
     "_clips": [
       {
         "__uuid__": "b839b55f-e88a-4c98-af3c-d0641706bad0"
@@ -3415,7 +3415,7 @@
     "_priority": 0,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 206.9112217561879,
+      "width": 183.53,
       "height": 126
     },
     "_anchorPoint": {
@@ -3455,7 +3455,7 @@
     "_enableWrapText": true,
     "_font": null,
     "_isSystemFontUsed": true,
-    "_isItalic": true,
+    "_isItalic": false,
     "_isBold": false,
     "_isUnderline": false,
     "_cacheMode": 0,
@@ -6004,6 +6004,9 @@
     "levelLabel": {
       "__id__": 56
     },
+    "teachingNode": {
+      "__id__": 97
+    },
     "_id": ""
   },
   {

+ 1 - 1
assets/resources/ui/loadingView/bow_anime.anim

@@ -5,7 +5,7 @@
   "_native": "",
   "sample": 60,
   "speed": 1,
-  "wrapMode": 1,
+  "wrapMode": 2,
   "events": [],
   "_duration": 1.15,
   "_keys": [

+ 6 - 5
assets/scripts/engines/gui/GUIProxy.ts

@@ -58,11 +58,7 @@ export default class GUIProxy{
      * 添加到层上并显示
      */
     private AddToLayer():void{
-        this.uiNode=cc.instantiate(this.prefab);
-        this.mediator=this.uiNode.getComponent(GUIMediator);
-        this.mediator.uiKey=this.key;
-        //添加到层
-        LayerManager.single.AddToLayer(this.mediator.LayerIndex,this.uiNode);
+        this.uiNode.active=true;
         this.mediator.OnShow(this.data);
     }
 
@@ -81,6 +77,11 @@ export default class GUIProxy{
         }
         this.prefab=assets;
         this.state=2;
+        this.uiNode=cc.instantiate(this.prefab);
+        this.mediator=this.uiNode.getComponent(GUIMediator);
+        this.mediator.uiKey=this.key;
+        //添加到层
+        LayerManager.single.AddToLayer(this.mediator.LayerIndex,this.uiNode);
         if(this.isShowing){
             this.AddToLayer();
         }

+ 27 - 1
assets/scripts/games/ui/fightings/FightingMediator.ts

@@ -124,6 +124,11 @@ export class FightingMediator extends GUIMediator {
     })
     levelLabel:LabelComponent=null;
 
+    @property({
+        type:Node
+    })
+    teachingNode:Node=null;
+
     /**
      * 弹夹子弹池
      */
@@ -142,9 +147,19 @@ export class FightingMediator extends GUIMediator {
         // Your initialization goes here.
     }
 
+    constructor(){
+        super();
+        console.log("创建!");
+    }
+
     OnShow():void{
         this.onShowed=false;
         this.LoadAssets();
+        if(GameModel.single.isNewPlayer){
+            this.teachingNode.active=true;
+        }else{
+            this.teachingNode.active=false;
+        }
     }
 
     private __OnShow():void{
@@ -350,7 +365,7 @@ export class FightingMediator extends GUIMediator {
             return;
         }
         super.update(deltaTime);
-        if(GameController.single.fence.hp!=this.fenceHp){
+        if(GameController.single.fence!=null&&GameController.single.fence.node!=null){
             this.RefreshFenceHp();
             this.fenceHp=GameController.single.fence.hp;
         }
@@ -364,6 +379,9 @@ export class FightingMediator extends GUIMediator {
 
     private currentFireButtonNode:Node;
     FireButtonTouchStart(e:EventTouch):void{
+        if(this.teachingNode.active){
+            this.teachingNode.active=false;
+        }
         this.currentFireButtonNode=e.target as Node;
         if(e.target==this.leftFireButton.node){
             GameController.single.TryFire(1);
@@ -395,6 +413,7 @@ export class FightingMediator extends GUIMediator {
      * 返回主界面
      */
     BackToPrepareScene():void{
+        GameController.single.OnGameOver(2);
         SceneManager.single.Swicth("PrepareScene");
         this.HideSelf();
     }
@@ -419,4 +438,11 @@ export class FightingMediator extends GUIMediator {
             console.error("重复回收弹夹子弹");
         }
     }
+
+    /**
+     * 跳过教学
+     */
+    SkipTeaching():void{
+        
+    }
 }

+ 26 - 11
assets/scripts/games/ui/fightings/GameController.ts

@@ -142,11 +142,8 @@ export class GameController extends EventDispatcher{
         GameModel.single.integral=0;
         //重置技能
         this.SkillReset();
-        this.GameOver=false;
         this.levelConfig=GameConfigManager.GetLevelConfig(GameModel.single.currentLevel);
         this.runTime=0;
-        //清理怪物
-        this.ClearMonsters();
         //复制一份配置
         this.monstersConfig=GameConfigManager.CreateMonsterByList(this.levelConfig.monsters,this.runTime);
         this.monsterTotalCount=this.monstersConfig.length;
@@ -154,6 +151,30 @@ export class GameController extends EventDispatcher{
         this.weapon.bulletCount=GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId).clip;
         //初始化栅栏
         this.InitFence();
+        this.GameOver=false;
+    }
+
+    /**
+     * 游戏结束
+     * @param state 0 胜利 1 失败 2正常退出
+     */
+    OnGameOver(state:number):void{
+        //清理怪物
+        this.ClearMonsters();
+        //清理武器
+        this.weapon.Destroy();
+        //销毁栅栏
+        if(this.fence.node){
+            this.fence.node.destroy();
+        }
+        if(state==0){
+            GUIManager.single.Show(UIConst.GAME_OVER_UI,true);
+        }else if(state==1)
+        {
+            GUIManager.single.Show(UIConst.GAME_OVER_UI,false);
+        }
+        GUIManager.single.Hide(UIConst.FIGHTING_UI);
+        this.GameOver=true;
     }
 
     /**
@@ -266,10 +287,7 @@ export class GameController extends EventDispatcher{
             if(GameModel.single.currentLevel>=GameConfigManager.MaxLevel){
                 GameModel.single.currentLevel=GameConfigManager.MaxLevel;
             }
-            this.ClearMonsters();
-            this.GameOver=true;
-            GUIManager.single.Show(UIConst.GAME_OVER_UI,true);
-            GUIManager.single.Hide(UIConst.FIGHTING_UI);
+            this.OnGameOver(0);
         }
     }
     
@@ -286,9 +304,7 @@ export class GameController extends EventDispatcher{
                 this.fence.Damage(damage);
             }
         }else{
-            this.GameOver=true;
-            GUIManager.single.Show(UIConst.GAME_OVER_UI,false);
-            GUIManager.single.Hide(UIConst.FIGHTING_UI);
+            this.OnGameOver(1);
         }
     }
 
@@ -343,7 +359,6 @@ export class GameController extends EventDispatcher{
      * 武器攻击
      */
     WeaponAttack():void{
-        console.log("开枪了");
         let monsterList:MonsterBase[];
         let monsterLists:Array<Array<MonsterBase>>=[];
         //攻击1条路

+ 11 - 3
assets/scripts/games/ui/fightings/fences/FenceBase.ts

@@ -4,7 +4,6 @@ const { ccclass, property } = _decorator;
 
 @ccclass('FenceBase')
 export class FenceBase extends Component {
-    config:any;
 
     hp:number;
 
@@ -15,16 +14,25 @@ export class FenceBase extends Component {
      * 状态 0 站立 1 受伤 2 死亡
      */
     private state:number=0;
+
     start () {
         // Your initialization goes here.
-        this.hp=this.maxHp=this.config.hp;
-
         this.animation=this.getComponent(AnimationComponent);
         CCSAnimationUtils.SetAnimationSpeed(this.animation,this.config.idleAnimation,this.config.idleAnimationSpeed);
         CCSAnimationUtils.SetAnimationSpeed(this.animation,this.config.damageAnimation,this.config.damageAnimationSpeed);
         CCSAnimationUtils.SetAnimationSpeed(this.animation,this.config.dieAnimation,this.config.dieAnimationSpeed);
     }
 
+    set config(value:any){
+        this.__config=value;
+        this.hp=this.maxHp=this.config.hp;
+    }
+    
+    private __config:any;
+    get config():any{
+        return this.__config;
+    }
+
     /**
      * 闲置
      */

+ 17 - 8
assets/scripts/games/ui/fightings/monsters/MonsterBase.ts

@@ -4,6 +4,7 @@ import CCSAnimationUtils from '../../../../engines/utils/CCSAnimationUtils';
 import GameConfigManager from '../../../models/GameConfigManager';
 import { GameController } from '../GameController';
 import { MonsterHP } from './MonsterHP';
+import { MonsterHPUIPool } from './MonsterHPUIPool';
 const { ccclass, property } = _decorator;
 
 @ccclass('MonsterBase')
@@ -65,7 +66,7 @@ export class MonsterBase extends Component {
     private InitAnimations():void{
         CCSAnimationUtils.SetAnimationSpeed(this.animation,this.monsterConfig.moveAnimation,this.monsterConfig.moveAnimationSpeed);
         CCSAnimationUtils.SetAnimationSpeed(this.animation,this.monsterConfig.attackAnimation,this.monsterConfig.attackAnimationSpeed);
-        CCSAnimationUtils.SetAnimationEvent(this.animation,this.monsterConfig.attackAnimation,this.monsterConfig.attackAnimationEvents);
+        // CCSAnimationUtils.SetAnimationEvent(this.animation,this.monsterConfig.attackAnimation,this.monsterConfig.attackAnimationEvents);
         CCSAnimationUtils.SetAnimationSpeed(this.animation,this.monsterConfig.dieAnimation,this.monsterConfig.dieAnimationSpeed);
     }
 
@@ -161,15 +162,17 @@ export class MonsterBase extends Component {
         this.animation.play(this.monsterConfig.attackAnimation);
     }
 
-    /**
-     * 攻击生效帧回调
-     */
-    AttackDamageFrame():void{
-        console.log(this.config.mId+"攻击"+this.attackType);
-        GameController.single.MonsterAttack(this.attackType,this.config.damage);
-    }
+    // /**
+    //  * 攻击生效帧回调
+    //  */
+    // AttackDamageFrame():void{
+    //     console.log(this.config.mId+"攻击"+this.attackType);
+    //     GameController.single.MonsterAttack(this.attackType,this.config.damage);
+    // }
 
     private AttackComplete():void{
+        console.log(this.config.mId+"攻击"+this.attackType);
+        GameController.single.MonsterAttack(this.attackType,this.config.damage);
         this.state=0;
         this.Move();
     }
@@ -248,8 +251,14 @@ export class MonsterBase extends Component {
     private DieComplete():void{
         this.node.active=false;
         this.node.destroy();
+
+    }
+
+    onDestroy():void{
         SoundManager.single.ClearSound(this.config.id);
         this.danHen=null;
+        MonsterHPUIPool.Recycle(this.hpView);
+        this.hpView=null;
     }
 
     private removeAllAnimationEvent():void{

+ 6 - 4
assets/scripts/games/ui/fightings/monsters/MonsterHP.ts

@@ -19,6 +19,12 @@ export class MonsterHP extends Component {
         this.progressBar.progress=0;
     }
 
+    onEnable():void{
+        this.progressBar=this.getComponent(ProgressBarComponent);
+        this.node.setScale(0,0,0);
+    }
+
+
     update (deltaTime: number) {
         if(this.monster==null){
             return;
@@ -36,9 +42,5 @@ export class MonsterHP extends Component {
         
         //更新HP
         this.progressBar.progress=this.monster.hp/this.monster.maxHP;
-
-        if(this.monster.isDie){
-            MonsterHPUIPool.Recycle(this);
-        }
     }
 }

+ 12 - 10
assets/scripts/games/ui/fightings/monsters/MonsterHPUIPool.ts

@@ -13,11 +13,12 @@ export class MonsterHPUIPool extends Component {
      */
     public static Create():MonsterHP{
         let monsterHPView:MonsterHP;
-        if(this.pool.length>0){
-            monsterHPView=this.pool.shift();
-            GameController.single.monsterHPUILayer.addChild(monsterHPView.node);
-            return monsterHPView
-        }
+        // if(this.pool.length>0){
+        //     monsterHPView=this.pool.shift();
+        //     // GameController.single.monsterHPUILayer.addChild(monsterHPView.node);
+        //     monsterHPView.node.active=true;
+        //     return monsterHPView
+        // }
         let prefab:Prefab=loader.getRes("ui/components/MonsterHPUI");
         let viewNode:Node=instantiate(prefab);
         monsterHPView=viewNode.addComponent(MonsterHP);
@@ -27,10 +28,11 @@ export class MonsterHPUIPool extends Component {
 
     public static Recycle(monsterHPView:MonsterHP):void{
         GameController.single.monsterHPUILayer.removeChild(monsterHPView.node);
-        monsterHPView.monster=null;
-        if(this.pool.indexOf(monsterHPView)>=0){
-            throw new Error("重复回收")
-        }
-        this.pool.push(monsterHPView);
+        monsterHPView.node.destroy();
+        // monsterHPView.monster=null;
+        // if(this.pool.indexOf(monsterHPView)>=0){
+        //     throw new Error("重复回收")
+        // }
+        // this.pool.push(monsterHPView);
     }
 }

+ 23 - 0
assets/scripts/games/ui/fightings/weapons/WeaponBase.ts

@@ -64,6 +64,27 @@ export class WeaponBase extends EventDispatcher{
         this.Idle();
     }
 
+    /**
+     * 销毁
+     */
+    Destroy():void{
+        this.weaponPrefab=null;
+        //枪口火焰
+
+        this.leftSocket.removeChild(this.leftWeapon);
+        this.leftWeapon.destroy();
+        this.leftWeapon=null;
+        this.rightSocket.removeChild(this.rightWeapon);
+        this.rightWeapon.destroy();
+        this.rightWeapon=null;
+
+        this.gunfirePrefab=null;
+        this.leftGunFire.node.destroy();
+        this.leftGunFire=null;
+        this.rightGunFire.node.destroy();
+        this.rightGunFire=null;
+    }
+
     protected InitHands():void{
         this.leftSocket=find("RootNode/Arm/upper_arm_R/lower_arm_R/transform1/hand_R/transform2/Guns",this.leftHand.node);
         this.rightSocket=find("RootNode/Arm/upper_arm_R/lower_arm_R/transform1/hand_R/transform2/Guns",this.rightHand.node);
@@ -236,4 +257,6 @@ export class WeaponBase extends EventDispatcher{
         }
         return -1;
     }
+
+ 
 }

+ 16 - 7
assets/scripts/games/ui/prepares/PrepareMediator.ts

@@ -1,4 +1,4 @@
-import { AudioClip, AudioSourceComponent, ButtonComponent, Color, EventTouch, find, instantiate, LabelComponent, LayoutComponent, loader, Material, ModelComponent, Node, Prefab, Quat, SpriteComponent, SpriteFrame, systemEvent, SystemEventType, Touch, Vec2, view, _decorator } from 'cc';
+import { ButtonComponent, EventTouch, find, instantiate, LabelComponent, LayoutComponent, loader, ModelComponent, Node, Prefab, Quat, SpriteComponent, SpriteFrame, SystemEventType, Touch, Vec2, view, _decorator } from 'cc';
 import { GUIManager } from '../../../engines/gui/GUIManager';
 import { GUIMediator } from '../../../engines/gui/GUIMediator';
 import { DataModelEventType } from '../../../engines/models/DataModelEventType';
@@ -9,10 +9,8 @@ import { PlatformManager } from '../../../Platform/PlatformManager';
 import GameConfigManager from '../../models/GameConfigManager';
 import { GameModel } from '../../models/GameModel';
 import { GamePropertys } from '../../models/GamePropertys';
-import { WeaponCell } from '../../models/weapons/WeaponCell';
 import { UIConst } from '../UIConst';
 import { WeaponCellListView } from './WeaponCellListView';
-import { WeaponCellScript } from './WeaponCellScript';
 const { ccclass, property } = _decorator;
 
 @ccclass('PrepareMediator')
@@ -115,6 +113,8 @@ export class PrepareMediator extends GUIMediator {
     })
     weaponList: LayoutComponent = null;
 
+
+
     private modelView: ModelComponent;
 
     private modelPrefab: Prefab;
@@ -123,6 +123,7 @@ export class PrepareMediator extends GUIMediator {
 
     private weaponCellListView: WeaponCellListView;
 
+
     onLoad(): void {
         this.weaponCellListView = new WeaponCellListView(this);
     }
@@ -152,9 +153,16 @@ export class PrepareMediator extends GUIMediator {
         this.modelView.node.active = true;
 
         let weaponConfig: any = GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
-        if (this.prefabInstance) {
+        if (this.modelPrefab) {
             this.modelView.mesh = null;
+            let target=this.modelView.materials[0];
+            target.setProperty("mainTexture", null);
+
             this.prefabInstance.destroy();
+            this.prefabInstance=null;
+            let deps:string[]=loader.getDependsRecursively(this.modelPrefab);
+            loader.release(deps);
+            this.modelPrefab=null;
         }
         loader.loadRes(weaponConfig.prefab, Prefab, (err, prefab) => {
             if (err) {
@@ -180,7 +188,8 @@ export class PrepareMediator extends GUIMediator {
         this.RemoveEvents();
 
         this.modelView.mesh = null;
-        this.modelView.setMaterial(null, 0);
+        let target=this.modelView.materials[0];
+        target.setProperty("mainTexture", null);
         if (this.prefabInstance) {
             this.prefabInstance.destroy();
         }
@@ -344,8 +353,8 @@ export class PrepareMediator extends GUIMediator {
      */
     getAdGold(): void {
         PlatformManager.showRewardedVideo(()=>{
-            GameModel.single.gold += GameModel.single.fullEarnings * 3600;
-            NoticeManager.ShowPrompt(`获得${GameModel.single.fullEarnings * 3600}金币`);
+            GameModel.single.gold += GameModel.single.fullEarnings * 600;
+            NoticeManager.ShowPrompt(`获得${GameModel.single.fullEarnings * 600}金币`);
         },()=>{
             NoticeManager.ShowPrompt(`未看完广告,无奖励`);
         })