示例#1
0
文件: Cell.cs 项目: jjkl/AgarioServer
        public Cell(UInt32 ownerId, Socket socket, Byte[] name, Color color, UInt32 points, Vector direction, System.Windows.Point position)
            : base(ClientType.Cell)
        {
            this.OwnerID = ownerId;
            this.Score = points;
            this.Color = color;
            this.Direction = direction;
            this.Name = name;
            this.Position = position;

            this._socket = socket;
            this._socket.OnRecv += OnRecv;
            this._socket.OnDisconnect += OnDisconnect;

            this._timerSalt = new Timer(1000 / Config.IntervalPosition);
            this._timerSalt.Elapsed += MoveCell;
            this._timerSalt.Start();

            this._timer = new Timer(1000 / Config.IntervalPosition);
            this._timer.Elapsed += CalculateMovement;

            this.Connected = true;

            Packet32 p32 = new Packet32();
            p32.SetId(this.Id);
            this.Send(p32.ToByteArray());
        }
示例#2
0
文件: Cell.cs 项目: jjkl/AgarioServer
        public Cell(Socket socket)
            : base(ClientType.Cell)
        {
            this.OwnerID = this.Id;
            this.Score = 10;
            this.Connected = false;

            this._socket = socket;
            this._socket.OnRecv += OnRecv;
            this._socket.OnDisconnect += OnDisconnect;

            this._timer = new Timer(1000/Config.IntervalPosition);
            this._timer.Elapsed += CalculateMovement;

            Random rdm = new Random();
            this.Color = Color.FromKnownColor(Client.Colors[rdm.Next(Client.Colors.Length)]);
        }