Android Open Source - Castle-Invaders Object Selection Container






From Project

Back to project page Castle-Invaders.

License

The source code is released under:

GNU General Public License

If you think the Android project Castle-Invaders listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.noobygames.utils;
// w w w  .jav a2 s .co m
import com.badlogic.gdx.utils.Array;

/**ObjectSelection is a container class which accepts whether a generic single object or an generic array of multiple objects as target.
 * So Object Selection is just a container for generic objects
 * @author Nerzal**/
public class ObjectSelectionContainer<T> {

  private T singleTarget;
  private Array<T> multiTarget;
  
  /**false for single target mode
   * true for multi target mode**/
  private boolean multiTargetSelection;
  

  /**standard getter
   * @return true if in multi select mode**/
  public boolean getSelectionMode() {
    return multiTargetSelection;
  }

  /**standard setter
   * @param multiTargetSelection Indicates if multi target select mode is turned on/off**/
  public void setSelectionMode(boolean multiTargetSelection) {
    this.multiTargetSelection = multiTargetSelection;
  }  
  
  /**Constructor
   * @param singleTarget generic object
   * @param multiTarget generic array**/
  public ObjectSelectionContainer(T singleTarget, Array<T> multiTarget){
    this.singleTarget = singleTarget;
    this.multiTarget = multiTarget;
  }
  
  
  /**Standard getter (for generic type T)
   * @return returns the singleTarget object**/
  public T getSingleTarget(){
    return singleTarget;
  }
  
  /**Sets the generic field singleTarget to the given "value"
   * @param singleTarget **/
  public void setSingleTarget(T singleTarget){
    this.singleTarget = singleTarget;
  }

  /**@return Returns the array or null**/
  public Array<T> getMultiTarget() {
    return multiTarget;
  }
  
  /**Returns the specific element with the given index out of the multiTarget
   * @param index The index of the element**/
  public T getSingleTarget(int index){
    return multiTarget.get(index);
  }
  
  /**Returns the given object, if its in the array
   * @param object The object to look for
   * @return the object if found in the array, else null **/
  public T getSingleTarget(T object){
    for(T obj: multiTarget){
      if(obj.equals(object))
        return obj;
    }
    return null;
  }

  /**Sets the multiTarget array
   * @param multiTarget The generic array to set**/
  public void setNewMultiTarget(Array<T> multiTarget) {
    this.multiTarget = multiTarget;
  }
  
  /**removes a single object from the selection
   * @param object the object to remove**/
  public void removeTarget(T object){
    multiTarget.removeValue(object, true);  
    }
  
  
  /**Adds a object to multiTarget
   * @param object The object to add**/
  public void addTarget(T object){
    multiTarget.add(object);
  }
  
  /**Clears the multi select**/
  public void clearmultiTarget(){
    multiTarget.clear();
  }
  /**Clears the single Target**/
  public void clearSingleTarget(){
    singleTarget = null;
  }
  
  /**Clears all targets, sets mode to single target selection**/
  public void clearAll(){
    singleTarget = null;
    multiTarget = null;
    multiTargetSelection = false;
  }

}




Java Source Code List

com.noobgygames.castleinvaders.ui.DragonUltiButton.java
com.noobgygames.castleinvaders.ui.ElementSwitcherButton.java
com.noobgygames.castleinvaders.ui.StoreElement.java
com.noobgygames.castleinvaders.ui.TextureElement.java
com.noobygames.castleinvaders.Assets.java
com.noobygames.castleinvaders.CastleInvaders.java
com.noobygames.castleinvaders.DynamicGameObject.java
com.noobygames.castleinvaders.GameLiving.java
com.noobygames.castleinvaders.GameObject.java
com.noobygames.castleinvaders.MainActivity.java
com.noobygames.castleinvaders.Main.java
com.noobygames.castleinvaders.Player.java
com.noobygames.castleinvaders.Projectile.java
com.noobygames.castleinvaders.Settings.java
com.noobygames.castleinvaders.WorldRenderer.java
com.noobygames.castleinvaders.World.java
com.noobygames.castleinvaders.mobs.Croco.java
com.noobygames.castleinvaders.mobs.EarthDragon.java
com.noobygames.castleinvaders.mobs.FireDragon.java
com.noobygames.castleinvaders.mobs.FireTroll.java
com.noobygames.castleinvaders.mobs.GameScreen.java
com.noobygames.castleinvaders.mobs.GreyTroll.java
com.noobygames.castleinvaders.mobs.IceDragon.java
com.noobygames.castleinvaders.mobs.IceTroll.java
com.noobygames.castleinvaders.mobs.Murloc.java
com.noobygames.castleinvaders.mobs.Orc.java
com.noobygames.castleinvaders.mobs.Skeleton.java
com.noobygames.castleinvaders.screens.GameScreen.java
com.noobygames.castleinvaders.screens.MainMenuScreen.java
com.noobygames.castleinvaders.screens.ScoreScreen.java
com.noobygames.castleinvaders.screens.SplashScreen.java
com.noobygames.castleinvaders.screens.StoreScreen.java
com.noobygames.castleinvaders.store.StoreObject.java
com.noobygames.castleinvaders.store.Store.java
com.noobygames.nerzal.castleinvaders.spells.Burning.java
com.noobygames.nerzal.castleinvaders.spells.Freeze.java
com.noobygames.nerzal.castleinvaders.spells.SpellEffect.java
com.noobygames.nerzal.castleinvaders.spells.Spells.java
com.noobygames.utils.ArrayListUtils.java
com.noobygames.utils.ObjectSelectionContainer.java
com.noobygames.utils.OverlapTester.java
com.noobygames.utils.exceptions.OutOfBoundingException.java
com.noobygames.utils.exceptions.SliderOutOfBoundingsException.java
com.noobygames.utils.ui.Button.java
com.noobygames.utils.ui.ClickableElement.java
com.noobygames.utils.ui.DropDownMenu.java
com.noobygames.utils.ui.Element.java
com.noobygames.utils.ui.RadioButton.java
com.noobygames.utils.ui.RadioGroupButton.java
com.noobygames.utils.ui.ScrollableElement.java
com.noobygames.utils.ui.SimpleElement.java
com.noobygames.utils.ui.Slider.java
com.noobygames.utils.ui.Table.java
com.noobygames.utils.ui.TextBox.java
com.noobygames.utils.ui.Text.java
com.noobygames.utils.ui.Window.java