|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, BoxCollider2D, CircleCollider2D, Collider2D, Component, Contact2DType, Director, director, IPhysics2DContact, Label, math, Node, ParticleSystem2D, PolygonCollider2D, Rect, RigidBody, RigidBody2D, Sprite, tween, Tween, UITransform, Vec2, Vec3, View } from 'cc';
|
|
|
+import { _decorator, BoxCollider2D, CircleCollider2D, Collider2D, Component, Contact2DType, Director, director, instantiate, IPhysics2DContact, Label, math, Node, ParticleSystem2D, PolygonCollider2D, Prefab, Rect, RigidBody, RigidBody2D, Sprite, tween, Tween, UITransform, Vec2, Vec3, View } from 'cc';
|
|
|
import { wall } from './wall';
|
|
|
import { box } from './box';
|
|
|
import { coin } from './coin';
|
|
@@ -12,6 +12,7 @@ import { audioManager } from '../manager/audioManager';
|
|
|
import { buff_manager } from './buff/buff_manager';
|
|
|
import { hp_bar } from './hp_bar';
|
|
|
import { GameManager } from '../GameManager';
|
|
|
+import { buff_active_effect_item } from './buff/buff_active_effect_item';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('car')
|
|
@@ -45,6 +46,7 @@ export class car extends Component {
|
|
|
private isStartGame:Boolean = false
|
|
|
@property(Node) spr:Node = null
|
|
|
@property(Node) hp_bar:Node = null
|
|
|
+ @property(Prefab) buff_active_effect_pf:Prefab = null
|
|
|
@property(ParticleSystem2D) smoke_particle:ParticleSystem2D = null
|
|
|
private mIsReLife:boolean = false
|
|
|
public init(m:Node,cb,cb1,g:game,isReLife:boolean = false){
|
|
@@ -156,6 +158,10 @@ export class car extends Component {
|
|
|
coin_node.getComponent(coin).removeSelf()
|
|
|
this.hp+=coin_node.getComponent(coin).getAddHpNum()
|
|
|
this.updateHp()
|
|
|
+
|
|
|
+ let box_world=coin_node.parent.getComponent(UITransform).convertToWorldSpaceAR(coin_node.position)
|
|
|
+ let p = this.node.parent.getComponent(UITransform).convertToNodeSpaceAR(box_world)
|
|
|
+ this.getGame().showQiYouEffect(p)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -237,19 +243,50 @@ export class car extends Component {
|
|
|
}
|
|
|
}else{
|
|
|
if(data!=null){
|
|
|
- switch (data.buff_type) {
|
|
|
- case config.buff_type.dun:
|
|
|
- // console.log("获取buff 盾")
|
|
|
- this.buff_dun()
|
|
|
- break;
|
|
|
- case config.buff_type.xing:
|
|
|
- // console.log("获取buff 星")
|
|
|
- this.buff_xing()
|
|
|
- break;
|
|
|
- case config.buff_type.xi:
|
|
|
- // console.log("获取buff 吸")
|
|
|
- this.buff_xi()
|
|
|
- break;
|
|
|
+ if(data.buff_type!=-1){
|
|
|
+ let buff_info = this.game_manager.getBuffShowView()
|
|
|
+ let buff_active_node = instantiate(this.buff_active_effect_pf)
|
|
|
+ buff_active_node.parent = buff_info.node.parent
|
|
|
+
|
|
|
+ console.log("data.buff_type::",data.buff_type)
|
|
|
+ let box_p = buff_info.node.parent.getComponent(UITransform).convertToNodeSpaceAR(data.pos)
|
|
|
+ switch (data.buff_type) {
|
|
|
+ case config.buff_type.dun:
|
|
|
+ // console.log("获取buff 盾")
|
|
|
+ {
|
|
|
+ let dis_node = buff_info.getBuffDun();
|
|
|
+ let world = dis_node.parent.getComponent(UITransform).convertToWorldSpaceAR(dis_node.position)
|
|
|
+ let p = buff_info.node.parent.getComponent(UITransform).convertToNodeSpaceAR(world)
|
|
|
+ buff_active_node.getComponent(buff_active_effect_item).show(config.SHOW_BUFF_STATUS.DUN,p,box_p,()=>{
|
|
|
+ this.buff_dun()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case config.buff_type.xing:
|
|
|
+ // console.log("获取buff 星")
|
|
|
+ {
|
|
|
+ let dis_node = buff_info.getBuffXing();
|
|
|
+ let world = dis_node.parent.getComponent(UITransform).convertToWorldSpaceAR(dis_node.position)
|
|
|
+ let p = buff_info.node.parent.getComponent(UITransform).convertToNodeSpaceAR(world)
|
|
|
+ buff_active_node.getComponent(buff_active_effect_item).show(config.SHOW_BUFF_STATUS.XING,p,box_p,()=>{
|
|
|
+ this.buff_xing()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case config.buff_type.xi:
|
|
|
+ // console.log("获取buff 吸")
|
|
|
+ {
|
|
|
+ let dis_node = buff_info.getBuffXi();
|
|
|
+ let world = dis_node.parent.getComponent(UITransform).convertToWorldSpaceAR(dis_node.position)
|
|
|
+ let p = buff_info.node.parent.getComponent(UITransform).convertToNodeSpaceAR(world)
|
|
|
+ buff_active_node.getComponent(buff_active_effect_item).show(config.SHOW_BUFF_STATUS.XI,p,box_p,()=>{
|
|
|
+ this.buff_xi()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -407,6 +444,17 @@ export class car extends Component {
|
|
|
// Vec3.lerp(this._curRingPos_1, this.node.position, new Vec3(x,y), 50 * dt);
|
|
|
|
|
|
// this.node.setPosition(this._curRingPos_1);
|
|
|
+
|
|
|
+ if(this.carDir==DirType.LEFT){
|
|
|
+ if(x<=left){
|
|
|
+ x = left
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.carDir==DirType.RIGHT){
|
|
|
+ if(x>=right){
|
|
|
+ x = right
|
|
|
+ }
|
|
|
+ }
|
|
|
this.node.setPosition(x,y)
|
|
|
this.offsetY =Math.abs(this.origin_pos_y-y)
|
|
|
let dir = new Vec3(this.map.position.x,-this.offsetY,this.map.position.z)
|