DEADSOFTWARE

Add drop picking
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / objects / Drop.java
index 5ff36e476584f6eaa9ac34733d76ba550df0d9ea..e967f880314480a1fd9b9d73c77aedea4729622f 100644 (file)
@@ -7,23 +7,25 @@ import java.io.Serializable;
 
 public class Drop implements Serializable {
     private int id;
+    public boolean pickedUp = false;
     public Vector2 move, position;
 
-    public static void pickUpDrop(Player pl, int id) {
+    public Drop(float x, float y, int id) {
+        this.id = id;
+        position = new Vector2(x, y);
+        move = new Vector2(0, -1);
+    }
+
+    public void pickUpDrop(Player pl) {
         for (int i = 0; i < pl.inventory.length; i++) {
-            if (pl.inventory[i] == 0) {
+            if (pl.inventory[i] == 0 || pl.inventory[i] == id) {
                 pl.inventory[i] = id;
+                pickedUp = true;
                 break;
             }
         }
     }
 
-    public Drop(float x, float y, int id) {
-        this.id = id;
-        position = new Vector2(x, y);
-        move = new Vector2(0, -1);
-    }
-
     public int getId() {
         return id;
     }