Exemplo n.º 1
0
        private bool IsExistsPalette(PaletteEntity palette)
        {
            var  parameters      = new List <SqlParameter>();
            bool IsExistsPalette = false;
            int  paletteCount    = 0;
            var  sql             = @"
select
    count([palette_id]) as palette_id
from     [KGWS].[dbo].[palettes]
where
    [palette_id]=@palette_id
";

            parameters.Clear();
            parameters.Add(new SqlParameter("@palette_id", palette.PaletteId));

            SQLServerHelper.Query(
                sql,
                parameters.ToArray(),
                reader =>
            {
                paletteCount = Convert.ToInt32(reader["palette_id"]);
            });
            if (paletteCount == 0)
            {
                IsExistsPalette = false;
            }
            else
            {
                IsExistsPalette = true;
            }
            return(IsExistsPalette);
        }
Exemplo n.º 2
0
    private void PrepareMandala()
    {
        this.fType             = FloodTest.FillType.Fast;
        this.lineContourText   = this.LoadImage(FloodTest.IMG_NAME_INDEX.ToString());
        this.sourceImg.texture = this.lineContourText;
        this.colorSourceText   = this.LoadImage(FloodTest.IMG_NAME_INDEX + "ccc");
        this.pixels            = this.colorSourceText.GetPixels();
        this.sourceAlpha       = new byte[this.pixels.Length];
        if (this.paintEngine == null)
        {
            this.paintEngine = new AdvancedMobilePaint();
        }
        this.paintEngine.pixels    = new byte[this.colorSourceText.width * this.colorSourceText.height * 4];
        this.paintEngine.texHeight = this.colorSourceText.height;
        this.paintEngine.texWidth  = this.colorSourceText.width;
        this.paintEngine.source    = this.sourceAlpha;
        this.drawText = new Texture2D(this.colorSourceText.width, this.colorSourceText.height, TextureFormat.RGBA32, false);
        this.drawText.LoadRawTextureData(this.paintEngine.pixels);
        this.drawText.filterMode = FilterMode.Point;
        this.drawText.Apply();
        this.imageRect       = this.sourceImg.rectTransform.rect;
        this.drawImg.texture = this.drawText;
        float num;

        if (FloodTest.IMG_NAME_INDEX < 104)
        {
            num = 0.09f;
        }
        else
        {
            num = 0.02f;
        }
        for (int i = 0; i < this.pixels.Length; i++)
        {
            if (this.pixels[i].r < num && this.pixels[i].g < num && this.pixels[i].b < num)
            {
                this.sourceAlpha[i] = byte.MaxValue;
            }
            else
            {
                this.sourceAlpha[i] = 0;
            }
        }
        string      value       = FileHelper.LoadTextAssetResource(FloodTest.IMG_NAME_INDEX + "t");
        PaletteData paletteData = JsonConvert.DeserializeObject <PaletteData>(value);

        for (int j = 0; j < paletteData.entities.Length; j++)
        {
            PaletteEntity paletteEntity = paletteData.entities[j];
            for (int k = 0; k < paletteEntity.indexes.Length; k++)
            {
                Point p = default(Point);
                p.i = Mathf.FloorToInt((float)paletteEntity.indexes[k] / (float)this.colorSourceText.width);
                p.j = paletteEntity.indexes[k] - p.i * this.colorSourceText.width;
                this.CreateNumView(this.TextureToCanvas(p), j);
            }
        }
    }
Exemplo n.º 3
0
        public void PaletteSave(PaletteEntity palette)
        {
            if (IsExistsPalette(palette))
            {
                var parameters = new List <SqlParameter>();
                var sql        = @"
update
    [KGWS].[dbo].[palettes]
set
     [user_id]=@user_id
    ,[palette_name]=@palette_name
    ,[use_seg]=@use_seg
    ,[use_place]=@use_place
    ,[is_deleted]=@is_deleted
where
    [palette_id]=@palette_id
";

                parameters.Clear();
                parameters.Add(new SqlParameter("@palette_id", palette.PaletteId));
                parameters.Add(new SqlParameter("@user_id", palette.UserId));
                parameters.Add(new SqlParameter("@palette_name", palette.PaletteName));
                parameters.Add(new SqlParameter("@use_seg", palette.UseSeg));
                parameters.Add(new SqlParameter("@use_place", palette.UsePlace));
                parameters.Add(new SqlParameter("@is_deleted", palette.IsDeleted));
                SQLServerHelper.Execute(sql, parameters.ToArray());
            }
            else
            {
                var parameters = new List <SqlParameter>();
                var sql        = @"
insert into
    [KGWS].[dbo].[palettes]
    (
     [user_id]
    ,[palette_name]
    ,[use_seg]
    ,[use_place]
    ,[is_deleted]
    )
values
    (
     @user_id
    ,@palette_name
    ,@use_seg
    ,@use_place
    ,@is_deleted
    )
";
                parameters.Clear();
                parameters.Add(new SqlParameter("@user_id", palette.UserId));
                parameters.Add(new SqlParameter("@palette_name", palette.PaletteName));
                parameters.Add(new SqlParameter("@use_seg", palette.UseSeg));
                parameters.Add(new SqlParameter("@use_place", palette.UsePlace));
                parameters.Add(new SqlParameter("@is_deleted", palette.IsDeleted));
                SQLServerHelper.Execute(sql, parameters.ToArray());
            }
        }
        private void Update()
        {
            var update = new PaletteEntity(SelectedPalette.Value.PaletteId,
                                           Convert.ToInt32(SelectedUserIdText.Value),
                                           SelectedPaletteNameText.Value,
                                           SelectedUseSegText.Value,
                                           SelectedUsePlaceText.Value,
                                           SelectedPalette.Value.IsDeleted);

            _palettePartsRepository.PaletteSave(update);
            GetPalettes();
        }
        private void Delete()
        {
            var deleteParameter = true;
            var delete          = new PaletteEntity(SelectedPalette.Value.PaletteId,
                                                    SelectedPalette.Value.UserId,
                                                    SelectedPalette.Value.PaletteName,
                                                    SelectedPalette.Value.UseSeg,
                                                    SelectedPalette.Value.UsePlace,
                                                    deleteParameter);

            _palettePartsRepository.PaletteSave(delete);
            GetPalettes();
        }
        private void AddCommandExecute()
        {
            var deleteParameter = false;
            var add             = new PaletteEntity(0,
                                                    1,
                                                    SelectedPaletteNameText.Value,
                                                    SelectedUseSegText.Value,
                                                    SelectedUsePlaceText.Value,
                                                    deleteParameter);

            _palettePartsRepository.PaletteSave(add);
            GetPalettes();
        }
Exemplo n.º 7
0
    public void Create(PaletteData pd)
    {
        PaletteData paletteData = pd;
        int         num         = int.MaxValue;

        for (int i = 0; i < paletteData.entities.Length; i++)
        {
            paletteData.entities[i].color.a = byte.MaxValue;
            PaletteEntity paletteEntity = paletteData.entities[i];
            for (int j = 0; j < paletteEntity.indexes.Length; j++)
            {
                Vector2 position = this.ToCanvasPosition(paletteEntity.indexes[j]);
                int     num2     = Mathf.RoundToInt((float)paletteEntity.sizes[j] * this.textureScaleRatio);
                if (num2 < num)
                {
                    num = num2;
                }
                Num item = this.CreateNumView(position, i, num2);
                this.numbers.Add(item);
            }
        }
        this.ScaleRequiredForNum = (float)this.numInitialSize / (float)num + 0.05f;
    }
Exemplo n.º 8
0
    public void HighlightColor(int colorId)
    {
        if (this.currentColorId == colorId)
        {
            UnityEngine.Debug.Log("Rehighlight. Skip");
            return;
        }
        if (this.highlightCoroutine != null)
        {
            if (this.prev != null)
            {
                for (int i = 0; i < this.prev.zones.Count; i++)
                {
                    List <int> indexes = this.prev.zones[i];
                    FloodAlgorithm.FillIndexes(indexes, this.highlightEngine, this.startColor);
                }
            }
            base.StopCoroutine(this.highlightCoroutine);
        }
        this.currentColorId = colorId;
        PaletteEntity paletteEntity = this.pd.entities[colorId];
        Color32       newColor      = this.startColor;

        if (this.current != null)
        {
            this.prev = this.current;
        }
        this.current         = new FloodHighlightController.HState();
        this.current.colorId = colorId;
        this.current.color   = paletteEntity.color;
        this.current.zones   = new List <List <int> >();
        for (int j = 0; j < paletteEntity.indexes.Length; j++)
        {
            int num = paletteEntity.indexes[j];
            if (!this.IsPainted(num, paletteEntity.color))
            {
                Point point = default(Point);
                point.i = Mathf.FloorToInt((float)num / (float)this.paintEngine.texWidth);
                point.j = num - point.i * this.paintEngine.texWidth;
                byte b = this.paintEngine.source[num];
                if (b < 253)
                {
                    b += 1;
                }
                else
                {
                    b = 1;
                }
                List <int> item = FloodAlgorithm.FloodFillExtended(point.j, point.i, this.highlightEngine, newColor, b);
                this.current.zones.Add(item);
            }
        }
        if (this.prev != null)
        {
            for (int k = this.prev.zones.Count - 1; k >= 0; k--)
            {
                if (this.IsPainted(this.prev.zones[k][0], this.prev.color))
                {
                    this.prev.zones.RemoveAt(k);
                }
            }
        }
        this.highlightCoroutine = base.StartCoroutine(this.HighlightCoroutine(this.duration));
    }
Exemplo n.º 9
0
    private void Create(Texture2D l, Texture2D c, PaletteData p)
    {
        FillAlgorithm fillAlgorithm = this.fillType;

        if (fillAlgorithm != FillAlgorithm.Flood)
        {
            if (fillAlgorithm == FillAlgorithm.Chop)
            {
                this.chopFill = new ChopFill();
                this.chopFill.Create(l, p, true);
                this.sourceImg.texture = l;
                this.drawImg.texture   = this.chopFill.DrawTex;
                this.imageRect         = this.sourceImg.rectTransform.rect;
                this.paintFill         = this.chopFill;
            }
        }
        else
        {
            this.floodFill = new FloodFill();
            this.floodFill.Create(l, c, p);
            this.sourceImg.texture = l;
            this.drawImg.texture   = this.floodFill.DrawTex;
            this.imageRect         = this.sourceImg.rectTransform.rect;
            this.paintFill         = this.floodFill;
        }
        this.paletteData = p;
        PaletteData  paletteData = p;
        List <Color> list        = new List <Color>();

        for (int i = 0; i < paletteData.entities.Length; i++)
        {
            paletteData.entities[i].color.a = byte.MaxValue;
            PaletteEntity paletteEntity = paletteData.entities[i];
            list.Add(paletteEntity.color);
        }
        this.numController.Init(new Func <int, Vector2>(this.TextureIndexToCanvas), this.imageRect.width / (float)this.paintFill.TexWidth);
        this.numController.Create(paletteData);
        this.palette.Create(list);
        this.palette.NewColor += delegate(int cId)
        {
            this.highlighter.HighlightColor(cId);
        };
        FillAlgorithm fillAlgorithm2 = this.fillType;

        if (fillAlgorithm2 != FillAlgorithm.Flood)
        {
            if (fillAlgorithm2 == FillAlgorithm.Chop)
            {
                ChopHighlightController component = this.highlightGameObject.GetComponent <ChopHighlightController>();
                component.Init(this.chopFill, paletteData, this.numController);
                this.highlighter = component;
            }
        }
        else
        {
            FloodHighlightController component2 = this.highlightGameObject.GetComponent <FloodHighlightController>();
            component2.Init(this.floodFill.Paint, paletteData, this.paintFill.DrawTex);
            this.highlighter = component2;
        }
        this.validator = new LevelValidator();
        this.validator.Init(paletteData);
        this.save = new BoardSave();
        this.boardController.Init(this.numController);
        this.boardController.Click += this.OnClick;
    }
Exemplo n.º 10
0
    public void HighlightColor(int colorId)
    {
        if (this.currentColorId == colorId)
        {
            UnityEngine.Debug.Log("Rehighlight. Skip");
            return;
        }
        if (this.highlightCoroutine != null)
        {
            if (this.prev != null)
            {
                for (int i = 0; i < this.prev.zoneIds.Count; i++)
                {
                    this.chopFill.FillId(this.prev.startColor, this.prev.zoneIds[i]);
                }
                this.numController.DehighlightVisable(this.prev.colorId);
            }
            base.StopCoroutine(this.highlightCoroutine);
        }
        this.currentColorId = colorId;
        PaletteEntity paletteEntity = this.pd.entities[colorId];

        if (this.current != null)
        {
            this.prev = this.current;
        }
        this.current         = new ChopHighlightController.HState();
        this.current.colorId = colorId;
        this.current.color   = paletteEntity.color;
        if (ColorUtils.IsSameColors(paletteEntity.color, this.highlightColor))
        {
            this.current.highlightColor = this.highlightBackupColor;
            this.current.startColor     = this.startBackupColor;
        }
        else
        {
            this.current.highlightColor = this.highlightColor;
            this.current.startColor     = this.startColor;
        }
        this.current.zoneIds = new List <short>();
        short num = 0;

        while ((int)num < this.chopFill.ColorMap.Count)
        {
            if (this.chopFill.ColorMap[(int)num] == colorId && !this.chopFill.HasColorInId(paletteEntity.color, num))
            {
                this.current.zoneIds.Add(num);
            }
            num += 1;
        }
        if (this.prev != null)
        {
            for (int j = this.prev.zoneIds.Count - 1; j >= 0; j--)
            {
                if (this.chopFill.HasColorInId(this.prev.color, this.prev.zoneIds[j]))
                {
                    this.prev.zoneIds.RemoveAt(j);
                }
            }
        }
        this.highlightCoroutine = base.StartCoroutine(this.HighlightCoroutine(this.duration));
    }