Android Open Source - RPGWorld Character Factory






From Project

Back to project page RPGWorld.

License

The source code is released under:

MIT License

If you think the Android project RPGWorld 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

/**
 * Jun 9, 2013//from   w ww . j av a2  s .  co  m
 * CharacterFactory.java
 * Daniel Pok
 * AP Java 6th
 */
package com.nokarateclass.rpgworld.editor;

import android.content.Context;
import android.graphics.drawable.Drawable;
import com.nokarateclass.rpgworld.R;
import com.nokarateclass.rpgworld.backgrounds.*;
import com.nokarateclass.rpgworld.characters.*;

/**
 * @author poler_000
 *
 */
public class CharacterFactory {

  //constants
  public final static int DEFAULT_CHARACTER = 10000, HERO = 10001, MONSTER = 10002, ANDROID = 10003, ROCK = 10004, CACTUS = 10005, TREE = 10006;
  public final static int DEFAULT_BACKGROUND = 20000, SAND = 20001, GRASS = 20002;
  
  //variables
  private Context mContext;
  
  /**
   * 
   */
  public CharacterFactory(Context context) {
    mContext = context;
  }
  
  public Drawable getDrawable(int id){
    return mContext.getResources().getDrawable(id);
  }
  
  public CharacterActor makeCharacter(int id){
    switch(id){
    case DEFAULT_CHARACTER:{
      return new CharacterActor();
    }
    case HERO:{
      return new HeroCharacter(getDrawable(R.drawable.hero));
    }
    case MONSTER:{
      return new MonsterCharacter(getDrawable(R.drawable.monster));
    }
    case ANDROID:{
      return new AndroidCharacter(getDrawable(R.drawable.ic_launcher));
    }
    case ROCK:{
      return new RockCharacter(getDrawable(R.drawable.rock));
    }
    case CACTUS: {
      return new CactusCharacter(getDrawable(R.drawable.cactus));
    }
    case TREE: {
      return new TreeCharacter(getDrawable(R.drawable.tree));
    }
    case DEFAULT_BACKGROUND:{
      return new BackgroundCharacter();
    }
    case SAND:{
      return new SandBackground(getDrawable(R.drawable.sand));
    }
    case GRASS:{
      return new GrassBackground(getDrawable(R.drawable.grass));
    }
    default:{
      return null;
    }
    }
  }
  
  public BackgroundCharacter makeBackground(int id){
    switch(id){
    case DEFAULT_BACKGROUND:{
      return new BackgroundCharacter();
    }
    case SAND:{
      return new SandBackground(getDrawable(R.drawable.sand));
    }
    case GRASS:{
      return new GrassBackground(getDrawable(R.drawable.grass));
    }
    default:{
      return null;
    }
    }
  }
}




Java Source Code List

com.nokarateclass.rpgworld.Grid.java
com.nokarateclass.rpgworld.MapEditor.java
com.nokarateclass.rpgworld.backgrounds.BackgroundCharacter.java
com.nokarateclass.rpgworld.backgrounds.GrassBackground.java
com.nokarateclass.rpgworld.backgrounds.SandBackground.java
com.nokarateclass.rpgworld.characters.AndroidCharacter.java
com.nokarateclass.rpgworld.characters.CactusCharacter.java
com.nokarateclass.rpgworld.characters.CharacterActor.java
com.nokarateclass.rpgworld.characters.HeroCharacter.java
com.nokarateclass.rpgworld.characters.MonsterCharacter.java
com.nokarateclass.rpgworld.characters.Player.java
com.nokarateclass.rpgworld.characters.RockCharacter.java
com.nokarateclass.rpgworld.characters.Status.java
com.nokarateclass.rpgworld.characters.TreeCharacter.java
com.nokarateclass.rpgworld.editor.CharacterFactory.java
com.nokarateclass.rpgworld.editor.EditorGrid.java
com.nokarateclass.rpgworld.grid.BackgroundGrid.java
com.nokarateclass.rpgworld.grid.BeatTask.java
com.nokarateclass.rpgworld.grid.CharacterGrid.java
com.nokarateclass.rpgworld.grid.Location.java
com.nokarateclass.rpgworld.grid.MainCharacterGrid.java
com.nokarateclass.rpgworld.io.FileExporter.java
com.nokarateclass.rpgworld.io.FileIO.java
com.nokarateclass.rpgworld.io.FileImporter.java
com.nokarateclass.rpgworld.io.GridSerializer.java
com.nokarateclass.rpgworld.io.SettingsHolder.java
com.nokarateclass.rpgworld.ui.GridClickListener.java
com.nokarateclass.rpgworld.ui.ImageGridView.java
com.nokarateclass.rpgworld.world.Region.java
com.nokarateclass.rpgworld.world.World.java
com.nokarateclass.rpgworld.world.Zone.java