Example #1
0
    private void Start()
    {
        _touchModel = GetComponent <TouchModel>();
        // 初始化地块
        for (int c = 0; c < _col; c++)
        {
            for (int r = 0; r < _row; r++)
            {
                Transform tileTr = Object.Instantiate(tilePrefab);
                tileTr.SetParent(transform);
                tileTr.localPosition = new Vector3(r * TileWidth, c * TileHeight);
                tileTr.name          = "Tile_" + (c * _col + r + 1);
                Tile tile = tileTr.GetComponent <Tile>();
                tile.SetPosition(r, c);
                _tileList.Add(tile);

                // 注册点击事件
                _touchModel.AddTouchEvent(tileTr.gameObject);
            }
        }
    }
Example #2
0
 private void Awake()
 {
     touchModel = new TouchModel();
 }