|
@@ -1,4 +1,4 @@
|
|
-import { ButtonComponent, Color, find, instantiate, LabelComponent, LayoutComponent, loader, ModelComponent, Node, Prefab, Quat, SpriteComponent, SpriteFrame, systemEvent, SystemEventType, Touch, Vec2, view, _decorator } from 'cc';
|
|
|
|
|
|
+import { ButtonComponent, Color, EventTouch, find, instantiate, LabelComponent, LayoutComponent, loader, Material, ModelComponent, Node, Prefab, Quat, SpriteComponent, SpriteFrame, systemEvent, SystemEventType, Touch, Vec2, view, _decorator } from 'cc';
|
|
import { GUIManager } from '../../../engines/gui/GUIManager';
|
|
import { GUIManager } from '../../../engines/gui/GUIManager';
|
|
import { GUIMediator } from '../../../engines/gui/GUIMediator';
|
|
import { GUIMediator } from '../../../engines/gui/GUIMediator';
|
|
import { DataModelEventType } from '../../../engines/models/DataModelEventType';
|
|
import { DataModelEventType } from '../../../engines/models/DataModelEventType';
|
|
@@ -15,7 +15,7 @@ const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('PrepareMediator')
|
|
@ccclass('PrepareMediator')
|
|
export class PrepareMediator extends GUIMediator {
|
|
export class PrepareMediator extends GUIMediator {
|
|
-
|
|
|
|
|
|
+
|
|
@property({
|
|
@property({
|
|
type:LabelComponent
|
|
type:LabelComponent
|
|
})
|
|
})
|
|
@@ -112,7 +112,6 @@ export class PrepareMediator extends GUIMediator {
|
|
|
|
|
|
private weaponCellListView:WeaponCellListView;
|
|
private weaponCellListView:WeaponCellListView;
|
|
|
|
|
|
-
|
|
|
|
onLoad():void{
|
|
onLoad():void{
|
|
this.weaponCellListView=new WeaponCellListView(this);
|
|
this.weaponCellListView=new WeaponCellListView(this);
|
|
}
|
|
}
|
|
@@ -141,7 +140,6 @@ export class PrepareMediator extends GUIMediator {
|
|
let weaponConfig:any=GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
|
|
let weaponConfig:any=GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
|
|
if(this.prefabInstance){
|
|
if(this.prefabInstance){
|
|
this.modelView.mesh=null;
|
|
this.modelView.mesh=null;
|
|
- this.modelView.setMaterial(null,0);
|
|
|
|
this.prefabInstance.destroy();
|
|
this.prefabInstance.destroy();
|
|
}
|
|
}
|
|
loader.loadRes(weaponConfig.prefab,Prefab,(err,prefab)=>{
|
|
loader.loadRes(weaponConfig.prefab,Prefab,(err,prefab)=>{
|
|
@@ -150,8 +148,13 @@ export class PrepareMediator extends GUIMediator {
|
|
}
|
|
}
|
|
this.prefabInstance=instantiate(prefab);
|
|
this.prefabInstance=instantiate(prefab);
|
|
this.prefabModelComponent=this.prefabInstance.getComponentInChildren(ModelComponent);
|
|
this.prefabModelComponent=this.prefabInstance.getComponentInChildren(ModelComponent);
|
|
|
|
+ //更换贴图
|
|
|
|
+ let source=this.prefabModelComponent.materials[0];
|
|
|
|
+ let target=this.modelView.materials[0];
|
|
|
|
+ let texture=source.getProperty("mainTexture");
|
|
|
|
+ target.setProperty("mainTexture",texture);
|
|
|
|
+ //更换模型
|
|
this.modelView.mesh=this.prefabModelComponent.mesh;
|
|
this.modelView.mesh=this.prefabModelComponent.mesh;
|
|
- this.modelView.setMaterial(this.prefabModelComponent.getMaterial(0),0);
|
|
|
|
});
|
|
});
|
|
if(this.gunNameLabel!=null){
|
|
if(this.gunNameLabel!=null){
|
|
this.gunNameLabel.string=weaponConfig.name;
|
|
this.gunNameLabel.string=weaponConfig.name;
|
|
@@ -281,19 +284,21 @@ export class PrepareMediator extends GUIMediator {
|
|
private currentPoint:Vec2=new Vec2();
|
|
private currentPoint:Vec2=new Vec2();
|
|
|
|
|
|
private TouchStartHandler(touch:Touch,touchEvent):void{
|
|
private TouchStartHandler(touch:Touch,touchEvent):void{
|
|
- let pos:Vec2=touch.getLocation();
|
|
|
|
|
|
+ let pos:Vec2=touch.getUILocation();
|
|
console.log(pos);
|
|
console.log(pos);
|
|
this.startPoint.set(pos.x,pos.y);
|
|
this.startPoint.set(pos.x,pos.y);
|
|
this.startRotation.x=this.modelView.node.rotation.x;
|
|
this.startRotation.x=this.modelView.node.rotation.x;
|
|
this.startRotation.set(this.modelView.node.rotation.x,this.modelView.node.rotation.y,this.modelView.node.rotation.z,this.modelView.node.rotation.w);
|
|
this.startRotation.set(this.modelView.node.rotation.x,this.modelView.node.rotation.y,this.modelView.node.rotation.z,this.modelView.node.rotation.w);
|
|
}
|
|
}
|
|
|
|
|
|
- private TouchMoveHandler(touch,touchEvent):void{
|
|
|
|
- let pos:Vec2=touch.getLocation();
|
|
|
|
|
|
+ private TouchMoveHandler(touch:EventTouch,touchEvent):void{
|
|
|
|
+ let pos:Vec2=touch.getUILocation();
|
|
this.currentPoint.set(pos.x,pos.y);
|
|
this.currentPoint.set(pos.x,pos.y);
|
|
let dis:number=Vec2.distance(this.currentPoint,this.startPoint);
|
|
let dis:number=Vec2.distance(this.currentPoint,this.startPoint);
|
|
let value:number=dis/view.getCanvasSize().width;
|
|
let value:number=dis/view.getCanvasSize().width;
|
|
-
|
|
|
|
|
|
+ if(this.currentPoint.x<this.startPoint.x){
|
|
|
|
+ value=-value;
|
|
|
|
+ }
|
|
Quat.rotateY(this.currentRotation,this.startRotation,value);
|
|
Quat.rotateY(this.currentRotation,this.startRotation,value);
|
|
|
|
|
|
Quat.normalize(this.currentRotation,this.currentRotation);
|
|
Quat.normalize(this.currentRotation,this.currentRotation);
|