Skip to content

Commit

Permalink
- Got changing ships working
Browse files Browse the repository at this point in the history
- Got capturing flags working
  • Loading branch information
Asser authored and Asser committed Jun 16, 2017
1 parent e2c41e7 commit c727db2
Show file tree
Hide file tree
Showing 53 changed files with 2,920 additions and 2,395 deletions.
2 changes: 1 addition & 1 deletion sim-eth-es/.gradle/2.13/taskArtifacts/cache.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#Sat May 27 14:47:45 CEST 2017
#Fri Jun 16 22:33:54 CEST 2017
Binary file modified sim-eth-es/.gradle/2.13/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified sim-eth-es/.gradle/2.13/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified sim-eth-es/.gradle/2.13/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified sim-eth-es/.gradle/2.13/taskArtifacts/taskArtifacts.bin
Binary file not shown.
4,489 changes: 2,229 additions & 2,260 deletions sim-eth-es/application.log

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions sim-eth-es/assets/Materials/FlagMaterial.j3m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Material BombMaterial : MatDefs/AnimateSpriteShader.j3md {
MaterialParameters {
AniTexMap : Flip Textures/Subspace/flag.bm2
numTilesX : 10
numTilesY : 2
Speed : 20
numTilesOffsetX : 0
numTilesOffsetY : 0
}
AdditionalRenderState {
Blend Alpha
Wireframe Off
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 6 additions & 2 deletions sim-eth-es/src/main/java/example/GameSessionState.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@
import example.net.chat.ChatSessionListener;
import example.net.chat.client.ChatClientService;
import example.view.CameraState;
import example.view.ClientMapState;
import example.view.FlagStateClient;
import example.view.MapStateClient;
import example.view.HudLabelState;
import example.view.MapEditorState;
import example.view.ModelViewState;
import example.view.PlayerListState;
import example.view.PlayerMovementState;
import example.view.SISpatialFactory;
import example.view.ShipFrequencyStateClient;
import example.view.SkyState;
import example.view.SpaceGridState;

Expand Down Expand Up @@ -93,12 +95,14 @@ public GameSessionState() {
// add normal states on the super-constructor
super(new MessageState(),
new TimeState(), // Has to be before any visuals that might need it.
new ClientMapState(),
new MapStateClient(),
new SkyState(),
new PlayerMovementState(),
new CameraState(),
new HudLabelState(),
new SpaceGridState(GameConstants.GRID_CELL_SIZE, 10, new ColorRGBA(0.8f, 1f, 1f, 0.5f)),
new ShipFrequencyStateClient(),
new FlagStateClient(),
new ModelViewState(new SISpatialFactory())
//new MapEditorState()
);
Expand Down
1 change: 1 addition & 0 deletions sim-eth-es/src/main/java/example/PhysicsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PhysicsConstants {
public final static double OVER5SIZERADIUS = 0.1;
public final static double OVER1SIZERADIUS = 0.5;
public final static double OVER2SIZERADIUS = 1;
public final static double FLAGSIZERADIUS = 0.5;

//Weights
public final static double SHIPMASS = 50;
Expand Down
1 change: 1 addition & 0 deletions sim-eth-es/src/main/java/example/ViewConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ViewConstants {
public final static float BOUNTYSIZE = 1f;
public final static float SHIPSIZE = 2f;
public final static float MAPTILESIZE = 1f;
public final static float FLAGSIZE = 1;


public final static float EXPLOSION2SIZE = 2f;
Expand Down
14 changes: 14 additions & 0 deletions sim-eth-es/src/main/java/example/es/Flag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package example.es;

import com.simsilica.es.EntityComponent;

/**
*
* @author Asser
*/
public class Flag implements EntityComponent{

public Flag() {
}

}
8 changes: 6 additions & 2 deletions sim-eth-es/src/main/java/example/es/Frequency.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
*
* @author Asser
*/
public class Frequency implements EntityComponent{
public class Frequency implements EntityComponent {

private int freq;

public Frequency() {

}

public Frequency(int freq) {
this.freq = freq;
}
Expand Down
5 changes: 3 additions & 2 deletions sim-eth-es/src/main/java/example/es/PhysicsMassTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class PhysicsMassTypes {
* Indicates that the mass is normal, but we want CCD enabled
*/
public static final String NORMAL_BULLET = "Normal_bullet";

public static PhysicsMassType normal(EntityData ed) {
return PhysicsMassType.create(NORMAL, ed);
}
Expand All @@ -52,7 +52,8 @@ public static PhysicsMassType fixedLinearVelocity(EntityData ed) {
return PhysicsMassType.create(FIXED_LINEAR_VELOCITY, ed);
}

public static PhysicsMassType normal_bullet(EntityData ed){
public static PhysicsMassType normal_bullet(EntityData ed) {
return PhysicsMassType.create(NORMAL_BULLET, ed);
}

}
3 changes: 1 addition & 2 deletions sim-eth-es/src/main/java/example/es/PhysicsShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ public class PhysicsShape implements EntityComponent {
BodyFixture fixture;

//Doesn't need empty serialization constructor because it will not be sent to client
public PhysicsShape(BodyFixture fixture, CategoryFilter collisionFilter) {
public PhysicsShape(BodyFixture fixture) {
this.fixture = fixture;
this.fixture.setFilter(collisionFilter);
}

public BodyFixture getFixture() {
Expand Down
36 changes: 0 additions & 36 deletions sim-eth-es/src/main/java/example/es/ShipType.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
/*
* $Id$
*
* Copyright (c) 2016, Simsilica, LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package example.es;

import com.simsilica.es.EntityComponent;
Expand Down
32 changes: 24 additions & 8 deletions sim-eth-es/src/main/java/example/es/ViewTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,44 @@ public class ViewTypes {
public static final String WORMHOLE = "wormhole";
public static final String WARP = "warp";
public static final String REPEL = "repel";
public static final String FLAG_OURS = "flag_ours";
public static final String FLAG_THEIRS = "flag_theirs";

/*
The different ships
*/
*/
public static ViewType ship_warbird(EntityData ed) {
return ViewType.create(SHIP_WARBIRD, ed);
}

public static ViewType ship_javelin(EntityData ed) {
return ViewType.create(SHIP_JAVELIN, ed);
}

public static ViewType ship_spider(EntityData ed) {
return ViewType.create(SHIP_SPIDER, ed);
}

public static ViewType ship_levi(EntityData ed) {
return ViewType.create(SHIP_LEVI, ed);
}

public static ViewType ship_terrier(EntityData ed) {
return ViewType.create(SHIP_TERRIER, ed);
}

public static ViewType ship_weasel(EntityData ed) {
return ViewType.create(SHIP_WEASEL, ed);
}

public static ViewType ship_lanc(EntityData ed) {
return ViewType.create(SHIP_LANCASTER, ed);
}

public static ViewType ship_shark(EntityData ed) {
return ViewType.create(SHIP_SHARK, ed);
}


public static ViewType gravSphereType(EntityData ed) {
return ViewType.create(GRAV_SPHERE, ed);
}
Expand Down Expand Up @@ -110,16 +118,24 @@ public static ViewType over5(EntityData ed) {
public static ViewType over1(EntityData ed) {
return ViewType.create(OVER1, ed);
}
public static ViewType warp(EntityData ed){

public static ViewType warp(EntityData ed) {
return ViewType.create(WARP, ed);
}
public static ViewType repel(EntityData ed){

public static ViewType repel(EntityData ed) {
return ViewType.create(REPEL, ed);
}
public static ViewType over2(EntityData ed){

public static ViewType over2(EntityData ed) {
return ViewType.create(OVER2, ed);
}

public static ViewType flag_ours(EntityData ed){
return ViewType.create(FLAG_OURS, ed);
}

public static ViewType flag_theirs(EntityData ed){
return ViewType.create(FLAG_THEIRS, ed);
}
}
69 changes: 69 additions & 0 deletions sim-eth-es/src/main/java/example/es/states/FlagStateServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package example.es.states;

import com.simsilica.es.Entity;
import com.simsilica.es.EntityData;
import com.simsilica.es.EntityId;
import com.simsilica.es.EntitySet;
import com.simsilica.sim.AbstractGameSystem;
import com.simsilica.sim.SimTime;
import example.es.Flag;
import example.es.Frequency;
import org.dyn4j.collision.manifold.Manifold;
import org.dyn4j.dynamics.BodyFixture;

/**
*
* @author Asser
*/
public class FlagStateServer extends AbstractGameSystem {

private EntityData ed;
private EntitySet teamFlags;
private ShipFrequencyStateServer shipState;

@Override
protected void initialize() {
this.ed = getSystem(EntityData.class);

teamFlags = ed.getEntities(Flag.class, Frequency.class);

shipState = getSystem(ShipFrequencyStateServer.class);
}

@Override
protected void terminate() {
teamFlags.release();
teamFlags = null;

}

public boolean isFlag(EntityId flagEntityId){
return teamFlags.getEntityIds().contains(flagEntityId);
}

@Override
public void update(SimTime tpf) {
teamFlags.applyChanges();
}

@Override
public void start() {
}

@Override
public void stop() {
}

public void collide(org.dyn4j.dynamics.Body body1, BodyFixture fixture1, org.dyn4j.dynamics.Body body2, BodyFixture fixture2, Manifold manifold, double tpf) {
EntityId one = (EntityId) body1.getUserData();
EntityId two = (EntityId) body2.getUserData();

if (teamFlags.getEntityIds().contains(one)) {
int freq = shipState.getFrequency(two);
ed.setComponent(one, new Frequency(freq));
} else if (teamFlags.getEntityIds().contains(two)) {
int freq = shipState.getFrequency(one);
ed.setComponent(two, new Frequency(freq));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @author Asser
*/
public class ShipState extends AbstractGameSystem {
public class GateState extends AbstractGameSystem {

private Ships shipContainer;
private EntityData ed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Asser
*/
public class ServerMapState extends AbstractGameSystem {
public class MapStateServer extends AbstractGameSystem {

private TMXMapReader reader;
private EntityData ed;
Expand Down Expand Up @@ -58,7 +58,7 @@ public void createEntitiesFromMap(LevelFile map, Vec3d arenaOffset) {
short s = tiles[xpos][ypos];
if (s != 0) {
//TODO: Check on the short and only create the map tiles, not the extras (asteroids, wormholes etc.)
/*
/* TILE STATUS
Row 2, tile 1 - Border tile
Row 9, tile 10 - Vertical warpgate (Mostly open)
Row 9, tile 11 - Vertical warpgate (Frequently open)
Expand All @@ -68,7 +68,7 @@ public void createEntitiesFromMap(LevelFile map, Vec3d arenaOffset) {
Row 9, tile 15 - Horizontal warpgate (Frequently open)
Row 9, tile 16 - Horizontal warpgate (Frequently closed)
Row 9, tile 17 - Horizontal warpgate (Mostly closed)
Row 9, tile 18 - Flag for turf
170 DONE Row 9, tile 18 - Flag for turf
Row 9, tile 19 - Safezone
Row 10, tile 1 - Soccer goal (leave blank if you want)
Row 10, tile 2 - Flyover tile
Expand All @@ -92,6 +92,10 @@ public void createEntitiesFromMap(LevelFile map, Vec3d arenaOffset) {
*/
Vec3d location = new Vec3d(xpos, -ypos, 0).add(arenaOffset);
switch (s) {
case 170:
//Turf flag
GameEntities.createCaptureTheFlag(location, ed);
break;
case 216:
GameEntities.createOver1(location, ed);
break;
Expand Down
Loading

0 comments on commit c727db2

Please sign in to comment.