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


C# Card.SetIndex方法代碼示例

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


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

示例1: MoveCardAt

        public void MoveCardAt(Player player, Card card, int x, int y, int idx, bool faceUp)
        {
            // Get the table control
            Table table = Program.GameEngine.Table;
            // Because every player may manipulate the table at the same time, the index may be out of bound
            if (card.Group == table)
            { if (idx >= table.Count) idx = table.Count - 1; }
            else
                if (idx > table.Count) idx = table.Count;

            // Ignore cards moved by the local player (already done, for responsiveness)
            if (player == Player.LocalPlayer)
            {
                // See remark in MoveCard
                if (card.Group == table)
                    card.SetIndex(idx); // This is done to preserve stack order consistency with other players (should be a noop most of the time)
                return;
            }
            // Find the old position on the table, if any
            //bool onTable = card.Group == table;
            //double oldX = card.X, oldY = card.Y;
            // Do the move
            new MoveCard(player, card, x, y, idx, faceUp).Do();
        }
開發者ID:Kamalisk,項目名稱:OCTGN,代碼行數:24,代碼來源:ClientHandler.cs

示例2: MoveCard

 public void MoveCard(Player player, Card card, Group to, int idx, bool faceUp)
 {
     // Ignore cards moved by the local player (already done, for responsiveness)
     if (player != Player.LocalPlayer)
         new MoveCard(player, card, to, idx, faceUp).Do();
     else
     {
         // Fix: cards may move quickly locally from one group to another one, before we get a chance
         // to execute this handler, during game actions scripts (e.g. Mulligan with one player -
         // shuffling happens locally). The result is that we are going to receive two messages,
         // one for the move to group A, then the move to group B; while the card already is in group B.
         // In this case, trying to set index inside group B with an index coming from the time the card
         // was in group A is just plain wrong and may crash depending on the index.
         if (card.Group == to)
             card.SetIndex(idx); // This is done to preserve stack order consistency with other players (should be a noop most of the time)
     }
 }
開發者ID:Kamalisk,項目名稱:OCTGN,代碼行數:17,代碼來源:ClientHandler.cs


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