|
@@ -9,6 +9,7 @@ import { DirType, model_content_item_data } from '../data';
|
|
|
import { config } from '../config';
|
|
|
import { imageCacheManager } from '../manager/imageCacheManager';
|
|
|
import { userDataManager } from '../manager/userDataManager';
|
|
|
+import { audioManager } from '../manager/audioManager';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('car')
|
|
@@ -39,7 +40,7 @@ export class car extends Component {
|
|
|
private carDir:DirType = DirType.NONE
|
|
|
private canvas_width:number = 1080;
|
|
|
private isStopY:boolean = false
|
|
|
- private _curRingPos_1: Vec3 = new Vec3();//当前圆圈坐标
|
|
|
+ private isStartGame:Boolean = false
|
|
|
@property(Node) spr:Node = null
|
|
|
public init(m:Node,cb,cb1,g:game){
|
|
|
this.spr.getComponent(Sprite).spriteFrame = imageCacheManager.getGameCarImageById(userDataManager.user_car_list.default_car_id)
|
|
@@ -55,6 +56,7 @@ export class car extends Component {
|
|
|
this.buff_xing_status = false;
|
|
|
this.isStopY = false;
|
|
|
this.canvas_width = View.instance.getVisibleSize().width
|
|
|
+ audioManager.Instance().playSound(config.AUDIO.car_qi_dong)
|
|
|
// let cd = this.node.getComponent(BoxCollider2D)
|
|
|
// cd.off(Contact2DType.BEGIN_CONTACT)
|
|
|
// cd.on(Contact2DType.BEGIN_CONTACT,this.onColliderCoin.bind(this))
|
|
@@ -134,6 +136,7 @@ export class car extends Component {
|
|
|
|
|
|
onColliderBox(box_node:Node){
|
|
|
if(box_node.getComponent(box)!=null){
|
|
|
+ audioManager.Instance().playSound(config.AUDIO.peng_zhuang)
|
|
|
box_node.getComponent(box).hurt(this.shake.bind(this),this.buff_dun_status)
|
|
|
}
|
|
|
}
|
|
@@ -197,6 +200,7 @@ export class car extends Component {
|
|
|
tween(this.lab_hp).delay(0.02).call(()=>{ this.isStopY = false}).start()
|
|
|
if(this.hp<0){
|
|
|
Tween.stopAllByTarget(this.node)
|
|
|
+ this.stopGame()
|
|
|
// this.node.getComponent(RigidBody2D).gravityScale = 0
|
|
|
// this.node.getComponent(RigidBody2D).linearDamping = 0
|
|
|
this.over_cb()
|
|
@@ -228,6 +232,7 @@ export class car extends Component {
|
|
|
this.scheduleOnce(this.cancelScheduleBuffXi.bind(this),tools.game_config.buff_xi)
|
|
|
this.game_manager.getBuffShowView().showBuffXi()
|
|
|
})
|
|
|
+ audioManager.Instance().playSound(config.AUDIO.buff_xi)
|
|
|
}
|
|
|
|
|
|
public cancelScheduleBuffXi(){
|
|
@@ -243,6 +248,7 @@ export class car extends Component {
|
|
|
this.scheduleOnce(this.cancelScheduleBuffXing.bind(this),tools.game_config.buff_xing)
|
|
|
this.game_manager.getBuffShowView().showBuffXing()
|
|
|
})
|
|
|
+ audioManager.Instance().playSound(config.AUDIO.buff_xing)
|
|
|
}
|
|
|
|
|
|
public cancelScheduleBuffXing(){
|
|
@@ -258,6 +264,7 @@ export class car extends Component {
|
|
|
this.scheduleOnce(this.cancelScheduleBuffDun.bind(this),tools.game_config.buff_dun)
|
|
|
this.game_manager.getBuffShowView().showBuffDun()
|
|
|
})
|
|
|
+ audioManager.Instance().playSound(config.AUDIO.buff_dun)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -270,9 +277,18 @@ export class car extends Component {
|
|
|
public setMoveSpeedX(speed_x:number){
|
|
|
// this.move_speed_x = speed_x
|
|
|
}
|
|
|
+ public startGame(){
|
|
|
+ this.isStartGame = true
|
|
|
+ }
|
|
|
+ public stopGame(){
|
|
|
+ this.isStartGame = false
|
|
|
+ }
|
|
|
check(){
|
|
|
}
|
|
|
protected update(dt: number): void {
|
|
|
+ if(!this.isStartGame){
|
|
|
+ return
|
|
|
+ }
|
|
|
if(this.map!=null&&this.hp>=0){
|
|
|
let x = 0
|
|
|
let y = this.isStopY?this.node.position.y:this.node.position.y+this.move_speed_y.valueOf()*dt;
|
|
@@ -358,6 +374,10 @@ export class car extends Component {
|
|
|
public setDisDir(dis:number){
|
|
|
this.speed_bei = dis / 10
|
|
|
|
|
|
+ if(this.speed_bei>5){
|
|
|
+ audioManager.Instance().playSound(config.AUDIO.car_sha_che,0.1)
|
|
|
+ }
|
|
|
+
|
|
|
if(this.carDir==DirType.LEFT){
|
|
|
this.mDir = new Vec3(this.node.position.x-dis,this.node.position.y)
|
|
|
}
|