From 913ee34c8dd77669c9926a3dc2598a95fabef4f8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 14 Apr 2018 13:47:55 -0400 Subject: [PATCH] Implemented item dumping --- core/assets/version.properties | 2 +- .../entities/ItemAnimationEffect.java | 7 ++++-- .../anuke/mindustry/input/InputHandler.java | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/assets/version.properties b/core/assets/version.properties index bc0f4ca16a..65ecbbb3a5 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,5 +1,5 @@ #Autogenerated file. Do not modify. -#Sat Apr 14 11:58:08 EDT 2018 +#Sat Apr 14 13:47:10 EDT 2018 version=release androidBuildCode=918 name=Mindustry diff --git a/core/src/io/anuke/mindustry/entities/ItemAnimationEffect.java b/core/src/io/anuke/mindustry/entities/ItemAnimationEffect.java index 67eb0b1e39..1c7838ef7d 100644 --- a/core/src/io/anuke/mindustry/entities/ItemAnimationEffect.java +++ b/core/src/io/anuke/mindustry/entities/ItemAnimationEffect.java @@ -17,6 +17,9 @@ public class ItemAnimationEffect extends TimedEntity { private final Vector2 to = new Vector2(); private final Item item; + public Interpolation interp = Interpolation.fade; + public float endSize = 0.8f; + public ItemAnimationEffect(Item item, float x, float y, float tox, float toy) { this.x = x; this.y = y; @@ -30,14 +33,14 @@ public class ItemAnimationEffect extends TimedEntity { public void update() { super.update(); - vec.set(from).interpolate(to, fin(), Interpolation.fade); + vec.set(from).interpolate(to, fin(), interp); x = vec.x; y = vec.y; } @Override public void draw() { - float s = size * Mathf.curve(fout(), 0.1f); + float s = size * (1f-Mathf.curve(fin(), endSize)); Draw.rect(item.region, x, y, s, s); } diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 07b9a4c2c5..bd984317ca 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -1,7 +1,9 @@ package io.anuke.mindustry.input; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.InputAdapter; import com.badlogic.gdx.math.GridPoint2; +import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.entities.ItemAnimationEffect; @@ -78,6 +80,26 @@ public abstract class InputHandler extends InputAdapter{ tile.drawx(), tile.drawy()).add(); }); } + }else{ + Vector2 vec = Graphics.screen(player.x, player.y); + + if(vec.dst(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()) > playerSelectRange) { + int sent = Mathf.clamp(stack.amount / 4, 1, 8); + float backTrns = 3f; + for (int i = 0; i < sent; i++) { + Timers.run(i, () -> { + float x = player.x + Angles.trnsx(rotation + 180f, backTrns), + y = player.y + Angles.trnsy(rotation + 180f, backTrns); + + ItemAnimationEffect e = new ItemAnimationEffect(stack.item, + x, y, x + Mathf.range(20f), y + Mathf.range(20f)).add(); + e.interp = Interpolation.pow3Out; + e.endSize = 0.5f; + e.lifetime = 20; + }); + } + player.inventory.clear(); + } } }