Пример #1
0
    void Spawn(Transform prefab, Color color, ChessCoord position, FigureType type)
    {
        Transform instance = Instantiate(prefab, CoordinatesConverter.ChessToVector(position), Quaternion.identity, this.transform);

        instance.localScale = scaleVector;
        instance.gameObject.GetComponent <MeshRenderer>().material.color = color;
        Figure addedF = instance.gameObject.AddComponent <Figure>();

        addedF.AssignTypeBehaviour(type);
        //Add to BoardManager
        BoardManager.board[(int)CoordinatesConverter.ChessToVector(position).x, (int)CoordinatesConverter.ChessToVector(position).z].figure = addedF;
        if (color == Color.black)
        {
            instance.localRotation = Quaternion.Euler(0f, 180f, 0f);
            BoardManager.blackFigures.Add(addedF);
        }
        else
        {
            BoardManager.whiteFigures.Add(addedF);
        }
    }