当前位置: 首页>>代码示例>>C#>>正文


C# Color.Any方法代码示例

本文整理汇总了C#中Color.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Color.Any方法的具体用法?C# Color.Any怎么用?C# Color.Any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color.Any方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NPC

        public NPC(NPCData data)
            : base(EOGame.Instance)
        {
            ApplyData(data);
            bool success = true;
            npcSheet = new EONPCSpriteSheet(this);
            int tries = 0;
            do
            {
                try
                {
                    //attempt to get standing frame 1. It will have non-black pixels if it exists.
                    Frame = NPCFrame.StandingFrame1;
                    Texture2D tmp = npcSheet.GetNPCTexture();
                    Color[] tmpData = new Color[tmp.Width*tmp.Height];
                    tmp.GetData(tmpData);
                    hasStandFrame1 = tmpData.Any(_c => _c.R != 0 || _c.G != 0 || _c.B != 0);

                    //get the first non-transparent pixel to determine offsets for name labels and damage counters
                    Frame = NPCFrame.Standing;
                    tmp = npcSheet.GetNPCTexture();
                    tmpData = new Color[tmp.Width*tmp.Height];
                    tmp.GetData(tmpData);
                    int i = 0;
                    while (i < tmpData.Length && tmpData[i].A == 0) i++;
                    TopPixel = i == tmpData.Length - 1 ? 0 : i/tmp.Height;

                } //this block throws errors sometimes..no idea why. Keep looping until it works.
                catch (InvalidOperationException)
                {
                    success = false;
                    tries++;
                }
            } while (!success && tries < 3);

            if(tries >= 3)
                throw new InvalidOperationException("Something weird happened initializing this NPC.");

            m_chatBubble = new EOChatBubble(this);
            m_damageCounter = new DamageCounter(this, GetType());
        }
开发者ID:Vulttwin,项目名称:EndlessClient,代码行数:41,代码来源:NPC.cs

示例2: ByPointsColors

        public static Display ByPointsColors([KeepReferenceAttribute]Point[] points, Color[] colors)
        {
            if(points == null)
            {
                throw new ArgumentNullException("points");
            }

            if (!points.Any())
            {
                throw new ArgumentException(Resources.NoVertexExceptionMessage, "points");
            }

            if (points.Count() %3 != 0)
            {
                throw new ArgumentException(Resources.VerticesDivisibleByThreeExceptionMessage);
            }

            if(colors == null)
            {
                throw new ArgumentNullException("colors");
            }

            if (!colors.Any())
            {
                throw new ArgumentException(Resources.NoColorsExceptionMessage, "colors");
            }

            if (colors.Count() != points.Count())
            {
                throw new ArgumentException(Resources.VertexColorCountMismatchExceptionMessage, "colors");
            }

            return new Display(points, colors);
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:34,代码来源:Display.cs

示例3: BySurfaceColors

        /// <summary>
        /// Display color values on a surface.
        /// </summary>
        /// <param name="surface">The surface on which to apply the colors.</param>
        /// <param name="colors">A two dimensional list of Colors.</param>
        /// <returns>A Display object.</returns>
        public static Display BySurfaceColors(Surface surface, Color[][] colors)
        {
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }

            if (colors == null)
            {
                throw new ArgumentNullException("colors");
            }

            if (!colors.Any())
            {
                throw new ArgumentException("You must supply some colors");
            }

            if (colors.Length == 1)
            {
                throw new ArgumentException("You must supply a two dimensional list of Colors.");
            }

            var size = colors[0].Count();
            foreach (var list in colors)
            {
                if (list.Count() != size)
                {
                    throw new ArgumentException("The list of colors must not be a jagged list.");
                }
            }

            return new Display(surface, colors);
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:39,代码来源:Display.cs

示例4: InitializeStandingFrame1

		private void InitializeStandingFrame1()
		{
			//attempt to get standing frame 1. It will have non-black pixels if it exists.
			Frame = NPCFrame.StandingFrame1;

			Texture2D frameTexture = _npcSheet.GetNPCTexture();
			Color[] textureData = new Color[frameTexture.Width * frameTexture.Height];
			frameTexture.GetData(textureData);

			hasStandFrame1 = textureData.Any(_c => _c.R != 0 || _c.G != 0 || _c.B != 0);
		}
开发者ID:Fallenoath,项目名称:EndlessClient,代码行数:11,代码来源:NPCRenderer.cs

示例5: NPC

		public NPC(NPCData data)
			: base(EOGame.Instance)
		{
			ApplyData(data);
			bool success = true;
			npcSheet = new EONPCSpriteSheet(((EOGame)Game).GFXManager, this);
			int tries = 0;
			do
			{
				try
				{
					//attempt to get standing frame 1. It will have non-black pixels if it exists.
					Frame = NPCFrame.StandingFrame1;
					Texture2D tmp = npcSheet.GetNPCTexture();
					Color[] tmpData = new Color[tmp.Width*tmp.Height];
					tmp.GetData(tmpData);
					hasStandFrame1 = tmpData.Any(_c => _c.R != 0 || _c.G != 0 || _c.B != 0);

					//get the first non-transparent pixel to determine offsets for name labels and damage counters
					Frame = NPCFrame.Standing;
					tmp = npcSheet.GetNPCTexture();
					tmpData = new Color[tmp.Width*tmp.Height];
					tmp.GetData(tmpData);
					int i = 0;
					while (i < tmpData.Length && tmpData[i].A == 0) i++;
					TopPixel = i == tmpData.Length - 1 ? 0 : i/tmp.Height;

				} //this block throws errors sometimes..no idea why. Keep looping until it works.
				catch (InvalidOperationException)
				{
					success = false;
					tries++;
				}
			} while (!success && tries < 3);

			if(tries >= 3)
				throw new InvalidOperationException("Something weird happened initializing this NPC.");

			m_chatBubble = new EOChatBubble(this);
			m_damageCounter = new DamageCounter(this);
			_mouseoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = false,
				Text = Data.Name,
				ForeColor = Color.White,
				AutoSize = false,
				DrawOrder = (int) ControlDrawLayer.BaseLayer + 3
			};
			_mouseoverName.DrawLocation = new Vector2(
				DrawArea.X + (DrawArea.Width - _mouseoverName.ActualWidth)/2f,
				DrawArea.Y + TopPixel - _mouseoverName.ActualHeight - 4);
			_mouseoverName.ResizeBasedOnText();
		}
开发者ID:weedindeed,项目名称:EndlessClient,代码行数:53,代码来源:NPC.cs


注:本文中的Color.Any方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。