Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void setupUI() {
hudTable.setFillParent(true);
hudTable.top().left();

healthBar = new ProgressBar(0, 100, 1, false, skin);
healthBar = new ProgressBar(0, 1, .01f, false, skin);
scoreLabel = new Label("Score: 0", skin);
levelLabel = new Label("Lvl: 1", skin);

Expand Down Expand Up @@ -142,12 +142,12 @@ private void setupMobileControls() {

Touchpad.TouchpadStyle touchpadStyle = skin.get(Touchpad.TouchpadStyle.class);

moveStick = new Touchpad(10, touchpadStyle);
moveStick = new Touchpad(SettingsManager.getFloat(ClientSettings.JOYSTICK_MOVE_DEADZONE), touchpadStyle);
moveStick.setBounds(50, 50, 200, 200);
uiStage.addActor(moveStick);

if (controlMode.equals("mobile_aim_joystick") || controlMode.equals("mobile_aim_all")) {
aimStick = new Touchpad(10, touchpadStyle);
aimStick = new Touchpad(SettingsManager.getFloat(ClientSettings.JOYSTICK_AIM_DEADZONE), touchpadStyle);
aimStick.setBounds(Gdx.graphics.getWidth() - 250, 50, 200, 200);
uiStage.addActor(aimStick);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,12 @@ private void showControlSettings() {

table.add(new Label("Control type:", skin));
SelectBox<String> controlSelect = new SelectBox<>(skin);
controlSelect.setItems("auto", "pc", "mobile_aim_joystick", "mobile_aim_button", "mobile_aim_all"); //TODO надо въебошить картинки
controlSelect.setItems("auto", "pc", "mobile_aim_joystick", "mobile_aim_button", "mobile_aim_all");
controlSelect.setSelected(SettingsManager.getString(ClientSettings.CONTROL));
table.add(controlSelect).width(200).row();
table.add(controlSelect).width(200).colspan(2).row();

table.add(createDeadzoneRow("Aim Deadzone:", ClientSettings.JOYSTICK_AIM_DEADZONE)).row();
table.add(createDeadzoneRow("Move Deadzone:", ClientSettings.JOYSTICK_MOVE_DEADZONE)).row();

TextButton applyBtn = new TextButton("Apply Control Settings", skin);
applyBtn.addListener(new ClickListener() {
Expand All @@ -285,11 +288,37 @@ public void clicked(InputEvent event, float x, float y) {
}
});

table.add(applyBtn).padTop(20).colspan(2).center();
table.add(applyBtn).padTop(20).colspan(3).center();

contentContainer.add(table).top();
}

private Table createDeadzoneRow(String labelText, ClientSettings settingKey) {
Table row = new Table();
row.defaults().padRight(10);

row.add(new Label(labelText, skin));

float currentValue = SettingsManager.getFloat(settingKey);
Slider slider = new Slider(0, 100, 1, false, skin);
slider.setValue(currentValue);

Label valueLabel = new Label(String.valueOf((int)currentValue), skin);

slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
float val = slider.getValue();
valueLabel.setText(String.valueOf((int)val));
SettingsManager.set(settingKey, val);
}
});

row.add(slider).width(150);
row.add(valueLabel).width(30);
return row;
}

private void applyGraphicsSettings() {
String resStr = SettingsManager.getString(ClientSettings.RESOLUTION);
String[] parts = resStr.split("x");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.samiker.theendlessweave.systems;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
import xyz.samiker.theendlessweave.entities.Entity;
Expand Down Expand Up @@ -47,11 +48,9 @@ private void updateUI(Entity player) {
float percent = lastRenderedHp / lastRenderedMaxHp;
healthBar.setValue(percent);

/*
if (percent > 0.5f) healthBar.setColor(Color.GREEN);
else if (percent > 0.25f) healthBar.setColor(Color.ORANGE);
else healthBar.setColor(Color.RED);
*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class InputSystem implements ISystem {
private final OrthographicCamera camera;
private Entity player;

private boolean isMobile = false;
private final boolean isMobile;
private float lastAngle = 0;

public InputSystem(GameClient client, Game game, OrthographicCamera camera) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public void initSystems() {

game.addLogicSystem(new ServerInputSystem(this, game));
game.addLogicSystem(new ServerDebugSystem(game.getProfiler()));
game.addLogicSystem(new WeaponSystem());
game.addLogicSystem(new AISystem(map, aiExecutor));
game.addLogicSystem(new AttackSystem(game));
game.addLogicSystem(new WeaponSystem(this.game));
//game.addLogicSystem(new AttackSystem(game)); //TODO:remove
game.addLogicSystem(new ProjectileSystem());
game.addLogicSystem(new MovementSystem(map));
game.addLogicSystem(new DamageSystem());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package xyz.samiker.theendlessweave.systems;

import xyz.samiker.theendlessweave.entities.Entity;
import xyz.samiker.theendlessweave.entities.components.AIComponent;
import xyz.samiker.theendlessweave.entities.components.PathfindingComponent;
import xyz.samiker.theendlessweave.entities.components.PlayerTagComponent;
import xyz.samiker.theendlessweave.entities.components.PositionComponent;
import xyz.samiker.theendlessweave.entities.components.*;
import xyz.samiker.theendlessweave.gamemap.GameMap;
import xyz.samiker.theendlessweave.logic.ai.EntityAIState;
import xyz.samiker.theendlessweave.logic.ai.LineOfSightUtil;
import xyz.samiker.theendlessweave.logic.ai.astar.AStarPathfinder;
import xyz.samiker.theendlessweave.systems.ISystem;
import xyz.samiker.theendlessweave.tile.Tile;
import xyz.samiker.theendlessweave.utils.Array;

Expand Down Expand Up @@ -62,7 +58,12 @@ public void update(Array<Entity> entities, double deltaTime) {
Entity entity = entities.get(i);

AIComponent ai = entity.getComponent(AIComponent.class);
if (ai == null) continue;
RotationComponent rot = entity.getComponent(RotationComponent.class);
PositionComponent pos = entity.getComponent(PositionComponent.class);
if (ai == null || rot == null || pos == null) continue;

double angleToPlayer = Math.atan2(cachedPlayerPos.y - pos.y, cachedPlayerPos.x - pos.x);
rot.angle = Math.toDegrees(angleToPlayer);

ai.addToTickAccumulator(deltaTime);
double timeToNextTick = ai.getTimeToNextTick();
Expand All @@ -72,8 +73,10 @@ public void update(Array<Entity> entities, double deltaTime) {
}
ai.minusTickAccumulator(timeToNextTick);

PositionComponent pos = entity.getComponent(PositionComponent.class);
if (pos == null) continue;
WeaponComponent weapon = entity.getComponent(WeaponComponent.class);
if (weapon == null) continue;

weapon.isFiring = ai.getState() == EntityAIState.ATTACK;

double distSq = getDistanceSquared(pos.x, pos.y, pX, pY);
updateEntityState(entity, ai, pos, distSq);
Expand Down Expand Up @@ -145,11 +148,12 @@ private void handleChaseState(Entity entity, AIComponent ai, PositionComponent p
pathfinding.setPath(null);
}
pathfinding.setDirectTarget(targetTile);
ai.lastPlayerPos = cachedPlayerPos;
} else {
pathfinding.setDirectTarget(null);

if (!pathfinding.hasPath() && !ai.isWaitingForPath()) {
submitPathfindingTask(entity, ai, pos, cachedPlayerPos);
if (!pathfinding.hasPath() && !ai.isWaitingForPath() && ai.lastPlayerPos != null) {
submitPathfindingTask(entity, ai, pos, ai.lastPlayerPos);
}
}
}
Expand Down Expand Up @@ -194,7 +198,6 @@ private void applyFinishedPaths() {
PathfindingComponent pc = e.getComponent(PathfindingComponent.class);
if (pc != null) {
pc.setDirectTarget(null);
// Здесь предполагается, что в PathfindingComponent метод setPath принимает Array<Tile>
pc.setPath(result.path);
}
}
Expand Down
Loading
Loading