Ejemplo n.º 1
0
        private void PlaceTile()
        {
            int pickedX = mv.getMouseLoc.X;
            int pickedY = mv.getMouseLoc.Y;

            if (pickedX < 0 || pickedY < 0 || pickedX > picMapViewer.Width || pickedY > picMapViewer.Height)
                return;

            pickedX = mv.getMouseLoc.X + mv.xOffSet;
            pickedY = mv.getMouseLoc.Y + mv.yOffSet;

            if (chkEvent.Checked)
                return;

            if (chkBlock.Checked != true)
            {
                if (Map.myLayer.Count <= 0)
                    return;

                if (pickedX >= Map.maxX * Editor.Instance.curGame.TileX)
                    pickedX = Map.maxX * Editor.Instance.curGame.TileX - 1;
                if (pickedY >= Map.maxY * Editor.Instance.curGame.TileY)
                    pickedY = Map.maxX * Editor.Instance.curGame.TileY - 1;

                pickedX /= Editor.Instance.curGame.TileX;
                pickedY /= Editor.Instance.curGame.TileY;

                Tile _newTile = new Tile(Editor.Instance.tilesetPick.PickedX, Editor.Instance.tilesetPick.PickedY, pickedX, pickedY, Editor.Instance.tilesetPick.CurTS, Editor.Instance.curGame.TileX, Editor.Instance.curGame.TileY, 100);

                if (chkBackground.Checked == true)
                {
                    if ((int)_layerCache[lstLayer.SelectedIndex].MyLayer.GetValue(pickedX, pickedY) > -1)
                        Map.myLayer[lstLayer.SelectedIndex].setTile(_newTile, (int)_layerCache[lstLayer.SelectedIndex].MyLayer.GetValue(pickedX, pickedY));
                    else
                    {
                        Map.myLayer[lstLayer.SelectedIndex].addTile(_newTile);
                        _layerCache[lstLayer.SelectedIndex].MyLayer.SetValue(Map.myLayer[lstLayer.SelectedIndex].myTile.Count - 1, pickedX, pickedY);
                    }
                }
                else
                {
                    if ((int)_layerCache[lstLayer.SelectedIndex].MyMiniLayer[lstMini.SelectedIndex].GetValue(pickedX, pickedY) > -1)
                        Map.myLayer[lstLayer.SelectedIndex].MiniLayer[lstMini.SelectedIndex].setTile(_newTile, (int)_layerCache[lstLayer.SelectedIndex].MyMiniLayer[lstMini.SelectedIndex].GetValue(pickedX, pickedY));
                    else
                    {
                        Map.myLayer[lstLayer.SelectedIndex].MiniLayer[lstMini.SelectedIndex].addTile(_newTile);
                        _layerCache[lstLayer.SelectedIndex].MyMiniLayer[lstMini.SelectedIndex].SetValue(Map.myLayer[lstLayer.SelectedIndex].MiniLayer[lstMini.SelectedIndex].myTile.Count - 1, pickedX, pickedY);
                    }
                }

                lbltileCount.Text = "Total tile: " + Map.myLayer[lstLayer.SelectedIndex].myTile.Count;

            }

            else
            {
                int theX = pickedX / Editor.Instance.curGame.TileX;
                int theY = pickedY / Editor.Instance.curGame.TileY;

                // Left
                if (pickedX > theX * Editor.Instance.curGame.TileX && pickedX < (theX * Editor.Instance.curGame.TileX) + 8 && pickedY > (theY * Editor.Instance.curGame.TileY) + ((Editor.Instance.curGame.TileY / 2) - 4) && pickedY < (theY * Editor.Instance.curGame.TileY) + ((Editor.Instance.curGame.TileY / 2) + 4))
                {
                    if (Map.Block[4].MyLayer[theX, theY] == 0)
                        Map.Block[4].MyLayer[theX, theY] = 1;
                    else
                        Map.Block[4].MyLayer[theX, theY] = 0;
                }

                // Top
                else if (pickedX > theX * Editor.Instance.curGame.TileX + Editor.Instance.curGame.TileX / 2 - 4 && pickedX < Editor.Instance.curGame.TileX * theX + Editor.Instance.curGame.TileX / 2 + 4 && pickedY > theY * Editor.Instance.curGame.TileY && pickedY < theY * Editor.Instance.curGame.TileY + 8)
                {
                    if (Map.Block[3].MyLayer[theX, theY] == 0)
                        Map.Block[3].MyLayer[theX, theY] = 1;
                    else
                        Map.Block[3].MyLayer[theX, theY] = 0;
                }

                // Right
                else if (pickedX > theX * Editor.Instance.curGame.TileX + Editor.Instance.curGame.TileX - 8 && pickedX < (theX + 1) * Editor.Instance.curGame.TileX && pickedY > theY * Editor.Instance.curGame.TileY + Editor.Instance.curGame.TileY / 2 - 4 && pickedY < theY * Editor.Instance.curGame.TileY + Editor.Instance.curGame.TileY / 2 + 4)
                {
                    if (Map.Block[2].MyLayer[theX, theY] == 0)
                        Map.Block[2].MyLayer[theX, theY] = 1;
                    else
                        Map.Block[2].MyLayer[theX, theY] = 0;
                }

                //Bottom
                else if (pickedX > theX * Editor.Instance.curGame.TileX + Editor.Instance.curGame.TileX / 2 - 4 && pickedX < Editor.Instance.curGame.TileX * theX + Editor.Instance.curGame.TileX / 2 + 4 && pickedY > theY * Editor.Instance.curGame.TileY + Editor.Instance.curGame.TileY - 8 && pickedY < (theY + 1) * Editor.Instance.curGame.TileY)
                {
                    if (Map.Block[1].MyLayer[theX, theY] == 0)
                        Map.Block[1].MyLayer[theX, theY] = 1;
                    else
                        Map.Block[1].MyLayer[theX, theY] = 0;
                }

                // Middle
                else if (pickedX > theX * Editor.Instance.curGame.TileX + Editor.Instance.curGame.TileX / 2 - 4 && pickedX < theX * Editor.Instance.curGame.TileX + Editor.Instance.curGame.TileX / 2 + 4 && pickedY > theY * Editor.Instance.curGame.TileY + Editor.Instance.curGame.TileY / 2 - 4 && pickedY < theY * Editor.Instance.curGame.TileY + Editor.Instance.curGame.TileY / 2 + 4)
                {
                    if (Map.Block[0].MyLayer[theX, theY] == 0)
                        Map.Block[0].MyLayer[theX, theY] = 1;
                    else
                        Map.Block[0].MyLayer[theX, theY] = 0;
                }
            }

            mv.Render();

            Editor.Instance.ChangeMade = true;
            Editor.Instance.UpdateTitle();
        }
Ejemplo n.º 2
0
 public void setTile(Tile tile, int pos)
 {
     _myTile[pos] = tile;
 }
Ejemplo n.º 3
0
 //Method
 public void addTile(Tile tile)
 {
     _myTile.Add(tile);
 }
Ejemplo n.º 4
0
 public void removeTile(Tile tile)
 {
     _myTile.Remove(tile);
 }
Ejemplo n.º 5
0
        // Load the actual project. This will be the load game function for the actual game as well. Along with others game-only-related stuffs like Character save and such
        public void LoadProject(string path, Game obj)
        {
            Tile _tempTile = new Tile();
            Tileset _tempTileset = new Tileset();
            TileLayer _tempLayer = new TileLayer();
            TileLayer _tempMiniLayer = new TileLayer();
            TileMap _tempMap = new TileMap();
            Actor _tempActor = new Actor();
            Sprites _tempSprite = new Sprites();
            Face _tempFace = new Face();
            Switch _tempSwitch = new Switch();
            Variable _tempVariable = new Variable();

            GResource _tempResource = new GResource();

            using (br = new BinaryReader(File.Open(path, FileMode.Open)))
            {
                obj.Name = br.ReadString();
                obj.Path = br.ReadString();
                obj.Author = br.ReadString();
                obj.Description = br.ReadString();
                obj.SubName = br.ReadString();
                obj.TileX = br.ReadInt32();
                obj.TileY = br.ReadInt32();
                obj.StartMap = br.ReadInt32();
                obj.StartX = br.ReadInt32();
                obj.StartY = br.ReadInt32();

                int max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempSwitch = new Switch();
                    _tempSwitch.Name = br.ReadString();

                    obj.MySwitch.Add(_tempSwitch);
                }

                max = br.ReadInt32();

                for (int i = 0; i < max; i++)
                {
                    _tempVariable = new Variable();
                    _tempVariable.Name = br.ReadString();

                    obj.MyVariable.Add(_tempVariable);
                }

                //Initial Party
                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    obj.InitialParty.Add(br.ReadInt32());
                }

                //Please keep all the non engine related stuff up here

                // From this point onward is all engine related stuff

                // Tile Engine
                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempTileset = new Tileset();
                    _tempTileset.Name = br.ReadString();
                    _tempTileset.ID = br.ReadInt32();
                    obj.TM.myTileset.Add(_tempTileset);
                }

                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempMap = new TileMap();
                    _tempMap.maxX = br.ReadInt32();
                    _tempMap.maxY = br.ReadInt32();

                    _tempMap.InitEvent();

                    _tempMap.Name = br.ReadString();
                    _tempMap.PlayerAbove = br.ReadInt32();

                    _tempMap.Block = new TileProperty[5];

                    for (int b = 0; b < 5; b++)
                    {
                        TileProperty _tempTileProperty = new TileProperty(_tempMap.maxX, _tempMap.maxY);
                        for (int x = 0; x < _tempMap.maxX; x++)
                            for (int y = 0; y < _tempMap.maxY; y++)
                                _tempTileProperty.MyLayer[x, y] = br.ReadByte();

                        _tempMap.Block[b] = _tempTileProperty;
                    }

                    int secmax = br.ReadInt32();
                    for (int l = 0; l < secmax; l++)
                    {
                        _tempLayer = new TileLayer();
                        _tempLayer.Name = br.ReadString();
                        _tempLayer.Opacity = br.ReadInt32();
                        _tempLayer.Order = br.ReadInt32();
                        _tempLayer.Visible = br.ReadBoolean();

                        int thimax = br.ReadInt32();
                        for (int t = 0; t < thimax; t++)
                        {
                            _tempTile = new Tile();
                            _tempTile.Width = br.ReadInt32();
                            _tempTile.Height = br.ReadInt32();
                            _tempTile.TS = br.ReadInt32();
                            _tempTile.Opacity = br.ReadInt32();
                            _tempTile.plcX = br.ReadInt32();
                            _tempTile.plcY = br.ReadInt32();
                            _tempTile.srcX = br.ReadInt32();
                            _tempTile.srcY = br.ReadInt32();

                            _tempLayer.addTile(_tempTile);
                        }

                        thimax = br.ReadInt32();
                        for (int ml = 0; ml < thimax; ml++)
                        {
                            _tempMiniLayer = new TileLayer();
                            _tempMiniLayer.Name = br.ReadString();
                            _tempMiniLayer.Opacity = br.ReadInt32();
                            _tempMiniLayer.Order = br.ReadInt32();
                            _tempMiniLayer.Visible = br.ReadBoolean();

                            int foumax = br.ReadInt32();
                            for (int t = 0; t < foumax; t++)
                            {
                                _tempTile = new Tile();
                                _tempTile.Width = br.ReadInt32();
                                _tempTile.Height = br.ReadInt32();
                                _tempTile.TS = br.ReadInt32();
                                _tempTile.Opacity = br.ReadInt32();
                                _tempTile.plcX = br.ReadInt32();
                                _tempTile.plcY = br.ReadInt32();
                                _tempTile.srcX = br.ReadInt32();
                                _tempTile.srcY = br.ReadInt32();

                                _tempMiniLayer.addTile(_tempTile);
                            }

                            _tempLayer.MiniLayer.Add(_tempMiniLayer);
                        }

                        _tempMap.myLayer.Add(_tempLayer);
                    }

                    for (int x = 0; x < _tempMap.maxX; x++)
                    {
                        for (int y = 0; y < _tempMap.maxY; y++)
                        {
                            int count = br.ReadInt32();
                            for (int c = 0; c < count; c++)
                                LoadEvent(obj, _tempMap.EM[x, y].MyEvent);
                        }
                    }

                    obj.TM.myMap.Add(_tempMap);
                }

                // Graphic Manager
                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempResource = new GResource();

                    _tempResource.Path = br.ReadString();
                    _tempResource.Type = br.ReadInt32();

                    obj.GM.myResource.Add(_tempResource);
                }

                // Actor Manager
                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempActor = new Actor();
                    _tempActor.Name = br.ReadString();
                    _tempActor.Description = br.ReadString();
                    _tempActor.Level = br.ReadInt32();
                    _tempActor.Gender = br.ReadInt32();
                    _tempActor.Face = br.ReadInt32();
                    _tempActor.Sprite = br.ReadInt32();
                    _tempActor.Job = br.ReadInt32();
                    _tempActor.JobLevel = br.ReadInt32();
                    _tempActor.StatPoints = br.ReadInt32();

                    _tempActor.Stat = new int[br.ReadInt32()];
                    for (int s = 0; s < _tempActor.Stat.Length; s++)
                    {
                        _tempActor.Stat[s] = br.ReadInt32();
                    }

                    obj.AM.MyActor.Add(_tempActor);
                }

                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempFace = new Face();
                    _tempFace.Name = br.ReadString();
                    _tempFace.ID = br.ReadInt32();

                    obj.AM.MyFace.Add(_tempFace);
                }

                max = br.ReadInt32();
                for (int i = 0; i < max; i++)
                {
                    _tempSprite = new Sprites();
                    _tempSprite.Name = br.ReadString();
                    _tempSprite.ID = br.ReadInt32();

                    obj.AM.MySprite.Add(_tempSprite);
                }
            }
        }