Skip to content
Snippets Groups Projects
Commit 8c2dbe90 authored by Anders H. Rebner's avatar Anders H. Rebner
Browse files

Moved getPlayerNameCoordinates function

parent c84afdb2
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,6 @@ import com.mygdx.game.model.Player; ...@@ -10,7 +10,6 @@ import com.mygdx.game.model.Player;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
public class NetworkController { public class NetworkController {
......
...@@ -123,7 +123,7 @@ class Game(gameState: GameState, playerIds: LinkedHashSet<Int>) { ...@@ -123,7 +123,7 @@ class Game(gameState: GameState, playerIds: LinkedHashSet<Int>) {
} }
fun getPlayerNameCoordinates(hex_side_length: Float): List<List<Float>> { fun getPlayerNameCoordinates(hex_side_length: Float): List<List<Float>> {
return gameState.getRules().getPlayerNameCoordinates(hex_side_length) return gameState.getBoardState().getPlayerNameCoordinates(hex_side_length)
} }
fun setPlayerLeftMidGame(playerId: Int): List<Vector3> { fun setPlayerLeftMidGame(playerId: Int): List<Vector3> {
......
...@@ -11,6 +11,7 @@ abstract class AbstractBoard { ...@@ -11,6 +11,7 @@ abstract class AbstractBoard {
abstract fun placePiecesAtStart(rules: AbstractRules, playerIds: HashSet<Int>) // Places pieces at startfields abstract fun placePiecesAtStart(rules: AbstractRules, playerIds: HashSet<Int>) // Places pieces at startfields
abstract fun movePiece(fromCoordinates: Vector3, toCoordinates: Vector3): Boolean // Moves piece abstract fun movePiece(fromCoordinates: Vector3, toCoordinates: Vector3): Boolean // Moves piece
abstract fun getBoardImagePath(): String // Returns path to board image abstract fun getBoardImagePath(): String // Returns path to board image
abstract fun getPlayerNameCoordinates(hex_side_length: Float): List<List<Float>> // Returns a list with lists of coordinates for playernames
fun playerLeftMidGame(playerId: Int): List<Vector3> { // Removes a players pieces and returns their coordinates fun playerLeftMidGame(playerId: Int): List<Vector3> { // Removes a players pieces and returns their coordinates
var removedPieces: List<Vector3> = listOf() var removedPieces: List<Vector3> = listOf()
......
//General board class //General board class
package com.mygdx.game.model package com.mygdx.game.model
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.Vector3 import com.badlogic.gdx.math.Vector3
import com.mygdx.game.Constants
import java.lang.Integer.max import java.lang.Integer.max
import java.lang.Integer.min import java.lang.Integer.min
...@@ -81,4 +83,15 @@ class DefaultBoard: AbstractBoard() { ...@@ -81,4 +83,15 @@ class DefaultBoard: AbstractBoard() {
override fun getBoardImagePath(): String { override fun getBoardImagePath(): String {
return "Game/1x/GameBoard@1x.png" return "Game/1x/GameBoard@1x.png"
} }
override fun getPlayerNameCoordinates(hex_side_length: Float): List<List<Float>> {
return listOf(
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 2.5f * hex_side_length, Gdx.graphics.height - Constants.PLAYER_NAME_TEXT_FIELD_HEIGHT - 1.5f * hex_side_length),
listOf(Gdx.graphics.width / 2f + Constants.PLAYER_NAME_TEXT_FIELD_WIDTH + 4f * hex_side_length, Gdx.graphics.height / 2f + 4 * hex_side_length),
listOf(Gdx.graphics.width / 2f + Constants.PLAYER_NAME_TEXT_FIELD_WIDTH + 4f * hex_side_length, Gdx.graphics.height / 2f - 5 * hex_side_length),
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 2.5f * hex_side_length, 1.5f * hex_side_length),
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 12f * hex_side_length, Gdx.graphics.height / 2f - 5 * hex_side_length),
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 12f * hex_side_length, Gdx.graphics.height / 2f + 4 * hex_side_length)
)
}
} }
\ No newline at end of file
...@@ -14,5 +14,4 @@ abstract class AbstractRules { ...@@ -14,5 +14,4 @@ abstract class AbstractRules {
abstract fun getPlayerTargetFields(boardSlot: Int) : List<Vector3> // Returns a list of targetfields for a given player abstract fun getPlayerTargetFields(boardSlot: Int) : List<Vector3> // Returns a list of targetfields for a given player
abstract fun generateStartFields(playerCount: Int = 6): List<List<Vector3>> // Returns a list with lists of startfields abstract fun generateStartFields(playerCount: Int = 6): List<List<Vector3>> // Returns a list with lists of startfields
abstract fun getUsedBoardSlots(playerCount: Int): List<Int> // Returns a list with used boardslots abstract fun getUsedBoardSlots(playerCount: Int): List<Int> // Returns a list with used boardslots
abstract fun getPlayerNameCoordinates(hex_side_length: Float): List<List<Float>> // Returns a list with lists of coordinates for playernames
} }
\ No newline at end of file
package com.mygdx.game.model.gamemodes.rules package com.mygdx.game.model.gamemodes.rules
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.Vector3 import com.badlogic.gdx.math.Vector3
import com.mygdx.game.Constants
import com.mygdx.game.model.AbstractRules import com.mygdx.game.model.AbstractRules
class DefaultRules: AbstractRules() { class DefaultRules: AbstractRules() {
...@@ -91,16 +89,5 @@ class DefaultRules: AbstractRules() { ...@@ -91,16 +89,5 @@ class DefaultRules: AbstractRules() {
} }
} }
} }
override fun getPlayerNameCoordinates(hex_side_length: Float): List<List<Float>> {
return listOf(
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 2.5f * hex_side_length, Gdx.graphics.height - Constants.PLAYER_NAME_TEXT_FIELD_HEIGHT - 1.5f * hex_side_length),
listOf(Gdx.graphics.width / 2f + Constants.PLAYER_NAME_TEXT_FIELD_WIDTH + 4f * hex_side_length, Gdx.graphics.height / 2f + 4 * hex_side_length),
listOf(Gdx.graphics.width / 2f + Constants.PLAYER_NAME_TEXT_FIELD_WIDTH + 4f * hex_side_length, Gdx.graphics.height / 2f - 5 * hex_side_length),
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 2.5f * hex_side_length, 1.5f * hex_side_length),
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 12f * hex_side_length, Gdx.graphics.height / 2f - 5 * hex_side_length),
listOf(Gdx.graphics.width / 2f - Constants.PLAYER_NAME_TEXT_FIELD_WIDTH - 12f * hex_side_length, Gdx.graphics.height / 2f + 4 * hex_side_length)
)
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment