コード例 #1
0
    private void SpawnSafeZoneCampfire()
    {
        GeneratorGrid        grid         = GetComponent <GeneratorGrid>();
        List <GeneratorRoom> safeRoomList = grid.SafeRoomList;

        foreach (GeneratorRoom room in safeRoomList)
        {
            GeneratorChunk chunk = room.chunks[Random.Range(0, room.chunks.Count)];

            float x = Random.Range(chunk.Location.x * (int)grid.chunkSize, (chunk.Location.x + 1) * (int)grid.chunkSize);
            float y = Random.Range(chunk.Location.y * (int)grid.chunkSize, (chunk.Location.y + 1) * (int)grid.chunkSize);

            SafeZone newCampfireSafeZone = Instantiate(safeZoneCampfire, new Vector3(x, 0, y), Quaternion.identity) as SafeZone;
            newCampfireSafeZone.transform.SetParent(transform.parent);
        }
    }
コード例 #2
0
    public void SpawnBoss()
    {
        GeneratorGrid         grid           = GetComponent <GeneratorGrid>();
        RoomList              unSafeRoomList = grid.UnSafeRoomList;
        List <GeneratorChunk> room           = unSafeRoomList[Random.Range(0, unSafeRoomList.Count)].chunks;

        GeneratorChunk chunk = room[Random.Range(0, room.Count)];

        float x = Random.Range(chunk.Location.x * (int)grid.chunkSize, (chunk.Location.x + 1) * (int)grid.chunkSize);
        float y = Random.Range(chunk.Location.y * (int)grid.chunkSize, (chunk.Location.y + 1) * (int)grid.chunkSize);

        Enemy theBoss = Instantiate(boss, new Vector3(x, 0, y), Quaternion.identity) as Enemy;

        theBoss.transform.SetParent(transform.parent);

        if (bossCreated != null)
        {
            bossCreated();
        }
    }
コード例 #3
0
    private void SpawnPortal()
    {
        GeneratorGrid         grid           = GetComponent <GeneratorGrid>();
        RoomList              unSafeRoomList = grid.UnSafeRoomList;
        List <GeneratorChunk> room           = unSafeRoomList[Random.Range(0, unSafeRoomList.Count)].chunks;

        GeneratorChunk chunk = room[Random.Range(0, room.Count)];

        float x = Random.Range(chunk.Location.x * (int)grid.chunkSize, (chunk.Location.x + 1) * (int)grid.chunkSize);
        float y = Random.Range(chunk.Location.y * (int)grid.chunkSize, (chunk.Location.y + 1) * (int)grid.chunkSize);

        PortalToOtherLevel newPortal = Instantiate(portal, new Vector3(x, 0, y), Quaternion.identity) as PortalToOtherLevel;

        newPortal.transform.SetParent(transform.parent);

        if (portalCreated != null)
        {
            portalCreated();
        }
    }
コード例 #4
0
    public IEnumerator CreateChest()
    {
        grid     = GetComponent <GeneratorGrid>();
        roomList = grid.RoomList;
        for (int i = 0; i < numberChest; i++)
        {
            int num = Random.Range(0, roomList.Count);
            List <GeneratorChunk> chunk = roomList[num].chunks;
            int   choose    = Random.Range(0, chunk.Count);
            float chunkPosX = chunk[choose].Location.x + 0.5f;
            float chunkPosY = chunk[choose].Location.y + 0.5f;
            int   xPosition = Random.Range((int)chunkPosX * (int)grid.chunkSize, ((int)(chunkPosX + 0.5f)) * (int)grid.chunkSize);
            int   yPosition = Random.Range((int)chunkPosY * (int)grid.chunkSize, ((int)(chunkPosY + 0.5f)) * (int)grid.chunkSize);

            TresureChest newChest = Instantiate(chest, new Vector3(xPosition, 0f, yPosition), Quaternion.identity) as TresureChest;
            newChest.transform.SetParent(transform);
            chests.Add(newChest);

            yield return(0);
        }
    }
コード例 #5
0
ファイル: RoomGenerator.cs プロジェクト: Halloweens/RogueRpg
    private List <Vector2i> GetPossibleRoomPos(Vector2i roomScale)
    {
        if (!grid)
        {
            grid = GetComponent <GeneratorGrid>();
        }

        List <Vector2i> roomPossiblePosition = new List <Vector2i>();

        for (int j = 0; j < grid.areaSize.y; ++j)
        {
            for (int i = 0; i < grid.areaSize.x; ++i)
            {
                if (CanPlaceRoomAt(new Vector2i(i, j), roomScale))
                {
                    roomPossiblePosition.Add(new Vector2i(i, j));
                }
            }
        }

        return(roomPossiblePosition);
    }
コード例 #6
0
 void Awake()
 {
     grid = GetComponent <GeneratorGrid>();
 }
コード例 #7
0
ファイル: GeneratorChunk.cs プロジェクト: Halloweens/RogueRpg
 public void Initialize(GeneratorGrid grid, Vector2i location)
 {
     this.grid     = grid;
     this.location = location;
 }
コード例 #8
0
 void Awake()
 {
     grid           = GetComponent <GeneratorGrid>();
     unSafeRoomList = grid.UnSafeRoomList;
 }