public ClienteRede(Tanque t, string ip, int port) { Porto = port; Tanque = t; Ip = ip; client = new TcpClient(Ip, Porto); }
public ServidorRede(Tanque tanque,int port) { Port = port; try { listener = new TcpListener(IPAddress.Any, Port); listener.Start(); } catch (SocketException e) { Environment.Exit(e.ErrorCode); } Tanque = tanque; }
public ServidorRede(Tanque tanque, int port) { Port = port; try { listener = new TcpListener(IPAddress.Any, Port); listener.Start(); } catch (SocketException e) { Environment.Exit(e.ErrorCode); } Tanque = tanque; }
public TelaDeJogo(int numeroDoTanque, string ip, int porto) { InitializeComponent(); Porto = porto; areaDeDesenho = new Bitmap(DimensaoDaTelaX, DimensaoDaTelaY); //Cria a área de desenho; pictureBox1.Image = areaDeDesenho; //Manda a região delimitada no Design do Visual mostrar nossa área de desenho; desenhista = Graphics.FromImage(areaDeDesenho); //Diz onde o desenhista desenha. Sprites = new List <ProtoSprite>(); Tanque1 = new Tanque(40, 275, 0, this); Tanque2 = new Tanque(710, 275, 2, this); Sprites.Add(Tanque1); Sprites.Add(Tanque2); for (int v = 0; v < 10; v++) { Sprites.Add(new Obstaculo(350, 50 * v, 50, 50, this)); } IP = ip; tanqueLocal = numeroDoTanque; t = new Thread(CriaRede); t.Start(); clockUpdate = new System.Windows.Forms.Timer(); clockUpdate.Tick += Update; clockUpdate.Interval = 5; clockUpdate.Start(); clockRefresh = new System.Windows.Forms.Timer(); clockRefresh.Tick += Draw; clockRefresh.Interval = 4; clockRefresh.Start(); clockAnimation = new System.Windows.Forms.Timer(); clockAnimation.Tick += AnimateAll; clockAnimation.Interval = 80; clockAnimation.Start(); }
public GerenciadorDeRede(Tanque tanque,int port,string ip,bool isClient) { Port = port; Tanque = tanque; if (isClient) { Ip = ip; client = new TcpClient(Ip, Port); } else { try { listener = new TcpListener(IPAddress.Any, Port); listener.Start(); } catch (SocketException e) { Environment.Exit(e.ErrorCode); } } FilaDeMensagens = new Queue<byte[]>(); }
private void InicializaObjetos() { Sprites = new List<ProtoSprite>(); SpritesASeremDeletados = new List<ProtoSprite>(); Tanque1 = new Tanque(0, 0.6f, 2, this, DimensaoDaTelaX, DimensaoDaTelaY); Tanque2 = new Tanque(0.95f, 0.6f, 2, this, DimensaoDaTelaX, DimensaoDaTelaY); Bandeira1 = new Bandeira(0.02f, 0.85f,1); Bandeira2 = new Bandeira(0.95f, 0.2f,2); PowerUp = new PowerUp(0.5f - 0.05f, 0.55f - 0.05f); Sprites.Add(Bandeira1); Sprites.Add(Bandeira2); Sprites.Add(PowerUp); Sprites.Add(Tanque1); Sprites.Add(Tanque2); for (int v = 0; v < 10; v++) { Sprites.Add(new Obstaculo(0.15f, 0.1f + 0.09f * v, this,1,1,(short)(v+1))); Sprites.Add(new Obstaculo(0.16f, 0.1f + 0.09f * v, this,1, 2, (short)(v + 1))); Sprites.Add(new Obstaculo(0.85f, 0.1f + 0.09f * v, this, 2, 1, (short)(v + 1))); Sprites.Add(new Obstaculo(0.86f, 0.1f + 0.09f * v, this, 2, 2, (short)(v + 1))); Sprites.Add(new Obstaculo(0.30f, 0.1f + 0.09f * v, this, 3, 1, (short)(v + 1))); Sprites.Add(new Obstaculo(0.31f, 0.1f + 0.09f * v, this, 3, 2, (short)(v + 1))); Sprites.Add(new Obstaculo(0.70f, 0.1f + 0.09f * v, this, 4, 1, (short)(v + 1))); Sprites.Add(new Obstaculo(0.71f, 0.1f + 0.09f * v, this, 4, 2, (short)(v + 1))); } }
public Tanque outroTanque(Tanque t) { if (t.Equals(Tanque1)) { return Tanque2; }else{ return Tanque1; } }