Inventory weiter vervollständigt
hinzufügen von weiteren gettern und settern sowie switch methoden um Inventarplätze zu wechseln
This commit is contained in:
@@ -17,6 +17,7 @@ public class PlayerInventory {
|
|||||||
*/
|
*/
|
||||||
public PlayerInventory(int inventorySize){
|
public PlayerInventory(int inventorySize){
|
||||||
items = new Item [inventorySize];
|
items = new Item [inventorySize];
|
||||||
|
currentItem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,6 +28,30 @@ public class PlayerInventory {
|
|||||||
return coins;
|
return coins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt die Anzahl von Coins im Inventar zu angegebener Anzahl.
|
||||||
|
* @param coins Anzahl an coins als int, die im Inventar sein sollen.
|
||||||
|
*/
|
||||||
|
public void setCoins(int coins) {
|
||||||
|
this.coins = coins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt die angegebene Anzahl an Coins in das Inventar hinzu.
|
||||||
|
* @param amount Die Anzahl an Coins als int, die hinzugefügt werden soll.
|
||||||
|
*/
|
||||||
|
public void addCoins(int amount){
|
||||||
|
this.coins+= amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entfernt die angegebene Anzahl an Coins vom Inventar.
|
||||||
|
* @param amount Die Anzahl an Coins als int, die entfernt werden soll.
|
||||||
|
*/
|
||||||
|
public void subtractCoins(int amount){
|
||||||
|
this.coins-= amount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter für das Items im Inventar.
|
* Getter für das Items im Inventar.
|
||||||
* @return gibt ein Array mit allen Item Objekten zurück, die im Inventar enthalten sind.
|
* @return gibt ein Array mit allen Item Objekten zurück, die im Inventar enthalten sind.
|
||||||
@@ -43,6 +68,14 @@ public class PlayerInventory {
|
|||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entfernt ein Item auf angegebner Position im Item-Array.
|
||||||
|
* @param itemPosition Position des Items das entfernt werden soll, angegeben als int.
|
||||||
|
*/
|
||||||
|
public void removeItem(int itemPosition) {
|
||||||
|
items[itemPosition]=null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setzt das gerade ausgewählte Item fest.
|
* Setzt das gerade ausgewählte Item fest.
|
||||||
* @param currentItem int gibt an welcher Index des Item Arrays ausgewählt werden soll.
|
* @param currentItem int gibt an welcher Index des Item Arrays ausgewählt werden soll.
|
||||||
@@ -51,6 +84,14 @@ public class PlayerInventory {
|
|||||||
this.currentItem = currentItem;
|
this.currentItem = currentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wechselt auf den nächsten Slot im Inventar.
|
||||||
|
*/
|
||||||
|
public void changeCurrentItem(){
|
||||||
|
if(currentItem>=items.length) currentItem=0;
|
||||||
|
else currentItem++;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methode zum Hinzufügen von Items.
|
* Methode zum Hinzufügen von Items.
|
||||||
* @param newItem Das Item, dass hinzugefügt werden soll.
|
* @param newItem Das Item, dass hinzugefügt werden soll.
|
||||||
|
|||||||
Reference in New Issue
Block a user