Beispiel #1
0
    public void AddEntity(EntityData entity)
    {
        if (objectIcons[entity.TilePosition.x, entity.TilePosition.y] != null)
        {
            Destroy(objectIcons[entity.TilePosition.x, entity.TilePosition.y].gameObject);
            objectIcons[entity.TilePosition.x, entity.TilePosition.y] = null;
        }

        EditorIcon icon = Instantiate(iconPrefab, objectsLayer);

        icon.transform.position = GetMapTilePosition(entity.TilePosition);
        Debug.Log("Placing a " + entity.EntityType.ToString());
        icon.SetIcon(objectSprites[(int)entity.EntityType]);

        room.entityData[entity.TilePosition.x, entity.TilePosition.y] = entity;
        objectIcons[entity.TilePosition.x, entity.TilePosition.y]     = icon;
    }
Beispiel #2
0
    public void AddNPCEntity(NPCData entity)
    {
        if (objectIcons[entity.TilePosition.x, entity.TilePosition.y] != null)
        {
            Destroy(objectIcons[entity.TilePosition.x, entity.TilePosition.y].gameObject);
            objectIcons[entity.TilePosition.x, entity.TilePosition.y] = null;
        }


        EditorIcon icon = Instantiate(iconPrefab, objectsLayer);

        icon.transform.position = GetMapTilePosition(entity.TilePosition) + new Vector2(0, -16);
        icon.SetIcon(NPCsprite);

        room.entityData[entity.TilePosition.x, entity.TilePosition.y] = entity;

        objectIcons[entity.TilePosition.x, entity.TilePosition.y] = icon;
    }