Example #1
0
    public List <CellInfo> ReleaseList(int monsterId)
    {
        List <CellInfo> releaseList = new List <CellInfo>();

        MonsterInfo monster = GetMonsterInfoByRunId(monsterId);

        if (monster != null && monster.releaseList.Count > 0)
        {
            TIVInfo tiv = monster.releaseList[0];

            CellModel.Instance.anims = new List <List <CellAnimInfo> >();

            List <CellInfo> waitList = new List <CellInfo>();

            if ((int)tiv.value <= 0)
            {
                CellInfo    centerCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY);
                CellDirType dirType    = WallModel.Instance.GetGapWallDir(centerCell);
                if (dirType != CellDirType.no)
                {
                    waitList = CellModel.Instance.GetDirCells(centerCell, dirType);
                }

                for (int i = 0; i < waitList.Count; i++)
                {
                    CellInfo cellInfo = waitList[i];
                    if (cellInfo != null && cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five)
                    {
                        cellInfo.SetConfig((int)tiv.id);
                        releaseList.Add(cellInfo);
                    }
                }
            }
            else
            {
                if (monster.progress > 0)
                {
                    if (monster.progress >= 1)
                    {
                        monster.progress = 0;
                        CellInfo centerCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY);
                        waitList = CellModel.Instance.GetNeighbors(centerCell);
                        for (int i = 0; i < waitList.Count; i++)
                        {
                            CellInfo cellInfo = waitList[i];
                            if (cellInfo != null && cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five)
                            {
                                cellInfo.SetConfig((int)tiv.id);
                                releaseList.Add(cellInfo);
                            }
                        }
                    }
                }
                else if (monster.banCount >= 0)
                {
                    if (monster.banCount == 0)
                    {
                        CellInfo domnCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY + 1);
                        if (domnCell != null)
                        {
                            if (domnCell.isBlank)
                            {
                                domnCell.SetConfig(monster.releaseId);
                                CellModel.Instance.RemoveFromLines(domnCell.posX, domnCell.posY);
                                releaseList.Add(domnCell);
                            }
                            else
                            {
                                if (domnCell.config.id != monster.releaseId && domnCell.config.cell_type != (int)CellType.terrain)
                                {
                                    config_cell_item config_cell = (config_cell_item)ResModel.Instance.config_cell.GetItem(monster.releaseId);

                                    bool       inHide = false;
                                    List <int> hides  = config_cell.GetHides();
                                    for (int h = 0; h < hides.Count; h++)
                                    {
                                        if (domnCell.config.id == hides[h])
                                        {
                                            inHide = true;
                                        }
                                    }

                                    if (inHide == false)
                                    {
                                        domnCell.SetConfig(monster.releaseId);
                                        CellModel.Instance.RemoveFromLines(domnCell.posX, domnCell.posY);
                                        releaseList.Add(domnCell);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < BattleModel.Instance.crtBattle.ShowHeight(); i++)
                    {
                        List <CellInfo> xCells = CellModel.Instance.allCells[i];
                        for (int j = 0; j < xCells.Count; j++)
                        {
                            CellInfo cellInfo = xCells[j];
                            if (cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five && cellInfo.changer == 0)
                            {
                                if (tiv.id != cellInfo.config.id)
                                {
                                    waitList.Add(cellInfo);
                                }
                            }
                        }
                    }
                    int minCount = Mathf.Min((int)tiv.value, waitList.Count);
                    for (int i = 0; i < minCount; i++)
                    {
                        int rangeIndex = Random.Range(0, waitList.Count);

                        CellInfo cellInfo = waitList[rangeIndex];
                        cellInfo.SetConfig((int)tiv.id);

                        waitList.RemoveAt(rangeIndex);

                        releaseList.Add(cellInfo);
                    }
                }
            }
        }
        return(releaseList);
    }