示例#1
0
文件: Arena.java 项目: pokus001/vivae
 public Surface getSurfaceUnderVivaeObject(VivaeObject actor) {
   Vector<Surface> surfacesActorIsOn = new Vector<Surface>();
   Surface srfc = null;
   for (Surface surface : surfaces) {
     srfc = surface;
     Area actArea = actor.getArea();
     actArea.intersect(srfc.getArea());
     if (!actArea.isEmpty()) {
       surfacesActorIsOn.add(srfc);
     }
   }
   if (surfacesActorIsOn.isEmpty()) {
     return null;
   }
   srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);
   return srfc;
 }
示例#2
0
 /**
  * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface.
  *
  * @param actor
  */
 public float getFrictionOfSurface(VivaeObject actor) {
   Vector<Surface> surfacesActorIsOn = new Vector<Surface>();
   Surface srfc;
   for (Surface surface : surfaces) {
     srfc = surface;
     Area actArea = actor.getArea();
     actArea.intersect(srfc.getArea());
     if (!actArea.isEmpty()) {
       surfacesActorIsOn.add(srfc);
     }
   }
   if (surfacesActorIsOn.isEmpty()) {
     return 0f;
   }
   srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);
   return srfc.getFriction();
 }
示例#3
0
文件: Arena.java 项目: pokus001/vivae
  /**
   * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface.
   *
   * @param actor
   */
  public float getFrictionOfSurface(VivaeObject actor) {

    ArrayList<Surface> surfacesActorIsOn = new ArrayList<Surface>();
    Surface srfc;
    Area actArea = actor.getArea();

    for (Surface surface : surfaces) {
      srfc = surface;
      Area actor2intersect = (Area) actArea.clone();
      actor2intersect.intersect(srfc.getArea());
      if (!actor2intersect.isEmpty()) {
        surfacesActorIsOn.add(srfc);
      }
    }
    if (surfacesActorIsOn.isEmpty()) {
      return 0f;
    }
    srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);

    float res = srfc.getFriction();
    //        System.out.println("Surface = " + srfc.getClass().toString() + " has friction " +
    // res);
    return res;
  }