Пример #1
0
    void Start()
    {
        GameObject optionObject = GameObject.Find("GameSize");

        if (optionObject == null)
        {
            Debug.LogError("GameOption component could be found therefore no Board settings can be extracted");
            return;
        }

        GameOption opt = optionObject.GetComponent <GameOption>();

        Destroy(optionObject);//remove so that there will be no issues if the game mode is changed before the game finishes

        trans = gameObject.GetComponent <RectTransform>();
        SizeSelector.GameSize option = opt.Option;
        int boardSize = option.X * option.Y;

        spareTiles = new ObjectPool <Tile>(() => CreateTile(), boardSize * 2, g => g.gameObject.activeInHierarchy, true);

        mover = GetComponent <TileMover>();

        if (SaveSystem.HasBoard(option.X, option.Y))
        {
            //load the previous state
            BuildBoard(SaveSystem.LoadBoard(option.X, option.Y));
        }
        else
        {
            //create a new game board
            BuildBoard(option.X, option.Y);
        }
        mover.boardSize = new BoardPos(option.X, option.Y);

        Destroy(opt);
    }
Пример #2
0
 public void SetOption(SizeSelector.GameSize newVal)
 {
     Option       = newVal;
     preInit      = true;
     selfDestruct = false;
 }