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


C# Player.Where方法代码示例

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


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

示例1: RevealTo

        /// <summary>Reveal a card's identity to one player only.</summary>
        /// <param name="players"> </param>
        /// <param name="card">The card, whose identity is revealed.</param>
        /// <param name="encrypted">Either a ulong[2] containing an encrypted aliased CardIdentity id. Or a ulong[5] containing an encrypted CardModel guid.</param>
        public void RevealTo(Player[] players, Card card, ulong[] encrypted)
        {
            var oldType = card.Type;
            ulong alias = 0;
            Guid id = Guid.Empty;
            players = players.Where(x => x != null).ToArray();
            switch (encrypted.Length)
            {
                case 2:
                    alias = Crypto.Decrypt(encrypted);
                    break;
                case 5:
                    id = Crypto.DecryptGuid(encrypted);
                    break;
                default:
                    Program.TraceWarning("[RevealTo] Invalid data received.");
                    return;
            }

            if (!players.All(p => (card.Group.Visibility == DataNew.Entities.GroupVisibility.Custom && card.Group.Viewers.Contains(p)) ||
                                  card.PlayersLooking.Contains(p) || card.PeekingPlayers.Contains(p)))
                Program.TraceWarning("[RevealTo] Revealing a card to a player, who isn't allowed to see it. This indicates a bug or cheating.");

            // If it's an alias, we must revealed it to the final recipient
            bool sendToMyself = true;
            if (alias != 0)
            {
                sendToMyself = false;
                CardIdentity ci = CardIdentity.Find((int)alias);
                if (ci == null)
                { Program.TraceWarning("[RevealTo] Identity not found."); return; }

                // If the revealed type is an alias, pass it to the one who owns it to continue the RevealTo chain.
                if (ci.Alias)
                {
                    Player p = Player.Find((byte)(ci.Key >> 16));
                    Program.Client.Rpc.RevealToReq(p, players, card, Crypto.Encrypt(ci.Key, p.PublicKey));
                }
                // Else revealed the card model to the ones, who must see it
                else
                {
                    Player[] pArray = new Player[1];
                    foreach (Player p in players)
                        if (p != Player.LocalPlayer)
                        {
                            pArray[0] = p;
                            Program.Client.Rpc.RevealToReq(p, pArray, card, Crypto.Encrypt(ci.Model.Id, p.PublicKey));
                        }
                        else
                        {
                            sendToMyself = true;
                            id = ci.Model.Id;
                        }
                }
            }
            // Else it's a type and we are the final recipients
            if (!sendToMyself) return;
            if (card.Type.Model == null)
                card.SetModel(Program.GameEngine.Definition.GetCardById(id));
            // Raise a notification
            oldType.OnRevealed(card.Type);
        }
开发者ID:Kamalisk,项目名称:OCTGN,代码行数:66,代码来源:ClientHandler.cs


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