Newer
Older
AlgebraicDataflowArchitectureModel / GameEngine / src / main / java / gameEngine / entites / gameComponents / EntityView.java
NoranekoFelician 3 days ago 1 KB Portをクリックし、判別します
package gameEngine.entites.gameComponents;

import gameEngine.entites.Entity;
import gameEngine.views.Sprite;
import org.joml.Vector3f;

public class EntityView extends Draggable{

    private Sprite sprite;
    private PortView portviewA;
    private PortView portviewB;

    public EntityView(Entity entity){
        this.parent = entity;
        this.sprite = new Sprite("GameEngine/resources/EntityView.png");
        sprite.updateSpriteDimensions();
        portviewA = new PortView(true);
        portviewB = new PortView(false);
    }

    @Override
    public GameComponent copy() {
        return this;
    }

    @Override
    public void init(){
        sprite.update();
        sprite.updateSpriteDimensions();
    }

    @Override
    public void update() {
        sprite.setPosition(parent.transform.position);
        sprite.setRotation(parent.transform.rotation);
        sprite.setScale(parent.transform.scale);
        sprite.update();
        Vector3f pos = new Vector3f(parent.transform.position.x-15,parent.transform.position.y+10,parent.transform.position.z);
        portviewA.update(pos, parent.transform.rotation, parent.transform.scale);
        portviewA.handleDragging("EntityPort");
        pos = new Vector3f(parent.transform.position.x-15,parent.transform.position.y+40,parent.transform.position.z);
        portviewB.update(pos, parent.transform.rotation, parent.transform.scale);
    }

    @Override
    protected boolean isMouseOver(float mouseX, float mouseY) {
        return sprite.isMouseOver(mouseX, mouseY);
    }

    @Override
    protected void draggingAction(float mouseX, float mouseY) {
        sprite.setPosition(mouseX - sprite.getDisplayedWidth() / 2,
                mouseY - sprite.getDisplayedHeight() / 2);
    }

    public PortView getPortView() {
        return portviewA;
    }
}