From 7cb17142478f5108515614b1988be52c52d713aa Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 20 Aug 2017 18:14:47 -0500 Subject: [PATCH] Implemented Megamon stats, Start menu. Consolidated Player functions into Player class. --- .../assets/Megamon/test_mini_sprite.png | Bin 0 -> 543 bytes Megamon-core/assets/Megamon/test_sprite.png | Bin 0 -> 1494 bytes Megamon-core/assets/startmenu_box.png | Bin 0 -> 711 bytes Megamon-core/assets/startmenu_box_bottom.png | Bin 0 -> 727 bytes Megamon-core/assets/startmenu_box_middle.png | Bin 0 -> 170 bytes Megamon-core/assets/startmenu_highlight.png | Bin 0 -> 741 bytes Megamon-core/src/sig/megamon/Megamon.java | 126 +++++++-------- .../src/sig/megamon/MegamonCreature.java | 74 +++++++-- Megamon-core/src/sig/megamon/MegamonPet.java | 146 ++++++++++++++++++ Megamon-core/src/sig/megamon/Player.java | 92 +++++++++++ Megamon-core/src/sig/megamon/Room.java | 2 +- .../sig/megamon/creature/CreatureLore.java | 15 ++ .../sig/megamon/creature/CreatureMove.java | 27 ++++ .../sig/megamon/creature/CreatureType.java | 2 + .../sig/megamon/creature/ExperienceRate.java | 12 ++ .../megamon/creature/NonVolatileStatus.java | 18 +++ .../megamon/creature/SpriteCollection.java | 27 ++++ .../sig/megamon/creature/VolatileStatus.java | 13 ++ .../src/sig/megamon/{ => menu}/DialogBox.java | 9 +- .../src/sig/megamon/menu/StartMenuBox.java | 59 +++++++ .../src/sig/megamon/utils/ColorUtils.java | 4 +- .../src/sig/megamon/utils/GraphicUtils.java | 3 +- .../src/sig/megamon/utils/PlayerUtils.java | 2 +- .../src/sig/megamon/utils/TrainerUtils.java | 7 + 24 files changed, 551 insertions(+), 87 deletions(-) create mode 100644 Megamon-core/assets/Megamon/test_mini_sprite.png create mode 100644 Megamon-core/assets/Megamon/test_sprite.png create mode 100644 Megamon-core/assets/startmenu_box.png create mode 100644 Megamon-core/assets/startmenu_box_bottom.png create mode 100644 Megamon-core/assets/startmenu_box_middle.png create mode 100644 Megamon-core/assets/startmenu_highlight.png create mode 100644 Megamon-core/src/sig/megamon/MegamonPet.java create mode 100644 Megamon-core/src/sig/megamon/Player.java create mode 100644 Megamon-core/src/sig/megamon/creature/CreatureLore.java create mode 100644 Megamon-core/src/sig/megamon/creature/ExperienceRate.java create mode 100644 Megamon-core/src/sig/megamon/creature/NonVolatileStatus.java create mode 100644 Megamon-core/src/sig/megamon/creature/VolatileStatus.java rename Megamon-core/src/sig/megamon/{ => menu}/DialogBox.java (89%) create mode 100644 Megamon-core/src/sig/megamon/menu/StartMenuBox.java create mode 100644 Megamon-core/src/sig/megamon/utils/TrainerUtils.java diff --git a/Megamon-core/assets/Megamon/test_mini_sprite.png b/Megamon-core/assets/Megamon/test_mini_sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..de7fe43857642e491226a0c95eb5a4bfc64eb030 GIT binary patch literal 543 zcmV+)0^t3LP)I$+ zEj;!8kWu#fL4w>RcR8`v3IG7WMU1i5$~7Va01+V~*8m_7^t!J5zQ-6t2nWX)v+uhQ zf{26=UqY>waUq11Qc7vxcW#tY^4?o(Ypuo@A%p~gbzPa@ob%o<%aU`hwYF_L3#2LI`7w zT-TL7IOkrk*F4W`1^|>&Ip@>qq?A%h4Z{#)l(p7UO3ry%mKb9xg>P=mL%jE;6n^}! z^;quT&)K$Z+qNU3|8hV?Ap{~yDW#N6(=<)fwr$(CM}l9|h{zHzmy5MF#z;imRcqaK zUElY8-!ldPBoT!Wh-eswoO3BfN~yKxEfLY}b{of$Q!~a${w=>MkKnqlv(`@2biH23 zakSPVqSRXdnpR59^PEy*Lf`ksm~kA5h={%uemUp!nFsRB^ZBflGR80(5%Cbi35F23 h;76@Be{a44;2$o$K(`@G?ScRR002ovPDHLkV1jTf=nnt@ literal 0 HcmV?d00001 diff --git a/Megamon-core/assets/Megamon/test_sprite.png b/Megamon-core/assets/Megamon/test_sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..1f95bcf5ba0876c3d35a76131fd4551583377285 GIT binary patch literal 1494 zcmV;{1u6Q8P)<%Q@$qGsYNW9*;-Yb$#F8@AtNC`@SEBVO>|P zbr1wm6mibuI1a-w3`52krIb?27?V;;DYGnN|1E8;wbm}nGEGz4wr$(qZnx9vbh%uH zVc529nkMI59LI4S3n7d#X_|&%XssoL7-I+_%d&)FsFeC@V6An|X|0Vh%d!l^aJ${= zx^9~0csw>u)3)t6j`KVRK|m>uqA1IdgG)>?4A0HoeUDtJeKA*d;Q%bGtN(iBpN+~^8LI|xjW9$_x3NpOoW!tu482Y~N z`@XL0)9Li*&!5xjRM&Oi_v1LO>$4Wh+V_1`Rlk4#KAlcgRRQ}rj>9l$tw91~ObCJ91VNCdDPxRt?nU-nVKB_P zuH!h~Znw5=tE#H1>f__%d_JE}r@rrRx7$3=+qPk&K@fyt2tLCw^uVzXAp{UmO2aT@ zfWK|qIF4=G9*@UgzkbzqT~*cPa%q}o7>0SCK{v<+G%x_j$#W4x(121(2qA=gQlymX z`@U`4%jME_-SK$5TrTkCJkJ1&$$*u;DJi9K9N+KvG)>bq<(#kUDy4)@Q4}#_47BaK z?s~oc{rk77Dljum)3Pk9LH&zilVUAV(u`8)LN^Q>bkD$ zI=JP0KEtW=JTJ?lwSKGaoP)Nn<_6V%!lNh>LP#m8F=m>k$K!FmUYn+An&y7L_k9ml z!TVeFw`Z;OvMk%SEz1J-!!VT3Mdx`QhG85>xMdiIX_~fegXLjLUyD4~>*V9RwH8k0 zoM%}krGzR}Yps+*8(_ykc|G6Yzc#}_fh*Vs)JIX2rfHt%QcC9Sf4yGs_xrYOp3PTs z0Q|Ky7QSP|IOkHzvMh_D$g(VsV<{z5N{!=qzu&#E7%0z-hxzse9tCQYPLc!>on={? zrb&_rA?Q5MN-3Z6aD`7R1dFc-4gHtTS!E2gWX}b8VN*8G^W*VY*HtM6xBXwmSKj>s zGn{iwa#0j;Ct5Pb=&NTSfT!N~c>Tpg7>0oFv6p38mSvJ8V4pFDIAVklr4*P&uwV|o zTkuQ>L9~H4LI{`v@UkqkEc4Z&3eYh4*Z&)RE`L^|C?1@1h+1PX^BkShG>xJNntAWB zIF5^=`0?WhMhrub!`&YMlu|rHTS5rr_2vP5Oco602b1M_zTfZHbwvZtIihr$CS(Ss z6r%?LaO7fi4~N5kzu)iokO7uOgD(xzG%d>#b3h1b+ZH#5BuVsh`7GPE4HiV4?RLAL zKY#A``@`XYZ1^0mw+7G<=7Z1jJjZc{Bf(D};4{X+&u+In91h>Vf8X!-a4KW$eFs7a z#JUd#A;j%=n+a literal 0 HcmV?d00001 diff --git a/Megamon-core/assets/startmenu_box.png b/Megamon-core/assets/startmenu_box.png new file mode 100644 index 0000000000000000000000000000000000000000..83a630a4324994668ce69814700de1db03e5bf1d GIT binary patch literal 711 zcmV;&0yzDNP)ao|{{PzMv=_ww2Xbfh1kboys zVPT8}4F!{3w#)2JFSD`+QtCywGT&)oX7=ztesA7@GVV2}_ZsVd!ZWH(jxU+v!N)bg7 zaU9#SJ^|%&nQFC4rE)KG72tIkhC8n7I>0aBD=@heoNLW{Cb`vFvA4Ik_`XlS-)A%$ zktB(&_#;v(l~`V0W^;3swY4>Bwc0(=uIpml?E#+FdLV>IvIJMneY<7avXdPQ!;p)M z3%cDdolXbO^SHUWAx%?T^+&{U9F~@rXfzt^?(VX^y-mGd&%|cbfQIoXfglsSV5a5O zeA^Dgkh8NhTCEoCb{i=rK@gCpDOzh=^~ZeA3c+|hMoLMq*JFQwpJubk#>Pfoas_w; zyfaSk1PilR%F-LhF@wQ?R;$I~;USlomnfxdrJw4-t2IfIFqup^KR+i30ssyU4p?7b z&$sIrMy^A?70)uAPB}R_q1|p tef{7BlO&0qmj9E%ODXl>JJ|9}_ybKM8jCHsH3t9y002ovPDHLkV1lSpI3I3U*x=$8k_f*_29(QVQ2~@jMU5ab^lHJf~8r*d$Ae)|x!eX*Qb#K`@hGKS>hW z?KW{7PklQq^TYEz;y7kwV}m3~W^OQH7}9FB*xcM?X=%wyE}7iL#YH-u4(sddgkd=K zQ#!ULzz`^a5#ac~PnxD|ZEXRtySq!j-)ArwFdB^z5u5ZqFI0}>ptUBBV>+D<+uPfu zX^QXrlSjV+H^$?g;2Yo*&<7p@{&>c(uCB7Pv%|{D3j6!}92^{QadE+DG_tABVWC=E zTch1>(`vOy(-f`s zg-!h)ab1^2qd}HsBuPRThQBr!;4|W8NYRmKIH%a002ov JPDHLkV1m|qLYDvl literal 0 HcmV?d00001 diff --git a/Megamon-core/assets/startmenu_box_middle.png b/Megamon-core/assets/startmenu_box_middle.png new file mode 100644 index 0000000000000000000000000000000000000000..c640df789bc14f60ec5220a8ee166cc755d717c4 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^6+q0$!3HEnJ+p2DDYhhUcNd2LAh=-f^2tCE&H|6f zVg?3oVGw3ym^DWND9B#o>Fdh=kV8aF&9Z8{Z30lp+|$J|MB?(>i;lbu3Ool6RNc_Y zPZKwp!hVpMf7YBPrUh+LuPUPM=B9Dg@ON{pJ~eaqxux4?F-WIQo_thp?#^dGBN#kg L{an^LB{Ts5+_^HS literal 0 HcmV?d00001 diff --git a/Megamon-core/assets/startmenu_highlight.png b/Megamon-core/assets/startmenu_highlight.png new file mode 100644 index 0000000000000000000000000000000000000000..135b456478086a1d65f51f36d4e308993924a041 GIT binary patch literal 741 zcmVWFU8GbZ8()Nlj2>E@cM*00K!#L_t(&-tAY*ZsRZv zoJq1M7W)ag`Tu{ZzV*6?9)jIPn(0BZEs2z!^x|y60SYu0C6OG84_>1m<_O>g(9iseO}^=oOG9kw7`5`P(|m8>XR9i6M?)Zc1-r5%t{QQB@p<=MBamnPEpCin*6Up9oDR9vz^ z*gliC*;uQ$D!bJpy?OO_mZa&olXJ<0{8>qI-UnT#T?A4 z&TP+`>vN-Z!~>O;IcMeSVk8u4deRWQ*2-j<#g9Cv;AP@)y0)apv5C{YUf&T-a XA5|Fo5!ijH00000NkvXXu0mjftm8_f literal 0 HcmV?d00001 diff --git a/Megamon-core/src/sig/megamon/Megamon.java b/Megamon-core/src/sig/megamon/Megamon.java index 5503267..4e95efd 100644 --- a/Megamon-core/src/sig/megamon/Megamon.java +++ b/Megamon-core/src/sig/megamon/Megamon.java @@ -4,6 +4,7 @@ import java.awt.Point; import java.awt.geom.Point2D; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; @@ -30,6 +31,11 @@ import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TmxMapLoader; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; +import sig.megamon.creature.CreatureMove; +import sig.megamon.creature.CreatureType; +import sig.megamon.creature.ExperienceRate; +import sig.megamon.menu.DialogBox; +import sig.megamon.menu.StartMenuBox; import sig.megamon.ref.Ref; import sig.megamon.ref.RoomRef; import sig.megamon.ref.SignRef; @@ -42,17 +48,16 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ Texture img; public static BitmapFont font; public static DialogBox messagebox; + public static StartMenuBox startmenubox; //AssetManager assets; //TiledMap map; - OrthographicCamera camera; + static OrthographicCamera camera; final public static int TILESIZE=16; final public static int WINDOW_WIDTH=640; final public static int WINDOW_HEIGHT=480; final public static double CHAR_SPD=0.1; - Point2D.Double direction = new Point2D.Double(0,0); - Point2D.Double lastdirection = new Point2D.Double(0,1); - final public static Point2D.Double position=new Point2D.Double(1,1); Calendar lastCheck = Calendar.getInstance(); + public static Player mainP; int framesPassed=0; final public static String HIDDENLAYERNAME = "Tile Layer 2"; final public static int ACTIONKEY = Keys.Z; @@ -61,6 +66,7 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ final public static int MOVERIGHTKEY = Keys.RIGHT; final public static int MOVEUPKEY = Keys.UP; final public static int MOVEDOWNKEY = Keys.DOWN; + final public static int MENUKEY = Keys.ENTER; //public static List objects = new ArrayList(); public static Room currentLevel; public static HashMap doorDatabase = new HashMap(); @@ -69,9 +75,8 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ @Override public void create() { batch = new SpriteBatch(); - img = new Texture("megamon_icon64.png"); font = new BitmapFont(Gdx.files.internal("fonts/AgencyFB.fnt")); - + mainP = new Player(new Point2D.Double(1,1),"megamon_icon64.png"); //assets = new AssetManager(); /*assets.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); @@ -86,8 +91,16 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ objects.add(new Object("megamonlogowip.png",new Point2D.Double(3, 7)));*/ Database.SetupDoorDatabase(); Database.SetupInfoDatabase(); - currentLevel = new Room(position,"Test Map"); + currentLevel = new Room(mainP.position,"Test Map"); + + /*MegamonPet testPet = new MegamonPet("Test", + new MegamonCreature("test_mini_sprite.png","test_sprite.png","test_sprite.png", + "Test Creature", "This is for testing purposes only.", 14, 60, CreatureType.NORMAL, + 40,60,30,30,50,55,30,ExperienceRate.MEDIUM_FAST,new CreatureMove[]{}), + 100); + System.out.println(testPet);*/ //messagebox = new DialogBox("This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message.This is a test message."); + //startmenubox = new StartMenuBox(0); } @Override @@ -102,45 +115,26 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ if (messagebox!=null) { messagebox.run(); } + else + if (startmenubox!=null){ + startmenubox.run(); + } else { for (Object o : currentLevel.getObjects()) { o.run(); } - if (PlayerUtils.isSnappedToGrid(position)) { - direction=new Point2D.Double(0, 0); - if (Gdx.input.isKeyPressed(MOVELEFTKEY)) { - direction=lastdirection=new Point2D.Double(-CHAR_SPD,0); - } else - if (Gdx.input.isKeyPressed(MOVEUPKEY)) { - direction=lastdirection=new Point2D.Double(0,CHAR_SPD); - } else - if (Gdx.input.isKeyPressed(MOVERIGHTKEY)) { - direction=lastdirection=new Point2D.Double(CHAR_SPD,0); - } else - if (Gdx.input.isKeyPressed(MOVEDOWNKEY)) { - direction=lastdirection=new Point2D.Double(0,-CHAR_SPD); - } - Point2D.Double destinationposition = new Point2D.Double(position.x+Math.signum(lastdirection.x),position.y+Math.signum(lastdirection.y)); - if (Gdx.input.isKeyJustPressed(ACTIONKEY)) { - CheckForInfo(destinationposition); - } - if (direction.x!=0 || direction.y!=0) { - //System.out.println("("+position.x+","+Math.signum(direction.x)+","+position.y+","+Math.signum(direction.y)+")"); - //Point2D.Double destinationposition = new Point2D.Double(position.x+Math.signum(direction.x),position.y+Math.signum(direction.y)); - if (PlayerUtils.isLocationPassable(currentLevel.getMap(),destinationposition)) { - position.setLocation(position.x+direction.x, position.y+direction.y); - } else { - //We hit a wall. - } - System.out.println(infoDatabase.keySet()); - CheckForDoor(destinationposition); - } - } else { - position.setLocation(position.x+direction.x, position.y+direction.y); - //System.out.println(position); + if (Gdx.input.isKeyJustPressed(Megamon.MENUKEY)) { + Megamon.startmenubox = new StartMenuBox(0); } + if (PlayerUtils.isSnappedToGrid(mainP.position)) { + mainP.run(); + } + } + if (!PlayerUtils.isSnappedToGrid(mainP.position)) { + mainP.position.setLocation(mainP.position.x+mainP.direction.x, mainP.position.y+mainP.direction.y); + //System.out.println(position); } - camera.position.set((float)position.x+0.5f, (float)position.y+0.5f, camera.position.z); + camera.position.set((float)mainP.position.x+0.5f, (float)mainP.position.y+0.5f, camera.position.z); //System.out.println("Camera position: "+camera.position); camera.update(); //System.out.println(Megamon.WINDOW_WIDTH+","+Megamon.WINDOW_HEIGHT+";"+camera.viewportWidth+","+camera.viewportHeight); @@ -154,10 +148,13 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ (float)GraphicUtils.getRelativePixelPositionFromPlayer(camera, o.position).y); o.draw(); } - batch.draw(img, (int)GraphicUtils.getPlayerPixelPosition(camera).getX(), (int)GraphicUtils.getPlayerPixelPosition(camera).getY(), (int)GraphicUtils.getTileSize(camera).getX(), (int)GraphicUtils.getTileSize(camera).getY()); + mainP.draw(batch); if (messagebox!=null) { messagebox.draw(batch); } + if (startmenubox!=null) { + startmenubox.draw(batch); + } GlyphLayout size = font.draw(batch, "Test Text", 0, 32); //font.draw(batch, "Test Text", Megamon.WINDOW_WIDTH-size.width, 128-size.height); batch.end(); @@ -168,32 +165,35 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{ lastCheck=Calendar.getInstance(); } } - - private void CheckForDoor(Point2D.Double destinationposition) { - if (doorDatabase.containsKey(PlayerUtils.getDoorPositionHash(destinationposition))) { - //System.out.println("This is a door!"); - RoomRef door = doorDatabase.get(PlayerUtils.getDoorPositionHash(destinationposition)); - if (!door.destinationRoom.equalsIgnoreCase(currentLevel.mapName)) { - currentLevel.destroy(); - currentLevel = new Room(door.doorDestination,door.destinationRoom); - } else { - position.setLocation(door.doorDestination); - } - } - } - - private void CheckForInfo(Point2D.Double destinationposition) { - if (infoDatabase.containsKey(PlayerUtils.getDoorPositionHash(destinationposition))) { - //System.out.println("This is a door!"); - SignRef info = infoDatabase.get(PlayerUtils.getDoorPositionHash(destinationposition)); - //TODO Do interface stuff here. - messagebox = new DialogBox(info.getMessages()); - } - } @Override public void dispose () { batch.dispose(); img.dispose(); } + + public String toString() { + StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"("); + boolean first=true; + for (Field f : this.getClass().getDeclaredFields()) { + try { + if (!first) { + sb.append(","); + } else { + first=false; + } + sb.append(f.getName()+"="+this.getClass().getDeclaredField(f.getName()).get(this)); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + sb.append(")"); + return sb.toString(); + } } diff --git a/Megamon-core/src/sig/megamon/MegamonCreature.java b/Megamon-core/src/sig/megamon/MegamonCreature.java index 8b81780..4c5784e 100644 --- a/Megamon-core/src/sig/megamon/MegamonCreature.java +++ b/Megamon-core/src/sig/megamon/MegamonCreature.java @@ -1,39 +1,51 @@ package sig.megamon; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import sig.megamon.creature.CreatureLore; import sig.megamon.creature.CreatureMove; import sig.megamon.creature.CreatureType; +import sig.megamon.creature.ExperienceRate; import sig.megamon.creature.SpriteCollection; public class MegamonCreature { - SpriteCollection sprites; - String name; - String bio; - CreatureType type1; - CreatureType type2; - int hp; - int atk; - int def; - int spd; - int spc; - List moveset; + final SpriteCollection sprites; + final String name; + final CreatureLore bio; + final CreatureType type1; + final CreatureType type2; + final int hp; + final int atk; + final int def; + final int spd; + final int spc; + final int catch_rate; + final int base_exp; + final ExperienceRate exp_rate; + final List moveset; + boolean seenByPlayer=false; public MegamonCreature(String mini_icon, String sprite, String back_sprite, - String name, String bio, CreatureType type1, int base_hp, int base_atk, int base_def, int base_spd, int base_spc, + String name, String bio, int size, float weight, CreatureType type1, + int base_hp, int base_atk, int base_def, int base_spd, int base_spc, + int catch_rate, int base_exp, ExperienceRate exp_rate, CreatureMove...moveset) { - this(mini_icon,sprite,back_sprite,name,bio,type1,CreatureType.NONE,base_hp,base_atk,base_def,base_spd,base_spc,moveset); + this(mini_icon,sprite,back_sprite,name,bio,size, weight,type1,CreatureType.NONE,base_hp,base_atk,base_def,base_spd,base_spc,catch_rate,base_exp,exp_rate,moveset); } public MegamonCreature(String mini_icon, String sprite, String back_sprite, - String name, String bio, CreatureType type1, CreatureType type2, int base_hp, int base_atk, int base_def, int base_spd, int base_spc, + String name, String bio, int size, float weight, CreatureType type1, + CreatureType type2, + int base_hp, int base_atk, int base_def, int base_spd, int base_spc, + int catch_rate, int base_exp, ExperienceRate exp_rate, CreatureMove...moveset) { this.sprites = new SpriteCollection(mini_icon,sprite,back_sprite); this.name = name; - this.bio = bio; + this.bio = new CreatureLore(bio,size,weight); this.type1 = type1; this.type2 = type2; this.hp = base_hp; @@ -41,6 +53,38 @@ public class MegamonCreature { this.def = base_def; this.spd = base_spd; this.spc = base_spc; + this.catch_rate=catch_rate; + this.base_exp=base_exp; + this.exp_rate = exp_rate; this.moveset = new LinkedList(Arrays.asList(moveset)); } + + public void setSeen(boolean seenByPlayer) { + this.seenByPlayer=seenByPlayer; + } + + public String toString() { + StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"("); + boolean first=true; + for (Field f : this.getClass().getDeclaredFields()) { + try { + if (!first) { + sb.append(","); + } else { + first=false; + } + sb.append(f.getName()+"="+this.getClass().getDeclaredField(f.getName()).get(this)); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + sb.append(")"); + return sb.toString(); + } } diff --git a/Megamon-core/src/sig/megamon/MegamonPet.java b/Megamon-core/src/sig/megamon/MegamonPet.java new file mode 100644 index 0000000..722cbec --- /dev/null +++ b/Megamon-core/src/sig/megamon/MegamonPet.java @@ -0,0 +1,146 @@ +package sig.megamon; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import sig.megamon.creature.NonVolatileStatus; +import sig.megamon.creature.VolatileStatus; + +public class MegamonPet { + MegamonCreature creature; + NonVolatileStatus status; + VolatileStatus battlestatus; + Integer atk_modifier; + Integer def_modifier; + Integer spd_modifier; + Integer spc_modifier; + Integer eva_modifier; + Integer acc_modifier; + Integer atk_iv; + Integer def_iv; + Integer spd_iv; + Integer spc_iv; + Integer atk_ev; + Integer def_ev; + Integer spd_ev; + Integer spc_ev; + Integer hp_ev; + Integer hp; + Integer maxhp; + Integer atk; + Integer def; + Integer spd; + Integer spc; + String nickname; + Integer original_trainer; + String original_trainer_name; + Integer level; + Integer hp_iv; + + public MegamonPet(String nickname, MegamonCreature creature_type, Integer level) { + this(nickname,creature_type,level,Megamon.mainP.trainer_id,Megamon.mainP.name); + } + + public MegamonPet(String nickname, MegamonCreature creature_type, Integer level, + Integer original_trainer, String original_trainer_name) { + this(nickname,creature_type,level,original_trainer,original_trainer_name, + new Integer[]{}, new Integer[]{}); + } + + public MegamonPet(String nickname, MegamonCreature creature_type, Integer level, + Integer original_trainer, String original_trainer_name, Integer[] stats_collection, + Integer...IV_EV_Collection) { + this.creature = creature_type; + if (nickname.length()>0) { + this.nickname = nickname; + } else { + this.nickname = creature_type.name; + } + this.level = level; + this.original_trainer = original_trainer; + this.original_trainer_name = original_trainer_name; + InitializeStats(stats_collection,IV_EV_Collection); + } + + private void InitializeStats(Integer[] stats_collection, Integer[] IV_EV_Collection) { + /*if (stats_collection.length<6) { + //System.out.println("WARNING! Malformed stats array! Will fill in with defaults."); + } + if (IV_EV_Collection.length<9) { + //System.out.println("WARNING! Malformed IV_EV array! Will fill in with defaults."); + }*/ + + int i=0; + atk_iv = UseStatOrDefault(IV_EV_Collection,i++,(int)(Math.random()*16)); + def_iv = UseStatOrDefault(IV_EV_Collection,i++,(int)(Math.random()*16)); + spd_iv = UseStatOrDefault(IV_EV_Collection,i++,(int)(Math.random()*16)); + spc_iv = UseStatOrDefault(IV_EV_Collection,i++,(int)(Math.random()*16)); + hp_iv = CalculateHPIV(); + atk_ev = UseStatOrDefault(IV_EV_Collection,i++,0); + def_ev = UseStatOrDefault(IV_EV_Collection,i++,0); + spd_ev = UseStatOrDefault(IV_EV_Collection,i++,0); + spc_ev = UseStatOrDefault(IV_EV_Collection,i++,0); + hp_ev = UseStatOrDefault(IV_EV_Collection,i++,0); + i=0; + hp = UseStatOrDefault(stats_collection,i++,CalculateHealth(level)); + maxhp = UseStatOrDefault(stats_collection,i++,CalculateHealth(level)); + atk = UseStatOrDefault(stats_collection,i++,CalculateStat(level,creature.atk,atk_iv,atk_ev)); + def = UseStatOrDefault(stats_collection,i++,CalculateStat(level,creature.def,def_iv,def_ev)); + spd = UseStatOrDefault(stats_collection,i++,CalculateStat(level,creature.spd,spd_iv,spd_ev)); + spc = UseStatOrDefault(stats_collection,i++,CalculateStat(level,creature.spc,spc_iv,spc_ev)); + } + + private boolean isOdd(Integer val) { + return val % 2 == 0; + } + + private Integer CalculateHPIV() { + int lsb_total = ((isOdd(atk_iv))?8:0)+ + ((isOdd(def_iv))?4:0)+ + ((isOdd(spd_iv))?2:0)+ + ((isOdd(spc_iv))?1:0); + return lsb_total; + } + + private Integer UseStatOrDefault(Integer[] stat_array, int index, int default_value) { + if (stat_array.length>index) { + return stat_array[index]; + } else { + return default_value; + } + } + + private int CalculateHealth(Integer lv) { + return (int)(((((creature.hp+hp_iv)*2)+(Math.sqrt(hp_ev)/4))*lv)/100)+lv+10; + } + + private int CalculateStat(Integer lv, int base, Integer iv, Integer ev) { + return (int)(((((base+iv)*2)+(Math.sqrt(ev)/4))*lv)/100)+5; + } + + public String toString() { + StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"("); + boolean first=true; + for (Field f : this.getClass().getDeclaredFields()) { + try { + if (!first) { + sb.append(","); + } else { + first=false; + } + sb.append(f.getName()+"="+this.getClass().getDeclaredField(f.getName()).get(this)); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + sb.append(")"); + return sb.toString(); + } +} diff --git a/Megamon-core/src/sig/megamon/Player.java b/Megamon-core/src/sig/megamon/Player.java new file mode 100644 index 0000000..1536b6c --- /dev/null +++ b/Megamon-core/src/sig/megamon/Player.java @@ -0,0 +1,92 @@ +package sig.megamon; + +import java.awt.geom.Point2D; +import java.awt.geom.Point2D.Double; +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import sig.megamon.menu.DialogBox; +import sig.megamon.ref.RoomRef; +import sig.megamon.ref.SignRef; +import sig.megamon.utils.GraphicUtils; +import sig.megamon.utils.PlayerUtils; +import sig.megamon.utils.TrainerUtils; + +public class Player { + + public Point2D.Double position = new Point2D.Double(1,1); + Point2D.Double direction = new Point2D.Double(0,0); + Point2D.Double lastdirection = new Point2D.Double(0,1); + Texture sprite; + List megamon_party = new ArrayList(); + int trainer_id; + String name; + + public Player(Point2D.Double position, String sprite) { + this.position=position; + this.sprite=new Texture(sprite); + this.trainer_id = TrainerUtils.getRandomTrainerID(); + this.name = "Rob"; + } + + public void run() { + direction=new Point2D.Double(0, 0); + if (Gdx.input.isKeyPressed(Megamon.MOVELEFTKEY)) { + direction=lastdirection=new Point2D.Double(-Megamon.CHAR_SPD,0); + } else + if (Gdx.input.isKeyPressed(Megamon.MOVEUPKEY)) { + direction=lastdirection=new Point2D.Double(0,Megamon.CHAR_SPD); + } else + if (Gdx.input.isKeyPressed(Megamon.MOVERIGHTKEY)) { + direction=lastdirection=new Point2D.Double(Megamon.CHAR_SPD,0); + } else + if (Gdx.input.isKeyPressed(Megamon.MOVEDOWNKEY)) { + direction=lastdirection=new Point2D.Double(0,-Megamon.CHAR_SPD); + } + Point2D.Double destinationposition = new Point2D.Double(position.x+Math.signum(lastdirection.x),position.y+Math.signum(lastdirection.y)); + if (Gdx.input.isKeyJustPressed(Megamon.ACTIONKEY)) { + CheckForInfo(destinationposition); + } + if (direction.x!=0 || direction.y!=0) { + //System.out.println("("+position.x+","+Math.signum(direction.x)+","+position.y+","+Math.signum(direction.y)+")"); + //Point2D.Double destinationposition = new Point2D.Double(position.x+Math.signum(direction.x),position.y+Math.signum(direction.y)); + if (PlayerUtils.isLocationPassable(Megamon.currentLevel.getMap(),destinationposition)) { + position.setLocation(position.x+direction.x, position.y+direction.y); + } else { + //We hit a wall. + } + //System.out.println(Megamon.infoDatabase.keySet()); + CheckForDoor(destinationposition); + } + } + + private void CheckForDoor(Point2D.Double destinationposition) { + if (Megamon.doorDatabase.containsKey(PlayerUtils.getDoorPositionHash(destinationposition))) { + //System.out.println("This is a door!"); + RoomRef door = Megamon.doorDatabase.get(PlayerUtils.getDoorPositionHash(destinationposition)); + if (!door.destinationRoom.equalsIgnoreCase(Megamon.currentLevel.mapName)) { + Megamon.currentLevel.destroy(); + Megamon.currentLevel = new Room(door.doorDestination,door.destinationRoom); + } else { + position.setLocation(door.doorDestination); + } + } + } + + private void CheckForInfo(Point2D.Double destinationposition) { + if (Megamon.infoDatabase.containsKey(PlayerUtils.getDoorPositionHash(destinationposition))) { + //System.out.println("This is a door!"); + SignRef info = Megamon.infoDatabase.get(PlayerUtils.getDoorPositionHash(destinationposition)); + //TODO Do interface stuff here. + Megamon.messagebox = new DialogBox(info.getMessages()); + } + } + + public void draw(SpriteBatch batch) { + batch.draw(sprite, (int)GraphicUtils.getPlayerPixelPosition(Megamon.camera).getX(), (int)GraphicUtils.getPlayerPixelPosition(Megamon.camera).getY(), (int)GraphicUtils.getTileSize(Megamon.camera).getX(), (int)GraphicUtils.getTileSize(Megamon.camera).getY()); + } +} diff --git a/Megamon-core/src/sig/megamon/Room.java b/Megamon-core/src/sig/megamon/Room.java index 1d42ead..c6d02c3 100644 --- a/Megamon-core/src/sig/megamon/Room.java +++ b/Megamon-core/src/sig/megamon/Room.java @@ -28,7 +28,7 @@ public class Room { */ public Room(Point2D.Double startingLoc, String mapFileRef) { this.startingLocation=startingLoc; - Megamon.position.setLocation(startingLoc); + Megamon.mainP.position.setLocation(startingLoc); this.map = new TmxMapLoader().load(MAPFOLDER+mapFileRef+".tmx"); this.map.getLayers().get(Megamon.HIDDENLAYERNAME).setVisible(false); renderer = new OrthogonalTiledMapRenderer(this.map,1/(float)Megamon.TILESIZE); diff --git a/Megamon-core/src/sig/megamon/creature/CreatureLore.java b/Megamon-core/src/sig/megamon/creature/CreatureLore.java new file mode 100644 index 0000000..3664d7b --- /dev/null +++ b/Megamon-core/src/sig/megamon/creature/CreatureLore.java @@ -0,0 +1,15 @@ +package sig.megamon.creature; + +import java.lang.reflect.Field; + +public class CreatureLore { + final String bio; + final int size; //In inches. + final float weight; //In lbs. + + public CreatureLore(String bio, int size, float weight) { + this.bio = bio; + this.size = size; + this.weight = weight; + } +} diff --git a/Megamon-core/src/sig/megamon/creature/CreatureMove.java b/Megamon-core/src/sig/megamon/creature/CreatureMove.java index 714f75b..cfc8156 100644 --- a/Megamon-core/src/sig/megamon/creature/CreatureMove.java +++ b/Megamon-core/src/sig/megamon/creature/CreatureMove.java @@ -1,5 +1,7 @@ package sig.megamon.creature; +import java.lang.reflect.Field; + public class CreatureMove { int lvLearned=0; String name=""; @@ -14,4 +16,29 @@ public class CreatureMove { this.type=type; this.cat=category; } + + public String toString() { + StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"("); + boolean first=true; + for (Field f : this.getClass().getDeclaredFields()) { + try { + if (!first) { + sb.append(","); + } else { + first=false; + } + sb.append(f.getName()+"="+this.getClass().getDeclaredField(f.getName()).get(this)); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + sb.append(")"); + return sb.toString(); + } } diff --git a/Megamon-core/src/sig/megamon/creature/CreatureType.java b/Megamon-core/src/sig/megamon/creature/CreatureType.java index fa51d36..fd724f6 100644 --- a/Megamon-core/src/sig/megamon/creature/CreatureType.java +++ b/Megamon-core/src/sig/megamon/creature/CreatureType.java @@ -1,5 +1,7 @@ package sig.megamon.creature; +import java.lang.reflect.Field; + public enum CreatureType { NORMAL, FIRE, diff --git a/Megamon-core/src/sig/megamon/creature/ExperienceRate.java b/Megamon-core/src/sig/megamon/creature/ExperienceRate.java new file mode 100644 index 0000000..7bbae44 --- /dev/null +++ b/Megamon-core/src/sig/megamon/creature/ExperienceRate.java @@ -0,0 +1,12 @@ +package sig.megamon.creature; + +import java.lang.reflect.Field; + +public enum ExperienceRate { + ERRATIC, + FAST, + MEDIUM_FAST, + MEDIUM_SLOW, + SLOW, + FLUCTUATING; +} diff --git a/Megamon-core/src/sig/megamon/creature/NonVolatileStatus.java b/Megamon-core/src/sig/megamon/creature/NonVolatileStatus.java new file mode 100644 index 0000000..3db2c79 --- /dev/null +++ b/Megamon-core/src/sig/megamon/creature/NonVolatileStatus.java @@ -0,0 +1,18 @@ +package sig.megamon.creature; + +import java.lang.reflect.Field; + +public enum NonVolatileStatus { + BURN("BRN"), + FREEZE("FRZ"), + PARALYSIS("BRN"), + POISON("PSN"), + BAD_POISON("PSN"), + SLEEP("SLP"); + + String abbreviation; + + NonVolatileStatus(String abbreviation) { + this.abbreviation=abbreviation; + } +} diff --git a/Megamon-core/src/sig/megamon/creature/SpriteCollection.java b/Megamon-core/src/sig/megamon/creature/SpriteCollection.java index e84b49c..a82b8a2 100644 --- a/Megamon-core/src/sig/megamon/creature/SpriteCollection.java +++ b/Megamon-core/src/sig/megamon/creature/SpriteCollection.java @@ -1,5 +1,7 @@ package sig.megamon.creature; +import java.lang.reflect.Field; + import com.badlogic.gdx.graphics.Texture; /** @@ -32,4 +34,29 @@ public class SpriteCollection { public Texture getBackSprite() { return back_sprite; } + + public String toString() { + StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"("); + boolean first=true; + for (Field f : this.getClass().getDeclaredFields()) { + try { + if (!first) { + sb.append(","); + } else { + first=false; + } + sb.append(f.getName()+"="+this.getClass().getDeclaredField(f.getName()).get(this)); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + sb.append(")"); + return sb.toString(); + } } diff --git a/Megamon-core/src/sig/megamon/creature/VolatileStatus.java b/Megamon-core/src/sig/megamon/creature/VolatileStatus.java new file mode 100644 index 0000000..02f986a --- /dev/null +++ b/Megamon-core/src/sig/megamon/creature/VolatileStatus.java @@ -0,0 +1,13 @@ +package sig.megamon.creature; + +import java.lang.reflect.Field; + +public enum VolatileStatus { + BIND, + NO_ESCAPE, + CONFUSED, + CURSE, + FLINCH, + LEECHED, + ; +} diff --git a/Megamon-core/src/sig/megamon/DialogBox.java b/Megamon-core/src/sig/megamon/menu/DialogBox.java similarity index 89% rename from Megamon-core/src/sig/megamon/DialogBox.java rename to Megamon-core/src/sig/megamon/menu/DialogBox.java index 49b7ce2..3ba6b4f 100644 --- a/Megamon-core/src/sig/megamon/DialogBox.java +++ b/Megamon-core/src/sig/megamon/menu/DialogBox.java @@ -1,4 +1,4 @@ -package sig.megamon; +package sig.megamon.menu; import java.util.ArrayList; import java.util.Arrays; @@ -13,6 +13,7 @@ import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.Align; +import sig.megamon.Megamon; import sig.megamon.utils.DrawUtils; public class DialogBox { @@ -34,7 +35,7 @@ public class DialogBox { public void run() { //TODO accept keyboard inputs for the dialog box. if (Gdx.input.isKeyJustPressed(Megamon.ACTIONKEY)) { - System.out.println("Cursor is at position "+cursor+"/"+displayedMessage.length()); + //System.out.println("Cursor is at position "+cursor+"/"+displayedMessage.length()); if (cursor==displayedMessage.length()) { if (cursor!=messageBody.length()) { displayedMessage=""; @@ -88,9 +89,9 @@ public class DialogBox { String subString=messageBody.substring(cursor, messageBody.length()); //System.out.println("Substring is "+subString); for (int i=0;i", + "Save", + "Options", + "Exit"}; + int menuitem_spacing = 28; + + public StartMenuBox(int cursorStartingPosition) { + this.selection=cursorStartingPosition; + } + + public void run() { + if (Gdx.input.isKeyJustPressed(Megamon.MOVEUPKEY)) { + selection = Math.floorMod(selection-1, menuitems.length); + } + if (Gdx.input.isKeyJustPressed(Megamon.MOVEDOWNKEY)) { + selection = Math.floorMod(selection+1, menuitems.length); + } + if (Gdx.input.isKeyJustPressed(Megamon.MENUKEY)) { + Megamon.startmenubox=null; + } + } + + public void draw(SpriteBatch batch) { + int windowx = Megamon.WINDOW_WIDTH-startmenu_background_top.getWidth(); + int windowy = Megamon.WINDOW_HEIGHT-startmenu_background_top.getHeight(); + int spacingpixels = menuitem_spacing*menuitems.length-startmenu_background_bottom.getHeight(); + int menubot = windowy-spacingpixels; + batch.draw(startmenu_background_top, windowx,windowy); + batch.draw(startmenu_background, windowx, windowy-spacingpixels, 0,0,startmenu_background.getWidth(), + spacingpixels); + batch.draw(startmenu_background_bottom, windowx,menubot-startmenu_background_bottom.getHeight()); + int i=0; + for (String s : menuitems) { + if (i==selection) { + batch.draw(startmenu_highlight, windowx-4, windowy-((i+1)*menuitem_spacing)+8); + } + DialogBox.messageboxfont.draw(batch, s, windowx+28, windowy-(i++*menuitem_spacing)); + } + Megamon.font.draw(batch, ">", windowx+8, windowy-(selection*menuitem_spacing)+8); + } +} diff --git a/Megamon-core/src/sig/megamon/utils/ColorUtils.java b/Megamon-core/src/sig/megamon/utils/ColorUtils.java index 6add929..a80aec7 100644 --- a/Megamon-core/src/sig/megamon/utils/ColorUtils.java +++ b/Megamon-core/src/sig/megamon/utils/ColorUtils.java @@ -12,11 +12,11 @@ public class ColorUtils { String r = hex.substring(1, 3); String g = hex.substring(3, 5); String b = hex.substring(5, 7); - System.out.println("Colors: "+r+","+g+","+b); + //System.out.println("Colors: "+r+","+g+","+b); float r_col = ConvertHexStringToDecimal(r); float g_col = ConvertHexStringToDecimal(g); float b_col = ConvertHexStringToDecimal(b); - System.out.println("Colors: "+r_col+","+g_col+","+b_col); + //System.out.println("Colors: "+r_col+","+g_col+","+b_col); return new Color(r_col/255,g_col/255,b_col/255,1); } diff --git a/Megamon-core/src/sig/megamon/utils/GraphicUtils.java b/Megamon-core/src/sig/megamon/utils/GraphicUtils.java index 0d959a2..9104f25 100644 --- a/Megamon-core/src/sig/megamon/utils/GraphicUtils.java +++ b/Megamon-core/src/sig/megamon/utils/GraphicUtils.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Camera; import sig.megamon.Megamon; +import sig.megamon.Player; public class GraphicUtils { public static double getAspectRatio() { @@ -24,7 +25,7 @@ public class GraphicUtils { } public static Point2D.Double getRelativePixelPositionFromPlayer(Camera camera,Point2D.Double position) { Point2D.Double pixelpos = getTileToPixel(camera,position); - Point2D.Double playerpos = getTileToPixel(camera,Megamon.position); + Point2D.Double playerpos = getTileToPixel(camera,Megamon.mainP.position); Point2D.Double playerpixelpos = getPlayerPixelPosition(camera); return new Point2D.Double(playerpixelpos.x+(pixelpos.x-playerpos.x), playerpixelpos.y+(pixelpos.y-playerpos.y)); } diff --git a/Megamon-core/src/sig/megamon/utils/PlayerUtils.java b/Megamon-core/src/sig/megamon/utils/PlayerUtils.java index 04f3388..fbe96e2 100644 --- a/Megamon-core/src/sig/megamon/utils/PlayerUtils.java +++ b/Megamon-core/src/sig/megamon/utils/PlayerUtils.java @@ -33,7 +33,7 @@ public class PlayerUtils { public static String getDoorPositionHash(Point2D.Double position) { //position = getRoundedPosition(position); String hash = Megamon.currentLevel.getMapName()+"_"+(int)Math.round(position.getX())+","+(int)Math.round(position.getY()); - System.out.println("Getting hash "+hash); + //System.out.println("Getting hash "+hash); return hash; } diff --git a/Megamon-core/src/sig/megamon/utils/TrainerUtils.java b/Megamon-core/src/sig/megamon/utils/TrainerUtils.java new file mode 100644 index 0000000..6f0aa0e --- /dev/null +++ b/Megamon-core/src/sig/megamon/utils/TrainerUtils.java @@ -0,0 +1,7 @@ +package sig.megamon.utils; + +public class TrainerUtils { + public static int getRandomTrainerID() { + return (int)(Math.random()*1000000); + } +}