コード例 #1
0
ファイル: MonsterInfo.cs プロジェクト: ErrorMee/update
    public void RecursionRandomCrawl()
    {
        if (crawlCount > 0)
        {
            CellInfo centerCell    = CellModel.Instance.GetCellByPos(posX, posY);
            CellInfo findCellPoint = null;

            List <CellDirType> priorityDirList = PosMgr.PriorityDirList((int)randomCrawlDir, true);

            for (int i = 0; i < priorityDirList.Count; i++)
            {
                CellDirType dir = priorityDirList[i];

                CellInfo dirCell = CellModel.Instance.GetDirCell(centerCell, dir);

                if (dirCell == null)
                {
                    continue;
                }

                if (dirCell.CanCrawl() == false)
                {
                    continue;
                }

                CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(dirCell.posY, dirCell.posY);
                if (coverInfo != null && coverInfo.IsOpen() == false)
                {
                    continue;
                }

                WallInfo wall = WallModel.Instance.GetWall(centerCell, dirCell);
                if (wall.IsNull() == false)
                {
                    continue;
                }
                randomCrawlDir = dir;
                findCellPoint  = dirCell;
                break;
            }

            if (findCellPoint != null)
            {
                Hold(false);
                MonsterInfo toMonsterInfo = MonsterModel.Instance.GetMonsterByPos(findCellPoint.posY, findCellPoint.posX);
                MonsterModel.Instance.SwitchPos(this, toMonsterInfo);
                this.SwitchPos(toMonsterInfo);
                Hold();

                crawlCount--;
                MonsterModel.Instance.AddCrawAnim(this, findCellPoint);

                if (crawlCount > 0)
                {
                    //RecursionRandomCrawl();
                }
            }
            else
            {
                crawlCount--;
                MonsterModel.Instance.AddCrawAnim(this, centerCell);
            }
        }
    }