Package game.view.inventory

Source Code of game.view.inventory.InventoryScreen

package game.view.inventory;

import game.model.inventory.InventoryModel;
import game.model.inventory.InventoryModelPatern;
import game.view.Displayable;
import java.awt.Image;
import java.util.Observable;
import java.util.Observer;

/**
*
* @author mastersnes
*/
public class InventoryScreen implements Observer, Displayable {

    private InventoryModel inventoryModel;
    private final InventoryExitScreen inventoryExitScreen;
    private final InventoryObjetScreen inventoryItemScreen;
    private final InventoryMenuScreen inventoryMenuScreen;
    private final InventoryOptionScreen inventoryOptionScreen;
    private final InventorySaveScreen inventorySaveScreen;
    private final InventorySkillScreen inventorySkillScreen;
    private final InventorySpellScreen inventorySpellScreen;
    private final InventoryStatScreen inventoryStatScreen;
    private final InventoryEquipmentScreen inventoryEquipmentScreen;
    private InventoryScreenPatern currentInventory;

    public InventoryScreen(final InventoryModel inventory) {
        this.inventoryModel = inventory;
        inventoryModel.addObserver(this);

        inventoryExitScreen = new InventoryExitScreen(inventory.getExitModel());
        inventoryItemScreen = new InventoryObjetScreen(inventory.getItemModel());
        inventoryMenuScreen = new InventoryMenuScreen(inventory.getMenuModel());
        inventoryOptionScreen = new InventoryOptionScreen(inventory.getOptionModel());
        inventorySaveScreen = new InventorySaveScreen();
        inventorySkillScreen = new InventorySkillScreen(inventory.getSkillModel());
        inventorySpellScreen = new InventorySpellScreen(inventory.getSpellModel());
        inventoryStatScreen = new InventoryStatScreen(inventory.getStatModel());
        inventoryEquipmentScreen = new InventoryEquipmentScreen(inventory.getEquipmentModel());

        currentInventory = inventoryMenuScreen;
    }

    /**
     *
     * @return
     */
    @Override
    public Image getImage() {
        return currentInventory.getImage();
    }

    /**
     * Mettre à jour la vue, et donc l'écran
     * @param o Le modèle qui a été mis à jour
     * @param arg Les paramètres de mise à jour (non utilisé)
     */
    @Override
    public void update(final Observable o, final Object arg) {
        inventoryModel = (InventoryModel) o;
        InventoryModelPatern currentModel = inventoryModel.getCurrentModel();
        //Si le modèle courant est le exit model
        if (currentModel == inventoryModel.getExitModel()) {
            currentInventory = inventoryExitScreen;
        } //Si le modèle courant est le menu principal
        else if (currentModel == inventoryModel.getMenuModel()) {
            currentInventory = inventoryMenuScreen;
        } //Si le modèle courant est le menu des objets
        else if (currentModel == inventoryModel.getItemModel()) {
            currentInventory = inventoryItemScreen;
        } //Si le modèle courant est le menu des sorts
        else if (currentModel == inventoryModel.getSpellModel()) {
            currentInventory = inventorySpellScreen;
        } //Si le modele courant est le menu des competences
        else if (currentModel == inventoryModel.getSkillModel()) {
            currentInventory = inventorySkillScreen;
        } //Si le modele courant est le menu des Stats
        else if (currentModel == inventoryModel.getStatModel()) {
            currentInventory = inventoryStatScreen;
        } //Si le modele courant est le menu des Equipement
        else if (currentModel == inventoryModel.getEquipmentModel()) {
            currentInventory = inventoryEquipmentScreen;
        }
        else if (currentModel == inventoryModel.getOptionModel()) {
            currentInventory = inventoryOptionScreen;
        }
    }
}
TOP

Related Classes of game.view.inventory.InventoryScreen

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.