Android Open Source - RPGWorld Zone






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 8, 2013/*from   w w  w. j a v a2s .c  o m*/
 * Zone.java
 * Daniel Pok
 * AP Java 6th
 */
package com.nokarateclass.rpgworld.world;

import java.io.Serializable;
import java.util.ArrayList;

import android.content.Context;

import com.nokarateclass.rpgworld.characters.CharacterActor;
import com.nokarateclass.rpgworld.grid.BackgroundGrid;
import com.nokarateclass.rpgworld.grid.CharacterGrid;
import com.nokarateclass.rpgworld.io.GridSerializer;
import com.nokarateclass.rpgworld.io.SettingsHolder;

/**
 * @author poler_000
 *
 */
public class Zone implements Serializable{

  /**
   * 
   */
  private static final long serialVersionUID = 6510398155068837988L;
  public ArrayList<SettingsHolder> mCharacters;//holds serialized info about the characters, first element in arraylist is the CharacterGrid's settings
  public ArrayList<SettingsHolder> mBackgrounds;//holds serialized info about the backgrounds, first element in arraylist is the BackgroundGrid's settings
  public CharacterActor[][] mCGrid; //must be null to serialize!
  public CharacterActor[][] mBGrid; //must be null to serialize!
  private String mId; //the unique id string of this Zone object. Cannot be added to a region without one
  protected String zoneNorth, zoneSouth, zoneEast, zoneWest; //the ids of the zones to the top, bottom, right and left of this one. id only b/c that's more serializable
                                 //the region object is responsible for finding the correct zone
  
  public Zone() {
    
  }
  
  public Zone(CharacterGrid cGrid, BackgroundGrid bGrid){
    save(cGrid, bGrid);
  }
  
  public Zone(String id){
    mId = id;
  }

  public String getId(){
    return mId;
  }
  
  public void setId(String id){
    mId = id;
  }
  
  public void save(CharacterGrid cGrid, BackgroundGrid bGrid){
    mCharacters = GridSerializer.getSettings(cGrid);
    mBackgrounds = GridSerializer.getSettings(bGrid);
  }
  
  public void prepareForSerialization(){
    mCGrid = null;
    mBGrid = null;
  }
  
  public CharacterActor[][] makeCharacterMatrix(Context context){
    GridSerializer serial = new GridSerializer(context);
    mCGrid = serial.getGrid(mCharacters);
    return mCGrid;
  }
  
  public CharacterActor[][] makeBackgroundMatrix(Context context){
    GridSerializer serial = new GridSerializer(context);
    mBGrid = serial.getGrid(mBackgrounds);
    return mBGrid;
  }
  
  public CharacterGrid loadCharacterGrid(Context context, CharacterGrid grid){
    GridSerializer serial = new GridSerializer(context);
    serial.loadGrid(mCharacters, grid);
    mCGrid = grid.getGrid();
    return grid;
  }
  
  public CharacterGrid loadBackgroundGrid(Context context, BackgroundGrid grid){
    GridSerializer serial = new GridSerializer(context);
    serial.loadGrid(mBackgrounds, grid);
    mBGrid = grid.getGrid();
    return grid;
  }
}




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