Skip to content

Commit

Permalink
new crusade editor and builds in crusade (somewhat unfinished)
Browse files Browse the repository at this point in the history
  • Loading branch information
aehmttw committed Feb 4, 2025
1 parent 56ec05f commit b1dbba8
Show file tree
Hide file tree
Showing 42 changed files with 2,335 additions and 697 deletions.
30 changes: 30 additions & 0 deletions src/main/java/tanks/Crusade.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public CrusadeLevel(String name, String lvl)

public ArrayList<TankAIControlled> customTanks = new ArrayList<>();
public ArrayList<Item.CrusadeShopItem> crusadeShopItems = new ArrayList<>();
public ArrayList<TankPlayer.CrusadeShopTankBuild> crusadeShopBuilds = new ArrayList<>();

public String name = "";
public String fileName = "";
Expand Down Expand Up @@ -154,6 +155,9 @@ public void initialize(ArrayList<String> levelArray, String name)
case "tanks":
parsing = 3;
break;
case "builds":
parsing = 4;
break;
default:
if (parsing == 0)
{
Expand Down Expand Up @@ -193,11 +197,19 @@ else if (parsing == 3)
tankOccurrences.put(t, first);
this.customTanks.add(t);
}
else if (parsing == 4)
{
TankPlayer.CrusadeShopTankBuild t = TankPlayer.CrusadeShopTankBuild.fromString(s);
this.crusadeShopBuilds.add(t);
}
break;
}

i++;
}

if (crusadeShopBuilds.isEmpty())
crusadeShopBuilds.add(new TankPlayer.CrusadeShopTankBuild());

this.name = name;

Expand Down Expand Up @@ -259,6 +271,10 @@ public void loadLevel()
{
livesTotal += player.remainingLives;
playersTotal++;

CrusadePlayer cp = crusadePlayers.get(player);
if (cp.currentBuild == null)
cp.currentBuild = this.crusadeShopBuilds.get(0).name;
}
}

Expand Down Expand Up @@ -457,6 +473,20 @@ public ArrayList<Item.ShopItem> getShop()
return shop;
}

public ArrayList<TankPlayer.ShopTankBuild> getBuildsShop()
{
ArrayList<TankPlayer.ShopTankBuild> shop = new ArrayList<>();

for (int i = 0; i < this.crusadeShopBuilds.size(); i++)
{
TankPlayer.CrusadeShopTankBuild item = this.crusadeShopBuilds.get(i);
if (item.levelUnlock <= this.currentLevel)
shop.add(item);
}

return shop;
}

public void saveHotbars()
{
for (Player p: Game.players)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tanks/CrusadePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import tanks.tank.TankPlayer;

import java.util.HashMap;
import java.util.HashSet;

public class CrusadePlayer
{
public Player player;

public ItemBar itemBar;
public HashSet<String> ownedBuilds = new HashSet<>();
public String currentBuild;

public int coins;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/tanks/Drawing.java
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,6 @@ public void drawConcentricPopup(double x, double y, double sX, double sY, double
{
fillInterfaceRect(x, y, sX - borderWidth * 2, sY - borderWidth * 2, borderRadius * (1.0 - (borderWidth / borderRadius)));
fillInterfaceRect(x, y, sX, sY, borderRadius);
Drawing.drawing.setColor(255, 255, 255);
}

public void playMusic(String sound, float volume, boolean looped, String id, long fadeTime)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/tanks/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public int hashCode()
public static final String savedCrusadePath = directoryPath + "/crusades/progress/";
public static final String itemDir = directoryPath + "/items";
public static final String tankDir = directoryPath + "/tanks";
public static final String buildDir = directoryPath + "/builds";
public static final String extensionDir = directoryPath + "/extensions/";
public static final String crashesPath = directoryPath + "/crashes/";
public static final String screenshotsPath = directoryPath + "/screenshots/";
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/tanks/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class Level
public int startingCoins;
public ArrayList<Item.ShopItem> shop = new ArrayList<>();
public ArrayList<Item.ItemStack<?>> startingItems = new ArrayList<>();
public ArrayList<TankPlayer> playerBuilds = new ArrayList<>();
public ArrayList<TankPlayer.ShopTankBuild> playerBuilds = new ArrayList<>();

// Saved on the client to keep track of what each item is
public int clientStartingCoins;
Expand Down Expand Up @@ -168,7 +168,8 @@ else if (parsing == 4)
}
else if (parsing == 5)
{
TankPlayer t = TankPlayer.fromString(s);
TankPlayer.ShopTankBuild t = TankPlayer.ShopTankBuild.fromString(s);
t.enableTertiaryColor = true;
this.playerBuilds.add(t);
}
else
Expand All @@ -186,7 +187,7 @@ else if (parsing == 2)

if (playerBuilds.isEmpty())
{
TankPlayer tp = new TankPlayer();
TankPlayer.ShopTankBuild tp = new TankPlayer.ShopTankBuild();
playerBuilds.add(tp);
}

Expand Down Expand Up @@ -526,6 +527,9 @@ else if (t.length >= 2)
t.networkID = Tank.nextFreeNetworkID();
Tank.idMap.put(t.networkID, t);

if (sc != null)
t.drawAge = 50;

if (remote)
Game.movables.add(new TankRemote(t));
else
Expand Down Expand Up @@ -710,6 +714,7 @@ else if (!remote)
TankPlayer tank = new TankPlayer(x, y, angle);
this.playerBuilds.get(0).clonePropertiesTo(tank);
Game.playerTank = tank;
Game.player.buildName = tank.buildName;
tank.team = team;
tank.registerNetworkID();
Game.movables.add(tank);
Expand All @@ -722,6 +727,7 @@ else if (!remote)
{
TankSpawnMarker t = new TankSpawnMarker("player", this.playerSpawnsX.get(i), this.playerSpawnsY.get(i), this.playerSpawnsAngle.get(i));
t.team = this.playerSpawnsTeam.get(i);
t.drawAge = 50;
Game.movables.add(t);

if (sc != null)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/tanks/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Player
public UUID clientID;
public String username;
public Tank tank;
public String buildName = "player";

public int colorR = 0;
public int colorG = 150;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/tanks/gui/ButtonList.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public void sortButtons()
buttons.get(i).imageG = this.imageG;
buttons.get(i).imageB = this.imageB;


if (hideText)
buttons.get(i).text = "";
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/tanks/gui/ButtonObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ButtonObject extends Button
public IDrawableForInterface object;
public boolean tempDisableHover = false;
public Runnable drawBeforeTooltip = null;
public boolean showText = false;

public double disabledColA = 127;
public double selectedColA = 64;
Expand Down Expand Up @@ -93,7 +94,7 @@ else if (selected && !Game.game.window.touchscreen)
drawing.fillInterfaceRect(posX, posY - sizeY / 2 + thickness / 2, sizeX - thickness * 2, thickness);
drawing.fillInterfaceRect(posX, posY + sizeY / 2 - thickness / 2, sizeX - thickness * 2, thickness);

if (!this.text.equals(""))
if (!this.text.equals("") && this.showText)
{
drawing.setColor(255, 255, 255);
drawing.setInterfaceFontSize(12);
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/tanks/gui/screen/ITankBuildScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package tanks.gui.screen;

import tanks.tank.TankPlayer;
import tanks.tankson.Pointer;

public interface ITankBuildScreen
{
default Pointer<TankPlayer.ShopTankBuild> addTank(TankPlayer.ShopTankBuild t)
{
return addTank(t, true);
}

Pointer<TankPlayer.ShopTankBuild> addTank(TankPlayer.ShopTankBuild t, boolean select);

void removeTank(TankPlayer t);

void refreshTanks(TankPlayer t);
}
Loading

0 comments on commit b1dbba8

Please sign in to comment.