Ejemplo n.º 1
0
    /// <summary>
    /// Updates all pixels next to a pixel that has been hit
    /// </summary>
    /// <param name="x">x position in pixels array</param>
    /// <param name="y">y position in pixels array</param>
    /// <param name="hit">Hit object originally passed to the pixel</param>
    public void UpdateNearby(Index2D index, Hit hit)
    {
        // The damage will decrease with the square of the distance from the
        // origin. This may be changed later to be linear.

        for (int i = -(int)hit.Radius; i <= hit.Radius; i++)
        {
            for (int j = -(int)hit.Radius; j <= hit.Radius; j++)
            {
                if (i * i + j * j == 0)
                {
                    continue;
                }
                var pixel  = pixels.GetElementOrNull(index.x + i, index.y + j);
                var modHit = new Hit(hit, damage: hit.Damage * ((1.0f / (i * i + j * j))));
                if (pixel != null)
                {
                    pixel.SendMessage(Const.TakeDamageCollateral, modHit);
                }
            }
        }
    }