Exemple #1
0
        public void DealDamage(float damage)
        {
            Health -= damage;
            var pixelcount = Health * _damagePixelsMax / 100f;

            // make next pixel black
            while (pixelcount < _damagePixels.Count && pixelcount >= 0)
            {
                var colors = new Color[_damageTexture.Width * _damageTexture.Height];
                _damageTexture.GetData <Color>(colors);

                var pixeltoremove = RngGenerator.GetUInt32() % _damagePixels.Count;
                var pixel         = _damagePixels[(int)pixeltoremove];
                colors[(int)(_damageTexture.Width * pixel.Y + pixel.X)] = Color.Black;
                _damagePixels.RemoveAt((int)pixeltoremove);

                _damageTexture.SetData <Color>(colors);
            }
        }
Exemple #2
0
 public Tower() : this((int)(RngGenerator.GetUInt32() % 4) + 1)
 {
     Health = 100f;
 }