Merge pull request #67 from Anuken/weapon-upgrade-rework

Weapon Upgrade Rework
This commit is contained in:
Anuken
2018-01-08 17:35:39 -05:00
committed by GitHub
58 changed files with 1197 additions and 895 deletions

View File

@@ -21,7 +21,7 @@ allprojects {
appName = "Mindustry" appName = "Mindustry"
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = '5e4e43ed39'; uCoreVersion = '713d187';
} }
repositories { repositories {

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

View File

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

View File

@@ -122,7 +122,7 @@ text.settings.game=Game
text.settings.sound=Sound text.settings.sound=Sound
text.settings.graphics=Graphics text.settings.graphics=Graphics
text.upgrades=Upgrades text.upgrades=Upgrades
text.purchased=[LIME]Purchased! text.purchased=[LIME]Created!
text.weapons=Weapons text.weapons=Weapons
text.paused=Paused text.paused=Paused
text.respawn=Respawning in text.respawn=Respawning in
@@ -166,6 +166,11 @@ text.blocks.health=Health
text.blocks.inaccuracy=Health text.blocks.inaccuracy=Health
text.blocks.shots=Shots text.blocks.shots=Shots
text.blocks.shotssecond=Shots/second text.blocks.shotssecond=Shots/second
text.blocks.fuel=Fuel
text.blocks.fuelduration=Fuel Duration
text.blocks.maxoutputsecond=Max output/second
text.blocks.inputcapacity=Input capacity
text.blocks.outputcapacity=Output capacity
text.placemode=Place Mode text.placemode=Place Mode
text.breakmode=Break Mode text.breakmode=Break Mode
text.health=health text.health=health
@@ -266,18 +271,20 @@ keybind.weapon_6.name=weapon_6
mode.waves.name=waves mode.waves.name=waves
mode.sandbox.name=sandbox mode.sandbox.name=sandbox
mode.freebuild.name=freebuild mode.freebuild.name=freebuild
weapon.blaster.name=blaster upgrade.standard.name=standard
weapon.blaster.description=Shoots a slow, weak bullet. upgrade.standard.description=The standard mech.
weapon.triblaster.name=triblaster upgrade.blaster.name=blaster
weapon.triblaster.description=Shoots 3 bullets in a spread. upgrade.blaster.description=Shoots a slow, weak bullet.
weapon.multigun.name=multigun upgrade.triblaster.name=triblaster
weapon.multigun.description=Shoots inaccurate bullets with a high\nrate of fire. upgrade.triblaster.description=Shoots 3 bullets in a spread.
weapon.flamer.name=flamer upgrade.clustergun.name=clustergun
weapon.flamer.description=Shoots a stream of fire. upgrade.clustergun.description=Shoots an inaccurate spread of explosive grenades.
weapon.railgun.name=railgun upgrade.beam.name=beam cannon
weapon.railgun.description=Shoots one long-range bullet. upgrade.beam.description=Shoots a long-range piercing laser beam.
weapon.mortar.name=mortar upgrade.vulcan.name=vulcan
weapon.mortar.description=Shoots a slow, but damaging shell. upgrade.vulcan.description=Shoots a barrage of fast bullets.
upgrade.shockgun.name=shockgun
upgrade.shockgun.description=Shoots a devastating blast of charged shrapnel.
item.stone.name=stone item.stone.name=stone
item.iron.name=iron item.iron.name=iron
item.coal.name=coal item.coal.name=coal
@@ -289,6 +296,7 @@ liquid.water.name=water
liquid.plasma.name=plasma liquid.plasma.name=plasma
liquid.lava.name=lava liquid.lava.name=lava
liquid.oil.name=oil liquid.oil.name=oil
block.weaponfactory.name=weapon factory
block.air.name=air block.air.name=air
block.blockpart.name=blockpart block.blockpart.name=blockpart
block.deepwater.name=deepwater block.deepwater.name=deepwater
@@ -338,25 +346,20 @@ block.titaniumshieldwall.name=shielded wall
block.titaniumshieldwall.fulldescription=A strong defensive block, with an extra built-in shield. Requires power. Uses energy to absorb enemy bullets. It is recommended to use power boosters to provide energy to this block. block.titaniumshieldwall.fulldescription=A strong defensive block, with an extra built-in shield. Requires power. Uses energy to absorb enemy bullets. It is recommended to use power boosters to provide energy to this block.
block.repairturret.name=repair turret block.repairturret.name=repair turret
block.repairturret.fulldescription=Repairs nearby damaged blocks in range at a slow rate. Uses small amounts of power. block.repairturret.fulldescription=Repairs nearby damaged blocks in range at a slow rate. Uses small amounts of power.
block.repairturret.description=[powerinfo]Uses power[white]\nRepairs nearby blocks.
block.megarepairturret.name=repair turret II block.megarepairturret.name=repair turret II
block.megarepairturret.fulldescription=Repairs nearby damaged blocks in range at a decent rate. Uses power. block.megarepairturret.fulldescription=Repairs nearby damaged blocks in range at a decent rate. Uses power.
block.megarepairturret.description=[powerinfo]Uses power[white]\nRepairs nearby blocks.
block.shieldgenerator.name=shield generator block.shieldgenerator.name=shield generator
block.shieldgenerator.fulldescription=An advanced defensive block. Shields all the blocks in a radius from attack. Uses power at a slow rate when idle, but drains energy quickly on bullet contact. block.shieldgenerator.fulldescription=An advanced defensive block. Shields all the blocks in a radius from attack. Uses power at a slow rate when idle, but drains energy quickly on bullet contact.
block.door.name=door block.door.name=door
block.door.fulldescription=A block than can be opened and closed by tapping it. block.door.fulldescription=A block than can be opened and closed by tapping it.
block.door.description=Opens and closes.\n[interact]Tap to toggle
block.door-large.name=large door block.door-large.name=large door
block.door-large.fulldescription=A block than can be opened and closed by tapping it. block.door-large.fulldescription=A block than can be opened and closed by tapping it.
block.door-large.description=Opens and closes.\n[interact]Tap to toggle
block.conduit.name=conduit block.conduit.name=conduit
block.conduit.fulldescription=Basic liquid transport block. Works like a conveyor, but with liquids. Best used with pumps or other conduits. Can be used as a bridge over liquids for enemies and players. block.conduit.fulldescription=Basic liquid transport block. Works like a conveyor, but with liquids. Best used with pumps or other conduits. Can be used as a bridge over liquids for enemies and players.
block.pulseconduit.name=pulse conduit block.pulseconduit.name=pulse conduit
block.pulseconduit.fulldescription=Advanced liquid transport block. Transports liquids faster and stores more than standard conduits. block.pulseconduit.fulldescription=Advanced liquid transport block. Transports liquids faster and stores more than standard conduits.
block.liquidrouter.name=liquid router block.liquidrouter.name=liquid router
block.liquidrouter.fulldescription=Works similarly to a router. Accepts liquid input from one side and outputs it to the other sides. Useful for splitting liquid from a single conduit into multiple other conduits. block.liquidrouter.fulldescription=Works similarly to a router. Accepts liquid input from one side and outputs it to the other sides. Useful for splitting liquid from a single conduit into multiple other conduits.
block.liquidrouter.description=Splits input liquid into 3 directions.
block.conveyor.name=conveyor block.conveyor.name=conveyor
block.conveyor.fulldescription=Basic item transport block. Moves items forward and automatically deposits them into turrets or crafters. Rotatable. Can be used as a bridge over liquids for enemies and players. block.conveyor.fulldescription=Basic item transport block. Moves items forward and automatically deposits them into turrets or crafters. Rotatable. Can be used as a bridge over liquids for enemies and players.
block.steelconveyor.name=steel conveyor block.steelconveyor.name=steel conveyor
@@ -365,131 +368,90 @@ block.poweredconveyor.name=pulse conveyor
block.poweredconveyor.fulldescription=The ultimate item transport block. Moves items faster than steel conveyors. block.poweredconveyor.fulldescription=The ultimate item transport block. Moves items faster than steel conveyors.
block.router.name=router block.router.name=router
block.router.fulldescription=Accepts items from one direction and outputs them to 3 other directions. Can also store a certain amount of items.Useful for splitting the materials from one drill into multiple turrets. block.router.fulldescription=Accepts items from one direction and outputs them to 3 other directions. Can also store a certain amount of items.Useful for splitting the materials from one drill into multiple turrets.
block.router.description=Split input materials into 3 directions.
block.junction.name=junction block.junction.name=junction
block.junction.fulldescription=Acts as a bridge for two crossing conveyor belts. Useful in situations with two different conveyors carrying different materials to different locations. block.junction.fulldescription=Acts as a bridge for two crossing conveyor belts. Useful in situations with two different conveyors carrying different materials to different locations.
block.junction.description=Serves as a conveyor junction.
block.conveyortunnel.name=conveyor tunnel block.conveyortunnel.name=conveyor tunnel
block.conveyortunnel.fulldescription=Transports item under blocks. To use, place one tunnel leading into the block to be tunneled under, and one on the other side. Make sure both tunnels face opposite directions, which is towards the blocks they are inputting or outputting to. block.conveyortunnel.fulldescription=Transports item under blocks. To use, place one tunnel leading into the block to be tunneled under, and one on the other side. Make sure both tunnels face opposite directions, which is towards the blocks they are inputting or outputting to.
block.conveyortunnel.description=Transports items under blocks.
block.liquidjunction.name=liquid junction block.liquidjunction.name=liquid junction
block.liquidjunction.fulldescription=Acts as a bridge for two crossing conduits. Useful in situations with two different conduits carrying different liquids to different locations. block.liquidjunction.fulldescription=Acts as a bridge for two crossing conduits. Useful in situations with two different conduits carrying different liquids to different locations.
block.liquiditemjunction.name=liquid-item junction block.liquiditemjunction.name=liquid-item junction
block.liquiditemjunction.fulldescription=Acts as a bridge for crossing conduits and conveyors. block.liquiditemjunction.fulldescription=Acts as a bridge for crossing conduits and conveyors.
block.liquiditemjunction.description=Serves as a junction for items and liquids.
block.powerbooster.name=power booster block.powerbooster.name=power booster
block.powerbooster.fulldescription=Distributes power to all blocks within its radius. block.powerbooster.fulldescription=Distributes power to all blocks within its radius.
block.powerbooster.description=Distributes power within a radius.
block.powerlaser.name=power laser block.powerlaser.name=power laser
block.powerlaser.fulldescription=Creates a laser that transmits power to the block in front of it. Does not generate any power itself. Best used with generators or other lasers. block.powerlaser.fulldescription=Creates a laser that transmits power to the block in front of it. Does not generate any power itself. Best used with generators or other lasers.
block.powerlaser.description=Transmits power.
block.powerlaserrouter.name=laser router block.powerlaserrouter.name=laser router
block.powerlaserrouter.fulldescription=Laser that distributes power to three directions at once. Useful in situations where it is required to power multiple blocks from one generator. block.powerlaserrouter.fulldescription=Laser that distributes power to three directions at once. Useful in situations where it is required to power multiple blocks from one generator.
block.powerlaserrouter.description=Splits input power into 3 lasers.
block.powerlasercorner.name=laser corner block.powerlasercorner.name=laser corner
block.powerlasercorner.fulldescription=Laser that distributes power to two directions at once. Useful in situations where it is required to power multiple blocks from one generator, and a router is imprecise. block.powerlasercorner.fulldescription=Laser that distributes power to two directions at once. Useful in situations where it is required to power multiple blocks from one generator, and a router is imprecise.
block.powerlasercorner.description=Splits input power into 2 lasers.
block.teleporter.name=teleporter block.teleporter.name=teleporter
block.teleporter.fulldescription=Advanced item transport block. Teleporters input items to other teleporters of the same color. Does nothing if no teleporters of the same color exist. If multiple teleporters exist of the same color, a random one is selected. Tap and click the arrows to change color. block.teleporter.fulldescription=Advanced item transport block. Teleporters input items to other teleporters of the same color. Does nothing if no teleporters of the same color exist. If multiple teleporters exist of the same color, a random one is selected. Tap and click the arrows to change color.
block.teleporter.description=[interact]Tap block to config[]
block.sorter.name=sorter block.sorter.name=sorter
block.sorter.fulldescription=Sorts item by material type. Material to accept is indicated by the color in the block. All items that match the sort material are outputted forward, everything else is outputted to the left and right. block.sorter.fulldescription=Sorts item by material type. Material to accept is indicated by the color in the block. All items that match the sort material are outputted forward, everything else is outputted to the left and right.
block.sorter.description=[interact]Tap block to config[]
block.core.name=core block.core.name=core
block.pump.name=pump block.pump.name=pump
block.pump.fulldescription=Pumps liquids from a source block- usually water, lava or oil. Outputs liquid into nearby conduits. block.pump.fulldescription=Pumps liquids from a source block- usually water, lava or oil. Outputs liquid into nearby conduits.
block.pump.description=Pumps liquids into nearby conduits.
block.fluxpump.name=fluxpump block.fluxpump.name=fluxpump
block.fluxpump.fulldescription=An advanced version of the pump. Stores more liquid and pumps liquid faster. block.fluxpump.fulldescription=An advanced version of the pump. Stores more liquid and pumps liquid faster.
block.fluxpump.description=Pumps liquids into nearby conduits.
block.smelter.name=smelter block.smelter.name=smelter
block.smelter.fulldescription=The essential crafting block. When inputted 1x iron and 1x coal, outputs one steel. block.smelter.fulldescription=The essential crafting block. When inputted 1x iron and 1x coal, outputs one steel.
block.smelter.description=Converts coal + iron to steel.
block.crucible.name=crucible block.crucible.name=crucible
block.crucible.fulldescription=An advanced crafting block. When inputted 1x titanium and 1x steel, outputs one dirium. block.crucible.fulldescription=An advanced crafting block. When inputted 1x titanium and 1x steel, outputs one dirium.
block.crucible.description=Converts steel + titanium to dirium.
block.coalpurifier.name=coal extractor block.coalpurifier.name=coal extractor
block.coalpurifier.fulldescription=A basic extractor block. Outputs coal when supplied with large amounts of water and stone. block.coalpurifier.fulldescription=A basic extractor block. Outputs coal when supplied with large amounts of water and stone.
block.coalpurifier.description=Converts stone + water to coal.
block.titaniumpurifier.name=titanium extractor block.titaniumpurifier.name=titanium extractor
block.titaniumpurifier.fulldescription=A standard extractor block. Outputs titanium when supplied with large amounts of water and iron. block.titaniumpurifier.fulldescription=A standard extractor block. Outputs titanium when supplied with large amounts of water and iron.
block.titaniumpurifier.description=Converts iron + water to titanium.
block.oilrefinery.name=oil refinery block.oilrefinery.name=oil refinery
block.oilrefinery.fulldescription=Refines large amounts of oil into coal items. Useful for fueling coal-based turrets when coal veins are scarce. block.oilrefinery.fulldescription=Refines large amounts of oil into coal items. Useful for fueling coal-based turrets when coal veins are scarce.
block.oilrefinery.description=Converts oil to coal.
block.stoneformer.name=stone former block.stoneformer.name=stone former
block.stoneformer.fulldescription=Soldifies liquid lava into stone. Useful for producing massive amounts of stone for coal purifiers. block.stoneformer.fulldescription=Soldifies liquid lava into stone. Useful for producing massive amounts of stone for coal purifiers.
block.stoneformer.description=Converts lava to stone.
block.lavasmelter.name=lava smelter block.lavasmelter.name=lava smelter
block.lavasmelter.fulldescription=Uses lava to convert iron to steel. An alternative to smelteries. Useful in situations where coal is scarce. block.lavasmelter.fulldescription=Uses lava to convert iron to steel. An alternative to smelteries. Useful in situations where coal is scarce.
block.lavasmelter.description=Converts iron + lava to steel.
block.stonedrill.name=stone drill block.stonedrill.name=stone drill
block.stonedrill.fulldescription=The essential drill. When placed on stone tiles, outputs stone at a slow pace indefinitely. block.stonedrill.fulldescription=The essential drill. When placed on stone tiles, outputs stone at a slow pace indefinitely.
block.stonedrill.description=Mines 1 stone every 4 seconds.
block.irondrill.name=iron drill block.irondrill.name=iron drill
block.irondrill.fulldescription=A basic drill. When placed on iron ore tiles, outputs iron at a slow pace indefinitely. block.irondrill.fulldescription=A basic drill. When placed on iron ore tiles, outputs iron at a slow pace indefinitely.
block.irondrill.description=Mines 1 iron every 5 seconds.
block.coaldrill.name=coal drill block.coaldrill.name=coal drill
block.coaldrill.fulldescription=A basic drill. When placed on coal ore tiles, outputs coal at a slow pace indefinitely. block.coaldrill.fulldescription=A basic drill. When placed on coal ore tiles, outputs coal at a slow pace indefinitely.
block.coaldrill.description=Mines 1 coal every 5 seconds.
block.uraniumdrill.name=uranium drill block.uraniumdrill.name=uranium drill
block.uraniumdrill.fulldescription=An advanced drill. When placed on uranium ore tiles, outputs uranium at a slow pace indefinitely. block.uraniumdrill.fulldescription=An advanced drill. When placed on uranium ore tiles, outputs uranium at a slow pace indefinitely.
block.uraniumdrill.description=Mines 1 uranium every 7 seconds.
block.titaniumdrill.name=titanium drill block.titaniumdrill.name=titanium drill
block.titaniumdrill.fulldescription=An advanced drill. When placed on titanium ore tiles, outputs titanium at a slow pace indefinitely. block.titaniumdrill.fulldescription=An advanced drill. When placed on titanium ore tiles, outputs titanium at a slow pace indefinitely.
block.titaniumdrill.description=Mines 1 titanium every 5 seconds.
block.omnidrill.name=omnidrill block.omnidrill.name=omnidrill
block.omnidrill.fulldescription=The ultimate drill. Will mine any ore it is placed on at a rapid pace. block.omnidrill.fulldescription=The ultimate drill. Will mine any ore it is placed on at a rapid pace.
block.omnidrill.description=Mines 1 of any resource every 3 seconds.
block.coalgenerator.name=coal generator block.coalgenerator.name=coal generator
block.coalgenerator.fulldescription=The essential generator. Generates power from coal. Outputs power as lasers to its 4 sides. block.coalgenerator.fulldescription=The essential generator. Generates power from coal. Outputs power as lasers to its 4 sides.
block.coalgenerator.description=Generates power from coal.
block.thermalgenerator.name=thermal generator block.thermalgenerator.name=thermal generator
block.thermalgenerator.fulldescription=Generates power from lava. Outputs power as lasers to its 4 sides. block.thermalgenerator.fulldescription=Generates power from lava. Outputs power as lasers to its 4 sides.
block.thermalgenerator.description=Generates power from lava.
block.combustiongenerator.name=combustion generator block.combustiongenerator.name=combustion generator
block.combustiongenerator.fulldescription=Generates power from oil. Outputs power as lasers to its 4 sides. block.combustiongenerator.fulldescription=Generates power from oil. Outputs power as lasers to its 4 sides.
block.combustiongenerator.description=Generates power from oil.
block.rtgenerator.name=RTG generator block.rtgenerator.name=RTG generator
block.rtgenerator.fulldescription=Generates small amounts of power from the radioactive decay of uranium. Outputs power as lasers to its 4 sides. block.rtgenerator.fulldescription=Generates small amounts of power from the radioactive decay of uranium. Outputs power as lasers to its 4 sides.
block.rtgenerator.description=Generates power from uranium.
block.nuclearreactor.name=nuclear reactor block.nuclearreactor.name=nuclear reactor
block.nuclearreactor.fulldescription=An advanced version of the RTG Generator, and the ultimate power generator. Generates power from uranium. Requires constant water cooling. Highly volatile; will explode violently if insufficient amounts of coolant are supplied. block.nuclearreactor.fulldescription=An advanced version of the RTG Generator, and the ultimate power generator. Generates power from uranium. Requires constant water cooling. Highly volatile; will explode violently if insufficient amounts of coolant are supplied.
block.turret.name=turret block.turret.name=turret
block.turret.fulldescription=A basic, cheap turret. Uses stone for ammo. Has slightly more range than the double-turret. block.turret.fulldescription=A basic, cheap turret. Uses stone for ammo. Has slightly more range than the double-turret.
block.turret.description=[turretinfo]Ammo: stone
block.doubleturret.name=double turret block.doubleturret.name=double turret
block.doubleturret.fulldescription=A slightly more powerful version of the turret. Uses stone for ammo. Does significantly more damage, but has a lower range. Shoots two bullets. block.doubleturret.fulldescription=A slightly more powerful version of the turret. Uses stone for ammo. Does significantly more damage, but has a lower range. Shoots two bullets.
block.doubleturret.description=[turretinfo]Ammo: stone
block.machineturret.name=gattling turret block.machineturret.name=gattling turret
block.machineturret.fulldescription=A standard all-around turret. Uses iron for ammo. Has a fast fire rate with decent damage. block.machineturret.fulldescription=A standard all-around turret. Uses iron for ammo. Has a fast fire rate with decent damage.
block.machineturret.description=[turretinfo]Ammo: iron
block.shotgunturret.name=splitter turret block.shotgunturret.name=splitter turret
block.shotgunturret.fulldescription=A standard turret. Uses iron for ammo. Shoots a spread of 7 bullets. Lower range, but higher damage output than the gattling turret. block.shotgunturret.fulldescription=A standard turret. Uses iron for ammo. Shoots a spread of 7 bullets. Lower range, but higher damage output than the gattling turret.
block.shotgunturret.description=[turretinfo]Ammo: iron
block.flameturret.name=flamer turret block.flameturret.name=flamer turret
block.flameturret.fulldescription=Advanced close-range turret. Uses coal for ammo. Has very low range, but very high damage. Good for close quarters. Recommended to be used behind walls. block.flameturret.fulldescription=Advanced close-range turret. Uses coal for ammo. Has very low range, but very high damage. Good for close quarters. Recommended to be used behind walls.
block.flameturret.description=[turretinfo]Ammo: coal
block.sniperturret.name=railgun turret block.sniperturret.name=railgun turret
block.sniperturret.fulldescription=Advanced long-range turret. Uses steel for ammo. Very high damage, but low fire rate. Expensive to use, but can be placed far away from enemy lines due to its range. block.sniperturret.fulldescription=Advanced long-range turret. Uses steel for ammo. Very high damage, but low fire rate. Expensive to use, but can be placed far away from enemy lines due to its range.
block.sniperturret.description=[turretinfo]Ammo: steel
block.mortarturret.name=flak turret block.mortarturret.name=flak turret
block.mortarturret.fulldescription=Advanced splash-damage turret. Uses coal for ammo. Very slow fire rate and bullets, but very high single-target and splash damage. Useful for large crowds of enemies. block.mortarturret.fulldescription=Advanced splash-damage turret. Uses coal for ammo. Very slow fire rate and bullets, but very high single-target and splash damage. Useful for large crowds of enemies.
block.mortarturret.description=[turretinfo]Ammo: coal
block.laserturret.name=laser turret block.laserturret.name=laser turret
block.laserturret.fulldescription=Advanced single-target turret. Uses power. Good medium-range all-around turret. Single-target only. Never misses. block.laserturret.fulldescription=Advanced single-target turret. Uses power. Good medium-range all-around turret. Single-target only. Never misses.
block.laserturret.description=[turretinfo]Uses power.
block.waveturret.name=tesla turret block.waveturret.name=tesla turret
block.waveturret.fulldescription=Advanced multi-target turret. Uses power. Medium range. Never misses.Average to low damage, but can hit multiple enemies simultaneously with chain lighting. block.waveturret.fulldescription=Advanced multi-target turret. Uses power. Medium range. Never misses.Average to low damage, but can hit multiple enemies simultaneously with chain lighting.
block.waveturret.description=[turretinfo]Uses power.
block.plasmaturret.name=plasma turret block.plasmaturret.name=plasma turret
block.plasmaturret.fulldescription=Highly advanced version of the flamer turret. Uses coal as ammo. Very high damage, low to medium range. block.plasmaturret.fulldescription=Highly advanced version of the flamer turret. Uses coal as ammo. Very high damage, low to medium range.
block.plasmaturret.description=[turretinfo]Ammo: coal
block.chainturret.name=chain turret block.chainturret.name=chain turret
block.chainturret.fulldescription=The ultimate rapid-fire turret. Uses uranium as ammo. Shoots large slugs at a high fire rate. Medium range. Spans multiple tiles. Extremely tough. block.chainturret.fulldescription=The ultimate rapid-fire turret. Uses uranium as ammo. Shoots large slugs at a high fire rate. Medium range. Spans multiple tiles. Extremely tough.
block.chainturret.description=[turretinfo]Ammo: uranium
block.titancannon.name=titan cannon block.titancannon.name=titan cannon
block.titancannon.fulldescription=The ultimate long-range turret. Uses uranium as ammo. Shoots large splash-damage shells at a medium rate of fire. Long range. Spans multiple tiles. Extremely tough. block.titancannon.fulldescription=The ultimate long-range turret. Uses uranium as ammo. Shoots large splash-damage shells at a medium rate of fire. Long range. Spans multiple tiles. Extremely tough.
block.titancannon.description=[turretinfo]Ammo: uranium
block.playerspawn.name=playerspawn block.playerspawn.name=playerspawn
block.enemyspawn.name=enemyspawn block.enemyspawn.name=enemyspawn

View File

@@ -7,6 +7,7 @@ uniform sampler2D u_texture;
uniform vec4 u_color; uniform vec4 u_color;
uniform vec2 u_texsize; uniform vec2 u_texsize;
uniform float u_lighten;
varying vec4 v_color; varying vec4 v_color;
varying vec2 v_texCoord; varying vec2 v_texCoord;
@@ -30,6 +31,7 @@ void main() {
if(any){ if(any){
gl_FragColor = u_color; gl_FragColor = u_color;
}else{ }else{
gl_FragColor = texture2D(u_texture, T) * v_color; vec4 c = texture2D(u_texture, T);
gl_FragColor = mix(c, vec4(1.0, 1.0, 1.0, c.a), u_lighten) * v_color;
} }
} }

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

View File

@@ -140,7 +140,8 @@ public class Control extends Module{
"move_y", new Axis(Input.S, Input.W), "move_y", new Axis(Input.S, Input.W),
"select", Input.MOUSE_LEFT, "select", Input.MOUSE_LEFT,
"break", Input.MOUSE_RIGHT, "break", Input.MOUSE_RIGHT,
"shootInternal", Input.MOUSE_LEFT, "shoot", Input.MOUSE_LEFT,
"weapon_alt_select", Input.Q,
"zoom_hold", Input.CONTROL_LEFT, "zoom_hold", Input.CONTROL_LEFT,
"zoom", new Axis(Input.SCROLL), "zoom", new Axis(Input.SCROLL),
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE, "menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
@@ -166,7 +167,7 @@ public class Control extends Module{
"cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS), "cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS),
"select", Input.CONTROLLER_R_BUMPER, "select", Input.CONTROLLER_R_BUMPER,
"break", Input.CONTROLLER_L_BUMPER, "break", Input.CONTROLLER_L_BUMPER,
"shootInternal", Input.CONTROLLER_R_TRIGGER, "shoot", Input.CONTROLLER_R_TRIGGER,
"zoom_hold", Input.ANY_KEY, "zoom_hold", Input.ANY_KEY,
"zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP), "zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP),
"menu", Input.CONTROLLER_X, "menu", Input.CONTROLLER_X,
@@ -223,7 +224,13 @@ public class Control extends Module{
weapons.clear(); weapons.clear();
weapons.add(Weapon.blaster); weapons.add(Weapon.blaster);
player.weapon = weapons.first(); player.weaponLeft = player.weaponRight = weapons.first();
if(debug){
//weapons.add(Weapon.triblaster, Weapon.clustergun, Weapon.beam, Weapon.vulcan);
//weapons.add(Weapon.shockgun);
player.weaponLeft = player.weaponRight = weapons.peek();
}
lastUpdated = -1; lastUpdated = -1;
wave = 1; wave = 1;
@@ -245,7 +252,7 @@ public class Control extends Module{
} }
ui.hudfrag.updateItems(); ui.hudfrag.updateItems();
ui.weaponfrag.update(); ui.hudfrag.updateWeapons();
} }
public void play(){ public void play(){
@@ -672,5 +679,4 @@ public class Control extends Module{
} }
} }
} }
} }

View File

@@ -17,6 +17,7 @@ import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.net.Syncable; import io.anuke.mindustry.net.Syncable;
import io.anuke.mindustry.net.Syncable.Interpolator; import io.anuke.mindustry.net.Syncable.Interpolator;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
@@ -148,7 +149,7 @@ public class NetClient extends Module {
Net.handle(ShootPacket.class, packet -> { Net.handle(ShootPacket.class, packet -> {
Player player = Vars.control.playerGroup.getByID(packet.playerid); Player player = Vars.control.playerGroup.getByID(packet.playerid);
Weapon weapon = Weapon.values()[packet.weaponid]; Weapon weapon = (Weapon) Upgrade.getByID(packet.weaponid);
weapon.shoot(player, packet.x, packet.y, packet.rotation); weapon.shoot(player, packet.x, packet.y, packet.rotation);
}); });
@@ -251,6 +252,15 @@ public class NetClient extends Module {
GameState.set(State.menu); GameState.set(State.menu);
Gdx.app.postRunnable(() -> Vars.ui.showError("$text.server.kicked." + KickReason.values()[packet.reason].name())); Gdx.app.postRunnable(() -> Vars.ui.showError("$text.server.kicked." + KickReason.values()[packet.reason].name()));
}); });
Net.handle(WeaponSwitchPacket.class, packet -> {
Player player = Vars.control.playerGroup.getByID(packet.playerid);
if(player == null) return;
player.weaponLeft = (Weapon)Upgrade.getByID(packet.left);
player.weaponRight = (Weapon)Upgrade.getByID(packet.right);
});
} }
@Override @Override
@@ -264,9 +274,17 @@ public class NetClient extends Module {
} }
} }
public void handleWeaponSwitch(){
WeaponSwitchPacket packet = new WeaponSwitchPacket();
packet.left = Vars.player.weaponLeft.id;
packet.right = Vars.player.weaponRight.id;
packet.playerid = Vars.player.id;
Net.send(packet, SendMode.tcp);
}
public void handleUpgrade(Weapon weapon){ public void handleUpgrade(Weapon weapon){
UpgradePacket packet = new UpgradePacket(); UpgradePacket packet = new UpgradePacket();
packet.id = weapon.ordinal(); packet.id = weapon.id;
Net.send(packet, SendMode.tcp); Net.send(packet, SendMode.tcp);
} }
@@ -283,7 +301,7 @@ public class NetClient extends Module {
public void handleShoot(Weapon weapon, float x, float y, float angle){ public void handleShoot(Weapon weapon, float x, float y, float angle){
ShootPacket packet = new ShootPacket(); ShootPacket packet = new ShootPacket();
packet.weaponid = (byte)weapon.ordinal(); packet.weaponid = weapon.id;
packet.x = x; packet.x = x;
packet.y = y; packet.y = y;
packet.rotation = angle; packet.rotation = angle;

View File

@@ -15,9 +15,7 @@ import io.anuke.mindustry.io.NetworkIO;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Net.SendMode; import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.*;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.UCore; import io.anuke.ucore.UCore;
@@ -118,7 +116,7 @@ public class NetServer extends Module{
Net.handleServer(ShootPacket.class, packet -> { Net.handleServer(ShootPacket.class, packet -> {
Player player = connections.get(Net.getLastConnection()); Player player = connections.get(Net.getLastConnection());
Weapon weapon = Weapon.values()[packet.weaponid]; Weapon weapon = (Weapon)Upgrade.getByID(packet.weaponid);
weapon.shoot(player, packet.x, packet.y, packet.rotation); weapon.shoot(player, packet.x, packet.y, packet.rotation);
packet.playerid = player.id; packet.playerid = player.id;
@@ -129,7 +127,7 @@ public class NetServer extends Module{
Vars.control.input.placeBlockInternal(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, false); Vars.control.input.placeBlockInternal(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, false);
packet.playerid = connections.get(Net.getLastConnection()).id; packet.playerid = connections.get(Net.getLastConnection()).id;
Recipe recipe = Recipe.getByResult(Block.getByID(packet.block)); Recipe recipe = Recipes.getByResult(Block.getByID(packet.block));
if(recipe != null){ if(recipe != null){
for(ItemStack stack : recipe.requirements){ for(ItemStack stack : recipe.requirements){
Vars.control.removeItem(stack); Vars.control.removeItem(stack);
@@ -149,16 +147,28 @@ public class NetServer extends Module{
Net.handleServer(ChatPacket.class, packet -> { Net.handleServer(ChatPacket.class, packet -> {
Player player = connections.get(Net.getLastConnection()); Player player = connections.get(Net.getLastConnection());
if(player == null) if(player == null) return; //GHOSTS AAAA
return; //GHOSTS AAAA
packet.name = player.name; packet.name = player.name;
Net.send(packet, SendMode.tcp); Net.send(packet, SendMode.tcp);
}); });
Net.handleServer(UpgradePacket.class, packet -> { Net.handleServer(UpgradePacket.class, packet -> {
Weapon weapon = Weapon.values()[packet.id]; Weapon weapon = (Weapon)Upgrade.getByID(packet.id);
Vars.control.removeItems(weapon.requirements); Vars.control.removeItems(UpgradeRecipes.get(weapon));
});
Net.handleServer(WeaponSwitchPacket.class, packet -> {
Player player = connections.get(Net.getLastConnection());
if(player == null) return;
packet.playerid = player.id;
player.weaponLeft = (Weapon)Upgrade.getByID(packet.left);
player.weaponRight = (Weapon)Upgrade.getByID(packet.right);
Net.sendExcept(player.clientid, packet, SendMode.tcp);
}); });
} }

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.core;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
@@ -324,6 +325,16 @@ public class Renderer extends RendererModule{
} }
Draw.reset(); Draw.reset();
} }
//draw config selected block
if(Vars.ui.configfrag.isShown()){
Tile tile = ui.configfrag.getSelectedTile();
Draw.color(Colors.get("accent"));
Draw.thick(1f);
Draw.square(tile.worldx() + tile.block().getPlaceOffset().x, tile.worldy() + tile.block().getPlaceOffset().y,
tile.block().width * Vars.tilesize / 2f + 1f);
Draw.reset();
}
int tilex = control.input.getBlockX(); int tilex = control.input.getBlockX();
int tiley = control.input.getBlockY(); int tiley = control.input.getBlockY();

View File

@@ -392,9 +392,9 @@ public class Tutorial{
} }
void onSwitch(){ void onSwitch(){
if(!Vars.control.getWeapons().contains(Weapon.multigun, true)){ if(!Vars.control.getWeapons().contains(Weapon.triblaster, true)){
Vars.control.getWeapons().add(Weapon.multigun); Vars.control.getWeapons().add(Weapon.triblaster);
Vars.ui.weaponfrag.update(); Vars.ui.hudfrag.updateWeapons();
} }
} }
}, },

View File

@@ -39,13 +39,11 @@ public class UI extends SceneModule{
public SettingsMenuDialog settings; public SettingsMenuDialog settings;
public ControlsDialog controls; public ControlsDialog controls;
public MapEditorDialog editor; public MapEditorDialog editor;
public UpgradeDialog upgrades;
public final MenuFragment menufrag = new MenuFragment(); public final MenuFragment menufrag = new MenuFragment();
public final ToolFragment toolfrag = new ToolFragment(); public final ToolFragment toolfrag = new ToolFragment();
public final HudFragment hudfrag = new HudFragment(); public final HudFragment hudfrag = new HudFragment();
public final PlacementFragment placefrag = new PlacementFragment(); public final PlacementFragment placefrag = new PlacementFragment();
public final WeaponFragment weaponfrag = new WeaponFragment();
public final ChatFragment chatfrag = new ChatFragment(); public final ChatFragment chatfrag = new ChatFragment();
public final PlayerListFragment listfrag = new PlayerListFragment(); public final PlayerListFragment listfrag = new PlayerListFragment();
public final BackgroundFragment backfrag = new BackgroundFragment(); public final BackgroundFragment backfrag = new BackgroundFragment();
@@ -137,7 +135,6 @@ public class UI extends SceneModule{
join = new JoinDialog(); join = new JoinDialog();
discord = new DiscordDialog(); discord = new DiscordDialog();
load = new LoadDialog(); load = new LoadDialog();
upgrades = new UpgradeDialog();
levels = new LevelDialog(); levels = new LevelDialog();
settings = new SettingsMenuDialog(); settings = new SettingsMenuDialog();
paused = new PausedDialog(); paused = new PausedDialog();
@@ -147,7 +144,6 @@ public class UI extends SceneModule{
build.begin(scene); build.begin(scene);
backfrag.build(); backfrag.build();
weaponfrag.build();
hudfrag.build(); hudfrag.build();
configfrag.build(); configfrag.build();
menufrag.build(); menufrag.build();

View File

@@ -1,7 +1,6 @@
package io.anuke.mindustry.entities; package io.anuke.mindustry.entities;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.entities.effect.DamageArea; import io.anuke.mindustry.entities.effect.DamageArea;
import io.anuke.mindustry.entities.effect.EMP; import io.anuke.mindustry.entities.effect.EMP;
import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.Enemy;
@@ -10,17 +9,12 @@ import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.BaseBulletType; import io.anuke.ucore.entities.BaseBulletType;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
public abstract class BulletType extends BaseBulletType<Bullet>{ import static io.anuke.mindustry.graphics.Fx.*;
static Color glowy = Color.valueOf("fdc056");
static Color lightGold = Hue.mix(Color.GOLD, Color.WHITE, 0.4f); public abstract class BulletType extends BaseBulletType<Bullet>{
static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f);
static Color lightOrange = Color.valueOf("f68021");
static Color whiteOrange = Hue.mix(lightOrange, Color.WHITE, 0.6f);
static Color whiteYellow = Hue.mix(Color.YELLOW, Color.WHITE, 0.6f);
public static final BulletType public static final BulletType
@@ -88,9 +82,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
} }
public void removed(Bullet b){ public void removed(Bullet b){
Timers.run(5f, ()->{ Timers.run(5f, ()-> new EMP(b.x, b.y, b.getDamage()).add());
new EMP(b.x, b.y, b.getDamage()).add();
});
Effects.effect(Fx.empshockwave, b); Effects.effect(Fx.empshockwave, b);
Effects.shake(3f, 3f, b); Effects.shake(3f, 3f, b);
} }
@@ -220,12 +212,6 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void draw(Bullet b){} public void draw(Bullet b){}
}, },
shellshot = new BulletType(1.5f, 6){
{
lifetime = 7f;
}
public void draw(Bullet b){}
},
blastshot = new BulletType(1.6f, 6){ blastshot = new BulletType(1.6f, 6){
{ {
lifetime = 7f; lifetime = 7f;
@@ -255,7 +241,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.reset(); Draw.reset();
} }
}, },
flame = new BulletType(0.6f, 5){ flame = new BulletType(0.6f, 5){ //for turrets
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(Color.YELLOW, Color.SCARLET, b.time/lifetime); Draw.color(Color.YELLOW, Color.SCARLET, b.time/lifetime);
float size = 6f-b.time/lifetime*5f; float size = 6f-b.time/lifetime*5f;
@@ -274,7 +260,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.reset(); Draw.reset();
} }
}, },
flameshot = new BulletType(0.5f, 3){ flameshot = new BulletType(0.5f, 3){ //for enemies
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(Color.ORANGE, Color.SCARLET, b.time/lifetime); Draw.color(Color.ORANGE, Color.SCARLET, b.time/lifetime);
float size = 6f-b.time/lifetime*5f; float size = 6f-b.time/lifetime*5f;
@@ -282,21 +268,158 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.reset(); Draw.reset();
} }
}, },
shot = new BulletType(2.4f, 4){ shot = new BulletType(2.7f, 5){
{lifetime = 40;} {
lifetime = 40;
}
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(lightGold); Draw.color(Color.WHITE, lightOrange, b.fract()/2f + 0.25f);
Draw.rect("bullet", b.x, b.y, b.angle()); Draw.thick(1.5f);
Draw.lineAngle(b.x, b.y, b.angle(), 3f);
Draw.reset(); Draw.reset();
} }
}, },
multishot = new BulletType(2.5f, 3){ spread = new BulletType(2.4f, 7) {
{lifetime=40;} {
public void draw(Bullet b){ lifetime = 70;
Draw.color(Color.SKY); }
Draw.rect("bullet", b.x, b.y, b.angle());
public void draw(Bullet b) {
float size = 3f - b.ifract()*1f;
Draw.color(Color.PURPLE, Color.WHITE, 0.8f);
Draw.thick(1f);
Draw.circle(b.x, b.y, size);
Draw.reset(); Draw.reset();
} }
},
cluster = new BulletType(4.4f, 13){
{
lifetime = 60;
drag = 0.06f;
}
public void draw(Bullet b){
Draw.thick(2f);
Draw.color(lightOrange, Color.WHITE, 0.4f);
Draw.polygon(b.y, b.x, 3, 1.6f, b.angle());
Draw.thick(1f);
Draw.color(Color.WHITE, lightOrange, b.ifract()/2f);
Draw.alpha(b.ifract());
Draw.spikes(b.x, b.y, 1.5f, 2f, 6);
Draw.reset();
}
public void despawned(Bullet b){
removed(b);
}
public void removed(Bullet b){
Effects.shake(1.5f, 1.5f, b);
Effects.effect(Fx.clusterbomb, b);
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 22f, damage);
}
},
vulcan = new BulletType(4.5f, 11) {
{
lifetime = 50;
}
public void init(Bullet b) {
Timers.reset(b, "smoke", Mathf.random(4f));
}
public void draw(Bullet b){
Draw.color(lightGray);
Draw.thick(1f);
Draw.lineAngleCenter(b.x, b.y, b.angle(), 2f);
Draw.reset();
}
public void update(Bullet b){
if(Timers.get(b, "smoke", 4)){
Effects.effect(Fx.chainsmoke, b.x, b.y);
}
}
},
shockshell = new BulletType(5.4f, 10) {
{
drag = 0.03f;
lifetime = 30f;
}
public void init(Bullet b) {
b.velocity.scl(Mathf.random(0.5f, 1f));
}
public void draw(Bullet b) {
Draw.color(Color.WHITE, Color.ORANGE, b.ifract());
Draw.thick(2f);
Draw.lineAngleCenter(b.x, b.y, b.angle(), b.fract()*5f);
Draw.reset();
}
public void despawned(Bullet b) {
removed(b);
}
public void removed(Bullet b) {
for(int i = 0; i < 4; i ++){
Bullet bullet = new Bullet(scrap, b.owner, b.x, b.y, b.angle() + Mathf.range(80f));
bullet.add();
}
}
},
scrap = new BulletType(2f, 3) {
{
drag = 0.06f;
lifetime = 30f;
}
public void init(Bullet b) {
b.velocity.scl(Mathf.random(0.5f, 1f));
}
public void draw(Bullet b) {
Draw.color(Color.WHITE, Color.ORANGE, b.ifract());
Draw.thick(1f);
Draw.lineAngleCenter(b.x, b.y, b.angle(), b.fract()*4f);
Draw.reset();
}
},
beamlaser = new BulletType(0.001f, 35) {
float length = 230f;
{
drawSize = length*2f+20f;
lifetime = 15f;
}
public void init(Bullet b) {
DamageArea.damageLine(true, Fx.beamhit, b.x, b.y, b.angle(), length, damage);
}
public void draw(Bullet b) {
float f = b.fract()*1.5f;
Draw.color(beam);
Draw.rect("circle", b.x, b.y, 6f*f, 6f*f);
Draw.thick(3f * f);
Draw.lineAngle(b.x, b.y, b.angle(), length);
Draw.thick(2f * f);
Draw.lineAngle(b.x, b.y, b.angle(), length + 6f);
Draw.thick(1f * f);
Draw.lineAngle(b.x, b.y, b.angle(), length + 12f);
Draw.color(beamLight);
Draw.thick(1.5f * f);
Draw.rect("circle", b.x, b.y, 3f*f, 3f*f);
Draw.lineAngle(b.x, b.y, b.angle(), length);
}
}; };
private BulletType(float speed, int damage){ private BulletType(float speed, int damage){

View File

@@ -16,15 +16,17 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
public class Player extends DestructibleEntity implements Syncable{ public class Player extends DestructibleEntity implements Syncable{
private static final float speed = 1.1f; static final float speed = 1.1f;
private static final float dashSpeed = 1.8f; static final float dashSpeed = 1.8f;
public String name = "name"; public String name = "name";
public transient Weapon weapon = Weapon.blaster;
public Mech mech = Mech.standard;
public float angle;
public boolean isAndroid; public boolean isAndroid;
public Weapon weaponLeft = Weapon.blaster;
public Weapon weaponRight = Weapon.blaster;
public Mech mech = Mech.standard;
public float angle;
public transient float targetAngle = 0f; public transient float targetAngle = 0f;
public transient int clientid; public transient int clientid;
@@ -86,15 +88,28 @@ public class Player extends DestructibleEntity implements Syncable{
} }
if((Vars.debug && (!Vars.showPlayer || !Vars.showUI)) || (isAndroid && isLocal)) return; if((Vars.debug && (!Vars.showPlayer || !Vars.showUI)) || (isAndroid && isLocal)) return;
boolean snap = Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal;
String part = isAndroid ? "ship" : "mech"; String part = isAndroid ? "ship" : "mech";
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal){ if(snap){
Draw.rect(part+"-"+mech.name(), (int)x, (int)y, angle-90); Draw.rect(part + "-" + mech.name, (int)x, (int)y, angle-90);
}else{ }else{
Draw.rect(part+"-"+mech.name(), x, y, angle-90); Draw.rect(part + "-" + mech.name, x, y, angle-90);
}
if(!isAndroid) {
for (boolean b : new boolean[]{true, false}) {
Weapon weapon = b ? weaponLeft : weaponRight;
Angles.translation(angle + Mathf.sign(b) * -50f, 3.5f);
float s = 5f;
if(snap){
Draw.rect(weapon.name, (int)x + Angles.x(), (int)y + Angles.y(), s, s, angle- 90);
}else{
Draw.rect(weapon.name, x + Angles.x(), y + Angles.y(), s, s, angle - 90);
}
}
} }
} }
@Override @Override
@@ -124,12 +139,12 @@ public class Player extends DestructibleEntity implements Syncable{
vector.y += ya*speed; vector.y += ya*speed;
vector.x += xa*speed; vector.x += xa*speed;
boolean shooting = !Inputs.keyDown("dash") && Inputs.keyDown("shootInternal") && control.getInput().recipe == null boolean shooting = !Inputs.keyDown("dash") && Inputs.keyDown("shoot") && control.getInput().recipe == null
&& !ui.hasMouse() && !control.getInput().onConfigurable(); && !ui.hasMouse() && !control.getInput().onConfigurable();
if(shooting && Timers.get(this, "reload", weapon.reload)){ if(shooting){
weapon.shoot(this, x, y, Angles.mouseAngle(x, y)); weaponLeft.update(player, true);
Sounds.play(weapon.shootsound); weaponRight.update(player, false);
} }
if(Inputs.keyDown("dash") && Timers.get(this, "dashfx", 3) && vector.len() > 0){ if(Inputs.keyDown("dash") && Timers.get(this, "dashfx", 3) && vector.len() > 0){

View File

@@ -1,22 +1,66 @@
package io.anuke.mindustry.entities.effect; package io.anuke.mindustry.entities.effect;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.*;
//TODO
public class DamageArea{ public class DamageArea{
private static Rectangle rect = new Rectangle();
//only for entities, not tiles (yet!)
public static void damageLine(boolean enemies, Effect effect, float x, float y, float angle, float length, int damage){
Angles.translation(angle, length);
rect.setPosition(x, y).setSize(Angles.x(), Angles.y());
float x2 = Angles.x() + x, y2 = Angles.y() + y;
if(rect.width < 0){
rect.x += rect.width;
rect.width *= -1;
}
if(rect.height < 0){
rect.y += rect.height;
rect.height *= -1;
}
float expand = 3f;
rect.y -= expand;
rect.x -= expand;
rect.width += expand*2;
rect.height += expand*2;
if(enemies){
Entities.getNearby(Vars.control.enemyGroup, rect, e -> {
Enemy enemy = (Enemy)e;
Rectangle other = enemy.hitbox.getRect(enemy.x, enemy.y);
other.y -= expand;
other.x -= expand;
other.width += expand*2;
other.height += expand*2;
Vector2 vec = Physics.raycastRect(x, y, x2, y2, other);
if(vec != null){
Effects.effect(effect, vec.x, vec.y);
enemy.damage(damage);
}
});
}//TODO else damage players and blocks?
}
public static void damageEntities(float x, float y, float radius, int damage){ public static void damageEntities(float x, float y, float radius, int damage){
damage(true, x, y, radius, damage); damage(true, x, y, radius, damage);
if(!Vars.android && Vars.player.distanceTo(x, y) < radius){ for(Player player : Vars.control.playerGroup.all()){
Player player = Vars.player; if(player.isAndroid) continue;
int amount = calculateDamage(x, y, player.x, player.y, radius, damage); int amount = calculateDamage(x, y, player.x, player.y, radius, damage);
player.damage(amount); player.damage(amount);
} }

View File

@@ -56,7 +56,9 @@ public class EMP extends TimedEntity{
p.setPower(tile, 0f); p.setPower(tile, 0f);
tile.entity.damage((int)(damage*1.5f)); //extra damage tile.entity.damage((int)(damage*1.5f)); //extra damage
} }
if(tile == null) continue;
//entity may be null here, after the block is dead! //entity may be null here, after the block is dead!
Effects.effect(Fx.empspark, tile.worldx(), tile.worldy()); Effects.effect(Fx.empspark, tile.worldx(), tile.worldy());
if(tile.entity != null) tile.entity.damage(damage); if(tile.entity != null) tile.entity.damage(damage);
@@ -82,7 +84,7 @@ public class EMP extends TimedEntity{
} }
Draw.thick(fract()*2f); Draw.thick(fract()*2f);
Draw.polygon(34, x, y, radius * Vars.tilesize); Draw.polygon(y, x, 34, radius * Vars.tilesize);
Draw.reset(); Draw.reset();
} }
@@ -96,7 +98,7 @@ public class EMP extends TimedEntity{
float dx = Mathf.range(r), float dx = Mathf.range(r),
dy = Mathf.range(r); dy = Mathf.range(r);
float frac = (float)(seg+1f)/joints; float frac = (seg+1f)/joints;
float tx = (targetx - x)*frac + x + dx, float tx = (targetx - x)*frac + x + dx,
ty = (targety - y)*frac + y + dy; ty = (targety - y)*frac + y + dy;

View File

@@ -28,6 +28,7 @@ public class Enemy extends DestructibleEntity implements Syncable{
public float angle; public float angle;
public Vector2 velocity = new Vector2(); public Vector2 velocity = new Vector2();
public Entity target; public Entity target;
public float hitTime;
public int tier = 1; public int tier = 1;
public Enemy(EnemyType type){ public Enemy(EnemyType type){
@@ -59,6 +60,12 @@ public class Enemy extends DestructibleEntity implements Syncable{
return (other instanceof Bullet) && !(((Bullet) other).owner instanceof Enemy); return (other instanceof Bullet) && !(((Bullet) other).owner instanceof Enemy);
} }
@Override
public void damage(int amount){
super.damage(amount);
hitTime = EnemyType.hitDuration;
}
@Override @Override
public void onDeath(){ public void onDeath(){
type.onDeath(this); type.onDeath(this);

View File

@@ -31,6 +31,7 @@ public class EnemyType {
public final static int maxtier = 4; public final static int maxtier = 4;
public final static float maxIdle = 60*1.5f; public final static float maxIdle = 60*1.5f;
public final static float maxIdleLife = 60f*13f; //13 seconds idle = death public final static float maxIdleLife = 60f*13f; //13 seconds idle = death
public final static float hitDuration = 5f;
public final String name; public final String name;
public final byte id; public final byte id;
@@ -65,6 +66,7 @@ public class EnemyType {
String region = name + "-t" + Mathf.clamp(enemy.tier, 1, 3); String region = name + "-t" + Mathf.clamp(enemy.tier, 1, 3);
Shaders.outline.color.set(tierColors[enemy.tier - 1]); Shaders.outline.color.set(tierColors[enemy.tier - 1]);
Shaders.outline.lighten = Mathf.clamp(enemy.hitTime/hitDuration);
Shaders.outline.region = Draw.region(region); Shaders.outline.region = Draw.region(region);
Shaders.outline.apply(); Shaders.outline.apply();
@@ -73,12 +75,16 @@ public class EnemyType {
Draw.color(); Draw.color();
Graphics.flush(); Graphics.flush();
Shaders.outline.lighten = 0f;
} }
public void drawOver(Enemy enemy){ } public void drawOver(Enemy enemy){ }
public void update(Enemy enemy){ public void update(Enemy enemy){
float lastx = enemy.x, lasty = enemy.y; float lastx = enemy.x, lasty = enemy.y;
if(enemy.hitTime > 0){
enemy.hitTime -= Timers.delta();
}
move(enemy); move(enemy);

View File

@@ -27,7 +27,7 @@ public class TitanType extends EnemyType {
if(Timers.getTime(enemy, "salvo") < 60){ if(Timers.getTime(enemy, "salvo") < 60){
if(Timers.get(enemy, "salvoShoot", 6)){ if(Timers.get(enemy, "salvoShoot", 6)){
enemy.shoot(BulletType.flame, Mathf.range(20f)); enemy.shoot(BulletType.flameshot, Mathf.range(20f));
} }
} }

View File

@@ -2,7 +2,6 @@ package io.anuke.mindustry.graphics;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors; import com.badlogic.gdx.graphics.Colors;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.core.Effects.Effect;
@@ -11,10 +10,15 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
public class Fx{ public class Fx{
static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f); public static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f);
static Color lightOrange = Color.valueOf("f68021"); public static Color lightOrange = Color.valueOf("f68021");
static Color whiteOrange = Hue.mix(lightOrange, Color.WHITE, 0.6f); public static Color lighterOrange = Color.valueOf("f6e096");
static Color whiteYellow = Hue.mix(Color.YELLOW, Color.WHITE, 0.6f); public static Color whiteOrange = Hue.mix(lightOrange, Color.WHITE, 0.6f);
public static Color whiteYellow = Hue.mix(Color.YELLOW, Color.WHITE, 0.6f);
public static Color lightGray = Color.valueOf("b0b0b0");
public static Color glowy = Color.valueOf("fdc056");
public static Color beam = Color.valueOf("9bffbe");
public static Color beamLight = Color.valueOf("ddffe9");
public static final Effect public static final Effect
@@ -117,7 +121,7 @@ public class Fx{
nuclearShockwave = new Effect(10f, 200f, e -> { nuclearShockwave = new Effect(10f, 200f, e -> {
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract()); Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract());
Draw.thick(e.fract()*3f + 0.2f); Draw.thick(e.fract()*3f + 0.2f);
Draw.polygon(40, e.x, e.y, e.ifract()*140f); Draw.polygon(e.y, e.x, 40, e.ifract()*140f);
Draw.reset(); Draw.reset();
}), }),
@@ -350,42 +354,51 @@ public class Fx{
Draw.reset(); Draw.reset();
}), }),
shoot = new Effect(8, e -> { laserShoot = new Effect(8, e -> {
Draw.thickness(1f); Draw.color(Color.WHITE, lightOrange, e.ifract());
Draw.color(Color.WHITE, Color.GOLD, e.ifract()); Draw.lineShot(e.x, e.y, e.rotation, 3, e.fract(), 6f, 2f, 0.8f);
Draw.spikes(e.x, e.y, e.ifract() * 2f, 2, 5); Draw.reset();
}),
spreadShoot = new Effect(12, e -> {
Draw.color(Color.WHITE, Color.PURPLE, e.ifract());
Draw.lineShot(e.x, e.y, e.rotation, 3, e.fract(), 9f, 3.5f, 0.8f);
Draw.reset();
}),
clusterShoot = new Effect(12, e -> {
Draw.color(Color.WHITE, lightOrange, e.ifract());
Draw.lineShot(e.x, e.y, e.rotation, 3, e.fract(), 10f, 2.5f, 0.7f);
Draw.reset(); Draw.reset();
}), }),
shoot2 = new Effect(8, e -> { vulcanShoot = new Effect(8, e -> {
Draw.thickness(1f); Draw.color(lighterOrange, lightOrange, e.ifract());
Draw.color(Color.WHITE, Color.SKY, e.ifract()); Draw.lineShot(e.x, e.y, e.rotation, 3, e.fract(), 10f, 2f, 0.7f);
Draw.spikes(e.x, e.y, e.ifract() * 2f, 1, 5);
Draw.reset(); Draw.reset();
}), }),
shoot3 = new Effect(8, e -> { shockShoot = new Effect(8, e -> {
Draw.thickness(1f);
Draw.color(Color.WHITE, Color.GOLD, e.ifract());
Draw.spikes(e.x, e.y, e.ifract() * 2f, 1, 5);
Draw.reset();
}),
railshoot = new Effect(8, e -> {
Draw.thickness(2f - e.ifract()*2f);
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract());
Draw.spikes(e.x, e.y, 1f + e.ifract() * 4f, 1, 5);
Draw.reset();
}),
mortarshoot = new Effect(9, e -> {
Draw.thickness(1.3f - e.ifract());
Draw.color(Color.WHITE, Color.ORANGE, e.ifract()); Draw.color(Color.WHITE, Color.ORANGE, e.ifract());
Draw.spikes(e.x, e.y, e.ifract() * 4f, 2, 6); Draw.lineShot(e.x, e.y, e.rotation, 3, e.fract(), 14f, 4f, 0.8f);
Draw.circle(e.x, e.y, e.ifract() * 5f + 1f);
Draw.reset(); Draw.reset();
}), }),
beamShoot = new Effect(8, e -> {
Draw.color(beamLight, beam, e.ifract());
Draw.lineShot(e.x, e.y, e.rotation - 70, 3, e.fract(), 12f, 1f, 0.5f);
Draw.lineShot(e.x, e.y, e.rotation + 70, 3, e.fract(), 12f, 1f, 0.5f);
Draw.reset();
}),
beamhit = new Effect(8, e -> {
Draw.color(beamLight, beam, e.ifract());
Draw.thick(e.fract()*3f+0.5f);
Draw.circle(e.x, e.y, e.ifract()*8f);
Draw.spikes(e.x, e.y, e.ifract()*6f, 2f, 4, 45);
Draw.reset();
}),
titanExplosion = new Effect(11, 48f, e -> { titanExplosion = new Effect(11, 48f, e -> {
Draw.thickness(2f*e.fract()+0.5f); Draw.thickness(2f*e.fract()+0.5f);
Draw.color(Color.WHITE, Color.DARK_GRAY, e.powfract()); Draw.color(Color.WHITE, Color.DARK_GRAY, e.powfract());
@@ -435,6 +448,14 @@ public class Fx{
Draw.reset(); Draw.reset();
}), }),
clusterbomb = new Effect(10f, e -> {
Draw.color(Color.WHITE, lightOrange, e.ifract());
Draw.thick(e.fract()*1.5f);
Draw.polygon(e.y, e.x, 4, e.fract()*8f);
Draw.circle(e.x, e.y, e.ifract()*14f);
Draw.reset();
}),
coreexplosion = new Effect(13, e -> { coreexplosion = new Effect(13, e -> {
Draw.thickness(3f-e.ifract()*2f); Draw.thickness(3f-e.ifract()*2f);
@@ -457,10 +478,16 @@ public class Fx{
Draw.rect("circle", e.x, e.y, size, size); Draw.rect("circle", e.x, e.y, size, size);
Draw.reset(); Draw.reset();
}), }),
chainsmoke = new Effect(30, e -> {
Draw.color(lightGray);
float size = e.fract()*4f;
Draw.rect("circle", e.x, e.y, size, size);
Draw.reset();
}),
dashsmoke = new Effect(30, e -> { dashsmoke = new Effect(30, e -> {
Draw.color(Color.CORAL, Color.GRAY, e.ifract()); Draw.color(Color.CORAL, Color.GRAY, e.ifract());
//Draw.alpha(e.fract());
float size = e.fract()*4f; float size = e.fract()*4f;
Draw.rect("circle", e.x, e.y, size, size); Draw.rect("circle", e.x, e.y, size, size);
Draw.reset(); Draw.reset();
@@ -472,13 +499,6 @@ public class Fx{
Draw.circle(e.x, e.y, 7f - e.ifract() * 6f); Draw.circle(e.x, e.y, 7f - e.ifract() * 6f);
Draw.reset(); Draw.reset();
}), }),
ind = new Effect(100, e -> {
Draw.thickness(3f);
Draw.color(Color.ROYAL);
Draw.circle(e.x, e.y, 3);
Draw.reset();
}),
respawn = new Effect(Vars.respawnduration, e -> { respawn = new Effect(Vars.respawnduration, e -> {
Draw.tcolor(Color.SCARLET); Draw.tcolor(Color.SCARLET);

View File

@@ -16,7 +16,8 @@ public class Shaders{
public static class Outline extends Shader{ public static class Outline extends Shader{
public Color color = new Color(); public Color color = new Color();
public float lighten = 0f;
public Outline(){ public Outline(){
super("outline", "default"); super("outline", "default");
} }
@@ -24,6 +25,7 @@ public class Shaders{
@Override @Override
public void apply(){ public void apply(){
shader.setUniformf("u_color", color); shader.setUniformf("u_color", color);
shader.setUniformf("u_lighten", lighten);
shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth(), region.getTexture().getHeight())); shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
} }

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.input;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.resource.Weapon;
@@ -80,8 +81,9 @@ public class DesktopInput extends InputHandler{
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){ for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
if(Inputs.keyTap("weapon_" + i)){ if(Inputs.keyTap("weapon_" + i)){
player.weapon = control.getWeapons().get(i - 1); player.weaponLeft = player.weaponRight = control.getWeapons().get(i - 1);
ui.weaponfrag.update(); Vars.netClient.handleWeaponSwitch();
Vars.ui.hudfrag.updateWeapons();
} }
} }

View File

@@ -11,6 +11,7 @@ import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Recipes;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.SpawnPoint; import io.anuke.mindustry.world.SpawnPoint;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
@@ -241,7 +242,7 @@ public abstract class InputHandler extends InputAdapter{
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block(); Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
Recipe result = null; Recipe result = null;
for(Recipe recipe : Recipe.values()){ for(Recipe recipe : Recipes.all()){
if(recipe.result == block){ if(recipe.result == block){
result = recipe; result = recipe;
break; break;

View File

@@ -101,7 +101,7 @@ public enum PlaceMode{
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize); Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
}else if(android && control.getInput().breaktime > 0){ }else if(android && control.getInput().breaktime > 0){
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract); Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26); Draw.polygon(tile.worldy() + offset.y, tile.worldx() + offset.x, 25, 4 + (1f - fract) * 26);
} }
Draw.reset(); Draw.reset();
} }

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.io; package io.anuke.mindustry.io;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
@@ -7,7 +8,6 @@ import io.anuke.mindustry.core.Tutorial;
import io.anuke.mindustry.core.Tutorial.Stage; import io.anuke.mindustry.core.Tutorial.Stage;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.GameMode; import io.anuke.mindustry.world.GameMode;
import io.anuke.mindustry.world.Map; import io.anuke.mindustry.world.Map;
@@ -22,6 +22,17 @@ import io.anuke.ucore.util.Mathf;
public class BundleGen { public class BundleGen {
private static FileHandle file; private static FileHandle file;
public static void cleanBundles(FileHandle file){
String[] strings = file.readString().split("\n");
FileHandle out = Gdx.files.absolute("/home/anuke/out.properties");
out.writeString("", false);
for(String string : strings){
if(!string.contains(".description")){
out.writeString(string + "\n", true);
}
}
}
public static void buildBundle(FileHandle file){ public static void buildBundle(FileHandle file){
BundleGen.file = file; BundleGen.file = file;
@@ -47,10 +58,6 @@ public class BundleGen {
for(GameMode mode : GameMode.values()){ for(GameMode mode : GameMode.values()){
write("mode." + mode.name() + ".name=" + mode.name()); write("mode." + mode.name() + ".name=" + mode.name());
} }
for(Weapon weapon : Weapon.values()){
write("weapon." + weapon.name() + ".name=" + weapon.name());
write("weapon." + weapon.name() + ".description=" + weapon.description);
}
for(Item item : Item.getAllItems()){ for(Item item : Item.getAllItems()){
write("item." + item.name + ".name=" + item.name); write("item." + item.name + ".name=" + item.name);
} }

View File

@@ -154,7 +154,7 @@ public class NetworkIO {
load(file.read()); load(file.read());
} }
//TODO GWT support
public static void load(InputStream is){ public static void load(InputStream is){
try(DataInputStream stream = new DataInputStream(is)){ try(DataInputStream stream = new DataInputStream(is)){
@@ -187,7 +187,8 @@ public class NetworkIO {
Vars.control.getWeapons().clear(); Vars.control.getWeapons().clear();
Vars.control.getWeapons().add(Weapon.blaster); Vars.control.getWeapons().add(Weapon.blaster);
Vars.ui.weaponfrag.update(); Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
Vars.ui.hudfrag.updateWeapons();
//enemies //enemies

View File

@@ -7,6 +7,7 @@ import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.entities.enemies.EnemyType; import io.anuke.mindustry.entities.enemies.EnemyType;
import io.anuke.mindustry.io.SaveFileVersion; import io.anuke.mindustry.io.SaveFileVersion;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.BlockLoader; import io.anuke.mindustry.world.BlockLoader;
import io.anuke.mindustry.world.GameMode; import io.anuke.mindustry.world.GameMode;
@@ -60,15 +61,15 @@ public class Save12 extends SaveFileVersion {
Vars.control.getWeapons().clear(); Vars.control.getWeapons().clear();
Vars.control.getWeapons().add(Weapon.blaster); Vars.control.getWeapons().add(Weapon.blaster);
Vars.player.weapon = Weapon.blaster; Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
int weapons = stream.readByte(); int weapons = stream.readByte();
for(int i = 0; i < weapons; i ++){ for(int i = 0; i < weapons; i ++){
Vars.control.addWeapon(Weapon.values()[stream.readByte()]); Vars.control.addWeapon((Weapon)Upgrade.getByID(stream.readByte()));
} }
Vars.ui.weaponfrag.update(); Vars.ui.hudfrag.updateWeapons();
//inventory //inventory
@@ -194,7 +195,7 @@ public class Save12 extends SaveFileVersion {
//start at 1, because the first weapon is always the starter - ignore that //start at 1, because the first weapon is always the starter - ignore that
for(int i = 1; i < Vars.control.getWeapons().size; i ++){ for(int i = 1; i < Vars.control.getWeapons().size; i ++){
stream.writeByte(Vars.control.getWeapons().get(i).ordinal()); //weapon ordinal stream.writeByte(Vars.control.getWeapons().get(i).id); //weapon ordinal
} }
//--INVENTORY-- //--INVENTORY--

View File

@@ -7,6 +7,7 @@ import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.entities.enemies.EnemyType; import io.anuke.mindustry.entities.enemies.EnemyType;
import io.anuke.mindustry.io.SaveFileVersion; import io.anuke.mindustry.io.SaveFileVersion;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.Blocks;
@@ -60,15 +61,15 @@ public class Save13 extends SaveFileVersion {
Vars.control.getWeapons().clear(); Vars.control.getWeapons().clear();
Vars.control.getWeapons().add(Weapon.blaster); Vars.control.getWeapons().add(Weapon.blaster);
Vars.player.weapon = Weapon.blaster; Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
int weapons = stream.readByte(); int weapons = stream.readByte();
for(int i = 0; i < weapons; i ++){ for(int i = 0; i < weapons; i ++){
Vars.control.addWeapon(Weapon.values()[stream.readByte()]); Vars.control.addWeapon((Weapon) Upgrade.getByID(stream.readByte()));
} }
Vars.ui.weaponfrag.update(); Vars.ui.hudfrag.updateWeapons();
//inventory //inventory
@@ -204,7 +205,7 @@ public class Save13 extends SaveFileVersion {
//start at 1, because the first weapon is always the starter - ignore that //start at 1, because the first weapon is always the starter - ignore that
for(int i = 1; i < Vars.control.getWeapons().size; i ++){ for(int i = 1; i < Vars.control.getWeapons().size; i ++){
stream.writeByte(Vars.control.getWeapons().get(i).ordinal()); //weapon ordinal stream.writeByte(Vars.control.getWeapons().get(i).id); //weapon ordinal
} }
//--INVENTORY-- //--INVENTORY--

View File

@@ -8,6 +8,7 @@ import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.entities.enemies.EnemyType; import io.anuke.mindustry.entities.enemies.EnemyType;
import io.anuke.mindustry.io.SaveFileVersion; import io.anuke.mindustry.io.SaveFileVersion;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.GameMode; import io.anuke.mindustry.world.GameMode;
@@ -78,15 +79,15 @@ public class Save14 extends SaveFileVersion{
Vars.control.getWeapons().clear(); Vars.control.getWeapons().clear();
Vars.control.getWeapons().add(Weapon.blaster); Vars.control.getWeapons().add(Weapon.blaster);
Vars.player.weapon = Weapon.blaster; Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
int weapons = stream.readByte(); int weapons = stream.readByte();
for(int i = 0; i < weapons; i ++){ for(int i = 0; i < weapons; i ++){
Vars.control.addWeapon(Weapon.values()[stream.readByte()]); Vars.control.addWeapon((Weapon) Upgrade.getByID(stream.readByte()));
} }
Vars.ui.weaponfrag.update(); Vars.ui.hudfrag.updateWeapons();
//inventory //inventory
@@ -232,7 +233,7 @@ public class Save14 extends SaveFileVersion{
//start at 1, because the first weapon is always the starter - ignore that //start at 1, because the first weapon is always the starter - ignore that
for(int i = 1; i < Vars.control.getWeapons().size; i ++){ for(int i = 1; i < Vars.control.getWeapons().size; i ++){
stream.writeByte(Vars.control.getWeapons().get(i).ordinal()); //weapon ordinal stream.writeByte(Vars.control.getWeapons().get(i).id); //weapon ordinal
} }
//--INVENTORY-- //--INVENTORY--

View File

@@ -238,9 +238,9 @@ public class MapView extends Element implements GestureListener{
Draw.thick(Unit.dp.scl(3f * zoom)); Draw.thick(Unit.dp.scl(3f * zoom));
Draw.line(sx, sy, v2.x, v2.y); Draw.line(sx, sy, v2.x, v2.y);
Draw.polygon(40, sx, sy, editor.getBrushSize() * zoom * 3); Draw.polygon(sy, sx, 40, editor.getBrushSize() * zoom * 3);
Draw.polygon(40, v2.x, v2.y, editor.getBrushSize() * zoom * 3); Draw.polygon(v2.y, v2.x, 40, editor.getBrushSize() * zoom * 3);
} }
batch.flush(); batch.flush();

View File

@@ -116,6 +116,11 @@ public class Packets {
} }
public static class UpgradePacket{ public static class UpgradePacket{
public int id; //weapon ID only, currently public byte id; //weapon ID only, currently
}
public static class WeaponSwitchPacket{
public int playerid;
public byte left, right;
} }
} }

View File

@@ -35,6 +35,7 @@ public class Registrator {
ChatPacket.class, ChatPacket.class,
KickPacket.class, KickPacket.class,
UpgradePacket.class, UpgradePacket.class,
WeaponSwitchPacket.class,
Class.class, Class.class,
byte[].class, byte[].class,

View File

@@ -1,15 +1,11 @@
package io.anuke.mindustry.resource; package io.anuke.mindustry.resource;
public enum Mech{ public class Mech extends Upgrade{
standard, public static final Mech
scout{{
}};
public float speedBoost = 1f, damageBoost = 1f;
public int regenRate = 10;
public int health = 20;
private Mech(){ standard = new Mech("standard");
public Mech(String name){
super(name);
} }
} }

View File

@@ -1,114 +1,15 @@
package io.anuke.mindustry.resource; package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.*;
import static io.anuke.mindustry.resource.Section.*; public class Recipe {
public Block result;
public ItemStack[] requirements;
public Section section;
public enum Recipe{ public Recipe(Section section, Block result, ItemStack... requirements){
stonewall(defense, DefenseBlocks.stonewall, stack(Item.stone, 12)), this.result = result;
ironwall(defense, DefenseBlocks.ironwall, stack(Item.iron, 12)), this.requirements = requirements;
steelwall(defense, DefenseBlocks.steelwall, stack(Item.steel, 12)), this.section = section;
titaniumwall(defense, DefenseBlocks.titaniumwall, stack(Item.titanium, 12)), }
duriumwall(defense, DefenseBlocks.diriumwall, stack(Item.dirium, 12)),
//compositewall(defense, DefenseBlocks.compositewall, stack(Item.dirium, 2), stack(Item.titanium, 2), stack(Item.steel, 2), stack(Item.iron, 2)),
steelwalllarge(defense, DefenseBlocks.steelwalllarge, stack(Item.steel, 12*4)),
titaniumwalllarge(defense, DefenseBlocks.titaniumwalllarge, stack(Item.titanium, 12*4)),
duriumwalllarge(defense, DefenseBlocks.diriumwalllarge, stack(Item.dirium, 12*4)),
door(defense, DefenseBlocks.door, stack(Item.steel, 3), stack(Item.iron, 3*4)),
largedoor(defense, DefenseBlocks.largedoor, stack(Item.steel, 3*4), stack(Item.iron, 3*4*4)),
titaniumshieldwall(defense, DefenseBlocks.titaniumshieldwall, stack(Item.titanium, 16)),
conveyor(distribution, DistributionBlocks.conveyor, stack(Item.stone, 1)),
steelconveyor(distribution, DistributionBlocks.steelconveyor, stack(Item.steel, 1)),
poweredconveyor(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
router(distribution, DistributionBlocks.router, stack(Item.stone, 2)),
junction(distribution, DistributionBlocks.junction, stack(Item.iron, 2)),
tunnel(distribution, DistributionBlocks.tunnel, stack(Item.iron, 2)),
conduit(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)),
pulseconduit(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
liquidrouter(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
liquidjunction(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
sorter(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)),
turret(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
dturret(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
machineturret(weapon, WeaponBlocks.machineturret, stack(Item.iron, 8), stack(Item.stone, 10)),
shotgunturret(weapon, WeaponBlocks.shotgunturret, stack(Item.iron, 10), stack(Item.stone, 10)),
flameturret(weapon, WeaponBlocks.flameturret, stack(Item.iron, 12), stack(Item.steel, 9)),
sniperturret(weapon, WeaponBlocks.sniperturret, stack(Item.iron, 15), stack(Item.steel, 10)),
laserturret(weapon, WeaponBlocks.laserturret, stack(Item.steel, 12), stack(Item.titanium, 12)),
mortarturret(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 15)),
teslaturret(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 25), stack(Item.dirium, 15)),
plasmaturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 20), stack(Item.dirium, 15)),
chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 40)),
titanturret(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
smelter(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
crucible(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
coalpurifier(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
titaniumpurifier(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
oilrefinery(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
stoneformer(crafting, ProductionBlocks.stoneformer, stack(Item.steel, 10), stack(Item.iron, 10)),
lavasmelter(crafting, ProductionBlocks.lavasmelter, stack(Item.steel, 30), stack(Item.titanium, 15)),
stonedrill(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),
irondrill(production, ProductionBlocks.irondrill, stack(Item.stone, 25)),
coaldrill(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)),
titaniumdrill(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 50)),
uraniumdrill(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 30), stack(Item.dirium, 40)),
coalgenerator(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
thermalgenerator(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
combustiongenerator(power, ProductionBlocks.combustiongenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
rtgenerator(power, ProductionBlocks.rtgenerator, stack(Item.titanium, 20), stack(Item.steel, 20)),
nuclearreactor(power, ProductionBlocks.nuclearReactor, stack(Item.titanium, 40), stack(Item.dirium, 40), stack(Item.steel, 50)),
powerbooster(power, DistributionBlocks.powerbooster, stack(Item.steel, 8), stack(Item.iron, 8)),
powerlaser(power, DistributionBlocks.powerlaser, stack(Item.steel, 3), stack(Item.iron, 3)),
powerlasercorner(power, DistributionBlocks.powerlasercorner, stack(Item.steel, 4), stack(Item.iron, 4)),
powerlaserrouter(power, DistributionBlocks.powerlaserrouter, stack(Item.steel, 5), stack(Item.iron, 5)),
shieldgenerator(power, DefenseBlocks.shieldgenerator, stack(Item.titanium, 30), stack(Item.dirium, 30)),
teleporter(distribution, DistributionBlocks.teleporter, stack(Item.steel, 20), stack(Item.dirium, 15)),
healturret(power, DefenseBlocks.repairturret, stack(Item.iron, 30)),
megahealturret(power, DefenseBlocks.megarepairturret, stack(Item.iron, 20), stack(Item.steel, 30)),
pump(production, ProductionBlocks.pump, stack(Item.steel, 10)),
fluxpump(production, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5));
public Block result;
public ItemStack[] requirements;
public Section section;
private Recipe(Section section, Block result, ItemStack... requirements){
this.result = result;
this.requirements = requirements;
this.section = section;
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
public static Recipe getByResult(Block block){
for(Recipe recipe : Recipe.values()){
if(recipe.result == block){
return recipe;
}
}
return null;
}
public static Array<Recipe> getBy(Section section, Array<Recipe> r){
for(Recipe recipe : Recipe.values()){
if(recipe.section == section)
r.add(recipe);
}
return r;
}
} }

View File

@@ -0,0 +1,113 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.DefenseBlocks;
import io.anuke.mindustry.world.blocks.DistributionBlocks;
import io.anuke.mindustry.world.blocks.ProductionBlocks;
import io.anuke.mindustry.world.blocks.WeaponBlocks;
import static io.anuke.mindustry.resource.Section.*;
public class Recipes {
private static final Array<Recipe> list = Array.with(
new Recipe(defense, DefenseBlocks.stonewall, stack(Item.stone, 12)),
new Recipe(defense, DefenseBlocks.ironwall, stack(Item.iron, 12)),
new Recipe(defense, DefenseBlocks.steelwall, stack(Item.steel, 12)),
new Recipe(defense, DefenseBlocks.titaniumwall, stack(Item.titanium, 12)),
new Recipe(defense, DefenseBlocks.diriumwall, stack(Item.dirium, 12)),
new Recipe(defense, DefenseBlocks.steelwalllarge, stack(Item.steel, 12*4)),
new Recipe(defense, DefenseBlocks.titaniumwalllarge, stack(Item.titanium, 12*4)),
new Recipe(defense, DefenseBlocks.diriumwalllarge, stack(Item.dirium, 12*4)),
new Recipe(defense, DefenseBlocks.door, stack(Item.steel, 3), stack(Item.iron, 3*4)),
new Recipe(defense, DefenseBlocks.largedoor, stack(Item.steel, 3*4), stack(Item.iron, 3*4*4)),
new Recipe(defense, DefenseBlocks.titaniumshieldwall, stack(Item.titanium, 16)),
new Recipe(distribution, DistributionBlocks.conveyor, stack(Item.stone, 1)),
new Recipe(distribution, DistributionBlocks.steelconveyor, stack(Item.steel, 1)),
new Recipe(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
new Recipe(distribution, DistributionBlocks.router, stack(Item.stone, 2)),
new Recipe(distribution, DistributionBlocks.junction, stack(Item.iron, 2)),
new Recipe(distribution, DistributionBlocks.tunnel, stack(Item.iron, 2)),
new Recipe(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)),
new Recipe(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
new Recipe(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
new Recipe(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
new Recipe(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)),
new Recipe(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
new Recipe(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
new Recipe(weapon, WeaponBlocks.machineturret, stack(Item.iron, 8), stack(Item.stone, 10)),
new Recipe(weapon, WeaponBlocks.shotgunturret, stack(Item.iron, 10), stack(Item.stone, 10)),
new Recipe(weapon, WeaponBlocks.flameturret, stack(Item.iron, 12), stack(Item.steel, 9)),
new Recipe(weapon, WeaponBlocks.sniperturret, stack(Item.iron, 15), stack(Item.steel, 10)),
new Recipe(weapon, WeaponBlocks.laserturret, stack(Item.steel, 12), stack(Item.titanium, 12)),
new Recipe(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 15)),
new Recipe(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 25), stack(Item.dirium, 15)),
new Recipe(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 20), stack(Item.dirium, 15)),
new Recipe(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 40)),
new Recipe(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
new Recipe(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
new Recipe(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
new Recipe(crafting, ProductionBlocks.stoneformer, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.lavasmelter, stack(Item.steel, 30), stack(Item.titanium, 15)),
new Recipe(crafting, ProductionBlocks.weaponFactory, stack(Item.steel, 60), stack(Item.iron, 60)),
new Recipe(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),
new Recipe(production, ProductionBlocks.irondrill, stack(Item.stone, 25)),
new Recipe(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)),
new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 50)),
new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
new Recipe(production, ProductionBlocks.omnidrill, stack(Item.titanium, 30), stack(Item.dirium, 40)),
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(power, ProductionBlocks.combustiongenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.rtgenerator, stack(Item.titanium, 20), stack(Item.steel, 20)),
new Recipe(power, ProductionBlocks.nuclearReactor, stack(Item.titanium, 40), stack(Item.dirium, 40), stack(Item.steel, 50)),
new Recipe(power, DistributionBlocks.powerbooster, stack(Item.steel, 8), stack(Item.iron, 8)),
new Recipe(power, DistributionBlocks.powerlaser, stack(Item.steel, 3), stack(Item.iron, 3)),
new Recipe(power, DistributionBlocks.powerlasercorner, stack(Item.steel, 4), stack(Item.iron, 4)),
new Recipe(power, DistributionBlocks.powerlaserrouter, stack(Item.steel, 5), stack(Item.iron, 5)),
new Recipe(power, DefenseBlocks.shieldgenerator, stack(Item.titanium, 30), stack(Item.dirium, 30)),
new Recipe(distribution, DistributionBlocks.teleporter, stack(Item.steel, 20), stack(Item.dirium, 15)),
new Recipe(power, DefenseBlocks.repairturret, stack(Item.iron, 30)),
new Recipe(power, DefenseBlocks.megarepairturret, stack(Item.iron, 20), stack(Item.steel, 30)),
new Recipe(production, ProductionBlocks.pump, stack(Item.steel, 10)),
new Recipe(production, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5))
);
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
public static Array<Recipe> all(){
return list;
}
public static Recipe getByResult(Block block){
for(Recipe recipe : list){
if(recipe.result == block){
return recipe;
}
}
return null;
}
public static Array<Recipe> getBy(Section section, Array<Recipe> r){
for(Recipe recipe : list){
if(recipe.section == section)
r.add(recipe);
}
return r;
}
}

View File

@@ -0,0 +1,33 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import io.anuke.ucore.util.Bundles;
public abstract class Upgrade {
private static Array<Upgrade> upgrades = new Array<>();
private static byte lastid;
public final byte id;
public final String name;
public final String description;
public Upgrade(String name){
this.id = lastid ++;
this.name = name;
this.description = Bundles.getNotNull("upgrade."+name+".description");
upgrades.add(this);
}
public String localized(){
return Bundles.get("upgrade." + name + ".name");
}
public static Upgrade getByID(byte id){
return upgrades.get(id);
}
public static Array<Upgrade> getAllUpgrades() {
return upgrades;
}
}

View File

@@ -0,0 +1,33 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectMap.Entries;
import io.anuke.ucore.util.Mathf;
public class UpgradeRecipes {
private static final ObjectMap<Upgrade, ItemStack[]> recipes = Mathf.map(
Weapon.triblaster, list(stack(Item.iron, 40), stack(Item.steel, 40)),
Weapon.clustergun, list(stack(Item.iron, 60), stack(Item.steel, 80)),
Weapon.vulcan, list(stack(Item.iron, 60), stack(Item.steel, 120), stack(Item.titanium, 60)),
Weapon.beam, list(stack(Item.steel, 240), stack(Item.titanium, 120), stack(Item.dirium, 80)),
Weapon.shockgun, list(stack(Item.steel, 120), stack(Item.titanium, 120), stack(Item.dirium, 120))
);
private static final ItemStack[] empty = {};
public static ItemStack[] get(Upgrade upgrade){
return recipes.get(upgrade, empty);
}
public static Entries<Upgrade, ItemStack[]> getAllRecipes(){
return recipes.entries();
}
private static ItemStack[] list(ItemStack... stacks){
return stacks;
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
}

View File

@@ -1,8 +1,5 @@
package io.anuke.mindustry.resource; package io.anuke.mindustry.resource;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Bullet; import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.BulletType;
@@ -10,106 +7,105 @@ import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.graphics.Fx; import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entity; import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
public enum Weapon{ public class Weapon extends Upgrade{
blaster(15, BulletType.shot){ public static final Weapon
blaster = new Weapon("blaster", 12, BulletType.shot){
{ {
unlocked = true; effect = Fx.laserShoot;
}
@Override
public void shootInternal(Player p, float x, float y, float rotation){
super.shootInternal(p, x, y, rotation);
Effects.effect(Fx.shoot3, x + vector.x, y+vector.y);
} }
}, },
triblaster(13, BulletType.shot, stack(Item.iron, 40)){ triblaster = new Weapon("triblaster", 20, BulletType.spread){
@Override
public void shootInternal(Player p, float x, float y, float rotation){
float space = 12;
bullet(p, x, y, rotation);
bullet(p, x, y, rotation + space);
bullet(p, x, y, rotation - space);
Effects.effect(Fx.shoot, x + vector.x, y + vector.y);
}
},
multigun(6, BulletType.multishot, stack(Item.iron, 60), stack(Item.steel, 20)){
@Override
public void shootInternal(Player p, float x, float y, float rotation){
MathUtils.random.setSeed(Gdx.graphics.getFrameId());
bullet(p, x, y, rotation + Mathf.range(8));
Effects.effect(Fx.shoot2, x + vector.x, y + vector.y);
}
},
flamer(5, BulletType.flame, stack(Item.steel, 60), stack(Item.iron, 120)){
{ {
shootsound = "flame2"; shots = 3;
} effect = Fx.spreadShoot;
roundrobin = true;
@Override
public void shootInternal(Player p, float x, float y, float rotation){
MathUtils.random.setSeed(Gdx.graphics.getFrameId());
bullet(p, x, y, rotation + Mathf.range(12));
} }
}, },
railgun(40, BulletType.sniper, stack(Item.steel, 60), stack(Item.iron, 60)){ clustergun = new Weapon("clustergun", 26f, BulletType.cluster){
{ {
shootsound = "railgun"; effect = Fx.clusterShoot;
} inaccuracy = 20f;
roundrobin = true;
@Override shots = 2;
public void shootInternal(Player p, float x, float y, float rotation){ spacing = 0;
bullet(p, x, y, rotation);
Effects.effect(Fx.railshoot, x + vector.x, y + vector.y);
} }
}, },
mortar(100, BulletType.shell, stack(Item.titanium, 40), stack(Item.steel, 60)){ beam = new Weapon("beam", 30f, BulletType.beamlaser){
{
effect = Fx.beamShoot;
inaccuracy = 0;
roundrobin = true;
shake = 2f;
}
},
vulcan = new Weapon("vulcan", 5, BulletType.vulcan){
{
effect = Fx.vulcanShoot;
inaccuracy = 5;
roundrobin = true;
shake = 1f;
inaccuracy = 4f;
}
},
shockgun = new Weapon("shockgun", 36, BulletType.shockshell){
{ {
shootsound = "bigshot"; shootsound = "bigshot";
} effect = Fx.shockShoot;
shake = 2f;
@Override roundrobin = true;
public void shootInternal(Player p, float x, float y, float rotation){ shots = 7;
bullet(p, x, y, rotation); inaccuracy = 15f;
Effects.effect(Fx.mortarshoot, x + vector.x, y + vector.y);
Effects.shake(2f, 2f, p);
} }
}; };
public float reload; /**weapon reload in frames*/
public BulletType type; float reload;
public String shootsound = "shoot"; /**type of bullet shot*/
public boolean unlocked; BulletType type;
public ItemStack[] requirements; /**sound made when shooting*/
public final String description; String shootsound = "shoot";
/**amount of shots per fire*/
Vector2 vector = new Vector2(); int shots = 1;
/**spacing in degrees between multiple shots, if applicable*/
public String localized(){ float spacing = 12f;
return Bundles.get("weapon."+name() + ".name"); /**inaccuracy of degrees of each shot*/
} float inaccuracy = 0f;
/**intensity and duration of each shot's screen shake*/
float shake = 0f;
/**effect displayed when shooting*/
Effect effect;
/**whether to shoot the weapons in different arms one after another, rather an all at once*/
boolean roundrobin = false;
private Weapon(float reload, BulletType type, ItemStack... requirements){ private Weapon(String name, float reload, BulletType type){
super(name);
this.reload = reload; this.reload = reload;
this.type = type; this.type = type;
this.requirements = requirements; }
this.description = Bundles.getNotNull("weapon."+name()+".description");
public void update(Player p, boolean left){
if(Timers.get(p, "reload"+left, reload)){
if(roundrobin){
Timers.reset(p, "reload" + !left, reload/2f);
}
float ang = Angles.mouseAngle(p.x, p.y);
Angles.translation(ang + Mathf.sign(left) * -60f, 3f);
shoot(p, p.x + Angles.x(), p.y + Angles.y(), Angles.mouseAngle(p.x + Angles.x(), p.y + Angles.y()));
}
} }
void shootInternal(Player p, float x, float y, float rotation){ void shootInternal(Player p, float x, float y, float rotation){
bullet(p, x, y, rotation); Angles.shotgun(shots, spacing, rotation, f -> bullet(p, x, y, f + Mathf.range(inaccuracy)));
Angles.translation(rotation, 3f);
if(effect != null) Effects.effect(effect, x + Angles.x(), y + Angles.y(), rotation);
Effects.shake(shake, shake, x, y);
Effects.sound(shootsound, x, y);
} }
public void shoot(Player p, float x, float y, float angle){ public void shoot(Player p, float x, float y, float angle){
@@ -121,11 +117,7 @@ public enum Weapon{
} }
void bullet(Entity owner, float x, float y, float angle){ void bullet(Entity owner, float x, float y, float angle){
vector.set(3, 0).rotate(angle); Angles.translation(angle, 3f);
new Bullet(type, owner, x + vector.x, y + vector.y, angle).add(); new Bullet(type, owner, x + Angles.x(), y + Angles.y(), angle).add();
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
} }
} }

View File

@@ -1,144 +0,0 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.function.Listenable;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.Tooltip;
import io.anuke.ucore.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.ui;
public class UpgradeDialog extends FloatingDialog{
boolean wasPaused = false;
public UpgradeDialog() {
super("$text.upgrades");
setup();
}
void setup(){
addCloseButton();
hidden(()->{
if(!wasPaused)
GameState.set(State.playing);
});
shown(()->{
wasPaused = GameState.is(State.paused);
GameState.set(State.paused);
});
Table weptab = new Table();
weptab.margin(20);
int i = 0;
for(Weapon weapon : Weapon.values()){
TextButton button = new TextButton("$weapon."+weapon.name()+".name");
Image img = new Image(Draw.region(weapon.name()));
button.add(img).size(8*5);
button.getCells().reverse();
button.row();
button.margin(14);
button.getLabelCell().left();
button.pack();
button.update(()->{
if(control.hasWeapon(weapon)){
button.setDisabled(true);
button.setColor(Color.GRAY);
}else if(!control.hasItems(weapon.requirements)){
button.setDisabled(true);
}else{
button.setDisabled(false);
button.setColor(Color.WHITE);
}
});
if(i > 0 && (i)%2==0)
weptab.row();
i++;
weptab.add(button).width(220);
Table tiptable = new Table();
Listenable run = ()->{
tiptable.clearChildren();
String description = weapon.description;
tiptable.background("pane");
tiptable.add("[orange]" + weapon.localized(), 0.5f).left().padBottom(4f);
Table reqtable = new Table();
tiptable.row();
tiptable.add(reqtable).left();
if(!control.hasWeapon(weapon)){
ItemStack[] req = weapon.requirements;
for(ItemStack s : req){
int amount = Math.min(control.getAmount(s.item), s.amount);
reqtable.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
reqtable.add(
(amount >= s.amount ? "" : "[RED]")
+ amount + " / " +s.amount, 0.5f).left();
reqtable.row();
}
}
tiptable.row();
tiptable.add().size(10);
tiptable.row();
tiptable.add("[gray]" + description).left();
tiptable.row();
if(control.hasWeapon(weapon)){
tiptable.add("$text.purchased").padTop(6).left();
}
tiptable.margin(14f);
};
run.listen();
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
tip.setInstant(true);
button.addListener(tip);
button.clicked(()->{
if(button.isDisabled()) return;
control.removeItems(weapon.requirements);
control.addWeapon(weapon);
ui.weaponfrag.update();
run.listen();
Effects.sound("purchase");
if(Net.active() && Net.client()){
Vars.netClient.handleUpgrade(weapon);
}
});
}
content().add("$text.weapons");
content().row();
content().add(weptab);
content().row();
}
}

View File

@@ -23,6 +23,14 @@ public class BlockConfigFragment implements Fragment {
Core.scene.add(table); Core.scene.add(table);
} }
public boolean isShown(){
return table.isVisible() && configTile != null;
}
public Tile getSelectedTile(){
return configTile;
}
public void showConfig(Tile tile){ public void showConfig(Tile tile){
configTile = tile; configTile = tile;
@@ -35,7 +43,7 @@ public class BlockConfigFragment implements Fragment {
table.update(()->{ table.update(()->{
table.setOrigin(Align.center); table.setOrigin(Align.center);
Vector2 pos = Graphics.screen(tile.worldx(), tile.worldy()); Vector2 pos = Graphics.screen(tile.worldx() + tile.block().getPlaceOffset().x, tile.worldy() + tile.block().getPlaceOffset().y);
table.setPosition(pos.x, pos.y, Align.center); table.setPosition(pos.x, pos.y, Align.center);
if(configTile == null || configTile.block() == Blocks.air){ if(configTile == null || configTile.block() == Blocks.air){
hideConfig(); hideConfig();

View File

@@ -9,10 +9,7 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.InputHandler; import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.*;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Section;
import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Draw;
import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.graphics.Hue;
@@ -30,7 +27,7 @@ import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.fontscale; import static io.anuke.mindustry.Vars.fontscale;
public class BlocksFragment implements Fragment{ public class BlocksFragment implements Fragment{
private Table desctable, itemtable, blocks; private Table desctable, itemtable, blocks, weapons;
private Stack stack = new Stack(); private Stack stack = new Stack();
private Array<String> statlist = new Array<>(); private Array<String> statlist = new Array<>();
private boolean shown = true; private boolean shown = true;
@@ -72,17 +69,17 @@ public class BlocksFragment implements Fragment{
Stack stack = new Stack(); Stack stack = new Stack();
ButtonGroup<ImageButton> group = new ButtonGroup<>(); ButtonGroup<ImageButton> group = new ButtonGroup<>();
Array<Recipe> recipes = new Array<Recipe>(); Array<Recipe> recipes = new Array<>();
for (Section sec : Section.values()) { for (Section sec : Section.values()) {
recipes.clear(); recipes.clear();
Recipe.getBy(sec, recipes); Recipes.getBy(sec, recipes);
maxcol = Math.max((int) ((float) recipes.size / rows + 1), maxcol); maxcol = Math.max((int) ((float) recipes.size / rows + 1), maxcol);
} }
for (Section sec : Section.values()) { for (Section sec : Section.values()) {
recipes.clear(); recipes.clear();
Recipe.getBy(sec, recipes); Recipes.getBy(sec, recipes);
Table table = new Table(); Table table = new Table();
@@ -93,7 +90,7 @@ public class BlocksFragment implements Fragment{
} }
}); });
button.setName("sectionbutton" + sec.name()); button.setName("sectionbutton" + sec.name());
add(button).growX().height(54).padRight(-1).padTop(sec.ordinal() <= 2 ? -10 : -5); add(button).growX().height(54).padLeft(-1).padTop(sec.ordinal() <= 2 ? -10 : -5);
button.getImageCell().size(40).padBottom(4).padTop(2); button.getImageCell().size(40).padBottom(4).padTop(2);
group.add(button); group.add(button);
@@ -147,16 +144,47 @@ public class BlocksFragment implements Fragment{
add(stack).colspan(Section.values().length); add(stack).colspan(Section.values().length);
margin(10f); margin(10f);
marginLeft(0f); marginLeft(1f);
marginRight(0f); marginRight(1f);
end(); end();
}}.right().bottom().uniformX(); }}.right().bottom().uniformX();
row();
if(!Vars.android) {
weapons = new table("button").margin(0).fillX().end().get();
}
visible(() -> !GameState.is(State.menu) && shown); visible(() -> !GameState.is(State.menu) && shown);
}}.end().get(); }}.end().get();
}}.end(); }}.end();
updateWeapons();
}
public void updateWeapons(){
if(Vars.android) return;
weapons.clearChildren();
weapons.left();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
for(int i = 0; i < Vars.control.getWeapons().size; i ++){
Weapon weapon = Vars.control.getWeapons().get(i);
weapons.addImageButton(weapon.name, "toggle", 8*3, () -> {
Vars.player.weaponLeft = Vars.player.weaponRight = weapon;
}).left().size(40f, 45f).padRight(-1).group(group);
}
int idx = Vars.control.getWeapons().indexOf(Vars.player.weaponLeft, true);
if(idx != -1)
group.getButtons().get(idx).setChecked(true);
else if(group.getButtons().size > 0)
group.getButtons().get(0).setChecked(true);
} }
public void toggle(boolean show, float t, Interpolation ip){ public void toggle(boolean show, float t, Interpolation ip){
@@ -244,7 +272,6 @@ public class BlocksFragment implements Fragment{
}).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2); }).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
} }
desctable.add().pad(2); desctable.add().pad(2);
Table requirements = new Table(); Table requirements = new Table();
@@ -255,12 +282,11 @@ public class BlocksFragment implements Fragment{
desctable.left(); desctable.left();
for(ItemStack stack : recipe.requirements){ for(ItemStack stack : recipe.requirements){
ItemStack fs = stack;
requirements.addImage(Draw.region("icon-"+stack.item.name)).size(8*3); requirements.addImage(Draw.region("icon-"+stack.item.name)).size(8*3);
Label reqlabel = new Label(""); Label reqlabel = new Label("");
reqlabel.update(()->{ reqlabel.update(()->{
int current = control.getAmount(fs.item); int current = control.getAmount(stack.item);
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount; String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE); reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
@@ -274,8 +300,7 @@ public class BlocksFragment implements Fragment{
desctable.row(); desctable.row();
Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health + (recipe.result.description == null ? Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health);
"" : ("\n[]" + recipe.result.description)));
label.setWrap(true); label.setWrap(true);
desctable.add(label).width(200).padTop(4).padBottom(2); desctable.add(label).width(200).padTop(4).padBottom(2);

View File

@@ -219,6 +219,10 @@ public class HudFragment implements Fragment{
public void updateItems(){ public void updateItems(){
blockfrag.updateItems(); blockfrag.updateItems();
} }
public void updateWeapons(){
blockfrag.updateWeapons();
}
public void fadeRespawn(boolean in){ public void fadeRespawn(boolean in){
respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f)); respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f));

View File

@@ -1,71 +0,0 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.Tooltip;
import io.anuke.ucore.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.*;
public class WeaponFragment implements Fragment{
Table weapontable;
public void build(){
weapontable = Core.scene.table();
weapontable.bottom().left();
weapontable.setVisible(()-> !GameState.is(State.menu));
if(android){
weapontable.remove();
}
}
public void update(){
weapontable.clearChildren();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
weapontable.defaults().size(58, 62);
for(Weapon weapon : control.getWeapons()){
ImageButton button = new ImageButton(Draw.region(weapon.name()), "toggle");
button.getImageCell().size(8*5);
group.add(button);
button.clicked(()->{
if(weapon == player.weapon) return;
player.weapon = weapon;
button.setChecked(true);
});
button.setChecked(weapon == player.weapon);
weapontable.add(button);
Table tiptable = new Table();
String description = weapon.description;
tiptable.background("button");
tiptable.add("$weapon."+weapon.name()+".name", 0.5f).left().padBottom(3f);
tiptable.row();
tiptable.row();
tiptable.add("[GRAY]" + description).left();
tiptable.margin(14f);
Tooltip<Table> tip = new Tooltip<>(tiptable);
tip.setInstant(true);
button.addListener(tip);
}
weapontable.addImageButton("icon-menu", 8*4, ui.upgrades::show);
}
}

View File

@@ -50,7 +50,7 @@ public class DefenseBlocks{
repairturret = new RepairTurret("repairturret"){ repairturret = new RepairTurret("repairturret"){
{ {
range = 30; range = 30;
reload = 60f; reload = 40f;
health = 60; health = 60;
powerUsed = 0.08f; powerUsed = 0.08f;
} }
@@ -59,7 +59,7 @@ public class DefenseBlocks{
megarepairturret = new RepairTurret("megarepairturret"){ megarepairturret = new RepairTurret("megarepairturret"){
{ {
range = 44; range = 44;
reload = 30f; reload = 20f;
health = 90; health = 90;
powerUsed = 0.13f; powerUsed = 0.13f;
} }

View File

@@ -199,5 +199,10 @@ public class ProductionBlocks{
health = 600; health = 600;
breaktime *= 2.3f; breaktime *= 2.3f;
} }
},
weaponFactory = new WeaponFactory("weaponfactory"){
{
width = height = 2;
}
}; };
} }

View File

@@ -0,0 +1,109 @@
package io.anuke.mindustry.world.blocks.types.production;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.UpgradeRecipes;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.Configurable;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.function.Listenable;
import io.anuke.ucore.scene.style.TextureRegionDrawable;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.Tooltip;
import io.anuke.ucore.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.control;
public class WeaponFactory extends Block implements Configurable{
public WeaponFactory(String name){
super(name);
solid = true;
destructible = true;
}
@Override
public void buildTable(Tile tile, Table table) {
int i = 0;
Table content = new Table();
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
if(!(upgrade instanceof Weapon)) continue;
Weapon weapon = (Weapon)upgrade;
ItemStack[] requirements = UpgradeRecipes.get(weapon);
Table tiptable = new Table();
Listenable run = ()->{
tiptable.clearChildren();
String description = weapon.description;
tiptable.background("pane");
tiptable.add("[orange]" + weapon.localized(), 0.5f).left().padBottom(2f);
Table reqtable = new Table();
tiptable.row();
tiptable.add(reqtable).left();
if(!control.hasWeapon(weapon)){
for(ItemStack s : requirements){
int amount = Math.min(control.getAmount(s.item), s.amount);
reqtable.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
reqtable.add(
(amount >= s.amount ? "" : "[RED]")
+ amount + " / " +s.amount, 0.5f).left();
reqtable.row();
}
}
tiptable.row();
tiptable.add().size(4);
tiptable.row();
tiptable.add("[gray]" + description).left();
tiptable.row();
if(control.hasWeapon(weapon)){
tiptable.add("$text.purchased").padTop(4).left();
}
tiptable.margin(8f);
};
run.listen();
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
tip.setInstant(true);
ImageButton button = content.addImageButton("white", 8*4, () -> {
control.removeItems(requirements);
control.addWeapon(weapon);
Vars.ui.hudfrag.updateWeapons();
run.listen();
Effects.sound("purchase");
if(Net.active() && Net.client()){
Vars.netClient.handleUpgrade(weapon);
}
}).size(49f, 54f).padBottom(-5).get();
button.setDisabled(() -> control.hasWeapon(weapon));
button.getStyle().imageUp = new TextureRegionDrawable(Draw.region(weapon.name));
button.addListener(tip);
if(++i % 3 == 0){
content.row();
}
}
table.add(content).padTop(140f);
}
}

View File

@@ -136,6 +136,7 @@ public class KryoClient implements ClientProvider{
for(Class<?> c : types){ for(Class<?> c : types){
client.getKryo().register(c); client.getKryo().register(c);
} }
KryoRegistrator.register(client.getKryo());
} }
@Override @Override

View File

@@ -0,0 +1,38 @@
package io.anuke.kryonet;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import io.anuke.mindustry.resource.Mech;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon;
public class KryoRegistrator {
public static void register(Kryo kryo){
kryo.register(Weapon.class, new Serializer<Weapon>() {
@Override
public void write(Kryo kryo, Output output, Weapon object) {
output.writeByte(object.id);
}
@Override
public Weapon read(Kryo kryo, Input input, Class type) {
return (Weapon)Upgrade.getByID(input.readByte());
}
});
kryo.register(Mech.class, new Serializer<Mech>() {
@Override
public void write(Kryo kryo, Output output, Mech object) {
output.writeByte(object.id);
}
@Override
public Mech read(Kryo kryo, Input input, Class type) {
return (Mech)Upgrade.getByID(input.readByte());
}
});
}
}

View File

@@ -190,6 +190,7 @@ public class KryoServer implements ServerProvider {
for(Class<?> c : types){ for(Class<?> c : types){
server.getKryo().register(c); server.getKryo().register(c);
} }
KryoRegistrator.register(server.getKryo());
} }
@Override @Override