Beispiel #1
0
 public TileAnim(TileAnim oldTileAnim)
 {
     Frames = new List<TileTexture>();
     for (int i = 0; i < oldTileAnim.Frames.Count; i++)
     {
         Frames.Add(oldTileAnim.Frames[i]);
     }
     FrameLength = oldTileAnim.FrameLength;
 }
Beispiel #2
0
 public TileAnim(TileAnim oldTileAnim)
 {
     Frames = new List <TileTexture>();
     for (int i = 0; i < oldTileAnim.Frames.Count; i++)
     {
         Frames.Add(oldTileAnim.Frames[i]);
     }
     FrameLength = oldTileAnim.FrameLength;
 }
Beispiel #3
0
 public MapLayer(string name, int width, int height)
 {
     Name  = name;
     Tiles = new TileAnim[width, height];
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             Tiles[x, y] = new TileAnim();
         }
     }
 }
Beispiel #4
0
        public MapEditor()
        {
            drawLock = new object();
            inAnimMode = false;
            chosenTile = new Loc2D();
            chosenTileset = 0;
            chosenAnim = new TileAnim();
            SetupLayerVisibility();

            InitializeComponent();

            if (tiles == null)
            {
                tiles = new List<Image>();
                for (int i = 0; i < 10; i++)
                {
                    tiles.Add(new Bitmap(Paths.TilesPath+"Tiles" + i + ".png"));
                }
            }

            RefreshTitle();

            if (!Directory.Exists(Paths.MapPath))
                Directory.CreateDirectory(Paths.MapPath);
            openFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + Paths.MapPath;
            saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + Paths.MapPath;

            tbTileset.Value = 0;

            nudTimeLimit.Maximum = Int32.MaxValue;

            for (int i = 0; i < 12; i++)
            {
                cbWeather.Items.Add(((Enums.Weather)i).ToString());
            }

            nudDarkness.Maximum = Int32.MaxValue;

            nudFrameLength.Maximum = Int32.MaxValue;

            RefreshTileset();
            RefreshAnimControls();

            ReloadMusic();

            LoadMapProperties();
        }
Beispiel #5
0
        private void chkAnimationMode_CheckedChanged(object sender, EventArgs e)
        {
            if (inAnimMode != chkAnimationMode.Checked)
            {
                inAnimMode = chkAnimationMode.Checked;
                if (inAnimMode)
                {
                    chosenAnim = new TileAnim(chosenTile, chosenTileset);
                }
                else
                {
                    if (chosenAnim.Frames.Count > 0)
                    {
                        chosenTile = chosenAnim.Frames[0].Texture;
                        chosenTileset = chosenAnim.Frames[0].Sheet;
                    }
                    else
                    {
                        chosenTile = new Loc2D();
                        chosenTileset = 0;
                    }
                    currentTileset = chosenTileset;
                }
            }
            UpdateAnimFrames();
            RefreshTileSelect();

            RefreshAnimControls();
        }
Beispiel #6
0
        static void GetTileTexFromTileAnim(TileAnim anim)
        {
            if (anim.Frames.Count == 1)
            {
                inAnimMode = false;
                chosenTileset = anim.Frames[0].Sheet;
                chosenTile = anim.Frames[0].Texture;

                currentTileset = chosenTileset;

                //refresh
                RefreshCallback refresh = new RefreshCallback(MainPanel.CurrentMapEditor.RefreshTileSelect);
                MainPanel.CurrentMapEditor.Invoke(refresh);
            }
            else if (anim.Frames.Count > 1)
            {
                inAnimMode = true;

                chosenAnim = new TileAnim(anim);

                //refresh
                RefreshCallback refresh = new RefreshCallback(MainPanel.CurrentMapEditor.RefreshTileSelect);
                MainPanel.CurrentMapEditor.Invoke(refresh);
            }
        }
Beispiel #7
0
        public static void PaintTile(Loc2D loc, TileAnim anim)
        {
            if (!Operations.IsInBound(Processor.CurrentMap.Width, Processor.CurrentMap.Height, loc.X, loc.Y))
                return;

            switch (chosenEditLayer)
            {
                case EditLayer.Data:
                    {

                        break;
                    }
                case EditLayer.Ground:
                case EditLayer.PropBack:
                case EditLayer.PropFront:
                case EditLayer.Fringe:
                    {
                        GetChosenEditLayer().Tiles[loc.X, loc.Y] = anim;
                        break;
                    }
            }

            Logic.Display.Screen.AddResult(new Logic.Results.SetTile(Processor.CurrentMap, loc));
        }
Beispiel #8
0
 public static TileAnim GetBrush()
 {
     TileAnim anim;
     if (inAnimMode)
         anim = new TileAnim(chosenAnim);
     else
         anim = new TileAnim(chosenTile, chosenTileset);
     return anim;
 }
Beispiel #9
0
        public static void FillTile(Loc2D loc, TileAnim anim)
        {
            if (!Operations.IsInBound(Processor.CurrentMap.Width, Processor.CurrentMap.Height, loc.X, loc.Y))
                return;

            switch (chosenEditLayer)
            {
                case EditLayer.Data:
                    {

                        break;
                    }
                case EditLayer.Ground:
                case EditLayer.PropBack:
                case EditLayer.PropFront:
                case EditLayer.Fringe:
                    {
                        TileAnim oldAnim = GetChosenEditLayer().Tiles[loc.X, loc.Y];

                        if (oldAnim != anim)
                        {
                            Operations.FillArray(GetChosenEditLayer().Tiles.GetLength(0), GetChosenEditLayer().Tiles.GetLength(1),
                                (int x, int y) =>
                                {
                                    return GetChosenEditLayer().Tiles[x, y] == oldAnim;
                                },
                                (int x, int y) =>
                                {
                                    GetChosenEditLayer().Tiles[x, y] = new TileAnim(anim);
                                    Logic.Display.Screen.AddResult(new Logic.Results.SetTile(Processor.CurrentMap, new Loc2D(x,y)));
                                },
                                loc);
                        }
                        break;
                    }
            }
        }