當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。