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


C# Group.AddAt方法代码示例

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


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

示例1: CreateCard

        /// <summary>Creates new Cards as well as the corresponding CardIdentities. All cards are created in the same group.</summary>
        /// <param name="id">An array with the new CardIdentity ids.</param>
        /// <param name="type">An array containing the corresponding CardModel guids (encrypted)</param>
        /// <param name="group">The group, in which the cards are added.</param>
        /// <seealso cref="CreateCard(int[], ulong[], Group[])"> to add cards to several groups</seealso>
        public void CreateCard(int[] id, ulong[] type, Group group)
        {
            Player owner = Player.Find((byte)(id[0] >> 16));
            if (owner == null)
            {
                Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[CreateCard] Player not found.");
                return;
            }
            //var c = new Card(owner,id[0], type[0], Program.Game.Definition.CardDefinition, null, false);
            var c = Card.Find(id[0]);

            Program.TracePlayerEvent(owner, "{0} creates {1} {2} in {3}'s {4}", owner.Name, id.Length, c == null ? "card" : c.Name, group.Owner.Name,group.Name);
            // Ignore cards created by oneself
            if (owner == Player.LocalPlayer) return;
            for (int i = 0; i < id.Length; i++)
            {
                //Card c = new Card(owner, id[i], type[i], Program.Game.Definition.CardDefinition, null, false);
                //group.AddAt(c, group.Count);
                var card = new Card(owner,id[i], type[i], null, false);
                group.AddAt(card, group.Count);
            }
        }
开发者ID:Kamalisk,项目名称:OCTGN,代码行数:27,代码来源:ClientHandler.cs

示例2: CreateCard

 /// <summary>Creates new Cards as well as the corresponding CardIdentities. All cards are created in the same group.</summary>
 /// <param name="id">An array with the new CardIdentity ids.</param>
 /// <param name="type">An array containing the corresponding CardModel guids (encrypted)</param>
 /// <param name="group">The group, in which the cards are added.</param>
 /// <seealso cref="CreateCard(int[], ulong[], Group[])"> to add cards to several groups</seealso>
 public void CreateCard(int[] id, ulong[] type, Group group)
 {
     Player owner = Player.Find((byte)(id[0] >> 16));
     if (owner == null)
     {
         Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[CreateCard] Player not found.");
         return;
     }
     // Ignore cards created by oneself
     if (owner == Player.LocalPlayer) return;
     for (int i = 0; i < id.Length; i++)
     {
         Card c = new Card(owner, id[i], type[i], Program.Game.Definition.CardDefinition, null, false);
         group.AddAt(c, group.Count);
     }
 }
开发者ID:TheWicked,项目名称:OCTGN,代码行数:21,代码来源:ClientHandler.cs

示例3: Shuffled

 /// <summary>Part of a shuffle process.</summary>
 /// <param name="group">The group being shuffled.</param>
 /// <param name="card">An array containing the CardIdentity ids to shuffle.</param>
 //public void Shuffle(Group group, int[] card)
 //{
 //    // Array to hold the new aliases (sent to CreateAlias)
 //    ulong[] aliases = new ulong[card.Length];
 //    // Intialize the group shuffle
 //    group.FilledShuffleSlots = 0;
 //    group.HasReceivedFirstShuffledMessage = false;
 //    group.MyShufflePos = new short[card.Length];
 //    // Check if we received enough cards
 //    if (Player.Count - 1 <= 0) return;
 //    if (card.Length < group.Count / (Player.Count - 1))
 //        Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Shuffle] Too few cards received.");
 //    // Do the shuffling
 //    var rnd = new CryptoRandom();
 //    for (int i = card.Length - 1; i >= 0; i--)
 //    {
 //        int r = rnd.Next(i + 1);
 //        int tc = card[r];
 //        card[r] = card[i];
 //        // Create a new alias, if the card is not face up
 //        CardIdentity ci = CardIdentity.Find(tc);
 //        if (group.FindByCardIdentity(ci) != null)
 //        {
 //            card[i] = tc; aliases[i] = ulong.MaxValue;
 //            ci.Visible = true;
 //        }
 //        else
 //        {
 //            ci = new CardIdentity(ExtensionMethods.GenerateCardId());
 //            ci.MySecret = ci.Alias = true;
 //            ci.Key = ((ulong)Crypto.PositiveRandom()) << 32 | (uint)tc;
 //            card[i] = ci.Id; aliases[i] = Crypto.ModExp(ci.Key);
 //            ci.Visible = false;
 //        }
 //        // Give a random position to the card
 //        group.MyShufflePos[i] = (short)Crypto.Random(group.Count);
 //    }
 //    // Send the results
 //    Program.Client.Rpc.CreateAlias(card, aliases);
 //    Program.Client.Rpc.Shuffled(group, card, group.MyShufflePos);
 //}
 public void Shuffled(Group group, int[] card, short[] pos)
 {
     // Check the args
     if (card.Length != pos.Length)
     {
         Program.TraceWarning("[Shuffled] Cards and positions lengths don't match.");
         return;
     }
     // Insert the cards
     for (int j = 0; j < card.Length; j++)
     {
         // Get the wished position
         int i = pos[j];
         // Get the card
         CardIdentity ci = CardIdentity.Find(card[j]);
         if (ci == null)
         {
             Program.TraceWarning("[Shuffled] Card not found.");
             continue;
         }
         // Check if the slot is free, otherwise choose the first free one
         //if (i >= group.Count || group[i].Type != null) i = group.FindNextFreeSlot(i);
         //if (i >= group.Count) continue;
         // Set the type
         //group[i].Type = ci;
         var mcard = group[j];
         group.Remove(group[j]);
         group.AddAt(mcard, i);
         group[i].SetVisibility(ci.Visible ? DataNew.Entities.GroupVisibility.Everybody : DataNew.Entities.GroupVisibility.Nobody, null);
     }
     group.OnShuffled();
 }
开发者ID:karlnp,项目名称:OCTGN,代码行数:76,代码来源:ClientHandler.cs

示例4: CreateCard

        /// <summary>Creates new Cards as well as the corresponding CardIdentities. All cards are created in the same group.</summary>
        /// <param name="id">An array with the new CardIdentity ids.</param>
        /// <param name="type">An array containing the corresponding CardModel guids (encrypted)</param>
        /// <param name="group">The group, in which the cards are added.</param>
        /// <seealso cref="CreateCard(int[], ulong[], Group[])"> to add cards to several groups</seealso>
        public void CreateCard(int[] id, Guid[] type, string[] size, Group group)
        {
            if (Player.Find((byte)(id[0] >> 16)) == Player.LocalPlayer) return;
            for (int i = 0; i < id.Length; i++)
            {
                Player owner = group.Owner;
                if (owner == null)
                {
                    Program.GameMess.Warning("[CreateCard] Player not found.");
                    return;
                }
                //var c = new Card(owner,id[0], type[0], Program.Game.Definition.CardDefinition, null, false);
                var c = Card.Find(id[0]);

                Program.GameMess.PlayerEvent(owner, "{0} creates {1} {2} in {3}'s {4}", owner.Name, id.Length, c == null ? "card" : (object)c, group.Owner.Name, group.Name);
                // Ignore cards created by oneself

                //Card c = new Card(owner, id[i], type[i], Program.Game.Definition.CardDefinition, null, false);
                //group.AddAt(c, group.Count);
                var card = new Card(owner, id[i], Program.GameEngine.Definition.GetCardById(type[i]), false, size[i]); group.AddAt(card, group.Count);
            }
        }
开发者ID:rexperalta,项目名称:OCTGN,代码行数:27,代码来源:ClientHandler.cs

示例5: Shuffled

        /// <summary>Part of a shuffle process.</summary>
        /// <param name="group">The group being shuffled.</param>
        /// <param name="card">An array containing the CardIdentity ids to shuffle.</param>
        //public void Shuffle(Group group, int[] card)
        //{
        //    // Array to hold the new aliases (sent to CreateAlias)
        //    ulong[] aliases = new ulong[card.Length];
        //    // Intialize the group shuffle
        //    group.FilledShuffleSlots = 0;
        //    group.HasReceivedFirstShuffledMessage = false;
        //    group.MyShufflePos = new short[card.Length];
        //    // Check if we received enough cards
        //    if (Player.Count - 1 <= 0) return;
        //    if (card.Length < group.Count / (Player.Count - 1))
        //        Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Shuffle] Too few cards received.");
        //    // Do the shuffling
        //    var rnd = new CryptoRandom();
        //    for (int i = card.Length - 1; i >= 0; i--)
        //    {
        //        int r = rnd.Next(i + 1);
        //        int tc = card[r];
        //        card[r] = card[i];
        //        // Create a new alias, if the card is not face up
        //        CardIdentity ci = CardIdentity.Find(tc);
        //        if (group.FindByCardIdentity(ci) != null)
        //        {
        //            card[i] = tc; aliases[i] = ulong.MaxValue;
        //            ci.Visible = true;
        //        }
        //        else
        //        {
        //            ci = new CardIdentity(ExtensionMethods.GenerateCardId());
        //            ci.MySecret = ci.Alias = true;
        //            ci.Key = ((ulong)Crypto.PositiveRandom()) << 32 | (uint)tc;
        //            card[i] = ci.Id; aliases[i] = Crypto.ModExp(ci.Key);
        //            ci.Visible = false;
        //        }
        //        // Give a random position to the card
        //        group.MyShufflePos[i] = (short)Crypto.Random(group.Count);
        //    }
        //    // Send the results
        //    Program.Client.Rpc.CreateAlias(card, aliases);
        //    Program.Client.Rpc.Shuffled(group, card, group.MyShufflePos);
        //}
        public void Shuffled(Group group, int[] card, short[] pos)
        {
            // Check the args
            if (card.Length != pos.Length)
            {
                Program.TraceWarning("[Shuffled] Cards and positions lengths don't match.");
                return;
            }
            //Build the Dict. of new locations
            var shuffled = new Dictionary<int, Card>();
            for (int i = 0; i < card.Length; i++)
            {
                shuffled.Add(pos[i],group[i]);
                // Get the card
                CardIdentity ci = CardIdentity.Find(card[i]);
                if (ci == null)
                {
                    Program.TraceWarning("[Shuffled] Card not found.");
                    continue;
                }
                group[i].SetVisibility(ci.Visible ? DataNew.Entities.GroupVisibility.Everybody : DataNew.Entities.GroupVisibility.Nobody, null);
            }
            //Move cards to their new indexes
            for (int i = 0; i < card.Length; i++)
            {
                group.Remove(shuffled[i]);
                group.AddAt(shuffled[i], i);
            }

            group.OnShuffled();
        }
开发者ID:vanzeeaj,项目名称:OCTGN,代码行数:75,代码来源:ClientHandler.cs


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