Back to project page diploma-assignment.
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.
package com.me.battlescreen; //from w w w . j a va 2 s . c o m import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; public class OpponentMonster extends PlayerMonster{ private int gold; private int index; public OpponentMonster(BattleScreen s, Texture[] t, int[] d, BattlePlayer p,int gold,int index) { super(s, t, d, p); currX=d[3]-ScreenFrameWidth; this.gold=gold; this.index=index; // TODO Auto-generated constructor stub } @Override public void draw(Batch batch, int coordsX) { // TODO Auto-generated method stub if (frame == -1){ if (dying){ screen.removeActor(this); screen.giveGoldandMana(gold); screen.killedOpponentMonster(index); return; } frame = FRAMES-1; } if(walking){ currX -= OFFSET; } if(hitted){ batch.setColor(Color.RED); } batch.draw(Element, currX-coordsX, currY, 0, 0, ScreenFrameWidth, height, 1, 1, 0,frame*ElFrLen, 0,ElFrLen, Element.getHeight(), false, false); if(hitted){ batch.setColor(Color.WHITE); } hitted=false; if(change%3==0) frame--; change++; } @Override public float giveX() { // TODO Auto-generated method stub return currX; } @Override public void checkForAttack(float x) { // TODO Auto-generated method stub if(!dying){ if (x>currX+ScreenFrameWidth-attackDistance){ if(!isAttacking()) changeToAttacking(); }else if(!walking && !dying) changeToWalk(); } } @Override public boolean timeToAttack() { // TODO Auto-generated method stub return frame==0 && change%3==0; } @Override protected void changeWidths() { int x=ScreenFrameWidth; ScreenFrameWidth=(int)(height*Element.getWidth()/(Element.getHeight()*FRAMES)); currX=currX-(ScreenFrameWidth-x); ElFrLen=Element.getWidth()/FRAMES; frame=FRAMES-1; } }