当前位置: 首页>>代码示例>>Java>>正文


Java Component类代码示例

本文整理汇总了Java中de.dakror.gamesetup.ui.Component的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Component类属于de.dakror.gamesetup.ui包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
	AffineTransform old = g.getTransform();
	AffineTransform at = g.getTransform();
	at.translate(x, y);
	g.setTransform(at);
	
	for (int i = 0; i < Math.ceil(width / (float) CHUNKSIZE); i++)
		for (int j = 0; j < Math.ceil(height / (float) CHUNKSIZE); j++)
			if (new Rectangle(0, 0, Game.getWidth(), Game.getHeight()).intersects(new Rectangle(minX + i * CHUNKSIZE + x, minY + j * CHUNKSIZE + y, CHUNKSIZE, CHUNKSIZE)))
				g.drawImage(chunk, minX + i * CHUNKSIZE, minY + j * CHUNKSIZE, null);
	
	Component hovered = null;
	
	for (Component c : components) {
		if (!new Rectangle(0, 0, Game.getWidth(), Game.getHeight()).intersects(new Rectangle(c.getX() + x, c.getY() + y, c.getWidth(), c.getHeight()))) continue;
		c.draw(g);
		if (c.state == 2) hovered = c;
	}
	
	if (hovered != null) hovered.drawTooltip(GameFrame.currentFrame.mouse.x, GameFrame.currentFrame.mouse.y, g);
	
	
	g.setTransform(old);
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:26,代码来源:World.java

示例2: updateSize

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public void updateSize() {
	int minX = -65536, minY = -65536, maxX = -65536, maxY = -65536;
	for (Component c : components) {
		if (c.getX() < minX || minX == -65536) minX = c.getX();
		if (c.getY() < minY || minY == -65536) minY = c.getY();
		if (c.getX() + c.getWidth() > maxX || maxX == -65536) maxX = c.getX() + c.getWidth();
		if (c.getY() + c.getHeight() > maxY || maxY == -65536) maxY = c.getY() + c.getHeight();
	}
	
	minX = minX > 0 ? 0 : minX;
	minY = minY > 0 ? 0 : minY;
	
	this.minX = minX;
	this.minY = minY;
	
	width = maxX - minX;
	width = width < Game.getWidth() ? Game.getWidth() : width;
	height = maxY - minY;
	height = height < Game.getHeight() ? Game.getHeight() : height;
	
	x = x < -(width - Game.getWidth() + minX) ? -(width - Game.getWidth() + minX) : x;
	y = y < -(height - Game.getHeight() + minY) ? -(height - Game.getHeight() + minY) : y;
	x = x > -minX ? -minX : x;
	y = y > -minY ? -minY : y;
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:26,代码来源:World.java

示例3: update

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void update(int tick) {
	updateComponents(tick);
	
	attack.enabled = false;
	for (Component c : components) {
		if (c instanceof Slider) {
			for (TroopType t : TroopType.values()) {
				if (((Slider) c).getTitle().equals(t.getType().getName())) {
					if (((Slider) c).getValue() > 0) attack.enabled = true;
					break;
				}
			}
		}
	}
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:17,代码来源:AttackCityDialog.java

示例4: draw

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
	g.drawImage(cache, 0, 0, null);
	
	if (selectedBuilding != null) {
		int width = 300, height = 200;
		Helper.drawContainer(Game.getWidth() - width, Game.getHeight() - height, width, height, true, false, g);
	}
	
	Component hovered = null;
	for (Component c : components) {
		c.draw(g);
		if (c.state == 2) hovered = c;
	}
	if (selectedBuilding != null) selectedBuilding.getGuiContainer().draw(g);
	if (hovered != null && Game.currentGame.getActiveLayer() instanceof CityHUDLayer) hovered.drawTooltip(GameFrame.currentFrame.mouse.x, GameFrame.currentFrame.mouse.y, g);
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:18,代码来源:CityHUDLayer.java

示例5: getWeaponData

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public WeaponData getWeaponData() {
	WeaponData data = new WeaponData();
	
	for (Component c : components) {
		if (c instanceof WeaponryPart) {
			WeaponryPart p = (WeaponryPart) c;
			data.addPart(p.part, p.x, p.y);
		}
	}
	
	if (auto != null) data.setAutomatic(auto.isSelected());
	
	data.calculateStats();
	
	renderWeaponStats(data);
	
	return data;
}
 
开发者ID:Dakror,项目名称:SpamWars,代码行数:19,代码来源:BuildWeaponLayer.java

示例6: drawGUI

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void drawGUI(Graphics2D g) {
	if (components.size() == 0) initGUI();
	try {
		Helper.drawContainer(guiPoint.x - 125, guiPoint.y - 125, 250, 250, false, false, g);
		Helper.drawHorizontallyCenteredString("Wissenschaft", guiPoint.x - 125, 250, guiPoint.y - 85, g, 40);
		
		drawComponents(guiPoint.x - 125, guiPoint.y - 125, g);
		for (Component c : components) {
			if ((c instanceof ResearchButton)) {
				ResearchButton n = (ResearchButton) c;
				if (n.state != 2) continue;
				
				((ResearchButton) c).drawTooltip(Game.currentGame.mouse.x, Game.currentGame.mouse.y, g);
				break;
			}
		}
	} catch (NullPointerException e) {}
}
 
开发者ID:Dakror,项目名称:VillageDefense,代码行数:20,代码来源:School.java

示例7: drawUpgrades

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public void drawUpgrades(Graphics2D g) {
	if (Game.currentGame.getResearches(researchClass).length == 0) return;
	
	if (components.size() < Researches.values(researchClass).length) initUpgrades();
	try {
		Helper.drawContainer(guiPoint.x - 125, guiPoint.y - 125, 250, 250, false, false, g);
		Helper.drawHorizontallyCenteredString("Verbesserungen", guiPoint.x - 125, 250, guiPoint.y - 85, g, 40);
		
		drawComponents(guiPoint.x - 125, guiPoint.y - 125, g);
		for (Component c : components) {
			if ((c instanceof ResearchButton)) {
				ResearchButton n = (ResearchButton) c;
				if (n.state != 2) continue;
				
				((ResearchButton) c).drawTooltip(Game.currentGame.mouse.x, Game.currentGame.mouse.y, g);
				break;
			}
		}
	} catch (NullPointerException e) {}
}
 
开发者ID:Dakror,项目名称:VillageDefense,代码行数:21,代码来源:Struct.java

示例8: mousePressed

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public boolean mousePressed(MouseEvent e) {
	if (guiPoint != null && guiSize != null) e.translatePoint(-(guiPoint.x - guiSize.width / 2), -(guiPoint.y - guiSize.height / 2));
	
	for (Component c : components)
		c.mousePressed(e);
	
	if (guiPoint != null && guiSize != null) e.translatePoint(guiPoint.x - guiSize.width / 2, guiPoint.y - guiSize.height / 2);
	
	boolean pressed = super.mousePressed(e);
	
	if (pressed && guiPoint == null && guiSize != null) {
		guiPoint = e.getPoint();
		guiPoint.translate(Game.world.x, Game.world.y);
		if (guiPoint.x - guiSize.width / 2 < 0) guiPoint.x = guiSize.width / 2;
		if (guiPoint.y - guiSize.height / 2 < 0) guiPoint.y = guiSize.height / 2;
		if (guiPoint.x + guiSize.width / 2 > Game.getWidth()) guiPoint.x = Game.getWidth() - guiSize.width / 2;
		if (guiPoint.y + guiSize.height / 2 > Game.getHeight()) guiPoint.y = Game.getHeight() - guiSize.height / 2;
	} else {
		if (guiPoint != null && guiSize != null && !new Rectangle(guiPoint.x - guiSize.width / 2, guiPoint.y - guiSize.height / 2, guiSize.width, guiSize.height).contains(e.getPoint())) {
			destroyGUI();
		}
	}
	
	return pressed;
}
 
开发者ID:Dakror,项目名称:VillageDefense,代码行数:27,代码来源:Struct.java

示例9: roam

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
private void roam() {
	Vector t = pos.clone().add(getRandomTarget());
	Rectangle2D r = getBumpFromPosToVector(t);
	if (Game.world.getBump().contains(r)) {
		boolean free = true;
		for (Component c : Game.world.components) {
			if (((Entity) c).getBump().intersects(r) && !c.equals(this)) {
				free = false;
				break;
			}
		}
		
		if (free) target = t;
	}
	
	roamTimeout = (int) (Math.random() * 60) + 60;
}
 
开发者ID:Dakror,项目名称:LiturfaliarCest,代码行数:18,代码来源:NPC.java

示例10: sortComponents

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public void sortComponents() {
	ArrayList<Component> c = new ArrayList<>(components);
	Collections.sort(c, new Comparator<Component>() {
		@Override
		public int compare(Component o1, Component o2) {
			if (o1.getClass().equals(o2.getClass())) return 1;
			if (o1 instanceof Transfer) return -1;
			return 1;
		}
	});
	
	components = new CopyOnWriteArrayList<>(c);
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:14,代码来源:World.java

示例11: mousePressed

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
	e.translatePoint(-x, -y);
	super.mousePressed(e);
	
	anyCityActive = false;
	for (Component c : components) {
		if (c instanceof City && c.state == 1) {
			anyCityActive = true;
			break;
		}
	}
	
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:15,代码来源:World.java

示例12: mouseMoved

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
	e.translatePoint(-x, -y);
	super.mouseMoved(e);
	for (Component c : components) {
		if (c instanceof City && c.state == 2) {
			WorldHUDLayer.hoveredCity = (City) c;
			return;
		}
	}
	WorldHUDLayer.hoveredCity = null;
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:13,代码来源:World.java

示例13: getCityCount

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public int getCityCount() {
	int i = 0;
	for (Component c : components)
		if (c instanceof City) i++;
	
	return i;
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:8,代码来源:World.java

示例14: getSelectedResources

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public Resources getSelectedResources() {
	Resources res = new Resources();
	for (Component c : components) {
		if (c instanceof Slider) {
			for (TroopType t : TroopType.values()) {
				if (((Slider) c).getTitle().equals(t.getType().getName())) {
					res.set(t.getType(), ((Slider) c).getValue());
					break;
				}
			}
		}
	}
	return res;
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:15,代码来源:AttackCityDialog.java

示例15: update

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void update(int tick) {
	components.get(2).enabled = slider.getValue() > 0;
	for (Component c : barracks.getGuiContainer().components)
		c.state = 0; // to remove tooltips
	
	updateComponents(tick);
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:9,代码来源:BuildTroopsDialog.java


注:本文中的de.dakror.gamesetup.ui.Component类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。