├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── CastleWars │ ├── Main.java │ ├── data │ ├── Icon.java │ ├── PlayerData.java │ └── UnitDeathData.java │ ├── game │ ├── Generator.java │ └── Logic.java │ └── logic │ ├── CoreRoom.java │ ├── ResourceRoom.java │ ├── Room.java │ ├── RoomComp.java │ ├── TurretRoom.java │ └── UnitRoom.java └── resources └── plugin.json /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | 4 | # Ignore Gradle GUI config 5 | gradle-app.setting 6 | 7 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 8 | !gradle-wrapper.jar 9 | 10 | # Cache of project 11 | .gradletasknamecache 12 | 13 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 14 | # gradle/wrapper/gradle-wrapper.properties 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Xusk947 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CastleWars -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | repositories{ 4 | mavenCentral() 5 | maven{ url 'https://www.jitpack.io' } 6 | } 7 | 8 | ext{ 9 | mindustryVersion = 'v121' 10 | gsonVersion = '2.8.6' 11 | } 12 | 13 | dependencies{ 14 | compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion" 15 | compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion" 16 | 17 | implementation "com.google.code.gson:gson:$gsonVersion" 18 | } 19 | 20 | jar{ 21 | from{configurations.runtimeClasspath.collect{it.isDirectory() ? it : zipTree(it)}} 22 | } 23 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xusk947/CastleWars/d6b1c7ebf9032843aa9c1a1c6835322a42b0ebb5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'CastleWars' 2 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/Main.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xusk947/CastleWars/d6b1c7ebf9032843aa9c1a1c6835322a42b0ebb5/src/main/java/CastleWars/Main.java -------------------------------------------------------------------------------- /src/main/java/CastleWars/data/Icon.java: -------------------------------------------------------------------------------- 1 | package CastleWars.data; 2 | 3 | import arc.struct.ObjectMap; 4 | import mindustry.content.Blocks; 5 | import mindustry.content.Items; 6 | import mindustry.content.UnitTypes; 7 | import mindustry.ctype.Content; 8 | import mindustry.gen.Iconc; 9 | 10 | public class Icon { 11 | 12 | public static ObjectMap icons = new ObjectMap<>(); 13 | 14 | public static void load() { 15 | // Ground 16 | icons.put(UnitTypes.dagger, Iconc.unitDagger); 17 | icons.put(UnitTypes.mace, Iconc.unitMace); 18 | icons.put(UnitTypes.fortress, Iconc.unitFortress); 19 | icons.put(UnitTypes.scepter, Iconc.unitScepter); 20 | icons.put(UnitTypes.reign, Iconc.unitReign); 21 | // Ground Support 22 | icons.put(UnitTypes.nova, Iconc.unitNova); 23 | icons.put(UnitTypes.pulsar, Iconc.unitPulsar); 24 | icons.put(UnitTypes.quasar, Iconc.unitQuasar); 25 | icons.put(UnitTypes.vela, Iconc.unitVela); 26 | icons.put(UnitTypes.corvus, Iconc.unitCorvus); 27 | // Spiders 28 | icons.put(UnitTypes.crawler, Iconc.unitCrawler); 29 | icons.put(UnitTypes.atrax, Iconc.unitAtrax); 30 | icons.put(UnitTypes.spiroct, Iconc.unitSpiroct); 31 | icons.put(UnitTypes.arkyid, Iconc.unitArkyid); 32 | icons.put(UnitTypes.toxopid, Iconc.unitToxopid); 33 | // Naval 34 | icons.put(UnitTypes.risso, Iconc.unitRisso); 35 | icons.put(UnitTypes.minke, Iconc.unitMinke); 36 | icons.put(UnitTypes.bryde, Iconc.unitBryde); 37 | icons.put(UnitTypes.sei, Iconc.unitSei); 38 | icons.put(UnitTypes.omura, Iconc.unitOmura); 39 | // Cores 40 | icons.put(Blocks.coreNucleus, Iconc.blockCoreNucleus); 41 | icons.put(Blocks.coreFoundation, Iconc.blockCoreFoundation); 42 | icons.put(Blocks.coreShard, Iconc.blockCoreShard); 43 | // Turrets 44 | icons.put(Blocks.foreshadow, Iconc.blockForeshadow); 45 | icons.put(Blocks.meltdown, Iconc.blockMeltdown); 46 | icons.put(Blocks.spectre, Iconc.blockSpectre); 47 | icons.put(Blocks.cyclone, Iconc.blockCyclone); 48 | icons.put(Blocks.ripple, Iconc.blockRipple); 49 | icons.put(Blocks.fuse, Iconc.blockFuse); 50 | icons.put(Blocks.segment, Iconc.blockSegment); 51 | icons.put(Blocks.lancer, Iconc.blockLancer); 52 | icons.put(Blocks.swarmer, Iconc.blockSwarmer); 53 | icons.put(Blocks.salvo, Iconc.blockSalvo); 54 | // Items 55 | icons.put(Items.thorium, Iconc.itemThorium); 56 | icons.put(Items.plastanium, Iconc.itemPlastanium); 57 | icons.put(Items.phaseFabric, Iconc.itemPhaseFabric); 58 | // Some stuff xd 59 | icons.put(Blocks.duo, Iconc.defense); 60 | icons.put(Blocks.commandCenter, Iconc.units); 61 | icons.put(Blocks.plastaniumCompressor, Iconc.blockPlastaniumCompressor); 62 | } 63 | 64 | public static String get(Content item) { 65 | if (icons.containsKey(item)) { 66 | return icons.get(item).toString(); 67 | } 68 | return ""; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/data/PlayerData.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xusk947/CastleWars/d6b1c7ebf9032843aa9c1a1c6835322a42b0ebb5/src/main/java/CastleWars/data/PlayerData.java -------------------------------------------------------------------------------- /src/main/java/CastleWars/data/UnitDeathData.java: -------------------------------------------------------------------------------- 1 | package CastleWars.data; 2 | 3 | import arc.Events; 4 | import arc.struct.ObjectMap; 5 | import mindustry.content.UnitTypes; 6 | import mindustry.game.EventType; 7 | import mindustry.gen.Call; 8 | import mindustry.type.UnitType; 9 | 10 | public class UnitDeathData { 11 | 12 | public static ObjectMap cost; 13 | 14 | public static void init() { 15 | cost = new ObjectMap<>(); 16 | 17 | // Ground 18 | cost.put(UnitTypes.dagger, 40); 19 | cost.put(UnitTypes.mace, 72); 20 | cost.put(UnitTypes.fortress, 250); 21 | cost.put(UnitTypes.scepter, 1200); 22 | cost.put(UnitTypes.reign, 3500); 23 | 24 | // GroundSupport 25 | cost.put(UnitTypes.nova, 50); 26 | cost.put(UnitTypes.pulsar, 80); 27 | cost.put(UnitTypes.quasar, 300); 28 | cost.put(UnitTypes.vela, 1000); 29 | cost.put(UnitTypes.corvus, 6000); 30 | 31 | // Naval 32 | cost.put(UnitTypes.risso, 75); 33 | cost.put(UnitTypes.minke, 150); 34 | cost.put(UnitTypes.bryde, 300); 35 | cost.put(UnitTypes.sei, 2500); 36 | cost.put(UnitTypes.omura, 6500); 37 | // Spiders 38 | cost.put(UnitTypes.crawler, 20); 39 | cost.put(UnitTypes.atrax, 80); 40 | cost.put(UnitTypes.spiroct, 150); 41 | cost.put(UnitTypes.arkyid, 1300); 42 | cost.put(UnitTypes.toxopid, 5000); 43 | 44 | // Air ?xd 45 | cost.put(UnitTypes.flare, 25); 46 | cost.put(UnitTypes.horizon, 50); 47 | cost.put(UnitTypes.zenith, 250); 48 | cost.put(UnitTypes.antumbra, 2500); 49 | cost.put(UnitTypes.eclipse, 5000); 50 | 51 | // Support Air | lol? 52 | cost.put(UnitTypes.mono, 50); 53 | cost.put(UnitTypes.poly, 100); 54 | cost.put(UnitTypes.mega, 300); 55 | cost.put(UnitTypes.quad, 1500); 56 | cost.put(UnitTypes.oct, 10000); 57 | 58 | // Core 59 | cost.put(UnitTypes.alpha, 100); 60 | cost.put(UnitTypes.beta, 150); 61 | cost.put(UnitTypes.gamma, 250); 62 | 63 | // Block xd | oh no 64 | cost.put(UnitTypes.block, 100); 65 | 66 | Events.on(EventType.UnitDestroyEvent.class, event -> { 67 | if (cost.containsKey(event.unit.type)) { 68 | for (PlayerData data : PlayerData.datas.values()) { 69 | if (event.unit.team != data.player.team() && !event.unit.spawnedByCore) { 70 | int m = get(event.unit.type); 71 | data.money += m; 72 | Call.label(data.player.con, "[lime]" + m, 0.5f, event.unit.x, event.unit.y); 73 | } 74 | } 75 | } 76 | }); 77 | } 78 | 79 | public static int get(UnitType type) { 80 | return cost.get(type); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/game/Generator.java: -------------------------------------------------------------------------------- 1 | package CastleWars.game; 2 | 3 | import CastleWars.Main; 4 | import CastleWars.logic.CoreRoom; 5 | import CastleWars.logic.ResourceRoom; 6 | import CastleWars.logic.Room; 7 | import CastleWars.logic.TurretRoom; 8 | import CastleWars.logic.UnitRoom; 9 | import arc.func.Cons; 10 | import arc.struct.Seq; 11 | import arc.util.Timer; 12 | import mindustry.Vars; 13 | import mindustry.content.Blocks; 14 | import mindustry.content.Items; 15 | import mindustry.content.UnitTypes; 16 | import mindustry.game.Gamemode; 17 | import mindustry.game.Team; 18 | import mindustry.game.Teams; 19 | import mindustry.type.UnitType; 20 | import mindustry.world.Block; 21 | import mindustry.world.Tile; 22 | import mindustry.world.Tiles; 23 | import mindustry.world.blocks.storage.CoreBlock; 24 | 25 | public class Generator implements Cons { 26 | 27 | Tiles saved; 28 | int width, height; 29 | Seq cores; 30 | 31 | public Generator() { 32 | cores = new Seq<>(); 33 | 34 | Vars.world.loadMap(Vars.maps.getNextMap(Gamemode.pvp, Vars.state.map), Main.rules.copy()); 35 | saved = Vars.world.tiles; 36 | width = saved.width; 37 | height = saved.height * 2 + (Room.ROOM_SIZE * 6); 38 | } 39 | 40 | public Seq run() { 41 | Vars.world.loadGenerator(width, height, this); 42 | for (Teams.TeamData teamData : Vars.state.teams.active) { 43 | for (CoreBlock.CoreBuild core : teamData.cores) { 44 | core.kill(); 45 | } 46 | } 47 | return cores; 48 | } 49 | 50 | @Override 51 | public void get(Tiles t) { 52 | for (int x = 0; x < t.width; x++) { 53 | for (int y = 0; y < t.height; y++) { 54 | t.set(x, y, new Tile(x, y, Blocks.space, Blocks.air, Blocks.air)); 55 | } 56 | } 57 | for (int x = 0; x < t.width; x++) { 58 | for (int y = 0; y < saved.height; y++) { 59 | t.getn(x, y).setFloor(saved.getn(x, y).floor()); 60 | t.getn(x, y).setBlock(saved.getn(x, y).block()); 61 | int yy = y + saved.height + (Room.ROOM_SIZE * 6); 62 | t.getn(x, yy).setFloor(saved.getn(x, y).floor()); 63 | if (!saved.getn(x, y).block().isAir()) { 64 | t.getn(x, yy).setBlock(saved.getn(x, y).block()); 65 | } 66 | } 67 | } 68 | postGeneration(t); 69 | } 70 | 71 | public void postGeneration(Tiles t) { 72 | for (int x = 0; x < t.width; x++) { 73 | for (int y = 0; y < saved.height; y++) { 74 | int yy = y + saved.height + (Room.ROOM_SIZE * 6); 75 | // Core Build 76 | if (saved.getn(x, y).floor().equals(Blocks.darkPanel1)) { 77 | final int cx = x, cy = y, cyy = yy; 78 | Timer.schedule(() -> { 79 | t.getn(cx, cy).setNet(Blocks.coreShard, Team.sharded, 0); 80 | t.getn(cx, cyy).setNet(Blocks.coreShard, Team.blue, 0); 81 | }, 1); 82 | 83 | cores.add(t.getn(x, y)); 84 | cores.add(t.getn(x, yy)); 85 | 86 | addCoreRoom(t.getn(x, y), yy); 87 | } 88 | // Turret Build 89 | if (saved.getn(x, y).floor().equals(Blocks.darkPanel3)) { 90 | turretGen(t.getn(x, y), yy); 91 | } 92 | // Spawners place 93 | if (saved.getn(x, y).floor().equals(Blocks.darkPanel2)) { 94 | UnitRoom.shardedSpawn = t.get(x, y); 95 | UnitRoom.blueSpawn = t.get(x, yy); 96 | } 97 | } 98 | } 99 | // UnitShop in centre 100 | unitInit(t); 101 | 102 | for (Room room : Room.rooms) { 103 | room.spawn(t); 104 | } 105 | } 106 | 107 | private void unitInit(Tiles t) { 108 | int cx = 2, cy = saved.height + 2; 109 | int Padding = Room.ROOM_SIZE + 2; 110 | // Ground 111 | addUnit(UnitTypes.dagger, cx, cy + 2, 50, 0); 112 | addUnit(UnitTypes.mace, cx + Padding, cy + 2, 100, 1); 113 | addUnit(UnitTypes.fortress, cx + Padding * 2, cy + 2, 300, 3); 114 | addUnit(UnitTypes.scepter, cx + Padding * 3, cy + 2, 2400, 24); 115 | addUnit(UnitTypes.reign, cx + Padding * 4, cy + 2, 7000, 70); 116 | // Support 117 | cx += 2; 118 | addUnit(UnitTypes.nova, cx + Padding * 5, cy + 2, 60, 0); 119 | addUnit(UnitTypes.pulsar, cx + Padding * 6, cy + 2, 120, 1); 120 | addUnit(UnitTypes.quasar, cx + Padding * 7, cy + 2, 400, 4); 121 | addUnit(UnitTypes.vela, cx + Padding * 8, cy + 2, 2000, 20); 122 | addUnit(UnitTypes.corvus, cx + Padding * 9, cy + 2, 8000, 80); 123 | // Spiders 124 | cx -= 2; 125 | addUnit(UnitTypes.crawler, cx, cy + 2 + Padding * 2, 40, 0); 126 | addUnit(UnitTypes.atrax, cx + Padding, cy + 2 + Padding * 2, 100, 1); 127 | addUnit(UnitTypes.spiroct, cx + Padding * 2, cy + 2 + Padding * 2, 300, 3); 128 | addUnit(UnitTypes.arkyid, cx + Padding * 3, cy + 2 + Padding * 2, 2600, 26); 129 | addUnit(UnitTypes.toxopid, cx + Padding * 4, cy + 2 + Padding * 2, 9000, 90); 130 | // Naval 131 | cx += 2; 132 | addUnit(UnitTypes.risso, cx + Padding * 5, cy + 2 + Padding * 2, 250, 2); 133 | addUnit(UnitTypes.minke, cx + Padding * 6, cy + 2 + Padding * 2, 350, 3); 134 | addUnit(UnitTypes.bryde, cx + Padding * 7, cy + 2 + Padding * 2, 800, 8); 135 | addUnit(UnitTypes.sei, cx + Padding * 8, cy + 2 + Padding * 2, 3500, 32); 136 | addUnit(UnitTypes.omura, cx + Padding * 9, cy + 2 + Padding * 2, 10000, 100); 137 | } 138 | 139 | private void turretGen(Tile tile, int yy) { 140 | // ForeShadow 141 | if (tile.nearby(1, 1).floor().equals(Blocks.darkPanel6) 142 | && tile.nearby(-1, -1).floor().equals(Blocks.darkPanel6) 143 | && tile.nearby(-1, 1).floor().equals(Blocks.darkPanel6) 144 | && tile.nearby(1, -1).floor().equals(Blocks.darkPanel6)) { 145 | addTurret(Blocks.foreshadow, tile, yy, 4000, 5); 146 | } // Spectre 147 | else if (tile.nearby(1, 1).floor().equals(Blocks.darkPanel4) 148 | && tile.nearby(-1, -1).floor().equals(Blocks.darkPanel4) 149 | && tile.nearby(-1, 1).floor().equals(Blocks.darkPanel4) 150 | && tile.nearby(1, -1).floor().equals(Blocks.darkPanel4)) { 151 | addTurret(Blocks.spectre, tile, yy, 3000, 5); 152 | } // MeltDown 153 | else if (tile.nearby(1, 1).floor().equals(Blocks.darkPanel6) 154 | && tile.nearby(-1, -1).floor().equals(Blocks.darkPanel6)) { 155 | addTurret(Blocks.meltdown, tile, yy, 2500, 5); 156 | } // Cyclone 157 | else if (tile.nearby(1, 1).floor().equals(Blocks.darkPanel4) 158 | && tile.nearby(-1, -1).floor().equals(Blocks.darkPanel4)) { 159 | addTurret(Blocks.cyclone, tile, yy, 1300, 4); 160 | } // Ripple 161 | else if (tile.nearby(0, 1).floor().equals(Blocks.darkPanel4) 162 | && tile.nearby(0, -1).floor().equals(Blocks.darkPanel4)) { 163 | addTurret(Blocks.ripple, tile, yy, 1700, 4); 164 | } // Fuse 165 | else if (tile.nearby(1, 0).floor().equals(Blocks.darkPanel4) 166 | && tile.nearby(-1, 0).floor().equals(Blocks.darkPanel4)) { 167 | addTurret(Blocks.fuse, tile, yy, 750, 4); 168 | }// Segment 169 | else if (tile.nearby(0, 1).floor().equals(Blocks.darkPanel4)) { 170 | addTurret(Blocks.segment, tile, yy, 1400, 3); 171 | } // Lancer 172 | else if (tile.nearby(-1, -1).floor().equals(Blocks.darkPanel4)) { 173 | addTurret(Blocks.lancer, tile, yy, 350, 3); 174 | } 175 | } 176 | 177 | private void addTurret(Block block, Tile tile, int yy, int cost, int size) { 178 | Room.rooms.add(new TurretRoom(Team.sharded, block, tile.x - size / 2, tile.y - size / 2, cost, size)); 179 | Room.rooms.add(new TurretRoom(Team.blue, block, tile.x - size / 2, yy - size / 2, cost, size)); 180 | } 181 | 182 | private void addUnit(UnitType type, int x, int y, int cost, int income) { 183 | Room.rooms.add(new UnitRoom(type, x, y, cost, income, UnitRoom.Type.Attacker)); 184 | if (type != UnitTypes.nova && type != UnitTypes.dagger && type != UnitTypes.crawler) { 185 | Room.rooms.add(new UnitRoom(type, x, y + Room.ROOM_SIZE + 2, cost, -income, UnitRoom.Type.Defender)); 186 | } 187 | // Some Resource Room Why be not? xd 188 | if (type == UnitTypes.nova) { 189 | Room.rooms.add(new ResourceRoom(Items.plastanium, x, y + Room.ROOM_SIZE + 2, 350)); 190 | } else if (type == UnitTypes.dagger) { 191 | Room.rooms.add(new ResourceRoom(Items.thorium, x, y + Room.ROOM_SIZE + 2, 250)); 192 | } else if (type == UnitTypes.crawler) { 193 | Room.rooms.add(new ResourceRoom(Items.phaseFabric, x, y + Room.ROOM_SIZE + 2, 450)); 194 | } 195 | } 196 | 197 | private void addCoreRoom(Tile tile, int yy) { 198 | Room.rooms.add(new CoreRoom(Team.sharded, tile.x - 2, tile.y - 2)); 199 | Room.rooms.add(new CoreRoom(Team.blue, tile.x - 2, yy - 2)); 200 | } 201 | 202 | } 203 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/game/Logic.java: -------------------------------------------------------------------------------- 1 | package CastleWars.game; 2 | 3 | import CastleWars.Main; 4 | import CastleWars.data.PlayerData; 5 | import arc.Events; 6 | import arc.struct.Seq; 7 | import mindustry.Vars; 8 | import mindustry.game.EventType; 9 | import mindustry.gen.Call; 10 | import mindustry.gen.Groups; 11 | import mindustry.gen.Player; 12 | import CastleWars.logic.Room; 13 | import arc.util.Log; 14 | import arc.util.Timer; 15 | import mindustry.content.Blocks; 16 | import mindustry.content.UnitTypes; 17 | import mindustry.game.Team; 18 | import mindustry.gen.Nulls; 19 | import mindustry.world.Block; 20 | import mindustry.world.Tile; 21 | import mindustry.world.blocks.storage.CoreBlock; 22 | 23 | public class Logic { 24 | 25 | public boolean worldLoaded = false; 26 | public float x = 0, y = 0, endx = 0, endy = 0; 27 | 28 | Seq cores = new Seq<>(); 29 | 30 | public Logic() { 31 | 32 | Events.on(EventType.BlockDestroyEvent.class, e -> { 33 | if (!(e.tile.build instanceof CoreBlock.CoreBuild) || e.tile.build.team.cores().size > 1 || !worldLoaded) return; 34 | 35 | if (e.tile.build.team == Team.sharded) gameOver(Team.blue); 36 | else gameOver(Team.sharded); 37 | }); 38 | } 39 | 40 | public void update() { 41 | if (Vars.state.isPaused() || !worldLoaded) return; 42 | for (PlayerData data : PlayerData.datas.values()) { 43 | data.update(); 44 | } 45 | 46 | for (Room room : Room.rooms) { 47 | room.update(); 48 | } 49 | // Kill all units in centre 50 | Groups.unit.intersect(x, y, endx, endy, u -> { 51 | if (u.isPlayer()) { 52 | u.getPlayer().unit(Nulls.unit); 53 | } 54 | u.kill(); 55 | }); 56 | } 57 | 58 | public void restart() { 59 | Seq players = new Seq<>(); 60 | Groups.player.copy(players); 61 | 62 | Vars.logic.reset(); 63 | 64 | UnitTypes.omura.abilities.clear(); 65 | UnitTypes.mono.weapons.add(UnitTypes.crawler.weapons.get(0)); 66 | Blocks.coreShard.unitCapModifier = 99999; 67 | Blocks.itemSource.health = 999999; 68 | Blocks.coreNucleus.unitCapModifier = 99999; 69 | Room.rooms.clear(); 70 | 71 | PlayerData.datas.values().forEach(PlayerData::reset); 72 | 73 | Generator gen = new Generator(); 74 | gen.run(); 75 | Timer.schedule(() -> { 76 | cores = gen.cores.copy(); 77 | }, 2); 78 | Call.worldDataBegin(); 79 | 80 | int half = gen.height - (Room.ROOM_SIZE * 6); 81 | half = half / 2; 82 | y = half * Vars.tilesize; 83 | endy = (Room.ROOM_SIZE * 6) * Vars.tilesize; 84 | x = -5 * Vars.tilesize; 85 | endx = (5 + gen.width) * Vars.tilesize; 86 | 87 | for (Player player : players) { 88 | Vars.netServer.assignTeam(player, players); 89 | Vars.netServer.sendWorldData(player); 90 | PlayerData.labels(player); 91 | } 92 | 93 | Call.setRules(Main.rules); 94 | Vars.logic.play(); 95 | Vars.state.rules = Main.rules; 96 | Call.setRules(Vars.state.rules); 97 | // AntiInstantGameStart 98 | Timer.schedule(() -> { 99 | worldLoaded = true; 100 | }, 5); 101 | } 102 | 103 | public void gameOver(Team team) { 104 | String winner = "[gold]Winner: "; 105 | 106 | if (team != Team.derelict) { 107 | winner += "[#" + team.color.toString() + "]" + team.name; 108 | } 109 | Call.infoMessage(winner); 110 | Timer.schedule(() -> { 111 | restart(); 112 | }, 3); 113 | worldLoaded = false; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/logic/CoreRoom.java: -------------------------------------------------------------------------------- 1 | package CastleWars.logic; 2 | 3 | import CastleWars.data.PlayerData; 4 | import mindustry.content.Blocks; 5 | import mindustry.game.Team; 6 | 7 | public class CoreRoom extends TurretRoom{ 8 | 9 | public CoreRoom(Team team, int x, int y) { 10 | super(team, Blocks.coreNucleus, x, y, 5000, 4); 11 | } 12 | 13 | @Override 14 | public void update() { 15 | } 16 | 17 | @Override 18 | public boolean canBuy(PlayerData data) { 19 | return data.money >= cost() && !buyyed; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/logic/ResourceRoom.java: -------------------------------------------------------------------------------- 1 | package CastleWars.logic; 2 | 3 | import CastleWars.data.Icon; 4 | import CastleWars.data.PlayerData; 5 | import mindustry.gen.Call; 6 | import mindustry.gen.Nulls; 7 | import mindustry.type.Item; 8 | import mindustry.content.Items; 9 | 10 | public class ResourceRoom extends Room { 11 | 12 | Item item; 13 | 14 | public ResourceRoom(Item item, int x, int y, int cost) { 15 | super(x, y, cost, 4); 16 | this.item = item; 17 | label = "[white]96x" + Icon.get(item) + " [white]: [gray]" + cost; 18 | } 19 | 20 | @Override 21 | public void buy(PlayerData data) { 22 | data.money -= cost; 23 | if (data.player.team().core() != null) { 24 | Call.transferItemTo(Nulls.unit, item, 96, centreDrawx, centreDrawy, data.player.team().core()); 25 | if (item == Items.plastanium) { 26 | Call.transferItemTo(Nulls.unit, Items.metaglass, 28, centreDrawx, centreDrawy, data.player.team().core()); 27 | } 28 | } 29 | } 30 | 31 | @Override 32 | public void update() { 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/logic/Room.java: -------------------------------------------------------------------------------- 1 | package CastleWars.logic; 2 | 3 | import arc.struct.Seq; 4 | import mindustry.Vars; 5 | 6 | public abstract class Room implements RoomComp { 7 | 8 | public static Seq rooms = new Seq(); 9 | public static int ROOM_SIZE = 8; 10 | 11 | public int size = ROOM_SIZE; 12 | public float drawSize = ROOM_SIZE * Vars.tilesize; 13 | public String label = ""; 14 | 15 | public int x, y, centrex, centrey, endx, endy; 16 | public float drawx, drawy, centreDrawx, centreDrawy, endDrawx, endDrawy; 17 | 18 | public boolean labelVisible = true; 19 | public int cost; 20 | 21 | public Room(int x, int y, int cost, int size) { 22 | 23 | this.cost = cost; 24 | this.size = size; 25 | this.drawSize = size * Vars.tilesize; 26 | 27 | this.x = x; 28 | this.y = y; 29 | this.centrex = x + size / 2; 30 | this.centrey = y + size / 2; 31 | this.endx = x + size; 32 | this.endy = y + size; 33 | this.drawx = x * Vars.tilesize; 34 | this.drawy = y * Vars.tilesize; 35 | this.centreDrawx = (x + size / 2) * Vars.tilesize; 36 | this.centreDrawy = (y + size / 2) * Vars.tilesize; 37 | this.endDrawx = drawx + drawSize; 38 | this.endDrawy = drawy + drawSize; 39 | } 40 | 41 | public Room(int x, int y, int cost) { 42 | this(x, y, cost, ROOM_SIZE); 43 | } 44 | 45 | @Override 46 | public int cost() { 47 | return cost; 48 | } 49 | 50 | @Override 51 | public int size() { 52 | return size; 53 | } 54 | 55 | @Override 56 | public float drawSize() { 57 | return drawSize(); 58 | } 59 | 60 | @Override 61 | public int x() { 62 | return x; 63 | } 64 | 65 | @Override 66 | public int y() { 67 | return y; 68 | } 69 | 70 | @Override 71 | public int endx() { 72 | return endx; 73 | } 74 | 75 | @Override 76 | public int endy() { 77 | return endy; 78 | } 79 | 80 | @Override 81 | public float drawx() { 82 | return drawx; 83 | } 84 | 85 | @Override 86 | public float drawy() { 87 | return drawy; 88 | } 89 | 90 | @Override 91 | public float endDrawx() { 92 | return endDrawx; 93 | } 94 | 95 | @Override 96 | public float endDrawy() { 97 | return endDrawy; 98 | } 99 | 100 | @Override 101 | public int centrex() { 102 | return centrex; 103 | } 104 | 105 | @Override 106 | public int centrey() { 107 | return centrey; 108 | } 109 | 110 | @Override 111 | public float centreDrawx() { 112 | return centreDrawx; 113 | } 114 | 115 | @Override 116 | public float centreDrawy() { 117 | return centreDrawy; 118 | } 119 | 120 | @Override 121 | public String label() { 122 | return label; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/logic/RoomComp.java: -------------------------------------------------------------------------------- 1 | package CastleWars.logic; 2 | 3 | import CastleWars.data.PlayerData; 4 | import mindustry.content.Blocks; 5 | import mindustry.world.Tiles; 6 | import mindustry.world.blocks.environment.Floor; 7 | 8 | public interface RoomComp { 9 | public int cost(); 10 | 11 | public int size(); 12 | public float drawSize(); 13 | 14 | public int x(); 15 | public int y(); 16 | 17 | public int centrex(); 18 | public int centrey(); 19 | 20 | public int endx(); 21 | public int endy(); 22 | 23 | public float drawx(); 24 | public float drawy(); 25 | 26 | public float centreDrawx(); 27 | public float centreDrawy(); 28 | 29 | public float endDrawx(); 30 | public float endDrawy(); 31 | 32 | public String label(); 33 | 34 | public void buy(PlayerData data); 35 | 36 | public void update(); 37 | 38 | default boolean canBuy(PlayerData data) { 39 | return data.money >= cost(); 40 | } 41 | 42 | default boolean check(float x, float y) { 43 | return (x > drawx() && y > drawy() && x < endDrawx() && y < endDrawy()); 44 | } 45 | 46 | default void spawn(Tiles t) { 47 | for (int x = 0; x <= size(); x++) { 48 | for (int y = 0; y <= size(); y++) { 49 | if (t.getn(x + x(), y + y()).floor().equals(Blocks.metalFloor) || t.getn(x + x(), y + y()).floor().equals(Blocks.metalFloor5)) break; 50 | if (x == 0 || y == 0 || x == size() || y == size()) { 51 | t.getn(x + x(), y + y()).setFloor((Floor) Blocks.metalFloor5); 52 | } else { 53 | t.getn(x + x(), y + y()).setFloor((Floor) Blocks.metalFloor); 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/logic/TurretRoom.java: -------------------------------------------------------------------------------- 1 | package CastleWars.logic; 2 | 3 | import CastleWars.data.Icon; 4 | import CastleWars.data.PlayerData; 5 | import arc.util.Interval; 6 | import mindustry.Vars; 7 | import mindustry.content.Blocks; 8 | import mindustry.content.Items; 9 | import mindustry.content.Liquids; 10 | import mindustry.game.Team; 11 | import mindustry.gen.Call; 12 | import mindustry.type.Item; 13 | import mindustry.world.Block; 14 | import mindustry.world.blocks.defense.turrets.ItemTurret; 15 | import mindustry.world.blocks.defense.turrets.LaserTurret; 16 | 17 | public class TurretRoom extends Room { 18 | 19 | public boolean buyyed = false; 20 | public Team team; 21 | Interval interval = new Interval(1); 22 | float updateTime = 60f * 15f; 23 | Block block; 24 | 25 | public TurretRoom(Team team, Block block, int x, int y, int cost, int size) { 26 | super(x, y, cost, size); 27 | this.team = team; 28 | this.block = block; 29 | 30 | label = Icon.get(block) + " :[white] " + cost; 31 | } 32 | 33 | @Override 34 | public void buy(PlayerData data) { 35 | data.money -= cost; 36 | buyyed = true; 37 | labelVisible = false; 38 | Call.label(data.player.name + "[lime] buy it", 5, centreDrawx, centreDrawy); 39 | Vars.world.tile(centrex, centrey).setNet(block, team, 0); 40 | if (block instanceof ItemTurret) { 41 | Vars.world.tile(x, centrey).setNet(Blocks.itemSource, team, 0); 42 | Vars.world.tile(x, centrey).build.configure(ammo(block)); 43 | } else if (block instanceof LaserTurret) { 44 | Vars.world.tile(x, centrey).setNet(Blocks.liquidSource, team, 0); 45 | Vars.world.tile(x, centrey).build.configure(Liquids.cryofluid); 46 | } 47 | } 48 | 49 | @Override 50 | public boolean canBuy(PlayerData data) { 51 | return super.canBuy(data) && !(buyyed = Vars.world.build(centrex, centrey) != null); 52 | } 53 | 54 | @Override 55 | public void update() { 56 | if (buyyed && interval.get(0, updateTime)) { 57 | if (Vars.world.tile(centrex, centrey).build == null) { 58 | Vars.world.tile(centrex, centrey).setNet(block, team, 0); 59 | } 60 | } 61 | } 62 | 63 | public static Item ammo(Block block) { 64 | if (block == Blocks.foreshadow) { 65 | return Items.surgeAlloy; 66 | } 67 | if (block == Blocks.cyclone) { 68 | return Items.plastanium; 69 | } 70 | if (block == Blocks.ripple) { 71 | return Items.blastCompound; 72 | } 73 | if (block == Blocks.spectre) { 74 | return Items.thorium; 75 | } 76 | if (block == Blocks.fuse) { 77 | return Items.thorium; 78 | } 79 | if (block == Blocks.swarmer) { 80 | return Items.surgeAlloy; 81 | } 82 | if (block == Blocks.salvo) { 83 | return Items.thorium; 84 | } 85 | return Items.copper; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/CastleWars/logic/UnitRoom.java: -------------------------------------------------------------------------------- 1 | package CastleWars.logic; 2 | 3 | import CastleWars.data.Icon; 4 | import CastleWars.data.PlayerData; 5 | import arc.math.Mathf; 6 | import mindustry.content.Blocks; 7 | import mindustry.content.UnitTypes; 8 | import mindustry.game.Team; 9 | import mindustry.gen.Unit; 10 | import mindustry.type.UnitType; 11 | import mindustry.world.Tile; 12 | import mindustry.world.Tiles; 13 | 14 | public class UnitRoom extends Room { 15 | 16 | public static Tile blueSpawn, shardedSpawn; 17 | 18 | public enum Type { 19 | Attacker, Defender; 20 | } 21 | 22 | public UnitType unit; 23 | public Type type; 24 | public int income = 0; 25 | 26 | public UnitRoom(UnitType type, int x, int y, int cost, int income, Type clas) { 27 | super(x, y, cost, 4); 28 | this.unit = type; 29 | this.type = clas; 30 | this.income = income; 31 | StringBuilder str = new StringBuilder(); 32 | 33 | int len = String.valueOf(income).length() + 2 + String.valueOf(cost).length(); 34 | for (int i = 0; i < len / 2; i++) { 35 | str.append(" "); 36 | } 37 | str.append(Icon.get(type)); 38 | 39 | if (clas == Type.Attacker) { 40 | str.append(" [accent]").append(Icon.get(Blocks.commandCenter)); 41 | } else { 42 | str.append(" [scarlet]").append(Icon.get(Blocks.duo)); 43 | } 44 | 45 | str.append("\n[gray]").append(cost).append("\n[white]").append(Icon.get(Blocks.plastaniumCompressor)).append(" : "); 46 | if (income < 0) { 47 | str.append("[crimson]"); 48 | } else if (income > 0) { 49 | str.append("[lime]"); 50 | } else { 51 | str.append("[gray]"); 52 | } 53 | str.append(income); 54 | label = str.toString(); 55 | } 56 | 57 | @Override 58 | public void buy(PlayerData data) { 59 | data.money -= cost; 60 | data.income += income; 61 | 62 | if (type == Type.Attacker) { 63 | Unit u = unit.spawn(data.player.team(), (data.player.team() == Team.sharded ? blueSpawn.drawx() : shardedSpawn.drawx()) + Mathf.random(-40, 40), (data.player.team() == Team.sharded ? blueSpawn.drawy() : shardedSpawn.drawy()) + Mathf.random(-40, 40)); 64 | if (unit == UnitTypes.crawler) { 65 | u.type = UnitTypes.mono; 66 | } 67 | u.team(data.player.team()); 68 | } else if (data.player.team().core() != null) { 69 | Unit u = unit.spawn(data.player.team(), data.player.team().core().x + 30, data.player.team().core().y + Mathf.random(-40, 40)); 70 | if (unit == UnitTypes.crawler) { 71 | u.type = UnitTypes.mono; 72 | } 73 | u.team(data.player.team()); 74 | } 75 | } 76 | 77 | @Override 78 | public boolean canBuy(PlayerData data) { 79 | return super.canBuy(data) && (income > 0 || data.income - income >= 0); 80 | } 81 | 82 | @Override 83 | public void spawn(Tiles t 84 | ) { 85 | super.spawn(t); 86 | } 87 | 88 | @Override 89 | public void update() { 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/resources/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "[gray]Castle [yellow]Wars", 3 | "author": "Xusk", 4 | "main": "CastleWars.Main", 5 | "description": "Defende your Side!", 6 | "version": 1.1 7 | } 8 | --------------------------------------------------------------------------------