ConditionalTextures.java :  » Game » agameframework » com » agameframework » texture » Android Open Source

Android Open Source » Game » agameframework 
agameframework » com » agameframework » texture » ConditionalTextures.java
package com.agameframework.texture;

import java.util.ArrayList;
import java.util.List;

import com.agameframework.interfaces.ICondition;
import com.agameframework.interfaces.ITexture;

public class ConditionalTextures extends Texture{

  private ArrayList<ITexture> mTextureList;
  private ArrayList<ICondition> mConditionList; 

  public ConditionalTextures(List<ICondition> conditionlist, List<ITexture> texlist)
  {
    mConditionList = new ArrayList<ICondition>(conditionlist);
    mTextureList = new ArrayList<ITexture>(texlist);
  }

  @Override
  public int getTextureName()
  {
    checkConditions();
    return super.getTextureName();
  }
  
  private void checkConditions()
  {
    int size = mConditionList.size();
    for (int i = 0; i != size; i++) 
    {
      if(mConditionList.get(i).getBoolean())
      {
        copyFromTexture(mTextureList.get(i));
        break;
      }
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.