Skip to content
Snippets Groups Projects
Commit 2191b4da authored by ODL guest ODL guest's avatar ODL guest ODL guest
Browse files

Merge branch 'master' of git.fossgalaxy.com:ce810/ggj2017

parents 3eeec671 85bed689
No related branches found
No related tags found
No related merge requests found
package com.fossgalaxy.games.ggj2017;
import org.codetome.hexameter.core.api.CubeCoordinate;
import com.fossgalaxy.games.rts.GameState;
import com.fossgalaxy.games.rts.entity.Entity;
import com.fossgalaxy.games.rts.order.MoveOrder;
public class DroneMovement extends MoveOrder {
public DroneMovement(CubeCoordinate move) {
super(move);
}
@Override
public void doOrder(Entity entity, GameState state) {
if (!JamApp.isZoneOfControl(state, entity)) {
return;
}
super.doOrder(entity, state);
}
}
......@@ -36,6 +36,23 @@ import com.fossgalaxy.games.rts.ui.UIController;
*/
public class JamApp
{
public static boolean isZoneOfControl(GameState state, Entity curr) {
Collection<Entity> entities = state.getOwnedEntities(curr.getOwner());
for (Entity e : entities) {
Integer zoneDistance = e.getType().getProperty("controlSignal");
if (zoneDistance != null) {
int distance = state.getDistance(e.getPos(), curr.getPos());
if (distance <= zoneDistance) {
return true;
}
}
}
return false;
}
public static void main( String[] args )
{
......@@ -116,6 +133,7 @@ public class JamApp
frame.add(view);
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
JButton moveBtn = new JButton("Move");
moveBtn.addActionListener(a -> {
......@@ -132,7 +150,15 @@ public class JamApp
});
toolbar.add(rangedAttackBtn);
toolbar.add(new JButton("Deploy Pigeon"));
JButton turnDone = new JButton("done");
turnDone.addActionListener(a -> {
model.done();
view.repaint();
});
toolbar.addSeparator();
toolbar.add(turnDone);
frame.add(toolbar, BorderLayout.SOUTH);
frame.pack();
......
......@@ -3,9 +3,11 @@ package com.fossgalaxy.games.ggj2017;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Area;
import java.awt.image.BufferedImage;
import java.util.Collection;
import org.codetome.hexameter.core.api.CubeCoordinate;
......@@ -14,6 +16,7 @@ import org.codetome.hexameter.core.api.Hexagon;
import com.fossgalaxy.games.rts.GameState;
import com.fossgalaxy.games.rts.entity.Entity;
import com.fossgalaxy.games.rts.entity.HexagonTile;
import com.fossgalaxy.games.rts.io.SpriteRegistry;
import com.fossgalaxy.games.rts.order.MoveOrder;
import com.fossgalaxy.games.rts.order.Order;
import com.fossgalaxy.games.rts.ui.GameAction;
......@@ -29,8 +32,18 @@ public class MoveAction implements GameAction {
return;
}
if (!JamApp.isZoneOfControl(s, actor)) {
SpriteRegistry sr = SpriteRegistry.INSTANCE;
BufferedImage img = sr.getImage("ui/no-signal");
Hexagon<HexagonTile> ht = s.cube2hex(actor.getPos());
g.drawImage(img, (int)ht.getCenterX() - 25, (int)ht.getCenterY() - 25, 50, 50, null);
return;
}
Collection<Hexagon<HexagonTile>> range = s.getRange(actor.getPos(), actor.getType().getMovement());
System.out.println(range);
Area area = new Area();
......@@ -55,7 +68,7 @@ public class MoveAction implements GameAction {
@Override
public Order generateOrder(CubeCoordinate co, GameState s) {
return new MoveOrder(co);
return new DroneMovement(co);
}
@Override
......
src/main/resources/img/ui/no-signal.png

33.7 KiB

[
{
"name": "blue_drone",
"image": "blue/enemyBlue1",
"sprite": {
"image": "blue/enemyBlue1"
},
"movement": 2,
"health": 10,
"attackRange": 2,
......@@ -14,7 +16,9 @@
},
{
"name": "blue_worker",
"image": "blue/enemyBlue4",
"sprite": {
"image": "blue/enemyBlue4"
},
"movement": 2,
"health": 10,
"attackRange": 0,
......@@ -27,7 +31,12 @@
},
{
"name": "blue_base",
"image": "blue/ufoBlue",
"sprite": {
"image": "blue/ufoBlue"
},
"properties": {
"controlSignal": 10
},
"movement": 0,
"health": 10,
"attackRange": 2,
......@@ -40,7 +49,9 @@
},
{
"name": "red_drone",
"image": "red/enemyRed1",
"sprite": {
"image": "red/enemyRed1"
},
"movement": 2,
"health": 10,
"attackRange": 2,
......@@ -53,7 +64,9 @@
},
{
"name": "red_worker",
"image": "red/enemyRed4",
"sprite": {
"image": "red/enemyRed4"
},
"movement": 2,
"health": 10,
"attackRange": 2,
......@@ -66,7 +79,9 @@
},
{
"name": "red_base",
"image": "/ufoRed",
"sprite": {
"image": "red/ufoRed"
},
"movement": 0,
"health": 10,
"attackRange": 2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment