Пример #1
0
    private void UnlockMonster(bool isJet = false)
    {
        List <int> unLockIds = MonsterModel.Instance.UnLock(isJet);

        MonsterModel.Instance.BackUpUnLockMonster(unLockIds);
        rootAction = new OrderAction();
        for (int j = 0; j < unLockIds.Count; j++)
        {
            int monsterRunId             = unLockIds[j];
            FightMonsterItem monsterItem = monsterLayer.GetItemByRunId(monsterRunId);
            rootAction.AddNode(new SetLayerActor(monsterItem.transform, effectLayer.transform));

            CellInfo monsterCell = new CellInfo();
            monsterCell.posX = monsterItem.monsterInfo.posX;
            monsterCell.posY = monsterItem.monsterInfo.posY;
            if (isJet)
            {
                if (monsterItem.monsterInfo.IsNull())
                {
                    CellDirType dirType = WallModel.Instance.GetGapWallDir(monsterCell);
                    int         zrotate = PosUtil.GetRotateByDir(dirType);
                    rootAction.AddNode(new RoatateActor((RectTransform)monsterItem.transform, new Vector3(0, 0, zrotate), 0.25f));
                }
                else
                {
                    rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(1.15f, 1.15f, 1f), 0.2f));
                }
            }

            List <CellInfo> releaseList = MonsterModel.Instance.ReleaseList(monsterRunId);
            if (releaseList.Count > 0)
            {
                ParallelAction paralle = new ParallelAction();
                for (int i = 0; i < releaseList.Count; i++)
                {
                    CellInfo      cellInfo = releaseList[i];
                    FightCellItem item     = GetItemByRunId(cellInfo.runId);
                    if (item == null)
                    {
                        GameObject itemObj = CreateCellItem(cellInfo);
                        item = itemObj.GetComponent <FightCellItem>();
                    }
                    OrderAction order = new OrderAction();
                    order.AddNode(new PlaySoundActor("Refresh"));

                    order.AddNode(new ShowEffectLineActor(effectLayer, cellInfo, monsterCell, monsterItem.monsterInfo.releaseId));

                    order.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0, 0, 0), 0.1f));

                    order.AddNode(new ChangeCellActor(item, cellInfo, monsterItem.monsterInfo.releaseId));

                    paralle.AddNode(order);
                }
                rootAction.AddNode(paralle);
            }
            if (monsterItem.monsterInfo.IsNull())
            {
                rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(1.25f, 1.25f, 0), 0.15f));
                if (j == 0)
                {
                    rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(0, 0, 0), 0.25f));
                }
                else
                {
                    rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(0, 0, 0), 0.15f));
                }
            }
            else
            {
                rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(1, 1, 1), 0.05f));

                CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(monsterItem.monsterInfo.posY, monsterItem.monsterInfo.posX);

                FightCoverItem coverItem = coverLayer.GetItemByRunId(coverInfo.runId);

                rootAction.AddNode(new ChangeCoverActor(coverLayer, coverItem, coverInfo));
                rootAction.AddNode(new ProgressMonsterActor(monsterItem, monsterItem.monsterInfo.progress));
                rootAction.AddNode(new SetLayerActor(monsterItem.transform, monsterLayer.transform));
            }
        }
        if (isJet)
        {
            ExecuteAction(FightStadus.jet_monster);
        }
        else
        {
            ParallelAction paralleTimer = new ParallelAction();

            List <CellInfo> timerCells = CellModel.Instance.Timing();
            for (int i = 0; i < timerCells.Count; i++)
            {
                CellInfo      cellInfo = timerCells[i];
                FightCellItem item     = GetItemByRunId(cellInfo.runId);
                if (item != null)
                {
                    OrderAction order = new OrderAction();
                    order.AddNode(new PlaySoundActor("Refresh"));
                    order.AddNode(new ChangeCellActor(item, cellInfo));
                    if (cellInfo.isBlank)
                    {
                        order.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0, 0, 0), 0.2f));
                        order.AddNode(new DestroyActor(item.gameObject));
                    }
                    paralleTimer.AddNode(order);
                }
            }

            List <CoverInfo> timerCovers = CoverModel.Instance.Timing();
            for (int i = 0; i < timerCovers.Count; i++)
            {
                CoverInfo      coverInfo = timerCovers[i];
                FightCoverItem item      = coverLayer.GetItemByRunId(coverInfo.runId);

                OrderAction order = new OrderAction();
                order.AddNode(new PlaySoundActor("Refresh"));
                order.AddNode(new ChangeCoverActor(coverLayer, item, coverInfo));

                if (coverInfo.IsNull())
                {
                    order.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0, 0, 0), 0.2f));
                    order.AddNode(new DestroyActor(item.gameObject));

                    List <CoverInfo> covers = CoverModel.Instance.GetNeighbors(coverInfo);
                    for (int n = 0; n < covers.Count; n++)
                    {
                        CoverInfo cover = covers[n];
                        if (cover != null)
                        {
                            item = coverLayer.GetItemByRunId(cover.runId);
                            order.AddNode(new ChangeCoverActor(coverLayer, item, cover));
                            if (cover.config != null)
                            {
                                coverFlowInterrupt = true;
                            }
                        }
                    }
                }
                paralleTimer.AddNode(order);
            }

            rootAction.AddNode(paralleTimer);

            if (coverFlowInterrupt)
            {
                rootAction.AddNode(new FuncActor(coverLayer.ShowList));                //todo 爆后流动导致多出蜘蛛网
            }

            ExecuteAction(FightStadus.unlock_monster);
        }
    }