public Fireball(World world, FireballDirection direction) : base(world, EntityType.FIREBALL) { this.dir = direction; isHorizontal = (direction == FireballDirection.HORIZONTAL); Velocity = new Vector2(0, 0); Direction = isHorizontal ? new Vector2(1, 0) : new Vector2(0, 1); Position = isHorizontal ? new Vector2(0, random.Next(4, 64) * 32) : new Vector2(random.Next(4, 80) * 32, 0); velPerSecond = random.Next(200, 360); boundBox.Width = isHorizontal ? 12 : 20; boundBox.Height = isHorizontal ? 18 : 14; xOffset = isHorizontal ? 12 : 8; yOffset = isHorizontal ? 8 : 12; }
public void Update() { NetIncomingMessage inMsg; while ((inMsg = client.ReadMessage()) != null) { switch (inMsg.MessageType) { case NetIncomingMessageType.Data: string dataType = inMsg.ReadString(); if (dataType.Equals("newplayer")) { Player p = new Player(world); string username = inMsg.ReadString(); int id = inMsg.ReadInt32(); if (players[id] != null) { Console.WriteLine("Aboooov {0} {1}", id, username); break; } float x = inMsg.ReadFloat(); float y = inMsg.ReadFloat(); p.Position = new Vector2(x, y); p.Username = username; p.IsPrimary = false; p.LoadContent(); world.entities.Add(p); players[id] = p; Console.WriteLine(players[id] + " Abidin gubidin"); } else if (dataType.Equals("move")) { string username = inMsg.ReadString(); int id = inMsg.ReadInt32(); if (players[id] != null) { Player p = players[id]; float x = inMsg.ReadFloat(); float y = inMsg.ReadFloat(); int animNum = inMsg.ReadInt32(); p.CurAnim = p.GetAnimByAnimNum(animNum); Vector2 newPos = new Vector2(x, y); p.Position = newPos; } else { Console.WriteLine("Yok artık daha neler :::::: {0} ,,,,,, {1}", username, id); } } else if (dataType.Equals("fireball")) { int dir = inMsg.ReadInt32(); FireballDirection fbdir = dir == 0 ? FireballDirection.HORIZONTAL : FireballDirection.VERTICAL; Fireball fb = new Fireball(world, fbdir); fb.Position.X = inMsg.ReadInt32(); fb.Position.Y = inMsg.ReadInt32(); fb.LoadContent(); world.entities.Add(fb); } else if (dataType.Equals("laser")) { int dir = inMsg.ReadInt32(); LaserDirection ldir = dir == 0 ? LaserDirection.HORIZONTAL : LaserDirection.VERTICAL; Laser l = new Laser(world, ldir); l.Position.X = inMsg.ReadInt32(); l.Position.Y = inMsg.ReadInt32(); l.LoadContent(); world.entities.Add(l); } break; } } client.Recycle(inMsg); }