Exemple #1
0
    /// <summary>
    /// Start the game, initialize the chessboard prefab.
    /// </summary>
    public void Play()
    {
        cgChessBoardScript newboard  = GameObject.Instantiate(ChessBoard).GetComponent <cgChessBoardScript>();
        cgEngine           newengine = newboard.GetComponent <cgEngine>();

        newengine.SearchDepthWeak   = _weakDepthDifficulties[(int)DifficultySlider.value - 1];
        newengine.SearchDepthStrong = _strongDepthDifficulties[(int)DifficultySlider.value - 1];
        newboard.StartGame(currentBoardMode);
        //newobj.GetComponent

        GameObject.DestroyImmediate(gameObject);
    }
Exemple #2
0
    private void _generate(List <sbyte> placements)
    {
        //Instantiate default cgBoard and cut out all pieces and squares, insert new ones as specified by these settings.
        GameObject boardObject = (GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath("Assets/ChessGame/prefabs/ChessBoardEmpty.prefab", typeof(GameObject)));

        boardObject.name = "ChessBoard " + _generator.boardWidth + "x" + _generator.boardHeight;
        PrefabUtility.UnpackPrefabInstance(boardObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
        cgChessBoardScript board = boardObject.GetComponent <cgChessBoardScript>();

        _generator.boardScript = board;
        _generator.generate(placements);
    }
    /// <summary>
    /// Start the game, initialize the chessboard prefab.
    /// </summary>
    public void Play()
    {
        cgChessBoardScript newboard = GameObject.Instantiate((this.BoardType.value == 0 ? ChessBoard : ChessBoardTiny)).GetComponent <cgChessBoardScript>();

        newboard.searchDepthStrong = _strongDepthDifficulties[(int)DifficultySlider.value - 1];
        newboard.searchDepthWeak   = _weakDepthDifficulties[(int)DifficultySlider.value - 1];
        cgEngine newengine = newboard.getEngine;

        newboard.Mode        = currentBoardMode;
        newboard.displayAs3d = DisplayAs3D.isOn;
        newboard.start();
        //newobj.GetComponent

        GameObject.DestroyImmediate(gameObject);
    }