public void ItemAdd(Point p, Loot s) { _affichage.ItemAdd(p, s); if (_liaison.IsFinRechercheServer()) { ObjectInstruction data = new ObjectInstruction(new DataPosition(s, p), "item", "add"); _liaison.SendData(data); System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ItemAdd {1}, {2} : Envoi", IsServer(), p, s)); } }
public void ItemRemove(Point p) { System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ItemRemove {1}", IsServer(), p)); _items.Remove(p); _affichage.ItemRemove(p); if (_liaison.IsServer()) { ObjectInstruction data = new ObjectInstruction(p, "item", "remove"); _liaison.SendData(data); System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ItemRemove {1} : Envoi aux clients", IsServer(), p)); } }
private void PositionChanged(int x, int y) { System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.PositionChanged : X {1}, Y {2}", IsServer(), x, y)); Point p = new Point(x, y); if (_liaison.IsServer()) // Si on est le server { ObjectInstruction data = new ObjectInstruction(p, "player", "move"); _liaison.SendData(data); // Si il y a des clients, on leur envoi sa position if (_items.Contains(p)) { System.Diagnostics.Debug.WriteLine(string.Format("{0} : ITEM ! : {1}", IsServer(), _items[p])); ItemEffect((Loot)_items[p]); ItemRemove(p); } } else // Si on est un client { ObjectInstruction data = new ObjectInstruction(p, "player", "move"); _liaison.SendData(data); // On leur envoi sa position au server } }
private void ReceptionObjectInstruction(string sender, ObjectInstruction data) { if (data.Type == "item") { if (data.Instruction == "add") { DataPosition dp = (DataPosition)data.Data; System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ReceptionObjectInstruction : Item add : X {1}, Y {2}", IsServer(), dp.Position.X, dp.Position.Y)); _affichage.ItemAdd(dp.Position, (Loot)dp.Data); } else if (data.Instruction == "remove") { Point p = (Point)data.Data; System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ReceptionObjectInstruction : Item remove : X {1}, Y {2}", IsServer(), p.X, p.Y)); ItemRemove(p); } } else if (data.Type == "player") { if (data.Instruction == "move") { System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ReceptionObjectInstruction : Player move", IsServer())); ReceptionPlayer(sender, (Point)data.Data); } } else if (data.Type == "effect") { System.Diagnostics.Debug.WriteLine(string.Format("{0} : Gestion.ReceptionObjectInstruction : effect {1}", IsServer(), data.Instruction)); if (data.Instruction == "addVitesse") { PersoVitesse++; } else if (data.Instruction == "addVision") { _affichage.WarfogSet(_affichage.WarfogGet() + 1); } } }