Android Open Source - RPGWorld Hero Character






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 5, 2013/*from w  w  w  .j  a v a 2  s  .  c  om*/
 * HeroCharacter.java
 * Daniel Pok
 * AP Java 6th
 */
package com.nokarateclass.rpgworld.characters;

import com.nokarateclass.rpgworld.R;
import com.nokarateclass.rpgworld.editor.CharacterFactory;
import com.nokarateclass.rpgworld.grid.MainCharacterGrid;
import com.nokarateclass.rpgworld.io.SettingsHolder;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.widget.Toast;

/**
 * @author dh.dpok
 *
 */
public class HeroCharacter extends CharacterActor {
  public static final int mDefaultId = CharacterFactory.HERO;

  /**
   * 
   */
  public HeroCharacter(Context context) {
    super(context.getResources().getDrawable(R.drawable.hero), mDefaultId);
    mPlayer.setMaxHealth(100);
    mPlayer.setHealth(100);
  }

  /**
   * @param sprite
   */
  public HeroCharacter(Drawable sprite) {
    super(sprite, mDefaultId);
    mPlayer.setMaxHealth(100);
    mPlayer.setHealth(100);
  }
  
  @Override
  public void act(int beat){
    Log.i("Status",Integer.valueOf(mStatus.mStatus).toString());
    if(mStatus.mStatus == Status.PATHING){
      stepTowardTarget();
    }
    //if(beat == 0) mPlayer.addHealth(5);
  }
  
  @Override
  public void interact(CharacterActor character){
    removeSelfFromGrid();
  }
  
  @Override
  public void restoreValues(SettingsHolder settings){
    super.restoreValues(settings);
    if(getGrid() instanceof MainCharacterGrid){
      ((MainCharacterGrid) getGrid()).setMainCharacter(this, true);
    }
  }
  
  @Override
  public void onHealthChange(int change){
    if(getGrid() != null) Toast.makeText(getGrid().getContext(), String.format("HP %d/%d (%d)", mPlayer.getHealth(), mPlayer.getMaxHealth(), change), Toast.LENGTH_SHORT).show();
  }
  
  @Override
  public void onDeath(){
    if(getGrid() != null) Toast.makeText(getGrid().getContext(), "GAME OVER", Toast.LENGTH_LONG).show();
    Log.d("Player", toString() + " died" + String.format(" HP: %d/%d", mPlayer.getHealth(), mPlayer.getMaxHealth()));
    removeSelfFromGrid();
  }
  
  @Override
  public void onOverHeal(int amount){
    mPlayer.addHealth(-amount);
  }

}




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