Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 public void RemoveCube(Cube b)
 {
     root.Remove(b);
 }
Exemplo n.º 6
0
 public void AddCube(Cube b)
 {
     root.AddCube(b);
 }
Exemplo n.º 7
0
 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);
 }