Ejemplo n.º 1
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            _controlManager.Update(gameTime);

            if (((Actors.Controllers.CEditorInputController)_controlManager.root)._shutDown)
            {
                _componentEditor.Visible = false;
                _tileEditor.Visible      = false;
                Gears.Cloud.Master.Pop();
            }

            _selectedTiles[0] = _tileEditor.tileRect;

            if (((Actors.Controllers.CEditorNew)_controlManager.actors["btnNew"]).createNew)
            {
                layers = null;
                layers = new Map.CLayer[1];
            }

            if (((Actors.Controllers.CEditorInputController)_controlManager.root).dropTile)
            {
                Vector2 mouseCoords = new Vector2((Gears.Cloud.Master.GetInputManager().GetCurrentInputHandler() as Input.CInput).mouseX,
                                                  (Gears.Cloud.Master.GetInputManager().GetCurrentInputHandler() as Input.CInput).mouseY);

                if (mouseCoords.Y <= 64)
                {
                    return;
                }

                Map.CTile temp = new Map.CTile(new Vector2(_selectedTiles[0].X, _selectedTiles[0].Y), mouseCoords, _tileEditor.Controls["cmbTexture"].Text);
                layers[0].addTile(temp);
            }
        }
Ejemplo n.º 2
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            _controlManager.Update(gameTime);
            Input.CInput input = Gears.Cloud.Master.GetInputManager().GetCurrentInputHandler() as Input.CInput;

            if (_tileEditor.selectorChange)
            {
                _currentTileSet = new Graphics.CSprite(_tileEditor.Controls["cmbTexture"].Text, Graphics.CTextures.textures[_tileEditor.Controls["cmbTexture"].Text]);
            }

            if (((Actors.Controllers.CEditorInputController)_controlManager.root)._shutDown)
            {
                _componentEditor.Visible = false;
                _tileEditor.Visible      = false;
                Gears.Cloud.Master.Pop();
            }

            _selectedTiles = _tileEditor.tileRect;

            if (((Actors.Controllers.CEditorNew)_controlManager.actors["btnNew"]).createNew)
            {
                layers = null;
                layers = new Map.CLayer[1];
            }

            if (_tileEditor.tileSetChanged)
            {
                //apply the current tileSet to all tiles that use it
                foreach (Map.CLayer layer in layers)
                {
                    layer.updateTileSet(_currentTileSet);
                }
            }

            if (((Actors.Controllers.CEditorInputController)_controlManager.root).dropTile)
            {
                Vector2 mouseCoords = new Vector2(input.mouseX, input.mouseY);
                string  tileSet     = "";

                if (mouseCoords.Y <= 64)
                {
                    return;
                }

                //if (_tileEditor.Controls["cmbTexture"].Text == _tileEditor.defaultTileSet)
                //tileSet = null;
                //else
                tileSet = _tileEditor.Controls["cmbTexture"].Text;

                Map.CTile[,] temp = new Map.CTile[_selectedTiles.GetUpperBound(0) + 1, _selectedTiles.GetUpperBound(1) + 1];

                for (int i = 0; i < _selectedTiles.GetUpperBound(0) + 1; i++)
                {
                    for (int j = 0; j < _selectedTiles.GetUpperBound(1) + 1; j++)
                    {
                        temp[i, j] = new Map.CTile(new Vector2(_selectedTiles[i, j].X, _selectedTiles[i, j].Y), mouseCoords + new Vector2(i * _selectedTiles[0, 0].Width, j * _selectedTiles[0, 0].Height), tileSet);
                        layers[0].addTile(temp[i, j]);
                    }
                }



                if (!layers[0].otherImages.ContainsKey(_currentTileSet.atlasName))
                {
                    layers[0].otherImages.Add(_currentTileSet.atlasName, _currentTileSet);
                }
            }

            if (input.mouseRightClick)
            {
                Vector2 mouseCoords = new Vector2(input.mouseX, input.mouseY);
                int     index       = 0;

                if ((index = layers[0].indexOfTile(mouseCoords)) > -1)
                {
                    layers[0].removeTile(index);
                }
            }
        }