Browse Source

removed tries, health is also shown as number, evil londoners drop bottles, ai water bugfix

Kajetan Johannes Hammerle 6 years ago
parent
commit
f508a4dafc

+ 1 - 1
src/me/hammerle/supersnuvi/entity/Entity.java

@@ -87,7 +87,7 @@ public final class Entity
     public Level getLevel()
     {
         return level;
-    }
+    }   
     
     //--------------------------------------------------------------------------
     // components

+ 2 - 7
src/me/hammerle/supersnuvi/entity/EntityBuilder.java

@@ -15,7 +15,6 @@ import me.hammerle.supersnuvi.entity.components.StoneMovement;
 import me.hammerle.supersnuvi.entity.components.ai.EntityController;
 import me.hammerle.supersnuvi.entity.components.ai.HumanController;
 import me.hammerle.supersnuvi.entity.components.ai.LondonerController;
-import me.hammerle.supersnuvi.entity.components.ai.WalkController;
 import me.hammerle.supersnuvi.entity.components.animator.StoneAnimator;
 import me.hammerle.supersnuvi.entity.components.animator.HeroAnimator;
 import me.hammerle.supersnuvi.entity.components.animator.EntityAnimator;
@@ -62,7 +61,7 @@ public final class EntityBuilder
         hero.animator = new LondonerAnimator(hero);
         //hero.controller = new FollowHeroController(hero, 2);
         hero.controller = new LondonerController(hero, evil);
-        hero.health = new DefaultHealth(hero, Death.NULL, 100.0);
+        hero.health = new DefaultHealth(hero, evil ? Death.DROP_BOTTLE : Death.NULL, 100.0);
         hero.energy = new DefaultEnergy(hero, 100.0);
         hero.move = new DefaultMovement(hero, ent -> level.getData().getInt("jump", 24));
         //hero.itemCollector = new HeroItemCollector(hero);
@@ -79,17 +78,13 @@ 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 buildLondoner(level, x, y, RND.nextBoolean());
-            case 2:
                 return buildLondoner(level, x, y, true);
-            case 3:
+            case 2:
                 return buildLondoner(level, x, y, false);
         }
         return null;

+ 14 - 0
src/me/hammerle/supersnuvi/entity/components/Death.java

@@ -1,6 +1,8 @@
 package me.hammerle.supersnuvi.entity.components;
 
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
+import me.hammerle.supersnuvi.util.SoundUtils;
 
 public abstract class Death
 {
@@ -12,5 +14,17 @@ public abstract class Death
         }
     };
     
+    public static final Death DROP_BOTTLE = new Death() 
+    {
+        @Override
+        public void onDeath(Entity ent) 
+        {
+            Level l = ent.getLevel();
+            SoundUtils.playSound(SoundUtils.Sound.COLLECT);
+            l.increaseSouls(1);
+            l.getHero().getHealth().addHealthPercent(0.143);
+        }
+    };
+    
     public abstract void onDeath(Entity ent);
 }

+ 19 - 21
src/me/hammerle/supersnuvi/gamelogic/Level.java

@@ -42,7 +42,7 @@ public final class Level
     private double time = 0.0;
     private double clockTick = 0.0;
     
-    private int tries = 7;
+    //private int tries = 7;
     
     private TreeSet<Point> spawns = new TreeSet<>();
     
@@ -60,13 +60,11 @@ public final class Level
             // debug stuff
             /*if(name.equals("00-Tech Demo"))
             {
-                int index = data.getBackgroundIndex();
-                data.setTile(index, 5, 4, 33);
-                data.setTile(index, 14, 4, 34);
+                int index = data.getBackgroundIndex() + 1;
+                data.setTile(index, 10, 6, 2);
+                data.setTile(index, 11, 6, 1);
                 
-                data.setTile(index, 15, 4, 64);
-                
-                for(int layer = 0; layer <= data.getBackgroundIndex(); layer++)
+                /*for(int layer = 0; layer <= data.getBackgroundIndex(); layer++)
                 {
                     for(int x = 0; x < data.getWidth(); x++)
                     {
@@ -120,6 +118,13 @@ public final class Level
                     spawns.add(new Point(x, y));
                 }
             });
+            data.forEachEntity((x, y, tile) -> 
+            {            
+                if(tile == 1)
+                {
+                    maxSouls++;
+                }
+            }, 0, data.getWidth(), 0, data.getHeight());
         }
         else
         {
@@ -132,15 +137,8 @@ public final class Level
         {
             spawns.add(new Point(5, 5));
         }
-        //spawns.add(new Point(15, 10));
 
         resetLevel();
-        
-        /*Entity test = EntityBuilder.fromId(3, this, 400, 200);
-        entities.put(entityCounter++, test);
-        
-        test = EntityBuilder.fromId(2, this, 600, 200);
-        entities.put(entityCounter++, test);*/
     }
     
     // -------------------------------------------------------------------------
@@ -175,7 +173,7 @@ public final class Level
     
     public boolean resetLevel()
     {
-        boolean dead = false;
+        /*boolean dead = false;
         if(!done) // hero just died
         {
             tries--;
@@ -184,18 +182,18 @@ public final class Level
                 tries = 7;
                 dead = true;
             }
-        }
+        }*/
         state.resetTiles();
         data.activateEntities();
         souls = 0;
         time = 0.0;
         shouldReset = false;
         done = false;
-        Entity h = spawnHero(dead);
+        Entity h = spawnHero(true);
         hero = h;
         entities.clear();
         entities.put(entityCounter++, h);
-        return dead;
+        return false;
     }
     
     public void spawnEntity(Entity ent)
@@ -470,9 +468,9 @@ public final class Level
                 // gui foreground
                 renderer.drawFixedImage(AROUND_FOREGROUND, x, y, w, h);   
                 
-                // tries go over foreground
-                renderer.drawFixedImage(LIFE_OVERLAY[tries], x + 89 * scale, y + 52 * scale,
-                        LIFE_OVERLAY[tries].getWidth() * scale, LIFE_OVERLAY[tries].getHeight() * scale);
+                // tries / health go over foreground
+                renderer.drawFixedImage(LIFE_OVERLAY[hFrame], x + 89 * scale, y + 52 * scale,
+                        LIFE_OVERLAY[hFrame].getWidth() * scale, LIFE_OVERLAY[hFrame].getHeight() * scale);
                 
                 
                 // grey background

+ 6 - 0
src/me/hammerle/supersnuvi/tiles/WaterTile.java

@@ -53,6 +53,12 @@ public class WaterTile extends Tile
         }
     }
 
+    @Override
+    public boolean shouldAiUseCollisionBox(int x, int y)
+    {
+        return false;
+    }
+
     @Override
     public Image getImage(int x, int y) 
     {