GameScene.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:NoRiskNoFun 作者:
/**
 * Creates a new Infantry on the Region specified within the message
 * @param message GUI Message containing position information
 */
private void spawnNewTroop(SpawnTroopGui message) {

    AssetMap.Region region = regionNameMap.get(message.getRegionName());
    Vector2 troopCoordinates = calculatePolygonCentroid(region.getVertices());

    Infantry infantry = new Infantry((troopCoordinates.x * Gdx.graphics.getWidth()) - 50, (troopCoordinates.y * Gdx.graphics.getHeight()) - 50, 100, 100, message.getId());
    infantry.addTouchListener();
    infantry.setFirstMove(false);
    infantry.setCurrentRegion(regionNameMap.get(message.getRegionName()));

    Gdx.app.log("Spawning", "Actor with ID: " + infantry.getId());


    // set color and owner only when the first troop spawns on this region
    if (region.getOwner().equals(Player.NULL_PLAYERNAME)) {
        region.setOwner(data.getCurrentPlayer().getPlayerName());
        setRegionColor(new Color(data.getCurrentPlayer().getColor()), infantry.getCurrentRegion());
    }

    region.updateTroops(1);
    data.setChangedFlag(true);

    figures.add(infantry);
    addSceneObject(infantry);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号