Ejemplo n.º 1
0
    public KeyValuePair <T, Color> GetClosest(Color32 c, ColorMatchMethod m)
    {
        Beri.Drawing.Color beriCol = c.ToBeriColor();
        int index = beriCol.GetColorMatch(ColorOnlyPallete, m);

        return(Pallette.ElementAt(index));
    }
Ejemplo n.º 2
0
    public static Texture2D ItemToTexture2D(Item t, out Color c)
    {
        if (t.IsNone)
        {
            c = Color.white;
            return(null);
        }

        Texture2D toAssignImage = ResourceLoader.GetLeafImage();

        Beri.Drawing.Color itemColor = ItemColor.GetItemColor(t);
        c = new Color(itemColor.R / 255f, itemColor.G / 255f, itemColor.B / 255f, itemColor.A / 255f);

        string path = GetImagePathFromItem(t);

        if (path != "")
        {
            if (File.Exists(path))
            {
                byte[] bytes = File.ReadAllBytes(path);
                toAssignImage = new Texture2D(2, 2);
                toAssignImage.LoadImage(bytes);
                c = Color.white;
            }
        }

        return(toAssignImage);
    }
Ejemplo n.º 3
0
    public static Texture2D ItemToTexture2D(Item tr, out Color c)
    {
        if (tr.IsNone)
        {
            c = Color.white;
            return(null);
        }

        Item t = new Item();

        t.CopyFrom(tr);
        if (t.ItemId >= 60_000)
        {
            if (FieldItemList.Items.TryGetValue(t.ItemId, out var def))
            {
                if (def.Dig != Item.NONE)
                {
                    t.ItemId = def.Dig;
                }
                else if (def.Pick != Item.NONE)
                {
                    t.ItemId = def.Pick;
                }
            }
        }

        Texture2D toAssignImage = ResourceLoader.GetLeafImage();

        Beri.Drawing.Color itemColor = FieldItemColor.GetItemColor(t);
        c = new Color(itemColor.R / 255f, itemColor.G / 255f, itemColor.B / 255f, itemColor.A / 255f);

        if (SpritesExist())
        {
            InitParser();
            ItemKind itemKind = ItemInfo.GetItemKind(Convert.ToUInt16(t.ItemId));
            var      tx       = SpriteParser.CurrentInstance.GetTexture(t.ItemId, itemKind == ItemKind.Kind_Fence ? t.UseCount : t.Count);
            if (tx != null)
            {
                toAssignImage = tx;
                c             = Color.white;
            }
        }

        return(toAssignImage);
    }
Ejemplo n.º 4
0
    public MapGraphicGenerator(FieldItemManager items, NHSE.Core.TerrainLayer terrain, ushort plazaX, ushort plazaY, Building[] buildings)
    {
        PixelsItemMap        = new int[items.Layer1.MaxWidth * items.Layer2.MaxHeight];
        PixelsBackgroundMap1 = new int[PixelsItemMap.Length / 4];
        PixelsBackgroundMapX = new int[PixelsItemMap.Length];
        ItemManager          = items;
        Terrain = terrain;

        Beri.Drawing.Color[] pixels = new Beri.Drawing.Color[PixelsBackgroundMap1.Length];
        MapBackgroundImage = new Texture2D(Terrain.MaxWidth, Terrain.MaxHeight);

        // draw rivers + height
        int i = 0;

        for (int y = 0; y < Terrain.MaxHeight; y++)
        {
            for (int x = 0; x < Terrain.MaxWidth; x++, i++)
            {
                var pxl = Terrain.GetTileColorRGB(x, y);
                MapBackgroundImage.SetPixel(x, y, new Color32(pxl.R, pxl.G, pxl.B, pxl.A));
                pixels[i] = pxl;
            }
        }

        // draw buildings
        PlaceBuildings(Terrain, MapBackgroundImage, buildings);

        // draw plaza
        Terrain.GetBuildingCoordinate(plazaX, plazaY, 1, out var xp, out var yp);
        FillRect(MapBackgroundImage, xp, yp, PlazaWidth, PlazaHeight, PlazaCol);

        background = new Texture2D(MapBackgroundImage.width, MapBackgroundImage.height);
        Graphics.CopyTexture(MapBackgroundImage, background);
        //background = FlipTexture(background); // no need to flip for backgroud pixels of acre

        UpdateImageForLayer(0);
    }
Ejemplo n.º 5
0
 public bool CompareUnityColorToSystemColor(Color32 c, Beri.Drawing.Color cs)
 {
     return(c.a == cs.A && c.r == cs.R && c.g == cs.G && c.b == cs.B);
 }