public void CheckWizardCollisions(Wizard wizard, GameTime gameTime) { fireballs.ForEach(f => { if (f == null) { return; } var radiusAdded = f.radius + wizard.radius; if (Vector2.Distance(f.GetPosition(), wizard.GetPosition()) < radiusAdded - 30f) { wizard.ApplyHealth(-f.damage); fireballRemovals.Add(f); Fireball newFireball = spawner.Spawn(game); newFireball.LoadContent(); fireballAdditions.Add(newFireball); BuildFireballSplash(gameTime, f.GetPosition()); PlaySplashSoundEffect(); } }); fireballs.RemoveAll(f => fireballRemovals.Contains(f)); fireballs.AddRange(fireballAdditions); ClearLists(); }
public override void Update(GameTime gameTime) { fireballs.ForEach(f => f.Update(gameTime)); fireballs.ForEach(f => { if (f.offScreen) { fireballRemovals.Add(f); Fireball newFireball = spawner.Spawn(game); newFireball.LoadContent(); fireballAdditions.Add(newFireball); } }); fireballs.RemoveAll(f => fireballRemovals.Contains(f)); fireballs.AddRange(fireballAdditions); ClearLists(); }
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); }