public BlockColors(BCColor pLightColor, BCColor pGlintColor, BCColor pCenterColor, BCColor pShadedColor)
 {
     LightColor  = pLightColor;
     GlintColor  = pGlintColor;
     CenterColor = pCenterColor;
     ShadedColor = pShadedColor;
 }
 public GameOverStatisticColumnData(String pText, BCColor pColor, BCColor pShadowColor, HorizontalAlignment hAlign = HorizontalAlignment.Left, VerticalAlignment vAlign = VerticalAlignment.Top)
 {
     this.InfoType = CellType.Text;
     Color         = pColor;
     CellText      = pText;
     ContentAlignmentHorizontal = hAlign;
     ContentAlignmentVertical   = vAlign;
     ShadowColor = pShadowColor;
 }
Example #3
0
        //GeneratePopParticles(pOwner, state, iterate);
        private void GeneratePopParticles(IStateOwner pOwner, GameplayGameState gstate, SKPointI pt)
        {
            var rgen    = TetrisGame.rgen;
            var popItem = gstate.PlayField.Contents[pt.Y][pt.X];

            BCColor[] useColor = YellowColors;
            if (popItem is LineSeriesBlock lsb)
            {
                switch (lsb.CombiningIndex)
                {
                case LineSeriesBlock.CombiningTypes.Red:
                    useColor = RedColors;
                    break;

                case LineSeriesBlock.CombiningTypes.Blue:
                    useColor = BlueColors;
                    break;

                case LineSeriesBlock.CombiningTypes.Yellow:
                    useColor = YellowColors;
                    break;

                case LineSeriesBlock.CombiningTypes.Orange:
                    useColor = OrangeColors;
                    break;

                case LineSeriesBlock.CombiningTypes.Magenta:
                    useColor = MagentaColors;
                    break;

                case LineSeriesBlock.CombiningTypes.Green:
                    useColor = GreenColors;
                    break;
                }
                for (int i = 0; i < ParticlesPerPop; i++)
                {
                    PointF  Offset   = new PointF((float)rgen.NextDouble(), (float)rgen.NextDouble());
                    BCColor selColor = TetrisGame.Choose(useColor);
                    BCPoint Velocity = TetrisGame.Choose(CardinalOptions);
                    float   Speed    = (float)rgen.NextDouble() * (MAX_SPEED - MIN_SPEED) + MIN_SPEED;
                    float   Sign     = TetrisGame.Choose(new float[] { -1f, 1f });

                    BCPoint VelocityUse = new BCPoint(Velocity.X * Speed * Sign, Velocity.Y * Speed * Sign);

                    BaseParticle bp = new BaseParticle(new BCPoint(pt.X + Offset.X, pt.Y + Offset.Y), VelocityUse, selColor);
                    gstate.Particles.Add(bp);
                }
            }

            /*for (int i=0;i<ParticlesPerPop;i++)
             * {
             *
             * }*/
        }
Example #4
0
        private void AddParticles(IStateOwner pOwner, int BlockX, int BlockY, int DirectionMultiplier, int RowsCleared)
        {
            //the actual block we are clearing...
            var     ClearingBlock = _BaseState.PlayField.Contents[BlockY][BlockX];
            SKColor baseColor     = TetrisGame.Choose(ClearLineParticleColours);
            Bitmap  sourcebitmap  = null;

            if (ClearingBlock != null && ClearingBlock is ImageBlock ib)
            {
                sourcebitmap = new Bitmap(ib._RotationImages[MathHelper.mod(ib.Rotation, ib._RotationImages.Length)]);
            }
            var blockWidth  = _BaseState.PlayField.GetBlockWidth((SKRect)pOwner.LastDrawBounds);
            var blockHeight = _BaseState.PlayField.GetBlockHeight((SKRect)pOwner.LastDrawBounds);
            var CoordPos    = new BCPoint(BlockX,
                                          BlockY - 2);

            lock (_BaseState.Particles)
            {
                List <BaseParticle> ToAdd = new List <BaseParticle>(ParticleCountPerBlock);
                for (int i = 0; i < ParticleCountPerBlock; i++)
                {
                    BCPoint ParticlePos = new BCPoint((float)TetrisGame.rgen.NextDouble(), (float)TetrisGame.rgen.NextDouble());
                    //choose a new random position within the block.
                    BCPoint NewParticlePoint = new BCPoint(CoordPos.X + ParticlePos.X, CoordPos.Y + ParticlePos.Y);
                    BCPoint Velocity         = new BCPoint(

                        (float)(DirectionMultiplier * (TetrisGame.rgen.NextDouble() * 1 + (Math.Abs(BlockX - (_BaseState.PlayField.ColCount / 2)) / 5))), 0

                        );
                    BCColor ChosenColor = baseColor;

                    if (sourcebitmap != null)
                    {
                        Point TargetPixel = new Point((int)(ParticlePos.X * sourcebitmap.Width), (int)(ParticlePos.Y * sourcebitmap.Height));
                        ChosenColor = sourcebitmap.GetPixel(TargetPixel.X, TargetPixel.Y);
                    }


                    BaseParticle p = new BaseParticle(NewParticlePoint, Velocity, ChosenColor);
                    if (RowsCleared >= 4)
                    {
                        if (TetrisGame.rgen.NextDouble() > 0.25d)
                        {
                            p.ColorCalculatorFunction = BaseParticle.GetRainbowColorFunc(pOwner, 500);
                        }
                    }
                    p.TTL = (uint)ClearParticleTTL;
                    ToAdd.Add(p);
                }
                _BaseState.Particles.AddRange(ToAdd);
            }
        }
 private void GenerateDropParticles(BCPoint Location, int NumGenerate, Func <BCPoint> VelocityGenerator, Func <float, float, BCColor> ColorFunc)
 {
     lock (Particles)
     {
         for (int i = 0; i < NumGenerate; i++)
         {
             var          genX         = (float)rgen.NextDouble();
             var          genY         = (float)rgen.NextDouble();
             BCPoint      Genpos       = new BCPoint(Location.X + genX, Location.Y + genY);
             BCColor      ChosenColor  = ColorFunc(genX, genY);
             BaseParticle MakeParticle = new BaseParticle(Genpos, VelocityGenerator(), ChosenColor);
             Particles.Add(MakeParticle);
         }
     }
 }
        private static SKBitmap DrawArrayImage(BlockColors basis, PT[][] ArraySrc)
        {
            SKBitmap drawimage = new SKBitmap(blockinfo, SKBitmapAllocFlags.ZeroPixels);
            SKCanvas skc       = new SKCanvas(drawimage);

            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    var     PixelType   = ArraySrc[y][x];
                    BCColor ChosenColor = SelectColor(PixelType, basis);
                    SKColor useChosen   = ChosenColor;
                    skc.DrawPoint(new SKPoint(x, y), ChosenColor);
                    //drawimage.SetPixel(x, y, ChosenColor);
                }
            }
            skc.Flush();
            return(drawimage);
        }
Example #7
0
 public LineParticle(BCPoint StartPoint, BCPoint EndPoint, BCPoint pVelocity, BCColor pColor) : base(StartPoint, pVelocity, pColor)
 {
 }
Example #8
0
 public BaseParticle(BCPoint pPosition, BCPoint pVelocity, BCColor pColor)
 {
     Position = pPosition;
     Velocity = pVelocity;
     Color    = pColor;
 }
Example #9
0
        public CharParticle(BCPoint pPosition, BCPoint pVelocity, BCColor pColor, String pText) : base(pPosition, pVelocity, pColor)
        {
            Text = pText;

            FontInfo = new BCFont(useFont.FontFamily.Name, 1, BCFont.BCFontStyle.Regular);
        }
Example #10
0
 public BitmapParticle(BCPoint pPosition, BCPoint pVelocity, BCColor pColor, BCImage img) : base(pPosition, pVelocity, pColor)
 {
     Image = img;
 }
Example #11
0
 protected RotatableBaseParticle(BCPoint pPosition, BCPoint pVelocity, BCColor pColor) : base(pPosition, pVelocity, pColor)
 {
 }
Example #12
0
 public MenuStateTextMenuItem()
 {
     ForeColor   = Color.Black;
     BackColor   = Color.Transparent;
     ShadowColor = Color.Gray;
 }
Example #13
0
        private void AddParticles_Row(IStateOwner pOwner, BCRect RowBounds, int Lines = 1)
        {
            String UseText = RowClearText?[Lines] ?? $"{Lines}LINE";
            Func <BaseParticle, BCColor> TetrisColorFunc     = BaseParticle.GetRainbowColorFunc(pOwner);
            Func <BaseParticle, BCColor> SingleLineColorFunc = (o) =>
            {
                int    timebase      = 2000;
                double DarknessValue = (Math.Sin((float)pOwner.GetElapsedTime().Ticks / 2000) / 2) + 1;

                BCColor usecolor = (Color) new HSLColor(0, 120, DarknessValue * 120);

                return(usecolor);
            };

            Func <BaseParticle, BCColor> DoubleLineColorFunc = (o) =>
            {
                int    timebase      = 2000;
                double DarknessValue = Math.Sin((float)pOwner.GetElapsedTime().Ticks / 2000);

                BCColor usecolor = (Color) new HSLColor(75, 120, DarknessValue * 120);

                return(usecolor);
            };
            Func <BaseParticle, BCColor> TripleLineColorFunc = (o) =>
            {
                int    timebase      = 2000;
                double DarknessValue = Math.Sin((float)pOwner.GetElapsedTime().Ticks / 2000);

                BCColor usecolor = (Color) new HSLColor(150, 120, DarknessValue * 120);

                return(usecolor);
            };


            Func <BaseParticle, BCColor>[] LineFuncs = new Func <BaseParticle, BCColor>[]
            {
                SingleLineColorFunc, DoubleLineColorFunc, TripleLineColorFunc, TetrisColorFunc
            };
            //split the text into characters...

            char[] CharsToShow = UseText.ToCharArray();

            float XOffset = (int)((float)RowBounds.Width / 2 - ((float)CharsToShow.Length / 2)); //one character per block, ideally.

            List <CharParticle> MakeParticles = new List <CharParticle>();

            for (int x = 0; x < CharsToShow.Length; x++)
            {
                int          i            = x % CharsToShow.Length;
                CharParticle makeparticle = new CharParticle(new BCPoint(RowBounds.Left + XOffset + x, RowBounds.Top + RowBounds.Height / 2), new BCPoint(0, -0.05f), Color.Red, CharsToShow[i].ToString());
                makeparticle.TTL = 1500;
                //makeparticle.Decay = new BCPoint(0.5f, 0.5f);
                MakeParticles.Add(makeparticle);
                Lines = Lines > 4 ? Lines = 4:Lines;
                if (Lines >= 4)
                {
                    makeparticle.ColorCalculatorFunction = LineFuncs[Lines - 1];
                }

                else
                {
                    makeparticle.Color = new Color[] { Color.Red, Color.Green, Color.Yellow }[Lines - 1];
                }



                lock (_BaseState.TopParticles)
                {
                    _BaseState.TopParticles.AddRange(MakeParticles);
                }
            }
        }