Esempio n. 1
0
        /// <summary>
        /// Collect requests from clients.
        /// </summary>
        /// <param name="gamers">List of Clients.</param>
        public void serverReadPackets(GamerCollection <LocalNetworkGamer> gamers, GameTime time)
        {
            UInt64[] data = new UInt64[2];

            foreach (LocalNetworkGamer gamer in gamers)
            {
                while (gamer.IsDataAvailable)
                {
                    NetworkGamer sender;
                    gamer.ReceiveData(_reader, out sender);

                    if (sender.IsLocal)
                    {
                        return;
                    }

                    data[0] = (UInt64)_reader.ReadInt64();
                    data[1] = (UInt64)_reader.ReadInt64();
                    Command command = new Command(data);
                    // TODO: Get Player from PlayerList
                    if (NewCommandEvent != null)
                    {
                        NewCommandEvent.Invoke(this, new NewCommandEventArgs(command, time.TotalGameTime, new Player()));
                    }
                }
            }
        }
Esempio n. 2
0
        public void updateBuffer(GameTime elps)
        {
            byte[] rawCmd = new byte[16];

            fileReader.Read(rawCmd, lastCmd, 16);
            lastCmd++;

            ulong first = 0;

            for (int i = 0; i < 8; i++)
            {
                first <<= 8;
                first  |= rawCmd[i];
            }
            ulong second = 0;

            for (int i = 0; i < 8; i++)
            {
                second <<= 8;
                first   |= rawCmd[i + 8];
            }

            ulong [] cmdDat = new ulong[2];
            cmdDat[0] = first;
            cmdDat[1] = second;

            Command cmd = new Command(cmdDat);

            if (NewCommandEvent != null)
            {
                NewCommandEvent.Invoke(this, new NewCommandEventArgs(cmd));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Handler for the add unit button.
        /// </summary>
        /// <param name="sender">Object that triggered the event.</param>
        /// <param name="args">Arguments for the AddButtonClicked Event.</param>
        private void AddHandler(object sender, EventArgs args)
        {
            Command        command;
            GameObjectType type = GameObjectFactory.The.getType("TestUnit");

            foreach (ActiveGameObject o in _selectedObjects)
            {
                command = new AddDecorator(o.ID, 0, type.ID, new TimeSpan(), new Command());
                if (NewCommandEvent != null)
                {
                    NewCommandEvent.Invoke(this, new NewCommandEventArgs(command));
                }
            }
        }