-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create digging right and digging left states (#379)
* create digging right and digging left states * put controller on solid blocks in generation * use digging on left and right * add digging left and right * digging is now transparent * server fire incoming attribute events * entity controller are set in factories * attack state last longer and ai uses punch left * attempt transition doesnt change if already in that state
- Loading branch information
1 parent
5fa37b6
commit 7f5a283
Showing
38 changed files
with
293 additions
and
46 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ public enum AnimationState { | |
FALLING, | ||
PUNCH_LEFT, | ||
PUNCH_RIGHT, | ||
DIGGING_LEFT, | ||
DIGGING_RIGHT, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
core/src/core/entity/controllers/SolidBlockController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package core.entity.controllers; | ||
|
||
import core.app.game.GameController; | ||
import core.common.GameStore; | ||
import core.common.events.EventService; | ||
import core.entity.Entity; | ||
import core.entity.controllers.actions.EntityActionFactory; | ||
import core.networking.events.EventTypeFactory; | ||
|
||
public class SolidBlockController extends EntityController { | ||
|
||
public SolidBlockController( | ||
GameController gameController, | ||
GameStore gameStore, | ||
EntityActionFactory entityActionFactory, | ||
EventService eventService, | ||
EventTypeFactory eventTypeFactory, | ||
Entity entity) { | ||
super(gameController, gameStore, entityActionFactory, eventService, eventTypeFactory, entity); | ||
} | ||
|
||
@Override | ||
public void beforeWorldUpdate() throws Exception {} | ||
|
||
@Override | ||
public void afterWorldUpdate() throws Exception {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
core/src/core/entity/statemachine/states/DiggingLeftState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package core.entity.statemachine.states; | ||
|
||
import com.google.inject.Inject; | ||
import core.app.screen.assets.animations.AnimationState; | ||
import core.common.Coordinates; | ||
import core.common.exceptions.EntityNotFound; | ||
import core.entity.Entity; | ||
import core.entity.attributes.msc.AnimationStateWrapper; | ||
import core.entity.attributes.msc.Health; | ||
import core.entity.block.Block; | ||
import core.entity.block.SolidBlock; | ||
import core.entity.collision.RayCastService; | ||
import core.entity.statemachine.EntityStateMachineNodeInterface; | ||
import java.util.Set; | ||
|
||
public class DiggingLeftState extends EntityStateMachineNodeInterface { | ||
|
||
@Inject RayCastService rayCastService; | ||
|
||
@Override | ||
public void callAnimation(Entity entity) { | ||
if (!entity | ||
.getAnimationStateWrapper() | ||
.getAnimationState() | ||
.equals(AnimationState.DIGGING_LEFT)) { | ||
try { | ||
gameController.updateEntityAttribute( | ||
entity.getUuid(), new AnimationStateWrapper(AnimationState.DIGGING_LEFT)); | ||
} catch (EntityNotFound e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void callAction(Entity entity, long timeInState) { | ||
|
||
if (timeInState < 350) return; | ||
else entity.getEntityStateMachine().setState(AnimationState.DEFAULT); | ||
|
||
// after time | ||
|
||
Coordinates entityCoordinates = entity.getCoordinatesWrapper().getCoordinates(); | ||
Coordinates targetCoordinates = entityCoordinates.add(-1, 0); | ||
|
||
Set<Entity> rayCastSet = rayCastService.rayCast(entityCoordinates, targetCoordinates); | ||
|
||
Block targetBlock = | ||
(Block) (rayCastSet.stream().filter(e -> e instanceof SolidBlock).findAny()).orElse(null); | ||
|
||
if (targetBlock == null) return; | ||
|
||
Health newHealth = targetBlock.getHealth().applyDiff(-50); | ||
|
||
try { | ||
gameController.updateEntityAttribute(targetBlock.getUuid(), newHealth); | ||
} catch (EntityNotFound e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
Oops, something went wrong.