示例#1
0
        /// <summary>
        /// Перенес из класса Машина
        /// забыл зачем
        /// </summary>
        protected internal void GetAction()
        {
            try
            {
                while (true)
                {
                    byte[] data = new byte[1024];
                    do
                    {
                        networkStream.Read(data, 0, data.Length);
                        machines2.Player = (ObjectAction)Serialization.Serialization.ByteArrayToObject(data);
                    } while (networkStream.DataAvailable);

                    machines2.Orientation(machines2.Player.keys);

                    this.Invoke(new Action(() =>
                    {
                        this.machines2.picture.Location = new Point(this.machines2.Player.X, this.machines2.Player.Y);
                        this.Invalidate();
                    }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " GetAction");
            }
        }
示例#2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys keys = e.KeyData;

            machines1.Player.keys = e.KeyData;
            SendAction();
            machines1.Orientation(keys);
            machines1.picture.Location = new Point(machines1.Player.X, machines1.Player.Y);
        }
示例#3
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Space || e.KeyData == Keys.Up || e.KeyData == Keys.Down || e.KeyData == Keys.Right || e.KeyData == Keys.Left)
            {
                if (e.KeyData == Keys.Space)
                {
                    if (machines1.Player.Up)
                    {
                        Bomb.Add(new Shells(machines1, Keys.Up)); machines1.Player.KeysShot = Keys.Up;
                    }
                    if (machines1.Player.Down)
                    {
                        Bomb.Add(new Shells(machines1, Keys.Down)); machines1.Player.KeysShot = Keys.Down;
                    }
                    if (machines1.Player.Righ)
                    {
                        Bomb.Add(new Shells(machines1, Keys.Right)); machines1.Player.KeysShot = Keys.Right;
                    }
                    if (machines1.Player.Left)
                    {
                        Bomb.Add(new Shells(machines1, Keys.Left)); machines1.Player.KeysShot = Keys.Left;
                    }
                    machines1.Player.KeysShot = e.KeyData;

                    machines1.Player.Shot = true;
                }
                else if (e.KeyData != Keys.Space)
                {
                    machines1.Player.KeysMove = e.KeyData;
                    SendAction();
                    machines1.Orientation(e.KeyData);
                }
                SendAction();
                machines1.Player.Shot      = false;
                machines1.picture.Location = new Point(machines1.Player.X, machines1.Player.Y);
            }
        }