示例#1
0
 public void DownFileWithProcess(DownloadFileData data)
 {
     _fileData    = data;
     _piceManager = new PiceManager(_fileData, _piceSize);
     CreateThreads(_maxThread);
     //finishHandle.WaitOne();
 }
示例#2
0
    public void LoadInfo(PuzzleInfo info)
    {
        // 把所有 pice 拿起
        foreach (var pice in PiceManager.list)
        {
            //pice.SetToFloating();
            PiceMover.SetBlockToFloat(pice);
            pice.StopTween();
        }

        // 逐个设置 pice 归属
        foreach (var i in info.piceInfoList)
        {
            var index = i.index;
            var pice  = PiceManager.GetByIndex(index);
            if (i.owner == PiceOwner.Board)
            {
                //pice.SetToBoard(i.boardX, i.boardY);
                PiceMover.SetBlockToBoard(pice, i.boardX, i.boardY);
            }
            else if (i.owner == PiceOwner.Side)
            {
                //pice.SetToSide(i.sideIndex);
                //side.Append(pice);
                PiceMover.SetToSide(pice, -1);
            }
            else if (i.owner == PiceOwner.Floating)
            {
                PiceMover.SetToSide(pice, -1);
                //pice.SetToSide(side.count - 1);
            }
            pice.isFixed      = i.isFixed;
            pice.SortingOrder = i.sortingOrder;
            // linking
            pice.linkingList.Clear();
            foreach (var linkingInfo in i.LinkingInfoList)
            {
                var linking = new Linking();
                linking.directory = linkingInfo.directory;
                var linkingToPinceIndex = linkingInfo.piceIndex;
                var linkingToPice       = PiceManager.GetByIndex(linkingToPinceIndex);
                linking.pice = linkingToPice;
                pice.linkingList.Add(linking);
            }
            // edge type
            pice.LeftType   = i.leftType;
            pice.RightType  = i.rightType;
            pice.BottomType = i.bottomType;
            pice.TopType    = i.topType;
        }
        board.RepositionAllPiceNoAnimation();
        side.RepositionPiceListNoAnimation();

        LayerOrderDispatcher.next = info.nextOrder;
    }
示例#3
0
    /// <summary>
    /// 每当开始新拼图时调用
    /// </summary>
    /// <param name="texture"></param>
    /// <param name="cellPixelSize"></param>
    public void StartPuzzle(Sprite content, int cellPixelSize)
    {
        Clean();
        EXPAND         = (int)(cellPixelSize * 0.25f);
        expanedTexture = ExpandTexture(content);
        map            = new Map();
        map.Init(expanedTexture, EXPAND, cellPixelSize);

        board.Init(map.validWidth, map.validHeight, map.xCount, map.yCount);
        side.Init(200);
        //side.Init(map.validHeight, map.yCount);
        var count = map.xCount * map.yCount;

        var indexList = new List <int>();

        for (int i = 0; i < count; i++)
        {
            indexList.Add(i);
        }
        if (SHUFF)
        {
            indexList = ArraryUtil.GetRandomList(indexList);
        }
        foreach (var index in indexList)
        {
            var pice = PiceManager.Create(map, index);
            PiceMover.SetToSide(pice, -1);
        }
        //side.RepositionPiceList();
        side.RepositionPiceListNoAnimation();

        if (!DEBUG)
        {
            core.HideDot();
        }
        // board 的 scrollRect content位置归零
        var p = side.scrollView.content.localPosition;

        p.x = 0;
        side.scrollView.content.localPosition = p;
        // 设置 valid rect sprite 到参考图
        core.validSpriet.sprite = map.validSprite;
        core.validSpriet.gameObject.SetActive(false);
    }
示例#4
0
    /// <summary>
    /// 整个游戏中只会被调用一次
    /// </summary>
    public void Init()
    {
        instance = this;
        PiceManager.Init();
        var core_go = GameObject.Find("Core");

        if (core_go == null)
        {
            var prefab_core = Resources.Load <Core>("Core/Core");
            this.core = GameObject.Instantiate(prefab_core);
        }
        else
        {
            this.core = core_go.GetComponent <Core>();
        }

        this.board = core.board;
        this.side  = core.side;
        core.Init();
    }
示例#5
0
 public void Clean()
 {
     PiceManager.Clean();
     LayerOrderDispatcher.Clean();
 }