瀏覽代碼

removed debugging stuff, added entity spawn ids

Kajetan Johannes Hammerle 6 年之前
父節點
當前提交
f9176faf74

+ 9 - 12
src/me/hammerle/supersnuvi/entity/EntityBuilder.java

@@ -1,5 +1,6 @@
 package me.hammerle.supersnuvi.entity;
 
+import java.util.Random;
 import me.hammerle.supersnuvi.entity.components.DefaultHealth;
 import me.hammerle.supersnuvi.entity.components.DefaultMovement;
 import me.hammerle.supersnuvi.entity.components.Death;
@@ -52,7 +53,7 @@ public final class EntityBuilder
         return hero;
     }
     
-    public static Entity buildTest(Level level, double x, double y)
+    public static Entity buildLondoner(Level level, double x, double y, boolean evil)
     {
         double w = Game.TILE_SIZE;
         double h = Game.TILE_SIZE * 2;
@@ -60,7 +61,7 @@ public final class EntityBuilder
         Entity hero = new Entity(level, x, y, w, h, w * 0.4375, h * 0.703125);
         hero.animator = new LondonerAnimator(hero);
         //hero.controller = new FollowHeroController(hero, 2);
-        hero.controller = new LondonerController(hero, true);
+        hero.controller = new LondonerController(hero, evil);
         hero.health = new DefaultHealth(hero, Death.NULL, 100.0);
         hero.energy = new DefaultEnergy(hero, 100.0);
         hero.move = new DefaultMovement(hero, ent -> level.getData().getInt("jump", 24));
@@ -78,22 +79,18 @@ public final class EntityBuilder
         return stone;
     }
     
+    private final static Random RND = new Random();
+    
     public static Entity fromId(int id, Level level, double x, double y)
     {
         switch(id)
         {
             case 1:
-                return buildTest(level, x, y);
+                return buildLondoner(level, x, y, RND.nextBoolean());
             case 2:
-            {
-                Entity ent = new Entity(level, x, y, Game.TILE_SIZE, Game.TILE_SIZE * 2);
-                ent.animator = new HeroAnimator(ent);
-                ent.controller = new WalkController(ent, 1);
-                ent.health = new DefaultHealth(ent, Death.NULL, 100.0);
-                ent.move = new DefaultMovement(ent, enti -> 12);
-                ent.movePenalty = new LandMovement(ent);
-                return ent;
-            }
+                return buildLondoner(level, x, y, true);
+            case 3:
+                return buildLondoner(level, x, y, false);
         }
         return null;
     }

+ 1 - 1
src/me/hammerle/supersnuvi/entity/components/ai/LondonerController.java

@@ -111,7 +111,7 @@ public class LondonerController extends EntityController
                     }
                     else if(!e.getController().isBlocking())
                     {
-                        e.getHealth().addHealth(-0.01);
+                        e.getHealth().addHealth(-14.2857);
                     }
                 }
             }

+ 9 - 6
src/me/hammerle/supersnuvi/gamelogic/Level.java

@@ -58,9 +58,9 @@ public final class Level
             this.name = data.getString("name", "error");
             
             // debug stuff
-            if(name.equals("00-Tech Demo"))
+            /*if(name.equals("00-Tech Demo"))
             {
-                /*int index = data.getBackgroundIndex();
+                int index = data.getBackgroundIndex();
                 data.setTile(index, 5, 4, 33);
                 data.setTile(index, 14, 4, 34);
                 
@@ -102,8 +102,8 @@ public final class Level
                     {
                         data.setTile(index, x + 6, y + 1, 256 + x + (4 - y) * 5);
                     }
-                }*/
-            }
+                }
+            }*/
             // end debug stuff
             
             maxSouls = 0;
@@ -132,12 +132,15 @@ public final class Level
         {
             spawns.add(new Point(5, 5));
         }
-        spawns.add(new Point(15, 10));
+        //spawns.add(new Point(15, 10));
 
         resetLevel();
         
-        Entity test = EntityBuilder.buildTest(this, 400, 200);
+        /*Entity test = EntityBuilder.fromId(3, this, 400, 200);
         entities.put(entityCounter++, test);
+        
+        test = EntityBuilder.fromId(2, this, 600, 200);
+        entities.put(entityCounter++, test);*/
     }
     
     // -------------------------------------------------------------------------