Exemple #1
0
        Move matchInputsToMoveList(Input input)
        {
            Move        resultingMove = null;
            List <Move> possibleMoves = Player.Character.MoveList
                                        .Where(w => w.Command.ActivatesOn == input)
                                        .OrderByDescending(o => o.Priority)
                                        .ToList();

            if (possibleMoves.Count > 0)
            {
                // Brute force approach for now...
                foreach (Move move in possibleMoves)
                {
                    if (isMoveInBuffer(move))
                    {
                        resultingMove = move;
                        if (move.FlushBuffer)
                        {
                            buffer.Clear();
                        }
                        break;
                    }
                }
            }

            return(resultingMove);
        }
Exemple #2
0
 public void ClearUndoHistory()
 {
     lock (m_syncRoot)
     {
         m_undoSteps.Clear();
         m_redoSteps.Clear();
     }
 }
Exemple #3
0
    public int Send(CSMsgC msg)
    {
        if (!sendQueue.Enqueue(msg))
        {
            sendQueue.Clear();
            sendQueue.Enqueue(msg);
        }

        return(0);
    }
        public void CanClear_Test()
        {
            CircularQueue <int> queue = new CircularQueue <int>(55)
            {
                0, 222, 2321
            };

            queue.Clear();

            Assert.IsTrue(queue.IsEmpty());
        }
Exemple #5
0
        public void CircularQueueClear()
        {
            var queue = new CircularQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            Assert.AreEqual(queue.Count, 2);
            queue.Clear();
            Assert.AreEqual(queue.Count, 0);
            Assert.IsFalse(queue.Contains(1));
            Assert.IsFalse(queue.Contains(2));
        }
        public void IsEmptyExample()
        {
            var circularQueue = new CircularQueue <string>(10);

            // CircularQueue will be empty initially
            Assert.IsTrue(circularQueue.IsEmpty);

            circularQueue.Enqueue("cat");

            // CircularQueue will be not be empty when an item is added
            Assert.IsFalse(circularQueue.IsEmpty);

            circularQueue.Clear();

            // CircularQueue will be empty when items are cleared
            Assert.IsTrue(circularQueue.IsEmpty);
        }
Exemple #7
0
    /// <summary>
    /// 停止所有线程
    /// </summary>
    public void StopAllThread()
    {
        mSendMsgQueue.Clear();
        mReceiveMsgQueue.Clear();
        if (mSendThread != null)
        {
            mSendWork = false;
            mSendThread.Join();
            mSendThread = null;
        }

        if (mReceiveThread != null)
        {
            mReceiveWork = false;
            mReceiveThread.Join();
            mReceiveThread = null;
        }
    }
Exemple #8
0
        public void Clear01()
        {
            var capacity = 4;
            var cq       = new CircularQueue <int>(capacity);

            Assert.AreEqual(capacity, cq.Capacity());
            for (int i = 0; i < 6; i++)
            {
                cq.Enqueue(i);
            }
            Assert.AreEqual(capacity, cq.Count());
            cq.Clear();
            Assert.AreEqual(0, cq.Count());
            for (int i = 0; i < 6; i++)
            {
                cq.Enqueue(i);
            }
            Assert.AreEqual(capacity, cq.Count());
        }
        public void ClearExample()
        {
            var circularQueue = new CircularQueue<string>(10);
            circularQueue.Enqueue("cat");
            circularQueue.Enqueue("dog");
            circularQueue.Enqueue("canary");

            // There should be 3 items in the circularQueue.
            Assert.AreEqual(3, circularQueue.Count);

            // Clear the circularQueue
            circularQueue.Clear();

            // The circularQueue should be empty.
            Assert.AreEqual(0, circularQueue.Count);

            // No cat here..
            Assert.IsFalse(circularQueue.Contains("cat"));
        }
        public void ClearExample()
        {
            var circularQueue = new CircularQueue <string>(10);

            circularQueue.Enqueue("cat");
            circularQueue.Enqueue("dog");
            circularQueue.Enqueue("canary");

            // There should be 3 items in the circularQueue.
            Assert.AreEqual(3, circularQueue.Count);

            // Clear the circularQueue
            circularQueue.Clear();

            // The circularQueue should be empty.
            Assert.AreEqual(0, circularQueue.Count);

            // No cat here..
            Assert.IsFalse(circularQueue.Contains("cat"));
        }
Exemple #11
0
    void RecvThread()
    {
        IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, port);

        while (!terminate)
        {
            try
            {
                byte[] buffer = null;
                if (udpClient.Available > 0)
                {
                    buffer = udpClient.Receive(ref anyIP);
                }

                int usedSize = 0;
                if (null != buffer)
                {
                    CSMsgS             msg   = new CSMsgS();
                    TdrError.ErrorType error = msg.unpack(ref buffer, ref usedSize);
                    if (TdrError.ErrorType.TDR_NO_ERROR == error)
                    {
                        if (!recvQueue.Enqueue(msg))
                        {
                            recvQueue.Clear();
                            recvQueue.Enqueue(msg);
                        }
                    }
                    else
                    {
                        Debug.LogError("[NetworkUdp.RecvThread] unpack message failed.");
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("[NetworkUdp.RecvThread] recv exception: " + e.Message);
            }

            Thread.Sleep(1);
        }
    }
Exemple #12
0
        public void CircularQueueHeavyLoad()
        {
            var queue = new CircularQueue <int>(5);

            for (int repeats = 1; repeats <= 100; repeats++)
            {
                var values = Enumerable.Range(120, 100).Select(val => val % repeats).ToList();
                foreach (var value in values)
                {
                    queue.Enqueue(value);
                }
                Assert.AreEqual(queue.Count, values.Count);
                Assert.IsTrue(queue.Capacity >= values.Count);
                foreach (var value in values)
                {
                    Assert.AreEqual(queue.Dequeue(), value);
                }
                queue.Clear();
                queue.Resize(repeats % 10 + 1);
            }
        }
        public void IsEmptyExample()
        {
            var circularQueue = new CircularQueue<string>(10);

            // CircularQueue will be empty initially
            Assert.IsTrue(circularQueue.IsEmpty);

            circularQueue.Enqueue("cat");

            // CircularQueue will be not be empty when an item is added
            Assert.IsFalse(circularQueue.IsEmpty);

            circularQueue.Clear();

            // CircularQueue will be empty when items are cleared
            Assert.IsTrue(circularQueue.IsEmpty);
        }
Exemple #14
0
 public void Clear()
 {
     dataCache.Clear();
 }