#I'm tweaking

1 messages · Page 1 of 1 (latest)

modern lichen
#


public class Board : MonoBehaviour
{

    public GameObject lightTile;
    public GameObject darkTile;

    public GameObject blackPawn;
    public GameObject blackKnight;
    public GameObject blackBishop;
    public GameObject blackRook;
    public GameObject blackQueen;
    public GameObject blackKing;

    public GameObject whitePawn;
    public GameObject whiteKnight;
    public GameObject whiteBishop;
    public GameObject whiteRook;
    public GameObject whiteQueen;
    public GameObject whiteKing;

    private GameHandler gameHandler;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        Debug.Log("hello world");
        GameObject[,] pieces = { {whitePawn, whiteKnight, whiteBishop, whiteRook, whiteQueen, whiteKing },
            { blackPawn, blackKnight, blackBishop, blackRook, blackQueen, blackKing } 
        };

        Piece.piecesGameObject = pieces;


        gameHandler = new GameHandler(lightTile, darkTile);
    }
}```
#
using UnityEngine;

public class GameHandler
{
    public Vector2 boardOffset;

    private Squares[,] board = new Squares[8, 8];


    public GameHandler(GameObject lightTile, GameObject darkTile)
    {
        for ( int i = 0; i < 8; i++)
        {
            for (int k = 0; k < 8; k++)
            {
                board[i, k] = new Squares(i, k, lightTile, darkTile);
            }
        }

    }

    
}
#

public class Coordinates
{
    private char file = 'a';
    private char rank = '1';

    public Coordinates(int rank, int file)
    {
        setRank(rank);
        setFile(file);
    }

    public char convertToRankName(int number)
    {
        switch (number)
        {
            case 0:
                return 'a';
            case 1:
                return 'b';
            case 2:
                return 'c';
            case 3:
                return 'd';
            case 4:
                return 'e';
            case 5:
                return 'f';
            case 6:
                return 'g';
            case 7:
                return 'h';
        }

        return 'z';
    }

    public char convertToFileName(int number)
    {
        string a = (number +1).ToString();
        return a[0];
    }

    public void setRank(int number)
    {
        this.file = convertToRankName(number);
    }

    public void setFile(int number)
    {
        this.rank = convertToFileName(number);
    }

    public char getRank()
    {
        return this.file;
    }

    public char getFile()
    {
        return this.rank;
    }

    public string GetCoordsStr()
    {
        return $"{this.file}{this.rank}";
    }

}```
#

that's all the scripts

#

also here's the only relevant object in the scene