void create_random_ghost(RoomMeta roomMeta, int numberOfGhost = 1)
 {
     for (int i = 0; i < numberOfGhost; i++)
     {
         random_create(roomMeta, ObjectBaseType.MONSTER, (int)MonsterType.GHOST);
     }
 }
    void create_random_block(RoomMeta roomMeta)
    {
        switch (gameManager.stagelv)
        {
        case 1:
            random_create(roomMeta, ObjectBaseType.BLOCK, (int)BlockType.BOX);
            break;

        case 2:
            int setnum = Random.Range(0, 3);
            if (setnum == 0)
            {
                random_create(roomMeta, ObjectBaseType.BLOCK, (int)BlockType.BOX);
            }
            else if (setnum == 1)
            {
                random_create(roomMeta, ObjectBaseType.TRAP, (int)TrapType.NORMAL_TYPE2);
            }
            else
            {
                random_create(roomMeta, ObjectBaseType.TRAP, (int)TrapType.NORMAL_TYPE3);
            }
            break;
        }
    }
    public void room_process()
    {
        if (!room_transition)
        {
            return;
        }
        continue_turn = false;
        RoomMeta next_room = get_next_room();

        // 자연스러운 변화 필요.
        if (next_room == null || next_room.room_locked)
        {
            process_continue();
            return;
        }

        playerbase.unactive();
        gameManager.sub_managers.boardManager.room_transition(next_room);
        playerbase.node_change(node_after_room_transition(next_room));
        playerbase.active();
        //animManager.anim_add(playerbase, AnimType.LANDING, 0, 0);
        room_landing(next_room);
        //camera
        gameManager.sub_managers.cameraManager.run_camera_anim(CameraAnimType.ROOMTRANSITION_HARD);

        //process_continue(); // 노턴소모
        process_done();         // 턴소모
        return;
    }
 public void room_landing(RoomMeta roommeta)
 {
     foreach (var nodelist in roommeta.node_list)
     {
         foreach (var node in nodelist)
         {
             foreach (var objectbase in node.object_here_list)
             {
                 if (objectbase is ItemBase)
                 {
                     continue;
                 }
                 if (objectbase is MonsterBase)
                 {
                     continue;
                 }
                 if (objectbase is BlockBase)
                 {
                     continue;
                 }
                 if (objectbase is TrapBase)
                 {
                     continue;
                 }
                 animManager.anim_add(objectbase, AnimType.LANDING, 0, 0);
             }
         }
     }
 }
    private RoomMeta get_next_room()
    {
        RoomMeta next_room = gameManager.roomMeta_now;

        //next_room = next_room.UDLR_room[(int)key];
        switch (key)
        {
        case Key.Up:
            next_room = next_room.UDLR_room[0];
            break;

        case Key.Down:
            next_room = next_room.UDLR_room[1];
            break;

        case Key.Left:
            next_room = next_room.UDLR_room[2];
            break;

        case Key.Right:
            next_room = next_room.UDLR_room[3];
            break;

        default:
            next_room = null;
            break;
        }
        return(next_room);
    }
 void create_random_zombie_toungue(RoomMeta roomMeta, int numberOfZombie = 1)
 {
     for (int i = 0; i < numberOfZombie; i++)
     {
         random_create(roomMeta, ObjectBaseType.MONSTER, (int)MonsterType.ZOMBIE_TONGUE);
     }
 }
Exemple #7
0
    public void setTiles(RoomMeta roomMeta, StageType stageType)
    {
        if (!roomMeta.instantDone)
        {
            roomMeta.room_thema_list.Clear();
            List <Sprite> tile_sprites = GameManager.Instance.pools.ImagePool.get_tile_imageList(stageType);
            List <int>    numlist      = new List <int>();
            for (int i = 0; i < tile_sprites.Count; i++)
            {
                numlist.Add(i);
            }


            SpriteRenderer[] spriteRenderers = tile_list.GetComponentsInChildren <SpriteRenderer>();

            for (int i = 0; i < spriteRenderers.Length; i++)
            {
                int subnum = Random.Range(0, numlist.Count);
                int num    = numlist[subnum];
                numlist.RemoveAt(subnum);

                spriteRenderers[i].sprite = tile_sprites[num];
                roomMeta.room_thema_list.Add(tile_sprites[num]);
            }
        }
        else
        {
            SpriteRenderer[] spriteRenderers = tile_list.GetComponentsInChildren <SpriteRenderer>();

            for (int i = 0; i < spriteRenderers.Length; i++)
            {
                spriteRenderers[i].sprite = roomMeta.room_thema_list[i];
            }
        }
    }
Exemple #8
0
        public override void End()
        {
            if (!Apply)
            {
                return;
            }

            Meta.Bounds.X      *= 8;
            Meta.Bounds.Y      *= 8;
            Meta.Bounds.Width  *= 8;
            Meta.Bounds.Height *= 8;

            if (Room != null)
            {
                if (Room.Meta.Equals(Meta))
                {
                    Room = null;
                    Meta = default;
                    return;
                }
                MapEditor.Instance.State.Apply(new RoomModificationAction(Room, Meta));
            }
            else
            {
                Room      = new Room();
                Room.Meta = Meta;
                MapEditor.Instance.State.Apply(new RoomAdditionAction(Room));
            }
            Room = null;
            Meta = default;
        }
        /// <summary>
        /// Registers the given room as a possibility if it isn't already registered.
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="part"></param>
        private RoomMeta RegisterKey(MatrixI transform, PartFromPrefab part)
        {
            var      key = new RoomKey(transform, part);
            RoomMeta room;

            if (!m_openRooms.TryGetValue(key, out room))
            {
                var ent = new ProceduralRoom();
                ent.Init(transform, part);
                m_openRooms[key] = room = new RoomMeta(ent);
            }
            else if (room.Nonce == m_nonce)
            {
                return(room);
            }
            room.Nonce    = m_nonce;
            room.InFactor = 0;
            foreach (var mount in room.Room.MountPoints)
            {
                var other = mount.AttachedToIn(m_construction);
                if (other == null)
                {
                    continue;
                }
                room.InFactor++;
                m_possibleRooms.Add(other, room);
            }
            return(room);
        }
    void set_RoomMeta(RoomMeta roomMeta)
    {
        if (roomMeta.room_locked)
        {
            roomMeta.room_locked = false;
        }

        if (!roomMeta.instantDone)
        {
            if (roomMeta.roomType == RoomType.NORMAL)
            {
                if (Random.Range(0, 3) > 0)
                {
                    create_random_room(roomMeta);
                }
                else
                {
                    create_saved_room(roomMeta);
                }
            }
            else
            {
                create_saved_room(roomMeta);
            }
            create_random_monster(roomMeta);
            create_random_item(roomMeta);
            door_connection(roomMeta);
        }
        else // instance done 룸
        {
            foreach (var stain in roomMeta.room_stain_list)
            {
                if (stain.GetComponent <ObjectBody>())
                {
                    if (!stain.GetComponent <ObjectBody>().DeathTrigger)
                    {
                        stain.SetActive(true);
                    }
                    continue;
                }
                stain.SetActive(true);
            }
        }
        if (roomMeta.roomType == RoomType.INITIAL && gameManager.stagelv == 1)
        {
            key_nav.SetActive(true);
        }
        else
        {
            key_nav.SetActive(false);
        }
        // random setting function 구현 필요.
        // RoomMetatype을 읽어서 objectbase_list를 새로 랜덤으로 셋팅. objectbasepool의 call objectbase사용


        //roomMeta.instantDone = true;
    }
Exemple #11
0
    public Node(int i, int j, RoomMeta roomMeta)
    {
        xy[0] = i;
        xy[1] = j;

        position = get_position(i, j);

        roommeta = roomMeta;
    }
Exemple #12
0
    public RoomMeta(int x, int y, int z)
    {
        // 생성시 정의하면 변경 없음.
        location     = new Vector3Int(x, y, z);
        thisRoomMeta = this;


        UDLR_door = new Node[4] { //// DOOR NODE 생성
            new Node(-1, 2, this), new Node(5, 2, this), new Node(2, -1, this), new Node(2, 5, this)
        };                        //

        node_list = new List <List <Node> >();

        //////////////////////////////

        for (int i = 0; i < Constant.MAX_INDEX; i++)
        {
            node_list.Add(new List <Node>());
            for (int j = 0; j < Constant.MAX_INDEX; j++)
            {
                node_list[i].Add(new Node(i, j, thisRoomMeta));
            }
        }

        for (int i = 0; i < Constant.MAX_INDEX; i++)
        {
            for (int j = 0; j < Constant.MAX_INDEX; j++)
            {
                // i v j > // Node Linked
                if (i != 0)
                {
                    node_list[i][j].UDLR_node[0] = node_list[i - 1][j];
                }

                if (i != Constant.MAX_INDEX - 1)
                {
                    node_list[i][j].UDLR_node[1] = node_list[i + 1][j];
                }

                if (j != 0)
                {
                    node_list[i][j].UDLR_node[2] = node_list[i][j - 1];
                }

                if (j != Constant.MAX_INDEX - 1)
                {
                    node_list[i][j].UDLR_node[3] = node_list[i][j + 1];
                }


                //노드 연결할것
            }
        }
    }
Exemple #13
0
 bool check_containsornot(List <RoomMeta> linkedroomlist, RoomMeta roomMeta_to_check)
 {
     for (int i = 0; i < linkedroomlist.Count; i++)
     {
         if (linkedroomlist[i].GetHashCode() == roomMeta_to_check.GetHashCode())
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #14
0
        public async Task <IActionResult> CreateRoomMeta(RoomMeta meta)
        {
            if (ModelState.IsValid)
            {
                db.RoomsMeta.Add(meta);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(meta));
        }
    void create_saved_room(RoomMeta roomMeta)
    {
        List <NodeSetter> nodeSetters = gameManager.pools.roomPools.get_roomsetters(gameManager.stagelv, roomMeta.roomType);

        for (int i = 0; i < nodeSetters.Count; i++)
        {
            if (nodeSetters[i].objectBaseType != ObjectBaseType.NONE)
            {
                create_object(nodeSetters[i].objectBaseType, nodeSetters[i].subtype, roomMeta.node_list[nodeSetters[i].nodeindex / 5][(int)(nodeSetters[i].nodeindex % 5)]);
            }
        }
    }
    void create_random_monster_normalroom(RoomMeta roomMeta)
    {
        switch (GameManager.Instance.stagelv)
        {
        case 1:
            create_random_zombie(roomMeta);
            break;

        case 2:
            create_random_zombie(roomMeta);
            break;
        }
    }
    Node find_neighbor_node(RoomMeta roommeta, Node node)
    {
        if (node.object_here_list.Count == 0)
        {
            return(node);
        }

        bool check = true;

        foreach (var objectbase in node.object_here_list)
        {
            if (objectbase.is_collide)
            {
                check = false;
            }
        }
        if (check)
        {
            return(node);
        }

        for (int distance = 1; distance < 10; distance++)
        {
            for (int i = 0; i < Constant.MAX_INDEX; i++)
            {
                for (int j = 0; j < Constant.MAX_INDEX; j++)
                {
                    if (Mathf.Abs(node.xy[0] - i) + Mathf.Abs(node.xy[1] - j) != distance)
                    {
                        continue;
                    }
                    if (roommeta.node_list[i][j] == null)
                    {
                        continue;
                    }
                    if (roommeta.node_list[i][j].is_extra_node)
                    {
                        continue;
                    }

                    if (roommeta.node_list[i][j].object_here_list.Count == 0)
                    {
                        return(roommeta.node_list[i][j]);
                    }
                }
            }
        }

        return(null);
    }
    public void resetRoomMeta(RoomMeta roomMeta)
    {
        //오브젝트베이스중에서 플레이어 타입은 특별취급해야함
        //노드 깔끔하게 다 정리하는 resetRoom


        foreach (var list in roomMeta.node_list)
        {
            foreach (var node in list)
            {
                foreach (var object_base in node.object_here_list)
                {
                    if (object_base is PlayerBase)
                    {
                        continue;                         // 캐릭터는 따로 처리.
                    }
                    if (object_base.is_alive == false)
                    {
                        //node.object_here_list.Remove(object_base);
                    }
                    object_base.unactive();
                }
                // Debug.Log(node.xy[0].ToString() + ",,," + node.xy[1].ToString());
            }
        }

        foreach (var node in roomMeta.UDLR_door)
        {
            foreach (var object_base in node.object_here_list)
            {
                object_base.unactive();
            }
        }
        for (int i = 0; i < roomMeta.room_stain_list.Count; i++)
        {
            if (roomMeta.room_stain_list[i].GetComponent <ObjectBody>() &&
                roomMeta.room_stain_list[i].GetComponent <ObjectBody>().needDeathEffect &&
                roomMeta.room_stain_list[i].GetComponent <ObjectBody>().DeathTrigger &&
                !roomMeta.room_stain_list[i].GetComponent <ObjectBody>().DeathEffectSpawnDone)
            {
                GameObject death = Instantiate(GameManager.Instance.pools.objectBodyPool.bodyPools.MonsterBodyPool.DeathEffect, roomMeta.room_stain_list[i].transform.position, transform.rotation) as GameObject;
                GameManager.Instance.garbageBox.garbageList.Add(death);
                roomMeta.room_stain_list.Add(death);
                roomMeta.room_stain_list[i].GetComponent <ObjectBody>().DeathEffectSpawnDone = true;
            }
            roomMeta.room_stain_list[i].SetActive(false);
        }
    }
Exemple #19
0
    RoomMeta set_init_room(List <RoomMeta> normal_list)
    {
        int index = Random.Range(0, normal_list.Count);

        if (normal_list[index].roomType == RoomType.NORMAL)
        {
            normal_list[index].roomType = RoomType.INITIAL;
        }

        RoomMeta initroom = normal_list[index];

        normal_list.RemoveAt(index);

        return(initroom);
        ////여기해
    }
 void create_random_monster_workshop(RoomMeta roomMeta)
 {
     switch (GameManager.Instance.stagelv)
     {
     case 2:
         int setnum = Random.Range(0, 5);
         if (setnum == 0)
         {
             create_random_ghost(roomMeta);
         }
         else if (setnum == 1)
         {
             create_random_zombie(roomMeta);
         }
         break;
     }
 }
Exemple #21
0
    void set_stage(int stagelv)
    {
        //link RoomMetanode, set RoomMetatype, etc...
        //룸 클래스에 룸의 메타정보를 넣어줌.
        //스테이지 시작할때 이 함수 콜함.
        init_stage();
        roomMeta_now = sub_managers.mapManager.setmap(stagelv); //set_roomMeta_list(RoomMeta_list, prev_roomMeta: roomMeta_now == null? null : roomMeta_now); //방연결. 방마다 room type 지정.

        GameManager.instance.anim_playing = true;
        GameManager.Instance.player_turn  = true;
        GameManager.Instance.enemy_turn   = false;
        GameManager.Instance.object_turn  = false;
        set_stagetype(stagelv);
        room.GetComponent <Room>().setMapBase(stageType);
        sub_managers.boardManager.setRoom(roomMeta_now);
        //sub_managers.boardManager.room_transition(roomMeta_now);
    }
    void create_random_monster(RoomMeta roomMeta)
    {
        switch (roomMeta.roomType)
        {
        case RoomType.NORMAL:
            create_random_monster_normalroom(roomMeta);
            break;

        case RoomType.WELL:
            create_random_monster_wellroom(roomMeta);
            break;

        case RoomType.WORKSHOP:
            create_random_monster_workshop(roomMeta);
            break;
        }
    }
Exemple #23
0
    void set_normal_room(List <RoomMeta> available_list, List <RoomMeta> normal_list)
    {
        List <RoomMeta> normal_list_now = new List <RoomMeta>();

        while (normal_list_now.Count < 12)
        {
            RoomMeta roomMeta = available_list[Random.Range(0, available_list.Count)];
            if (roomMeta.roomType == RoomType.None)
            {
                roomMeta.roomType = RoomType.NORMAL;
                normal_list_now.Add(roomMeta);
                normal_list.Add(roomMeta);
            }
        }
        //RoomMeta _roomMeta = available_list[Random.Range(0, available_list.Count)];
        //_roomMeta.roomType = RoomType.None;
    }
    Node RandomNode(RoomMeta roomMeta, bool Itemduplicate = true)
    {
        int random_x, random_y;

        for (int i = 0; i < 10; i++)
        {
            random_x = Random.Range(0, Constant.MAX_INDEX);
            random_y = Random.Range(0, Constant.MAX_INDEX);
            if (roomMeta.node_list[random_x][random_y].object_here_list.Count == 0)
            {
                return(roomMeta.node_list[random_x][random_y]);
            }
            else
            {
                bool isOk = true;
                for (int j = 0; j < roomMeta.node_list[random_x][random_y].object_here_list.Count; j++)
                {
                    if (Itemduplicate)
                    {
                        if (roomMeta.node_list[random_x][random_y].object_here_list[j].objectBase_type == ObjectBaseType.BLOCK ||
                            roomMeta.node_list[random_x][random_y].object_here_list[j].objectBase_type == ObjectBaseType.MONSTER)
                        {
                            isOk = false;
                            break;
                        }
                    }
                    else
                    {
                        if (roomMeta.node_list[random_x][random_y].object_here_list[j].objectBase_type == ObjectBaseType.BLOCK ||
                            roomMeta.node_list[random_x][random_y].object_here_list[j].objectBase_type == ObjectBaseType.MONSTER ||
                            roomMeta.node_list[random_x][random_y].object_here_list[j].objectBase_type == ObjectBaseType.ITEM)
                        {
                            isOk = false;
                            break;
                        }
                    }
                }
                if (isOk)
                {
                    return(roomMeta.node_list[random_x][random_y]);
                }
            }
        }
        return(null);
    }
Exemple #25
0
    void adjacent_add(RoomMeta roomMeta, List <RoomMeta> adjacent, List <RoomMeta> unvisited)
    {
        if (!unvisited.Contains(roomMeta))
        {
            return;                     // 방문했었다면 return
        }
        unvisited.Remove(roomMeta);     // 방문.
        adjacent.Add(roomMeta);         // 연결.

        for (int UDLR = 0; UDLR < 4; UDLR++)
        {
            if (roomMeta.UDLR_room[UDLR] == null || roomMeta.UDLR_room[UDLR].location.x != roomMeta.location.x)
            {
                continue;                                                                                                          // 없거나 같은층아니면
            }
            adjacent_add(roomMeta.UDLR_room[UDLR], adjacent, unvisited);
        }
    }
Exemple #26
0
        public WindowRoomConfig(Room room = null)
        {
            if (room != null)
            {
                Room = room;
                Meta = room.Meta;
            }
            else
            {
                Meta = new RoomMeta($"lvl_{MapEditor.Instance.State.LoadedLevel.Rooms.Count + 1}");
            }

            // Apply meta fixes
            Meta.Bounds.X      /= 8;
            Meta.Bounds.Y      /= 8;
            Meta.Bounds.Width  /= 8;
            Meta.Bounds.Height /= 8;
        }
    // Object Base.. RoomTransition때 생성.
    // Prefab이랑 연결.



    public void setRoom(RoomMeta roomMeta)
    {
        set_RoomMeta(roomMeta);

        gameManager.room.GetComponent <Room>().setTiles(roomMeta, gameManager.stageType);

        foreach (var list in roomMeta.node_list)
        {
            foreach (var node in list)
            {
                //foreach (var object_base in node.object_here_list) // for문 안에서 지워질 수 있음.
                for (int i = 0; i < node.object_here_list.Count; i++)
                {
                    if (!node.object_here_list[i].is_alive || node.object_here_list[i].node_now != node)
                    {
                        node.object_here_list.Remove(node.object_here_list[i]);
                        i--;
                    }
                    else
                    {
                        node.object_here_list[i].active();
                    }
                }
            }
        }
        foreach (var node in roomMeta.UDLR_door)                  //문 배치
        {
            for (int i = 0; i < node.object_here_list.Count; i++) // len 2 count 2 i 0
            {
                if (node.object_here_list[0].node_now != node)
                {
                    node.object_here_list.Remove(node.object_here_list[i]);
                    i--;
                }
                else
                {
                    node.object_here_list[i].active();
                }
            }
        }


        roomMeta.instantDone = true;
    }
 void create_random_zombie(RoomMeta roomMeta)
 {
     if (Random.Range(0, 2) == 0)
     {
         for (int i = 0; i < 2; i++)
         {
             if (Random.Range(0, 2) == 0)
             {
                 if (GameManager.Instance.stagelv > 1)
                 {
                 }
                 else
                 {
                     random_create(roomMeta, ObjectBaseType.MONSTER, (int)MonsterType.ZOMBIE);
                 }
             }
         }
     }
 }
Exemple #29
0
 void find_linkedroom(List <RoomMeta> linkedroomlist, RoomMeta roomMetanow, List <RoomMeta> sourcelist)
 {
     linkedroomlist.Add(roomMetanow);
     for (int i = 0; i < sourcelist.Count; i++)
     {
         if (sourcelist[i].GetHashCode() == roomMetanow.GetHashCode())
         {
             sourcelist.RemoveAt(i);
             break;
         }
     }
     for (int i = 0; i < roomMetanow.UDLR_room.Length; i++)
     {
         if (roomMetanow.UDLR_room[i] != null && !check_containsornot(linkedroomlist, roomMetanow.UDLR_room[i]))
         {
             find_linkedroom(linkedroomlist, roomMetanow.UDLR_room[i], sourcelist);
         }
     }
 }//링크된방을 다찾으니까 계단을 잇기 전에 사용하는게 권장됨.
Exemple #30
0
    List <RoomMeta> check_available_rooms(int floor, List <List <List <RoomMeta> > > roommetas)
    {
        List <RoomMeta> available_list = new List <RoomMeta>();

        if (floor == 0)
        {
            while (available_list.Count < 13)
            {
                RoomMeta _roomMeta = roommetas[0][Random.Range(0, 5)][Random.Range(0, 5)];
                bool     canadd    = true;
                for (int i = 0; i < available_list.Count; i++)
                {
                    if (available_list[i].location == _roomMeta.location)
                    {
                        canadd = false;
                        break;
                    }
                }
                if (canadd)
                {
                    available_list.Add(_roomMeta);
                }
            }
            //for (int i = 0; i < available_list.Count; i++) Debug.Log(available_list[i].location);
            return(available_list);
        }
        else
        {
            for (int i = 0; i < Constant.MAX_INDEX; i++)
            {
                for (int j = 0; j < Constant.MAX_INDEX; j++)
                {
                    if (roommetas[floor - 1][i][j].roomType == RoomType.None)
                    {
                        available_list.Add(roommetas[floor][i][j]);
                    }
                }
            }
        }
        //for (int i = 0; i < available_list.Count; i++) Debug.Log(available_list[i].location);
        return(available_list);
    }