Ejemplo n.º 1
0
    public override void Init()
    {
        bossController = GetComponent <BossMonsterController>();
        bossController.Init();

        idle.Controller         = bossController;
        detectTarget.Controller = bossController;

        chaseTarget.Controller         = bossController;
        checkCloseTarget.Controller    = bossController;
        checkPossibleAttack.Controller = bossController;
        startAttack.Controller         = bossController;

        checkPossibleSkill.Controller = bossController;
        skillAction.Controller        = bossController;

        deadAction.Controller = bossController;
        isDie.Controller      = bossController;

        //Node 추가
        aiRoot.AddChild(seqNormal);

        seqNormal.AddChild(idle);
        seqNormal.AddChild(detectTarget);

        aiRoot.AddChild(selector);

        selector.AddChild(seqchaseAttack);
        selector.AddChild(seqSkill);
        selector.AddChild(seqDead);

        seqchaseAttack.AddChild(chaseTarget);
        seqchaseAttack.AddChild(checkCloseTarget);
        seqchaseAttack.AddChild(checkPossibleAttack);
        seqchaseAttack.AddChild(startAttack);

        seqSkill.AddChild(checkPossibleSkill);
        seqSkill.AddChild(skillAction);

        seqDead.AddChild(isDie);
        seqDead.AddChild(deadAction);

        behaviorProcess = BehaviorProcess();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 몬스터 생성
    /// </summary>
    private void DrawPrefabByClearType()
    {
        foreach (DungeonRoom room in roomList)
        {
            DrawItem(room);
            switch (room.roomClearType)
            {
            case Room_ClearType.Battle:
                //몬스터 생성
                room.SetPrefabInfoList(room.monsterInfoList);

                foreach (SpawnMonsterInfo monsterinfo in room.monsterInfoList)
                {
                    Monster tmpm = Instantiate(loadData.monsterPrefabDic[monsterinfo.mType.ToString()], monsterinfo.startPos, Quaternion.identity, room.roomModel.transform);
                    tmpm.ownRoom             = room;
                    monsterinfo.monsterModel = tmpm;
                }

                break;

            case Room_ClearType.Puzzle:
                break;

            case Room_ClearType.Boss:
                room.SetBossPos();
                foreach (SpawnBossInfo bossinfo in room.bossInfoList)
                {
                    BossMonsterController tmpboss = Instantiate(loadData.bossPrefabDic[bossinfo.bType.ToString()], bossinfo.startPos, Quaternion.identity, room.roomModel.transform);
                    tmpboss.ownRoom    = room;
                    bossinfo.bossModel = tmpboss;
                }
                break;

            case Room_ClearType.None:
                Debug.Log("ClearType - None ");
                break;

            default:
                Debug.Log("ClearType Default");
                break;
            }
        }
    }
Ejemplo n.º 3
0
 public SpawnBossInfo(BOSS_TYPE _btype, Vector2 _startpos, BossMonsterController _bossmodel)
 {
     bType     = _btype;
     startPos  = _startpos;
     bossModel = _bossmodel;
 }
Ejemplo n.º 4
0
 public SpawnBossInfo(BOSS_TYPE _btype, Vector2 _startpos)
 {
     bType     = _btype;
     startPos  = _startpos;
     bossModel = null;
 }
Ejemplo n.º 5
0
    /// <summary>
    /// NOTE : Tileinfo를 통하여 Draw
    /// </summary>
    /// <param name="_rooms"></param>
    public GameObject DrawTilemap(DungeonRoom room, bool ingame)
    {
        //Tilemap 생성 및 초기화
        var tmpob = new GameObject("Room" + room.roomNumberOfList, typeof(Tilemap), typeof(CompositeCollider2D));

        tmpob.AddComponent <TilemapCollider2D>().usedByComposite = true;
        tmpob.GetComponent <Rigidbody2D>().bodyType             = RigidbodyType2D.Static;
        tmpob.AddComponent <TilemapRenderer>().sortingLayerName = "Ground";
        tmpob.tag   = "Ground";
        tmpob.layer = 8;
        Tilemap tmptilemap = tmpob.GetComponent <Tilemap>();

        //내부 생성
        for (int x = 0; x < room.roomRect.xMax; x++)
        {
            for (int y = 0; y < room.roomRect.yMax; y++)
            {
                if (room.roomTileArray[x, y] != null)
                {
                    TileInfo tmpdata = room.roomTileArray[x, y];
                    switch (tmpdata.tileType)
                    {
                    case TileType.Terrain:
                        tmptilemap.SetTile(new Vector3Int(x, y, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                        break;

                    case TileType.Structure:
                        StructureObject tmpen = Instantiate(loadData.structurePrefabDic[tmpdata.tileName], new Vector3(x + 0.5f, y + 0.5f, 0), Quaternion.identity, tmptilemap.transform);
                        tmpen.ownRoom = room;
                        if (tmpdata.tileName == STRUCTURE_TYPE.Entrance.ToString())
                        {
                            tmpen.transform.localPosition += new Vector3(0, 0.5f, 0);
                            //Maptool에서 사용할경우 대비
                            if (room.entranceInfoList.Count == 0)
                            {
                                room.entranceInfoList.Add(new EntranceConnectRoom(null, tmpen.GetComponent <EntranceSc>()));
                            }
                            if (room.roomClearType == Room_ClearType.Boss)
                            {
                                tmpen.sR.sprite = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0];
                            }

                            tmpen.sR.sprite           = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0];
                            tmpen.sR.sortingLayerName = "Entrance";
                            tmpen.GetComponent <EntranceSc>().spriteArray[0] = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0];
                            tmpen.GetComponent <EntranceSc>().spriteArray[1] = loadData.tileDataArray[room.roomSpriteType].entranceSprite[1];
                            tmpen.transform.SetParent(tmpob.transform);
                            //이미 출입문이 생성되어있는방 예외 처리
                            foreach (EntranceConnectRoom nroom in room.entranceInfoList)
                            {
                                if (nroom.entrance == null)
                                {
                                    tmpen.GetComponent <EntranceSc>().ownRoom = room;
                                    nroom.entrance = tmpen.GetComponent <EntranceSc>();
                                    break;
                                }
                            }
                        }
                        else if (tmpdata.tileName == STRUCTURE_TYPE.Box.ToString())
                        {
                            room.boxInfoList.Add(new SpawnBoxInfo(tmpdata.tileNamesType.ToString(), tmpen));
                        }
                        else if (tmpdata.tileName == STRUCTURE_TYPE.Switch.ToString())
                        {
                            room.switchInfoList.Add(new SpawnSwitchInfo(tmpdata.tileNamesType, tmpen));
                        }
                        break;

                    case TileType.Monster:
                        Monster tmpmonster = Instantiate(loadData.monsterPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), loadData.monsterPrefabDic[room.roomTileArray[x, y].tileName].transform.rotation, tmptilemap.transform);
                        tmpmonster.ownRoom = room;
                        room.monsterInfoList.Add(new SpawnMonsterInfo(tmpmonster.mType, new Vector2(x, y), tmpmonster));
                        break;

                    case TileType.Item:
                        ItemSc tmpitem = Instantiate(loadData.itemPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), Quaternion.identity, tmptilemap.transform);
                        break;

                    case TileType.Boss:
                        BossMonsterController tmpboss = Instantiate(loadData.bossPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), loadData.bossPrefabDic[room.roomTileArray[x, y].tileName].transform.rotation, tmptilemap.transform);
                        tmpboss.ownRoom = room;
                        room.bossInfoList.Add(new SpawnBossInfo(tmpboss.bType, new Vector2(x, y), tmpboss));
                        break;

                    default:
                        Debug.Log(room.roomTileArray[x, y].tileType.ToString());
                        break;
                    }
                }
            }
        }

        //인게임일 경우에만 생성 (맵툴의 경우에는 배경을 남겨두므로 제외)
        if (ingame)
        {
            //Edge생성
            for (int i = 0; i < room.roomRect.xMax; i++)
            {
                tmptilemap.SetTile(new Vector3Int(i, -1, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                tmptilemap.SetTile(new Vector3Int(i, -2, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                tmptilemap.SetTile(new Vector3Int(i, (int)room.roomRect.yMax, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                tmptilemap.SetTile(new Vector3Int(i, (int)room.roomRect.yMax + 1, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
            }

            //left, right
            for (int j = -2; j < room.roomRect.yMax + 2; j++)
            {
                tmptilemap.SetTile(new Vector3Int(-1, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                tmptilemap.SetTile(new Vector3Int(-2, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                tmptilemap.SetTile(new Vector3Int((int)room.roomRect.xMax, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
                tmptilemap.SetTile(new Vector3Int((int)room.roomRect.xMax + 1, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile);
            }
            //배경 생성
            GameObject tmpParent = new GameObject("BackGroundParent");
            int        count     = 0;
            foreach (var tmptile in loadData.tileDataArray[room.roomSpriteType].backGroundTile)
            {
                GameObject backgroundob = new GameObject("BackGround", typeof(SpriteRenderer));
                backgroundob.transform.localPosition = Vector3.zero;
                backgroundob.transform.localRotation = Quaternion.identity;
                backgroundob.GetComponent <SpriteRenderer>().sortingLayerName = "BackGround";
                backgroundob.GetComponent <SpriteRenderer>().drawMode         = SpriteDrawMode.Sliced;
                backgroundob.GetComponent <SpriteRenderer>().sprite           = tmptile.sprite;
                backgroundob.GetComponent <SpriteRenderer>().size             = room.roomRect.size;
                backgroundob.GetComponent <SpriteRenderer>().sortingOrder     = count;
                count++;
                backgroundob.transform.SetParent(tmpParent.transform);
            }
            tmpParent.transform.SetParent(tmpob.transform);
        }
        room.roomModel = tmpob;
        tmpob.SetActive(false);

        return(tmpob);
    }