Commit 8c2dbe90 authored by Anders H. Rebner's avatar Anders H. Rebner
Browse files

Moved getPlayerNameCoordinates function

parent c84afdb2
......@@ -10,7 +10,6 @@ import com.mygdx.game.model.Player;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
public class NetworkController {
......
......@@ -123,7 +123,7 @@ class Game(gameState: GameState, playerIds: LinkedHashSet<Int>) {
}
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> {
......
......@@ -11,6 +11,7 @@ abstract class AbstractBoard {
abstract fun placePiecesAtStart(rules: AbstractRules, playerIds: HashSet<Int>) // Places pieces at startfields
abstract fun movePiece(fromCoordinates: Vector3, toCoordinates: Vector3): Boolean // Moves piece
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
var removedPieces: List<Vector3> = listOf()
......
//General board class
package com.mygdx.game.model
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.Vector3
import com.mygdx.game.Constants
import java.lang.Integer.max
import java.lang.Integer.min
......@@ -81,4 +83,15 @@ class DefaultBoard: AbstractBoard() {
override fun getBoardImagePath(): String {
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 {
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 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
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.Vector3
import com.mygdx.game.Constants
import com.mygdx.game.model.AbstractRules
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)
)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment