public Client(RenderWindow window, ImageManager imageManager) : base(window, imageManager) { this.window = window; world = new RenderImage(800, 600); inputManager = new InputManager(this); ticker = new Ticker(); window.ShowMouseCursor (false); window.SetFramerateLimit (60); NetPeerConfiguration netConfiguration = new NetPeerConfiguration("2dThing"); client = new NetClient(netConfiguration); uMsgBuffer = new UserMessageBuffer(); otherClients = new Dictionary<int, NetworkClient>(); chat = new Chat(this); LoadRessources(); blockTypeDisplay = new Cube(blockType, imageManager); blockTypeDisplay.Position = new Vector2f(window.Width - 2*Cube.WIDTH, window.Height - 2* Cube.HEIGHT); layerDisplay = new LayerDisplay(imageManager); layerDisplay.Position = blockTypeDisplay.Position - new Vector2f(0, 50); mouse = new Sprite (imageManager.GetImage("mouse")); }
public void AddCube(Cube b) { if (child != null) { foreach (QuadTreeNode c in child) { if (c.range.Intersects(b.Bbox)) { c.AddCube(b); } } } else if (cubeList.Count < capacity) { cubeList.Add(b); } else { this.Explode(); this.AddCube(b); } }
public bool AddCube(Vector2f pos, int type, int layer) { Vector2f gridPos = new Vector2f((float)Math.Floor((pos.X / Cube.WIDTH)) * Cube.WIDTH, (float)Math.Floor((pos.Y / Cube.HEIGHT)) * Cube.HEIGHT); Cube cube = new Cube(type, imageManager); cube.Position = gridPos; bool exist = false; foreach (Cube c in quadTrees[layer].GetList(cube.Bbox)) if (c.Bbox.Intersects(cube.Bbox)) exist = true; foreach (Player p in playerList) if (p.Bbox.Intersects(cube.Bbox) && p.Layer == layer) exist = true; if (!exist) { cubeLists[layer].Add(cube); quadTrees[layer].AddCube(cube); } return !exist; }
public void ForceAddCube(Vector2f pos, int type, int layer) { Vector2f gridPos = new Vector2f((float)Math.Floor((pos.X / Cube.WIDTH)) * Cube.WIDTH, (float)Math.Floor((pos.Y / Cube.HEIGHT)) * Cube.HEIGHT); Cube cube = new Cube(type, imageManager); cube.Position = gridPos; cubeLists[layer].Add(cube); quadTrees[layer].AddCube(cube); }
public void RemoveCube(Cube b) { root.Remove(b); }
public void AddCube(Cube b) { root.AddCube(b); }
public void Remove(Cube b) { if (child != null) { foreach (QuadTreeNode c in child) { if (c.range.Intersects(b.Bbox)) c.Remove(b); } } else cubeList.Remove(b); }