private void stop() { bounce.stop(); chase.stop(); patrol.stopPatrol(); if (jump != null) { jump.setForeverJump(false); } }
public static bool beginCollisionWithKoopaTroopa(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; arbiter.GetShapes(out shape1, out shape2); KoopaTroopa koopa1 = shape1.getOwnComponent <KoopaTroopa>(); KoopaTroopa koopa2 = shape2.getOwnComponent <KoopaTroopa>(); bool hidden1 = koopa1._hide.isHidden(); bool hidden2 = koopa2._hide.isHidden(); bool bouncing1 = koopa1.bounce.isBouncing(); bool bouncing2 = koopa2.bounce.isBouncing(); // avoid koopa1 pushes hidden koopa2 Chase chase1 = shape1.GetComponent <Chase>(); if (chase1 != null && chase1.isChasing()) { chase1.stop(); chase1.enableOperateWhenOutOfSensor(); } // avoid koopa2 pushes hidden koopa1 Chase chase2 = shape2.GetComponent <Chase>(); if (chase2 != null && chase2.isChasing()) { chase2.stop(); chase2.enableOperateWhenOutOfSensor(); } // is koopa1 above the koopa2? if (GameObjectTools.isGrounded(arbiter)) { if (!hidden1 && koopa1.jump.isJumping()) { koopa1.jump.forceJump(koopa1.jumpSpeed); } else if (hidden1 && koopa2.jump.isJumping()) { koopa2.jump.forceJump(koopa1.jumpSpeed); } return(false); // avoid the collision since this frame } // hide koopa 2 else if (bouncing1 && !hidden2 && !bouncing2) { koopa2.hide(); } // hide koopa 1 else if (bouncing2 && !hidden1 && !bouncing1) { //koopa1.die(); koopa1.hide(); } // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next fixed step. return(true); }
public static void endCollisionWithPlayer(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; // The order of the arguments matches the order in the function name. arbiter.GetShapes(out shape1, out shape2); Chase chase = shape1.getOwnComponent <Chase>(); chase.stop(); chase.target = null; chase.enableOperate(); }
public static bool beginCollisionWithAny(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; // The order of the arguments matches the order in the function name. arbiter.GetShapes(out shape1, out shape2); // if chasing then avoid wall penetration Chase chase = shape1.GetComponent <Chase>(); if (chase != null && chase.isChasing() && GameObjectTools.isWallHit(arbiter)) { chase.stop(); chase.enableOperateWhenOutOfSensor(); } // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next fixed step. return(true); }
private void stop() { targetWalkComp = null; chase.stop(); fly.stopFlying(); }