當前位置: 首頁>>代碼示例>>C#>>正文


C# PlayerMobile.Where方法代碼示例

本文整理匯總了C#中Server.Mobiles.PlayerMobile.Where方法的典型用法代碼示例。如果您正苦於以下問題:C# PlayerMobile.Where方法的具體用法?C# PlayerMobile.Where怎麽用?C# PlayerMobile.Where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Server.Mobiles.PlayerMobile的用法示例。


在下文中一共展示了PlayerMobile.Where方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DisplayStatus

        private static void DisplayStatus(PlayerMobile target, int offset, PlayerMobile[] cams)
        {
            if (target == null || !target.Alive || cams == null || cams.Length == 0)
            {
                return;
            }

            const int red = 44; // lower than green
            const int yellow = 54; // somewhere inbetween green and red
            const int green = 69; // greater than red

            string hLabel = String.Format("{0} / {1}", target.Hits, target.HitsMax); // hits
            int hHue = offset < 0 ? red : offset > 0 ? green : yellow;
                // negative offset = red, positive = green, neutral = yellow

            /*
            double percent = target.Hits / (double)target.HitsMax;

            string pLabel = String.Format("[{0}%]", percent * 100); // percent
            int pHue = (int)(red + (green - red) * percent); // interpolate between two hues
            */

            if (offset != 0)
            {
                hLabel += String.Format(" ({0}{1:#,0})", offset > 0 ? "+" : String.Empty, offset);
            }

            Timer.DelayCall(
                TimeSpan.FromSeconds(0.5),
                () =>
                {
                    foreach (PlayerMobile cam in cams.Where(cam => cam != null && !cam.Deleted && cam.NetState != null))
                    {
                        target.PrivateOverheadMessage(MessageType.Regular, hHue, true, hLabel, cam.NetState); // hits
                        //target.PrivateOverheadMessage(MessageType.Regular, pHue, true, pLabel, cam.NetState); // percent
                    }
                });
        }
開發者ID:greeduomacro,項目名稱:UO-Forever,代碼行數:38,代碼來源:ActionCams.cs

示例2: DisplayDamage

        private static void DisplayDamage(PlayerMobile target, int damage, PlayerMobile[] cams)
        {
            if (target == null || cams == null || cams.Length == 0)
            {
                return;
            }

            Packet pNew = null;
            Packet pOld = null;

            foreach (PlayerMobile cam in cams.Where(cam => cam != null && !cam.Deleted && cam.NetState != null))
            {
                if (cam.NetState.DamagePacket)
                {
                    if (pNew == null)
                    {
                        pNew = Packet.Acquire(new DamagePacket(target, damage));
                    }

                    cam.Send(pNew);
                }
                else
                {
                    if (pOld == null)
                    {
                        pOld = Packet.Acquire(new DamagePacketOld(target, damage));
                    }

                    cam.Send(pOld);
                }
            }
        }
開發者ID:greeduomacro,項目名稱:UO-Forever,代碼行數:32,代碼來源:ActionCams.cs


注:本文中的Server.Mobiles.PlayerMobile.Where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。