本文整理汇总了C#中Color.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Color.Equals方法的具体用法?C# Color.Equals怎么用?C# Color.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.Equals方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LightBall
public LightBall(string name, Vector3 sPos, Transform eObj, float lTime, Color glowColor)
{
endPos = eObj.position;
lifeTime = lTime;
string prefabName = "LightBall(Clone)";
GameObject lightPrefab = PrefabFactory.GetLightBallPrefab();
if (glowColor.Equals(Color.red)){
lightPrefab = PrefabFactory.GetLightBallRedPrefab();
prefabName = "LightBallRed(Clone)";
}
else if (glowColor.Equals (Color.blue)){
lightPrefab = PrefabFactory.GetLightBallBluePrefab();
prefabName = "LightBallBlue(Clone)";
}
else if (glowColor.Equals (Color.black)){
lightPrefab = PrefabFactory.GetLightBallDarkPrefab();
prefabName = "LightBallDark(Clone)";
}
GameManager.InstantiateModel(lightPrefab, sPos);
lightBall = GameObject.Find(prefabName);
lightBall.name = name;
lightBall.AddComponent("LightBallMove");
lightBall.transform.LookAt(eObj);
GameObject glow = lightBall.transform.Find("Glow").gameObject;
glow.light.color = glowColor;
}
示例2: colorLerp1
IEnumerator colorLerp1(Color col1, Color col2)
{
float step = 0f;
while (!col1.Equals(col2))
{
yield return new WaitForSeconds(0.01f);
this.gameObject.GetComponent<Renderer>().material.SetColor("_Color", Color.Lerp(col1, col2, step += 0.005f));
}
yield return null;
}
示例3: SetColor
public void SetColor(Color newColor, float duration = 0)
{
// Don't do anything if we're being set to the same color:
if(!newColor.Equals(targetColor))
{
startColor = Color;
targetColor = newColor;
this.duration = duration;
timer = 0;
}
}
示例4: Equals
public void Equals()
{
var color1 = new Color(10, 20, 30, 40);
var color2 = new Color(20, 30, 40, 50);
Assert.AreNotEqual(color1, color2);
Assert.AreEqual(color1, new Color(10, 20, 30, 40));
Assert.IsTrue(color1 == new Color(10, 20, 30, 40));
Assert.IsTrue(color1 != color2);
Assert.IsTrue(color1.Equals((object)new Color(10, 20, 30, 40)));
Assert.AreEqual(color1.PackedRgba, color1.GetHashCode());
}
示例5: RobotRenderComponent
public RobotRenderComponent(Entity parent, float height, float scale, Color color)
: base(parent, ContentLoader.Robot)
{
this.Transform = Matrix.Identity;
this.height = height;
this.colorEffect = ContentLoader.ColorEffect;
this.scale = scale;
// Temp fix...
if (color.Equals(Color.Red))
{
this.model = ContentLoader.RobotRed;
}
else if (color.Equals(Color.Blue))
{
this.model = ContentLoader.RobotBlue;
}
else if (color.Equals(Color.Yellow))
{
this.model = ContentLoader.RobotYellow;
}
}
示例6: getConsoleColor
public static String getConsoleColor(Color cellColor)
{
if (cellColor.Equals(Color.Black))
{
return "x";
}
else if (cellColor.Equals(Color.Cyan))
{
return "I";
}
else if (cellColor.Equals(Color.Blue))
{
return "J";
}
else if (cellColor.Equals(Color.Orange))
{
return "L";
}
else if (cellColor.Equals(Color.Yellow))
{
return "O";
}
else if (cellColor.Equals(Color.Green))
{
return "S";
}
else if (cellColor.Equals(Color.Purple))
{
return "T";
}
else if (cellColor.Equals(Color.Red))
{
return "Z";
}
else
{
return "X";
}
}
示例7: GenerateColorFromNeighbor
Color GenerateColorFromNeighbor(XY xy , Color[,] pixels )
{
List<XY> neigh = getneighbors(xy,pixels,false);
float sumR =0 , sumG = 0, sumB = 0;
foreach(XY n in neigh )
{
sumR += pixels[n.x,n.y].r;
sumG += pixels[n.x,n.y].g;
sumB += pixels[n.x,n.y].b;
}
Color res = new Color( sumR / neigh.Count , sumG / neigh.Count , sumB / neigh.Count );
res.r += UnityEngine.Random.Range(-diversity,diversity);
res.g += UnityEngine.Random.Range(-diversity,diversity);
res.b += UnityEngine.Random.Range(-diversity,diversity);
if ( res.Equals(Color.black))
{
res.r = res.g = res.b = 0.05f;
}
return res;
}
示例8: Equality
public void Equality(Color left, Color right, bool expected)
{
Assert.True(left.Equals(left), "left should always Equals itself");
Assert.True(right.Equals(right), "right should always Equals itself");
Assert.Equal(expected, left == right);
Assert.Equal(expected, right == left);
Assert.Equal(expected, left.Equals(right));
Assert.Equal(expected, right.Equals(left));
Assert.Equal(!expected, left != right);
Assert.Equal(!expected, right != left);
}
示例9: Ensure_that_equals_returns_true_for_identity
public void Ensure_that_equals_returns_true_for_identity()
{
var color = new Color(0, 0, 0);
Assert.IsTrue(color.Equals(color));
Assert.IsTrue(color.Equals((object)color));
}
示例10: Ensure_that_equals_returns_false_when_compared_with_null
public void Ensure_that_equals_returns_false_when_compared_with_null()
{
var color = new Color(0, 0, 0);
Assert.IsFalse(color.Equals(null));
Assert.IsFalse(color.Equals((object)null));
}
示例11: Ensure_that_equals_returns_false_when_compared_with_a_different_type_of_object
public void Ensure_that_equals_returns_false_when_compared_with_a_different_type_of_object()
{
var color = new Color(0, 0, 0);
Assert.IsFalse(color.Equals(""));
}
示例12: SetColor
/// <summary>
/// Helper function sets a color overlay for every vertex in the buffer
/// </summary>
/// <param name="color">Color</param>
public void SetColor(Color color)
{
// inefficient
if (color.Equals(verts[0].Color))
return;
for (int i = 0; i < verts.Length; i++)
{
verts[i].Color = color;
}
vertexBuffer.SetData<VertexPositionColorTexture>(verts);
}
示例13: VColor
/// <summary>
/// sets the vertex color of a tile
/// </summary>
public Color VColor(IVector2 tile, Color color)
{
try
{
Color[] colors = mesh.colors;
int vidx = ((tile.x * tileMatrix.y) + tile.y) * 4;
if (!color.Equals(Color.clear))
{
colors[vidx + 0] = color;
colors[vidx + 1] = color;
colors[vidx + 2] = color;
colors[vidx + 3] = color;
mesh.colors = colors;
}
return colors[vidx + 0];
}
catch(System.Exception)
{
}
return Color.clear;
}