Android Open Source - diploma-assignment Player






From Project

Back to project page diploma-assignment.

License

The source code is released under:

MIT License

If you think the Android project diploma-assignment 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.me.main;
/*  ww w  .  j  ava  2 s . com*/
import com.me.openingscreen.Constants;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.JsonValue;

public class Player implements Json.Serializable{
  private long gold;
  private int maxMana;
  private int manaReg;
  private String name;
  private int[] upList;
  private int[] unlockedList;
  private int[] killed;
  private int level;
  private long allGold;

  public Player(){
    
  }
  
  public Player(String n){
    name=n;
    gold=2000;
    maxMana=400;
    manaReg=2;
    upList=new int[]{0,0,0,0,0,0,0};
    killed=new int[]{0,0,0,0,0,0,0};
    unlockedList=new int[]{1,0,0,0,0,0,0};
    level=1;
    allGold=gold;
  }
  
  public boolean unlock(int index){
    if (index<0 || index>=unlockedList.length)
      return false;
    if(gold<Constants.unlockedPrice[index] || unlockedList[index]==1)
      return false;
    gold-=Constants.unlockedPrice[index];
    unlockedList[index]=1;
    return true;
  }
  
  public boolean upgrade(int index){
    if (index<0 || index>=upList.length)
      return false;
    if(gold<Constants.upPrice[index] || upList[index]==1)
      return false;
    gold-=Constants.upPrice[index];
    upList[index]=1;
    return true;
  }
  
  public void kill(int index){
    if (index>=0 || index<killed.length)
      killed[index]++;
  }
  
  public void increaseLevel() {
    level++;
    if(level%3==0){
      maxMana=maxMana+150;
      manaReg=manaReg+1;
    }
  }

  public void setName(String name) {
    this.name = name;
  }

  public final long getGold() {
    return gold;
  }
  
  public final long getAllGold() {
    return allGold;
  }
  
  public final int[] getUnlockedList() {
    return unlockedList;
  }
  
  public final int[] getUpList() {
    return upList;
  }
  
  public final int[] getKilled() {
    return killed;
  }

  public void increaseGold(long gold) {
    this.gold += gold;
    allGold+=gold;
  }

  public final int getMaxMana() {
    return maxMana;
  }

  public void setMaxMana(int maxMana) {
    this.maxMana = maxMana;
  }

  public final int getManaReg() {
    return manaReg;
  }

  public void setManaReg(int manaReg) {
    this.manaReg = manaReg;
  }

  public final int getLevel() {
    return level;
  }

  public final String getName() {
    return name;
  }

  @Override
  public void write(Json json) {
    // TODO Auto-generated method stub
    json.writeValue("gold",gold);
    json.writeValue("maxMana",maxMana);
    json.writeValue("manaReg",manaReg);
    json.writeValue("name",name);
    json.writeValue("level",level);
    json.writeValue("upList",upList);
    json.writeValue("unlockedList",unlockedList);
    json.writeValue("killed",killed);
    json.writeValue("allGold",allGold);
  }

  @Override
  public void read(Json json, JsonValue jsonData) {
    // TODO Auto-generated method stub
    gold=json.readValue("gold",long.class,jsonData);
    maxMana=json.readValue("maxMana",int.class,jsonData);
    manaReg=json.readValue("manaReg",int.class,jsonData);
    name=json.readValue("name",String.class,jsonData);
    level=json.readValue("level",int.class,jsonData);
    upList=json.readValue("upList",int[].class,jsonData);
    unlockedList=json.readValue("unlockedList",int[].class,jsonData);
    killed=json.readValue("killed",int[].class,jsonData);
    allGold=json.readValue("allGold",long.class,jsonData);
  }
}




Java Source Code List

com.me.battlescreen.BallistaArrow.java
com.me.battlescreen.Ballista.java
com.me.battlescreen.BattlePlayer.java
com.me.battlescreen.BattleScreen.java
com.me.battlescreen.Bot.java
com.me.battlescreen.Castle.java
com.me.battlescreen.CleanBackground.java
com.me.battlescreen.ComputerPlayer.java
com.me.battlescreen.Constants.java
com.me.battlescreen.HumanPlayer.java
com.me.battlescreen.Monster.java
com.me.battlescreen.MyButton.java
com.me.battlescreen.MyLabel.java
com.me.battlescreen.OpponentMonster.java
com.me.battlescreen.PlayerMonster.java
com.me.battlescreen.TimeLabel.java
com.me.battlescreen.UnitButton.java
com.me.battlescreen.getTextures.java
com.me.battlescreen.iAttacking.java
com.me.battlescreen.iHittable.java
com.me.battlescreen.iUpdateable.java
com.me.main.MyGame.java
com.me.main.Player.java
com.me.mygdxgame.MainActivity.java
com.me.openingscreen.AbstractMenu.java
com.me.openingscreen.Constants.java
com.me.openingscreen.FirstMenu.java
com.me.openingscreen.FloatingBackground.java
com.me.openingscreen.OpeningScreen.java
com.me.openingscreen.PlayerMenu.java
com.me.openingscreen.ResetMenu.java
com.me.openingscreen.StatisticsMenu.java
com.me.openingscreen.UpgradeButton.java
com.me.openingscreen.UpgradeMenu.java