public BaseObject create(int x, int y, String name) {
   BaseObject obj = BaseObject.createObject(name);
   obj.move(x, y);
   add(obj);
   ungrabAll();
   grab(obj, x, y);
   return obj;
 }
示例#2
0
 @Override
 public void reset() {
   commitUpdates();
   final int count = mObjects.getCount();
   for (int i = 0; i < count; i++) {
     BaseObject object = mObjects.get(i);
     object.reset();
   }
 }
 public boolean canGrabAt(int x, int y) {
   BaseObject[] list = reversedList();
   for (int i = 0; i < list.length; i++) {
     BaseObject obj = list[i];
     if (obj.isAt(x, y)) {
       return true;
     }
   }
   return false;
 }
示例#4
0
 @Override
 public void update(float timeDelta, BaseObject parent) {
   commitUpdates();
   final int count = mObjects.getCount();
   if (count > 0) {
     final Object[] objectArray = mObjects.getArray();
     for (int i = 0; i < count; i++) {
       BaseObject object = (BaseObject) objectArray[i];
       object.update(timeDelta, this);
     }
   }
 }
示例#5
0
 /**
  * Finds a child object by its type. Note that this may invoke the class loader and therefore may
  * be slow.
  *
  * @param classObject The class type to search for (e.g. BaseObject.class).
  * @return
  */
 public <T> T findByClass(Class<T> classObject) {
   T object = null;
   final int count = mObjects.getCount();
   for (int i = 0; i < count; i++) {
     BaseObject currentObject = mObjects.get(i);
     if (currentObject.getClass() == classObject) {
       object = classObject.cast(currentObject);
       break;
     }
   }
   return object;
 }
  public synchronized void remove(BaseObject obj) {
    synchronized (objList) {
      if (!objList.contains(obj)) {
        return;
      }

      objList.remove(obj);
      obj.notifyListeners(obj);
      obj.removeListener(this);

      notifyListener(obj);
    }
  }
  public synchronized void add(BaseObject obj) {
    synchronized (objList) {
      if (objList.contains(obj)) {
        return;
      }

      obj.addListener(this);
      objList.add(obj);
      obj.notifyListeners(obj);

      notifyListener(obj);
    }
  }
  private void grab(BaseObject obj, int x, int y) {
    synchronized (grabList) {
      obj.selectAction(true);

      if (grabList.contains(obj)) {
        return;
      }

      grabList.add(obj);
      obj.setGrabbedAnchorAt(x, y);

      notifyListener(obj);
      lastGrabbed = obj;
    }
  }
示例#9
0
 @Override
 protected void assign_attributes(Map<String, Object> data) {
   super.assign_attributes(data);
   setTriggerId((String) data.get("triggerId"));
   setPayoffId((String) data.get("payoffId"));
   // @formatter:off
   /*{
    id=B6GFx2ZGSkSZr884L3MziA,
    name=My ShortTrigger,
    dateCreated=2015-01-21T03:01:48.643+0000,
    dateModified=2015-01-21T03:01:48.643+0000,
    payoffId=tjNPTElRSmukFO9u74eSBw,
    triggerId=46YCC30lS8ur4c_cuKx0BQ,
    link=[
      {href=https://www.livepaperapi.com/api/v1/links/B6GFx2ZGSkSZr884L3MziA,
       rel=self},
      {href=https://www.livepaperapi.com/analytics/v1/links/B6GFx2ZGSkSZr884L3MziA,
       rel=analytics},
      {href=https://www.livepaperapi.com/api/v1/payoffs/tjNPTElRSmukFO9u74eSBw,
       rel=payoff},
      {href=https://www.livepaperapi.com/api/v1/triggers/46YCC30lS8ur4c_cuKx0BQ,
       rel=trigger}]
   }*/
   // @formatter:on
 }
 public BaseObject grabAt(int x, int y, boolean ungrabAll) {
   BaseObject[] list = reversedList();
   for (int i = 0; i < list.length; i++) {
     BaseObject obj = list[i];
     if (obj.isAt(x, y)) {
       if (ungrabAll) {
         ungrabAll();
       }
       grab(obj, x, y);
       return obj;
     }
   }
   if (ungrabAll) {
     ungrabAll();
   }
   return null;
 }
 public void selectAllWithin(BaseObject boundary) {
   BaseObject[] list = list();
   for (int i = 0; i < list.length; i++) {
     java.awt.Shape s1 = boundary.getShape();
     java.awt.Shape s2 = list[i].getShape();
     if (s1.contains(s2.getBounds2D())) {
       grab(list[i]);
     }
   }
 }
  private void grab(BaseObject obj) {
    synchronized (grabList) {
      if (grabList.contains(obj)) {
        return;
      }

      obj.selectAction(true);
      grabList.add(obj);
      notifyListener(obj);
      lastGrabbed = obj;
    }
  }
  private void ungrab(BaseObject obj) {
    synchronized (grabList) {
      obj.selectAction(false);

      if (!grabList.contains(obj)) {
        return;
      }

      grabList.remove(obj);
      notifyListener(obj);
      lastGrabbed = null;
    }
  }
  public void run() {
    // TODO Auto-generated method stub
    mLastTime = SystemClock.uptimeMillis();
    mFinished = false;
    while (!mFinished) {

      if (mGameRoot != null) {
        // Wait for Rendering Thread to Finish

        mRenderer.checkRenderingIsFinshed();
        final long time = SystemClock.uptimeMillis();
        final long timeDelta = time - mLastTime;

        if (timeDelta > 12) {
          float secondsDelta = (time - mLastTime) * 0.001f;
          if (secondsDelta > 0.1f) {
            secondsDelta = 0.1f;
          }
          // TODO This is the game root, will be used to update objects under it!
          mGameRoot.update(secondsDelta, null);

          // TODO get camera positions and pass below
          // This calls the setRenderQueue in render system which will eventually set the rendering
          // thread to
          // a queue of objects

          BaseObject.renderSystem.swapQueue(mRenderer, 10f, 10f);

          mLastTime = SystemClock.uptimeMillis();
        } else {
        }
      }
    }
    BaseObject.renderSystem.emptyQueues(mRenderer);
    mRenderer.clearAllTextures(); // Clear all textures
    BaseObject.resetAllElements(); // resets everything except textures
  }
示例#15
0
 /** @param baseObject */
 UtilMapValuesIterator(final BaseObject<?> baseObject) {
   this.baseObject = baseObject;
   this.keys = baseObject.baseGetOwnIterator();
 }