• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Component类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: mouseDragged

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
	super.mouseDragged(e);
	
	selectedCity = null;
	
	showArrow = hoveredCity != null && hoveredCity.getUserId() == Game.userID && e.getModifiers() == 16; // LMB
	if (showArrow) {
		drag = e.getPoint();
		
		boolean ontoAny = false;
		for (Component c : Game.world.components) {
			if (c instanceof City) {
				if (!c.equals(hoveredCity) && !c.equals(selectedCity)) c.state = 0;
				if (c.contains(drag.x - Game.world.x, drag.y - Game.world.y) && !c.equals(hoveredCity) && !((City) c).isInTakeoverCooldown()) {
					boolean canTarget = true;
					
					for (Component c1 : Game.world.components) {
						if (c1 instanceof Transfer && ((Transfer) c1).getCityFrom().equals(hoveredCity) && ((Transfer) c1).getCityTo().equals(c)) {
							canTarget = false;
							break;
						}
					}
					
					if (!canTarget) continue;
					
					drag = new Point(c.getX() + Game.world.x + City.SIZE / 2, c.getY() + Game.world.y + City.SIZE / 2);
					draggedOnto = (City) c;
					draggedOnto.state = 2;
					ontoAny = true;
				}
			}
		}
		
		if (!ontoAny) draggedOnto = null;
	}
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:38,代码来源:WorldHUDLayer.java


示例17: intersectsBuildings

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
public boolean intersectsBuildings(Rectangle r) {
	for (Component c : components)
		if (c instanceof Building
				&& new Rectangle(c.getX() + ((Building) c).bx * Building.GRID, c.getY() + ((Building) c).by * Building.GRID, ((Building) c).bw * Building.GRID, ((Building) c).bh
						* Building.GRID).intersects(r)) return true;
	
	return false;
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:9,代码来源:CityLayer.java


示例18: mousePressed

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
	if (CityHUDLayer.anyComponentClicked) return;
	super.mousePressed(e);
	
	boolean anyBuildingActive = false;
	for (Component c : components) {
		if (c instanceof Building && c.state == 1) {
			anyBuildingActive = true;
			break;
		}
	}
	
	if (!anyBuildingActive) CityHUDLayer.selectedBuilding = null;
	
	if (activeBuilding != null) {
		if (e.getButton() == MouseEvent.BUTTON1 && Game.applet.getCursor().equals(Cursor.getDefaultCursor())) {
			int x = Helper.round(Game.currentGame.mouse.x - activeBuilding.getWidth() / 2, Building.GRID);
			int y = Helper.round(Game.currentGame.mouse.y - activeBuilding.getHeight() / 2, Building.GRID);
			
			try {
				Game.client.sendPacket(new Packet08PlaceBuilding(city.getId(), activeBuilding.getTypeId(), x / 32, y / 32));
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		if (e.getButton() == MouseEvent.BUTTON3) {
			activeBuilding = null;
			Game.applet.setCursor(Cursor.getDefaultCursor());
		}
	}
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:33,代码来源:CityLayer.java


示例19: 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) {
			return Integer.compare(o1.getY() + ((Building) o1).by * Building.GRID, o2.getY() + ((Building) o2).by * Building.GRID);
		}
	});
	
	components = new CopyOnWriteArrayList<>(c);
}
 
开发者ID:Dakror,项目名称:Arise,代码行数:12,代码来源:CityLayer.java


示例20: mouseMoved

import de.dakror.gamesetup.ui.Component; //导入依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
	if (!enabled) return;
	
	e.translatePoint(-x, -y);
	
	for (Component c : buttons)
		c.mouseMoved(e);
	e.translatePoint(x, y);
}
 
开发者ID:Dakror,项目名称:SpamWars,代码行数:11,代码来源:WeaponryGroup.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IndexableBinaryStringTools类代码示例发布时间:2022-05-22
下一篇:
Java JPAApi类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap