public void ColorTypeAttribute_Alpha_ShouldThrowArgumentException() { Assert.Throws <ArgumentException>(() => { // ReSharper disable once UnusedVariable ColorTypeAttribute color = new ColorTypeAttribute(0, 0, 0, 500); }); }
/// <summary> /// Sets the color palette of a sprite to a pre-defined value. /// </summary> /// <param name="entity">The entity to manipulate.</param> /// <param name="color">The pre-defined color to use.</param> public void SetColorPalette(Entity entity, ColorType color) { if (entity.HasComponent <Sprite>()) { ColorTypeAttribute attr = color.GetAttributeOfType <ColorTypeAttribute>(); entity.GetComponent <Sprite>().SetColorOverride(attr.Red, attr.Green, attr.Blue, attr.Alpha); } }
public void ColorTypeAttribute_Constructor_ValuesShouldMatch() { ColorTypeAttribute color = new ColorTypeAttribute(123, 222, 50, 25); Assert.AreEqual(123, color.Red); Assert.AreEqual(50, color.Blue); Assert.AreEqual(222, color.Green); Assert.AreEqual(25, color.Alpha); }
public void SetColorPalette_ShouldBeRed() { Entity entity = BuildEntity(); _spriteMethods.SetColorPalette(entity, ColorType.Red); Color?color = entity.GetComponent <Sprite>().ColorOverride; Assert.IsNotNull(color); ColorTypeAttribute attr = ColorType.Red.GetAttributeOfType <ColorTypeAttribute>(); Assert.AreEqual(attr.Red, color.Value.R); Assert.AreEqual(attr.Green, color.Value.G); Assert.AreEqual(attr.Blue, color.Value.B); Assert.AreEqual(attr.Alpha, color.Value.A); }