-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
141 additions
and
14 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
src/toniarts/openkeeper/game/controller/IShotsController.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,42 @@ | ||
/* | ||
* Copyright (C) 2014-2024 OpenKeeper | ||
* | ||
* OpenKeeper is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* OpenKeeper is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OpenKeeper. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package toniarts.openkeeper.game.controller; | ||
|
||
import com.jme3.math.Vector2f; | ||
import com.simsilica.es.EntityId; | ||
|
||
/** | ||
* Handles shots. Shots are spells and weapons cast by traps, creatures and | ||
* keepers | ||
* | ||
* @author Toni Helenius <[email protected]> | ||
*/ | ||
public interface IShotsController { | ||
|
||
/** | ||
* Creates a shot | ||
* | ||
* @param shotTypeId shot type to create | ||
* @param shotData1 arbitrary value, interpreted per shot | ||
* @param shotData2 arbitrary value, interpreted per shot | ||
* @param playerId owher of the shot | ||
* @param position 2D coordinate of the shot origin | ||
* @param target shot target, can be null | ||
*/ | ||
public void createShot(short shotTypeId, int shotData1, int shotData2, short playerId, Vector2f position, EntityId target); | ||
|
||
} |
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
84 changes: 84 additions & 0 deletions
84
src/toniarts/openkeeper/game/controller/ShotsController.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,84 @@ | ||
/* | ||
* Copyright (C) 2014-2024 OpenKeeper | ||
* | ||
* OpenKeeper is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* OpenKeeper is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OpenKeeper. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package toniarts.openkeeper.game.controller; | ||
|
||
import com.jme3.math.Vector2f; | ||
import com.simsilica.es.EntityData; | ||
import com.simsilica.es.EntityId; | ||
import java.lang.System.Logger; | ||
import java.util.Map; | ||
import toniarts.openkeeper.tools.convert.map.KwdFile; | ||
import toniarts.openkeeper.tools.convert.map.Shot; | ||
import static toniarts.openkeeper.tools.convert.map.Shot.ProcessType.CREATE_CREATURE; | ||
import static toniarts.openkeeper.tools.convert.map.Shot.ProcessType.CREATE_OBJECT; | ||
import static toniarts.openkeeper.tools.convert.map.Shot.ProcessType.MODIFY_HEALTH; | ||
import static toniarts.openkeeper.tools.convert.map.Shot.ProcessType.POSSESS_CREATURE; | ||
import toniarts.openkeeper.tools.convert.map.Variable; | ||
|
||
/** | ||
* | ||
* @author Toni Helenius <[email protected]> | ||
*/ | ||
public class ShotsController implements IShotsController { | ||
|
||
private static final Logger logger = System.getLogger(ShotsController.class.getName()); | ||
|
||
private final KwdFile kwdFile; | ||
private final EntityData entityData; | ||
private final Map<Variable.MiscVariable.MiscType, Variable.MiscVariable> gameSettings; | ||
private final IGameTimer gameTimer; | ||
private final IGameController gameController; | ||
private final IMapController mapController; | ||
private final ILevelInfo levelInfo; | ||
private final IObjectsController objectsController; | ||
private final ICreaturesController creaturesController; | ||
|
||
public ShotsController(KwdFile kwdFile, EntityData entityData, Map<Variable.MiscVariable.MiscType, Variable.MiscVariable> gameSettings, IGameTimer gameTimer, | ||
IGameController gameController, IMapController mapController, ILevelInfo levelInfo, IObjectsController objectsController, ICreaturesController creaturesController) { | ||
this.kwdFile = kwdFile; | ||
this.entityData = entityData; | ||
this.gameSettings = gameSettings; | ||
this.gameTimer = gameTimer; | ||
this.gameController = gameController; | ||
this.mapController = mapController; | ||
this.levelInfo = levelInfo; | ||
this.objectsController = objectsController; | ||
this.creaturesController = creaturesController; | ||
} | ||
|
||
@Override | ||
public void createShot(short shotTypeId, int shotData1, int shotData2, short playerId, Vector2f position, EntityId target) { | ||
Shot shot = kwdFile.getShotById(shotTypeId); | ||
switch (shot.getProcessType()) { | ||
case CREATE_CREATURE -> { | ||
creaturesController.spawnCreature((short) shotData1, playerId, shotData2, position, ICreaturesController.SpawnType.CONJURE); | ||
} | ||
case CREATE_OBJECT -> { | ||
objectsController.loadObject((short) shotData1, playerId, position, 0); | ||
} | ||
case POSSESS_CREATURE -> { | ||
|
||
} | ||
case MODIFY_HEALTH -> { | ||
|
||
} | ||
default -> | ||
logger.log(Logger.Level.WARNING, "Shot type {0} not implemented", shot.getProcessType()); | ||
} | ||
} | ||
|
||
} |