コード例 #1
0
        private void ObjMgr_ObjReceived(object sender, P2PNET.ObjectLayer.EventArgs.ObjReceivedEventArgs e)
        {
            switch (e.Meta.ObjectType)
            {
            case "KeyMsg":
                KeyMsg keyMsg = e.Obj.GetObject <KeyMsg>();
                ProccessKeyMsg(keyMsg);
                break;

            case "HeartBeatMsg":
                break;

            default:
                Console.WriteLine("unknown file type");
                break;
            }
        }
コード例 #2
0
        public void ReceivedKeyMessage(KeyMsg keyMsg)
        {
            List <ushort> receivedKeys = keyMsg.keyValues;
            List <ushort> curKeys      = this.ReceivedKeys;

            //compaire to KeyPressed

            //find keys that have been released
            List <ushort> releasedKeys = GetMissingFromSecondList(curKeys, receivedKeys);

            foreach (ushort keyValue in releasedKeys)
            {
                eventMgr.TriggerKeyPress(keyValue, false);
                ReceivedKeys.Remove(keyValue);
            }

            //find keys that have just been pressed
            List <ushort> newPressedKeys = GetMissingFromSecondList(receivedKeys, curKeys);

            foreach (ushort keyValue in newPressedKeys)
            {
                eventMgr.TriggerKeyPress(keyValue, true);
                ReceivedKeys.Add(keyValue);
            }

            /*
             * foreach(ushort keyValue in receivedKeys)
             * {
             *  eventMgr.TriggerKeyPress(keyValue, true);
             * }
             */

            /*
             * Console.Write("Received: ");
             * foreach(ushort keyValue in ReceivedKeys)
             * {
             *  Console.Write(keyValue);
             * }
             * Console.WriteLine();
             */
        }
コード例 #3
0
        private void ProccessKeyMsg(KeyMsg keyMsg)
        {
            gameLoop.ReceivedKeyMessage(keyMsg);

            UpdateKeysDisplay();
        }