Пример #1
0
    public void DrawMap()
    {
        foreach (Room room in rooms)
        {
            if (room == null)
            {
                continue;                 //skip where there is no room
            }

            Vector2 drawPos = room.gridPos;
            drawPos.x *= 16 * 16;          //aspect ratio of map sprite
            drawPos.y *= 8 * 16;
            //create map obj and assign its variables
            MapSpriteSelector mapper = GameObject.Instantiate(roomWhiteObj, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
            mapper.transform.localScale *= 16;
            mapper.type  = room.type;
            mapper.up    = room.doorTop;
            mapper.down  = room.doorBot;
            mapper.right = room.doorRight;
            mapper.left  = room.doorLeft;
            mapper.gameObject.transform.parent = mapRoot.GetChild(1);
        }

        mapRoot.GetComponent <MinimapController>().RefreshMiniMapSpriteList();
    }
Пример #2
0
    private void DrawMap(IntPtr bufferMaze)
    {
        for (int i = 0; i < WORLD_SIZE.x * 2; i++)
        {
            for (int j = 0; j < WORLD_SIZE.y * 2; j++)
            {
                var room = PGApi.PGApi.GetValueMazeWorm(bufferMaze, i, j);
                if (room == NO_DOORS)
                {
                    continue; //skip where there is no room
                }

                Vector2 drawPos = new Vector2(i, j) - WORLD_SIZE;
                drawPos.x *= 16;//aspect ratio of map sprite
                drawPos.y *= 8;

                //create map obj and assign its variables
                GameObject cell = Instantiate(roomWhiteObj, drawPos, Quaternion.identity);
                cell.transform.SetParent(m_Level.transform);
                MapSpriteSelector mapper = cell.GetComponent <MapSpriteSelector>();

                mapper.type = drawPos == Vector2Int.zero ? 1 : 0;

                mapper.up    = ((room & DOOR_TOP) == DOOR_TOP);
                mapper.down  = ((room & DOOR_BOTTOM) == DOOR_BOTTOM);
                mapper.left  = ((room & DOOR_LEFT) == DOOR_LEFT);
                mapper.right = ((room & DOOR_RIGHT) == DOOR_RIGHT);
            }
        }
    }
Пример #3
0
    void DrawMap()
    {
        foreach (Room room in rooms)
        {
            if (room == null)
            {
                continue;                 //skip where there is no room
            }
            Vector2 drawPos = room.gridPos;
            drawPos.x *= 16;            //aspect ratio of map sprite
            drawPos.y *= 8;
            drawPos   += new Vector2(-50.0f, 0);
            //create map obj and assign its variables
            GameObject guter = Object.Instantiate(roomWhiteObj, drawPos / 2, Quaternion.identity);
            guter.transform.parent = mapRoot;


            MapSpriteSelector mapper = guter.GetComponent <MapSpriteSelector>();
            mapper.type  = room.type;
            mapper.up    = room.doorTop;
            mapper.down  = room.doorBot;
            mapper.right = room.doorRight;
            mapper.left  = room.doorLeft;
            mapper.gameObject.transform.parent = mapRoot;
        }
    }
Пример #4
0
    void DrawMap()
    {
        foreach (Room room in rooms)
        {
            //skip where there is no room
            if (room == null)
            {
                continue;
            }

            Vector2 drawPos = room.gridPos;
            drawPos.x *= 16;
            drawPos.y *= 8;

            MapSpriteSelector mapper = Instantiate(mapSpritePrefab, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
            mapper.transform.parent = transform;
            mapper.type             = room.type;
            mapper.up    = room.doorTop;
            mapper.down  = room.doorBot;
            mapper.right = room.doorRight;
            mapper.left  = room.doorLeft;

            roomsList.Add(mapper.gameObject);
        }
    }
Пример #5
0
    public void DrawMap()
    {
        roomInstances = new GameObject[rooms.Length][];
        for (int i = 0; i < rooms.Length; i++)
        {
            roomInstances[i] = new GameObject[rooms[i].Length];
            for (int j = 0; j < rooms[i].Length; j++)
            {
                if (rooms[i][j] == null)
                {
                    continue; //skip where there is no room
                }
                Vector2 drawPos = rooms[i][j].GridPos;
                drawPos.x *= 0.8f;//aspect ratio of map sprite
                drawPos.y *= 0.4f;
                drawPos.x += 5.75f + gameObject.transform.position.x;
                drawPos.y += 3.3f + gameObject.transform.position.y;

                //create map obj and assign its variables
                var roomInstance         = Instantiate(RoomPrfab, drawPos, Quaternion.identity);
                MapSpriteSelector mapper = roomInstance.GetComponent <MapSpriteSelector>();
                mapper.transform.parent = gameObject.transform;
                mapper.type             = rooms[i][j].Type;
                mapper.up           = rooms[i][j].DoorTop;
                mapper.down         = rooms[i][j].DoorBot;
                mapper.right        = rooms[i][j].DoorRight;
                mapper.left         = rooms[i][j].DoorLeft;
                roomInstances[i][j] = roomInstance;
            }
        }
    }
Пример #6
0
 void DrawMap()
 {
     foreach (Room room in rooms)
     {
         if (room == null)
         {
             continue;
         }
         Vector2 drawPos = room.gridPos;
         float   offestX = 17 * offest;
         float   offestY = 9 * offest;
         drawPos.x = drawPos.x * 16 + offestX;
         drawPos.y = drawPos.y * 8 + offestY;
         MapSpriteSelector mapper = Object.Instantiate(roomWhiteObj, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
         mapper.type  = room.type;
         mapper.up    = room.doorTop;
         mapper.down  = room.doorBot;
         mapper.right = room.doorRight;
         mapper.left  = room.doorLeft;
         mapper.gameObject.transform.parent = mapRoot;
         if (mapper.type == 1)
         {
             GameObject go = Instantiate(playerMapPosition, drawPos, Quaternion.identity);
             go.transform.parent = mapRoot;
         }
     }
 }
Пример #7
0
    void DrawMap()
    {
        foreach (Room room in rooms)
        {
            if (room == null)
            {
                continue; // Skip where there is no room
            }
            Vector3 drawPos = room.gridPos;
            drawPos.x *= 16; // Aspect ratio of map sprite
            drawPos.y *= 10;
            //drawPos.z = -1;

            // Create map obj and assign its variables
            MapSpriteSelector mapper = Object.Instantiate(roomWhiteObj, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();

            if (room.gridPos == bossPos)
            {
                room.type = 2;
            }

            mapper.type  = room.type;
            mapper.up    = room.doorTop;
            mapper.down  = room.doorBot;
            mapper.right = room.doorRight;
            mapper.left  = room.doorLeft;
            mapper.gameObject.transform.parent = mapRoot;
        }
    }
Пример #8
0
    public void DrawMap()
    {
        foreach (Chamber chamber in chambers)
        {
            if (chamber == null)
            {
                continue;
            }

            Vector2 drawPosition = chamber.gridPosition;
            drawPosition.x *= 16;
            drawPosition.y *= 8;


            MapSpriteSelector mapper = Object.Instantiate(GenerationRoomObject, drawPosition, Quaternion.identity).GetComponent <MapSpriteSelector>();
            Debug.Log("new obj" + chamber);


            //set equal to other script
            mapper.type  = chamber.type;
            mapper.up    = chamber.doorTop;
            mapper.down  = chamber.doorBot;
            mapper.right = chamber.doorRight;
            mapper.left  = chamber.doorLeft;
        }
    }
    void DrawMap()
    {
        foreach (Room room in rooms)
        {
            if (room == null)
            {
                continue; //skip where there is no room
            }

            Vector2 drawPos = room.gridPos;
            drawPos.x *= xMapAspectRatio;//aspect ratio of map sprite
            drawPos.y *= yMapAspectRatio;

            //create map obj and assign its variables
            //MapSpriteSelector mapper = Object.Instantiate(roomWhiteObj, drawPos, Quaternion.identity).GetComponent<MapSpriteSelector>();

            MapSpriteSelector mapper = roomWhiteObj.GetComponent <MapSpriteSelector>();
            mapper.type  = room.type;
            mapper.up    = room.doorTop;
            mapper.down  = room.doorBot;
            mapper.right = room.doorRight;
            mapper.left  = room.doorLeft;
            //mapper.gameObject.transform.parent = mapRoot;

            Sprite mapSprite = mapper.ReturnPickedSprite();
            LocateRoomsAndInstatiateRoomGameObjects(room, drawPos, mapSprite);
        }
    }
Пример #10
0
 public void Setup(Texture2D _tex, Vector2 _gridPos, int _type, bool _doorTop, bool _doorBot, bool _doorLeft, bool _doorRight, bool _floorHasBoss, MapSpriteSelector _minimapSprite)
 {
     tex               = _tex;
     gridPos           = _gridPos;
     type              = _type;
     doorTop           = _doorTop;
     doorBot           = _doorBot;
     doorLeft          = _doorLeft;
     doorRight         = _doorRight;
     floorHasBoss      = _floorHasBoss;
     minimapSprite     = _minimapSprite;
     minimapCam        = FindObjectOfType <MiniMapCamera>();
     enemiesInThisRoom = 0;
     MakeDoors();
     GenerateRoomTiles();
 }
    private void DrawMap()
    {
        foreach (Room room in rooms)
        {
            if (room == null)
            {
                continue;
            }

            Vector2 drawPos = room.gridPos;
            drawPos.x *= 12;
            drawPos.y *= 12;
            MapSpriteSelector mapper = Object.Instantiate(minimapGo, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
            mapper.type   = room.type;
            mapper.typeId = room.typeId;
            mapper.gameObject.transform.parent = mapRoot;
        }
    }
Пример #12
0
 void DrawMap()
 {
     foreach (Room room in rooms)
     {
         if (room == null)
         {
             continue;
         }
         Vector2 drawPos = room.gridPos;
         drawPos.x *= 16;
         drawPos.y *= 8;
         MapSpriteSelector mapper = Object.Instantiate(roomWhiteObj, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
         mapper.type  = room.type;
         mapper.up    = room.doorTop;
         mapper.down  = room.doorBot;
         mapper.right = room.doorRight;
         mapper.left  = room.doorLeft;
     }
 }
Пример #13
0
 void DrawMap()
 {
     foreach (Room room in rooms)
     {
         if (room == null)
         {
             continue;                 //skip where there is no room
         }
         Vector2 drawPos = room.gridPos;
         drawPos.x *= 16;            //aspect ratio of map sprite
         drawPos.y *= 8;
         //맵 객체를 만들고 해당 변수를 할당합니다.
         MapSpriteSelector mapper = Object.Instantiate(roomWhiteObj, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
         mapper.type  = room.type;
         mapper.up    = room.doorTop;
         mapper.down  = room.doorBot;
         mapper.right = room.doorRight;
         mapper.left  = room.doorLeft;
         mapper.gameObject.transform.parent = mapRoot;
     }
 }
Пример #14
0
    public void Setup(Vector2 _gridPos, Vector2 _roomPos, RoomType _type, bool _doorTop, bool _doorRight, bool _doorBot, bool _doorLeft, int _numberOfNeighbours, Sprite _roomIconForMap)
    {
        gridPos             = _gridPos;
        roomPos             = _roomPos;
        type                = _type;
        doorTop             = _doorTop;
        doorBot             = _doorBot;
        doorLeft            = _doorLeft;
        doorRight           = _doorRight;
        numberOfNeighbours  = _numberOfNeighbours;
        roomIconForMap      = _roomIconForMap;
        defaultRoomColor    = MapSpriteSelector.PickColor(type);
        activeRoomColor     = MapSpriteSelector.PickColor(RoomType.Active);
        mortalEnemiesInRoom = GetComponentsInChildren <Enemy>();

        CMCamera = GetComponentInChildren <CinemachineVirtualCamera>();
        if (type == RoomType.BaseRoom)
        {
            CMCamera.Priority = 15;
            isActive          = true;
        }
        MakeDoors();
    }
Пример #15
0
    public void InstantiateMapSprite(Transform parent)
    {
        objectWithMapSprite      = new GameObject();
        objectWithMapSprite.name = "Map Piece";

        SpriteRenderer renderer = objectWithMapSprite.AddComponent <SpriteRenderer>();

        renderer.sprite = roomIconForMap;
        renderer.color  = MapSpriteSelector.PickColor(type);

        Vector2 drawPos = gridPos;

        drawPos.x *= 16;//aspect ratio of map sprite HAS TO BE THE SAME LIKE IN LEVEL GENERATION IN DRAWMAP
        drawPos.y *= 8;

        drawPos += new Vector2(-500, 500);

        objectWithMapSprite.transform.position = drawPos;
        if (parent != null)
        {
            objectWithMapSprite.transform.parent = parent;
        }
        // Instantiate(objectWithMapSprite, drawPos, Quaternion.identity);
    }
Пример #16
0
    void DrawMap()
    {
        //Loop through each room inside of the rooms array
        foreach (Room room in rooms)
        {
            if (room == null)
            {
                continue; //skip where there is no room
            }
            //Grab each rooms position and multiply it by the size of the sprite
            Vector2 drawPos = room.gridPos;
            drawPos.x *= 16;//aspect ratio of map sprite
            drawPos.y *= 8;

            //We instantiate the object and assign the right data to the respective variables
            MapSpriteSelector mapper = Object.Instantiate(mapSpriteSelector, drawPos, Quaternion.identity).GetComponent <MapSpriteSelector>();
            mapper.type  = room.type;
            mapper.up    = room.doorTop;
            mapper.down  = room.doorBot;
            mapper.right = room.doorRight;
            mapper.left  = room.doorLeft;
            mapper.gameObject.transform.parent = mapRoot; //Making all the object a child of the MapRoot object, so that the hierarchy is cleaner
        }
    }