|
@@ -344,7 +344,34 @@ export class car extends Component {
|
|
|
|
|
|
x = this.node.position.x-x;
|
|
|
|
|
|
+
|
|
|
+ let left = this.canvas_width*0.5*-1+90*0.5;
|
|
|
+ let right = this.canvas_width*0.5-90*0.5;
|
|
|
let size = this.node.getComponent(UITransform).contentSize;
|
|
|
+ if(this.carDir==DirType.LEFT){
|
|
|
+
|
|
|
+ let left_x = this.game_manager.getLeftObstacles(new Rect(this.node.position.x-size.width*0.5,this.node.position.y-size.height*0.5,size.width,size.height))
|
|
|
+ // console.log("left_x",left_x)
|
|
|
+ if(left_x!=null&&x<left_x){
|
|
|
+ x = left_x+5
|
|
|
+ }
|
|
|
+
|
|
|
+ if(x<=left){
|
|
|
+ x = this.node.position.x
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.carDir==DirType.RIGHT){
|
|
|
+ let right_x = this.game_manager.getRightObstacles(new Rect(this.node.position.x-size.width*0.5,this.node.position.y-size.height*0.5,size.width,size.height))
|
|
|
+ // console.log("right_x",right_x)
|
|
|
+ if(right_x!=null&&x>right_x){
|
|
|
+ x = right_x-5
|
|
|
+ }
|
|
|
+ if(x>=right){
|
|
|
+ x = this.node.position.x
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let rect = new Rect(x-size.width*0.5,y-size.height*0.5,size.width,size.height)
|
|
|
// let rect = this.node.getComponent(UITransform).getBoundingBox()
|
|
|
let list = this.game_manager.carCollider(rect)
|
|
@@ -373,32 +400,6 @@ export class car extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let left = this.canvas_width*0.5*-1+90*0.5;
|
|
|
- let right = this.canvas_width*0.5-90*0.5;
|
|
|
-
|
|
|
- if(this.carDir==DirType.LEFT){
|
|
|
-
|
|
|
- let left_x = this.game_manager.getLeftObstacles(new Rect(this.node.position.x-size.width*0.5,this.node.position.y-size.height*0.5,size.width,size.height))
|
|
|
- // console.log("left_x",left_x)
|
|
|
- if(left_x!=null&&x<left_x){
|
|
|
- x = left_x+5
|
|
|
- }
|
|
|
-
|
|
|
- if(x<=left){
|
|
|
- x = this.node.position.x
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(this.carDir==DirType.RIGHT){
|
|
|
- let right_x = this.game_manager.getRightObstacles(new Rect(this.node.position.x-size.width*0.5,this.node.position.y-size.height*0.5,size.width,size.height))
|
|
|
- // console.log("right_x",right_x)
|
|
|
- if(right_x!=null&&x>right_x){
|
|
|
- x = right_x-5
|
|
|
- }
|
|
|
- if(x>=right){
|
|
|
- x = this.node.position.x
|
|
|
- }
|
|
|
- }
|
|
|
// this._curRingPos_1.set(0, 0, 0);
|
|
|
// Vec3.lerp(this._curRingPos_1, this.node.position, new Vec3(x,y), 50 * dt);
|
|
|
|