Package game.view.inventory

Source Code of game.view.inventory.InventoryStatScreen

package game.view.inventory;

import beans.enumeration.Stat;
import game.control.StatsController;
import game.entity.Alphabet;
import game.model.inventory.InventoryStatModel;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.Observable;

/**
* Ecran d'affichage des statistiques.
*
* @author mastersnes
* @version InventoryStatScreen 1.0
* @since Game 1.0
*/
public class InventoryStatScreen extends InventoryScreenPatern {
   
    /**
     * Modèle de l'écran pour aller piocher des infos.
     * @since InventoryStatScreen 1.0
     */
    private final InventoryStatModel statModel;

    /**
     * Créer l'écran d'affichage des caractéristiques.
     * @param statModel Le modèle à observer.
     * @since InventoryStatScreen 1.0
     * @see InventoryStatModel
     */
    public InventoryStatScreen(final InventoryStatModel statModel) {
        this.statModel = statModel;
    }

    /**
     * Dessiner et récupérer l'image de l'écran.
     * @return l'image correspondant à l'écran.
     * @since InventoryStatScreen 1.0
     * @see Image
     */
    @Override
    public Image getImage() {
        final BufferedImage image = new BufferedImage(background.getWidth(null), background.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        final Graphics2D g = image.createGraphics();
        g.drawImage(background, 0, 0, null);

        final StatsController stats = statModel.getStats();
        g.drawImage(Alphabet.createString(stats.getPermanentStats().getName(), image.getWidth()), 20, 25, null);
        g.drawImage(Alphabet.createString(Stat.HP + " : " + stats.getCurrentHP() + " * " + stats.getTotalHPMax(), image.getWidth()), 20, 80, null);
        g.drawImage(Alphabet.createString(Stat.MP + " : " + stats.getCurrentMP() + " * " + stats.getTotalMPMax(), image.getWidth()), 20, 110, null);

        g.drawImage(Alphabet.createString(Stat.STRENGTH + " : " + stats.getPermanentStats().getStrength() + " + " + stats.getStrengthTemporaryModifier(), image.getWidth()), 20, 140, null);
        g.drawImage(Alphabet.createString(Stat.CONSTITUTION + " : " + stats.getPermanentStats().getConstitution() + " + " + stats.getConstitutionTemporaryModifier(), image.getWidth()), 20, 170, null);
        g.drawImage(Alphabet.createString(Stat.WISDOM + " : " + stats.getPermanentStats().getWisdom() + " + " + stats.getWisdomTemporaryModifier(), image.getWidth()), 20, 200, null);
        g.drawImage(Alphabet.createString(Stat.INTELLIGENCE + " : " + stats.getPermanentStats().getIntelligence() + " + " + stats.getIntelligenceTemporaryModifier(), image.getWidth()), 20, 230, null);
        g.drawImage(Alphabet.createString(Stat.CHARISMA + " : " + stats.getPermanentStats().getCharisma() + " + " + stats.getCharismaTemporaryModifier(), image.getWidth()), 20, 260, null);

        g.drawImage(Alphabet.createString(Stat.CLASS + " : " + stats.getPermanentStats().getClasse(), image.getWidth()), 20, 290, null);
        g.drawImage(Alphabet.createString(Stat.LEVEL + " : ", image.getWidth()), 20, 320, null);

        g.dispose();
        return image;
    }
   
    /**
     * Mettre à jour la vue.
     * @param o Le modèle mis à jour.
     * @param arg Les paramètres de mise à jour (non utilisé).
     * @since InventoryStatScreen 1.0
     */
    @Override
    public void update(final Observable o, final Object arg) {
    }
}
TOP

Related Classes of game.view.inventory.InventoryStatScreen

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.