Пример #1
0
 public void setTextureSequence(TileSequence sequence)
 {
     TileTextureSequence = sequence;
     if (sequence != null)
     {
         this.TileModelTexture = null;
     }
 }
Пример #2
0
 public void setObjectSequence(TileSequence sequence)
 {
     this.TileObjectSequence = sequence;
     if (sequence != null)
     {
         this.TileModelImageObject = null;
     }
 }
Пример #3
0
        //---------------------------------------------------
        //-------------------Methods-------------------------
        //---------------------------------------------------

        public void setTexture(TileModel model)
        {
            TileModelTexture = model;
            if (model != null)
            {
                this.TileTextureSequence = null;
            }
        }
Пример #4
0
 public void setObjectImage(TileModel model)
 {
     this.TileModelImageObject = model;
     if (model != null)
     {
         this.TileObjectSequence = null;
     }
 }
Пример #5
0
 private void objectSequenceListView_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.objectSequenceListView.SelectedItems.Count > 0)
     {
         this.mainForm.tilesMapEditor1.CreationMode = "CREATING_OBJECT_SEQUENCE";
         TileSequence seqSelected = (TileSequence)this.objectSequenceListView.SelectedItems[0].Tag;
         this.objectSequencePropGrid.SelectedObject = seqSelected;
     }
 }
Пример #6
0
        public void init(TilesMap map, Form1 mainForm)
        {
            this.currentTilesMap = map;
            this.mainForm        = mainForm;

            this.textureSequenceImageList.Images.Clear();
            this.textureSequenceListView.Items.Clear();
            this.textureSequencePropGrid.SelectedObject = null;

            this.objectSequenceImageList.Images.Clear();
            this.objectSequenceListView.Items.Clear();
            this.objectSequencePropGrid.SelectedObject = null;

            if (map.TextureSequences == null)
            {
                map.TextureSequences = new List <TileSequence>();
            }

            if (map.ObjectSequences == null)
            {
                map.ObjectSequences = new List <TileSequence>();
            }

            for (int i = 0; i < map.TextureSequences.Count; i++)
            {
                TileSequence seq        = map.TextureSequences[i];
                int          indexImage = this.textureSequenceImageList.Images.Count;
                this.textureSequenceImageList.Images.Add(seq.Frames[0].GorgonSprite.Image.SaveBitmap());


                ListViewItem seqItem = new ListViewItem();
                seqItem.Text       = seq.Name;
                seqItem.ImageIndex = indexImage;
                seqItem.Tag        = seq;
                this.textureSequenceListView.Items.Add(seqItem);
            }

            for (int i = 0; i < map.ObjectSequences.Count; i++)
            {
                TileSequence seq        = map.ObjectSequences[i];
                int          indexImage = this.objectSequenceImageList.Images.Count;
                this.objectSequenceImageList.Images.Add(seq.Frames[0].GorgonSprite.Image.SaveBitmap());


                ListViewItem seqItem = new ListViewItem();
                seqItem.Text       = seq.Name;
                seqItem.ImageIndex = indexImage;
                seqItem.Tag        = seq;
                this.objectSequenceListView.Items.Add(seqItem);
            }
        }
Пример #7
0
        private void createObjectSequenceBt_Click(object sender, EventArgs e)
        {
            if (this.TilesSelection.ListModelsSelected.Count > 1 && this.mainForm.tilesMapEditor1.CurrentTilesMap != null)
            {
                TilesMap map = this.mainForm.tilesMapEditor1.CurrentTilesMap;
                if (map.ObjectSequences == null)
                {
                    map.ObjectSequences = new List <TileSequence>();
                }


                TileSequence seq = new TileSequence("objectSequence" + map.ObjectSequences.Count, new List <TileModel>(this.TilesSelection.ListModelsSelected));

                this.mainForm.tilesMapEditor1.AddObjectSequence(seq);
            }
        }
Пример #8
0
        public void AddTextureSequence(TileSequence seq)
        {
            if (this.currentTilesMap != null && seq.Frames.Count>0)
            {
                this.currentTilesMap.TextureSequences.Add(seq);
                int indexImage = this.textureSequenceImageList.Images.Count;
                this.textureSequenceImageList.Images.Add(seq.Frames[0].Image);

                ListViewItem seqItem = new ListViewItem();
                seqItem.Text = seq.Name;
                seqItem.ImageIndex = indexImage;
                seqItem.Tag = seq;
                this.textureSequenceListView.Items.Add(seqItem);

            }
        }
Пример #9
0
        public void AddObjectSequence(TileSequence seq)
        {
            if (this.currentTilesMap != null && seq.Frames.Count > 0)
            {
                this.currentTilesMap.ObjectSequences.Add(seq);
                int indexImage = this.objectSequenceImageList.Images.Count;
                this.objectSequenceImageList.Images.Add(seq.Frames[0].Image);


                ListViewItem seqItem = new ListViewItem();
                seqItem.Text       = seq.Name;
                seqItem.ImageIndex = indexImage;
                seqItem.Tag        = seq;
                this.objectSequenceListView.Items.Add(seqItem);
            }
        }
Пример #10
0
        public void AddObjectSequence(TileSequence seq)
        {
            if (this.currentTilesMap != null && seq.Frames.Count > 0)
            {
                this.currentTilesMap.ObjectSequences.Add(seq);
                int indexImage = this.objectSequenceImageList.Images.Count;

                this.objectSequenceImageList.Images.Add(seq.Frames[0].GorgonSprite.Image.SaveBitmap());

                ListViewItem seqItem = new ListViewItem();
                seqItem.Text = seq.Name;
                seqItem.ImageIndex = indexImage;
                seqItem.Tag = seq;
                this.objectSequenceListView.Items.Add(seqItem);

            }
        }
Пример #11
0
        public JSONTileMap(TilesMap map, Scene sceneParent, float xRatio, float yRatio)
        {
            this.NbColumns            = map.NbColumns;
            this.NbLines              = map.NbLines;
            this.TilesHeight          = Convert.ToInt32(map.TilesHeight * yRatio);
            this.TilesWidth           = Convert.ToInt32(map.TilesWidth * xRatio);
            this.TilesMapName         = map.TilesMapName;
            this.Bounce               = map.Bounce;
            this.IsInfinite           = map.isInfinite;
            this.Friction             = map.Friction;
            this.Radius               = Convert.ToInt32(map.Radius * ((xRatio + yRatio) / 2));
            this.Density              = map.Density;
            this.IsPathFindingEnabled = map.IsPathFindingEnabled;
            this.isPhysicsEnabled     = map.isPhysicsEnabled;


            this.TextureCount = map.TileModelsTextureUsed.Count;
            this.ObjectCount  = map.TileModelsObjectsUsed.Count;

            if (map.TextureCountBySheet != null)
            {
                this.TextureCountBySheet = map.TextureCountBySheet.ToArray();
            }

            if (map.ObjectCountBySheet != null)
            {
                this.ObjectCountBySheet = map.ObjectCountBySheet.ToArray();
            }


            this.TextureSheetCount = map.NbTextureSheets;
            this.ObjectSheetCount  = map.NbObjectSheets;

            this.TextureSequenceCount = map.TextureSequences.Count;
            this.ObjectSequenceCount  = map.ObjectSequences.Count;

            if (map.TextureSequenceCountBySheet != null)
            {
                this.TextureSequenceCountBySheet = map.TextureSequenceCountBySheet.ToArray();
            }

            if (map.ObjectSequenceCountBySheet != null)
            {
                this.ObjectSequenceCountBySheet = map.ObjectSequenceCountBySheet.ToArray();
            }

            this.TextureSequenceSheetCount = map.NbTextureSequenceSheets;
            this.ObjectSequenceSheetCount  = map.NbObjectSequenceSheets;

            this.TextureSequences = new JSONTileSequence[map.TextureSequences.Count];
            int textureFrameCount = TextureCount;

            for (int i = 0; i < map.TextureSequences.Count; i++)
            {
                TileSequence     seq     = map.TextureSequences[i];
                JSONTileSequence seqJson = new JSONTileSequence(seq.Name.Replace(" ", ""), textureFrameCount + 1, seq.Frames.Count, seq.Lenght, seq.Iteration);
                this.TextureSequences[i] = seqJson;

                textureFrameCount = textureFrameCount + seq.Frames.Count;
            }

            this.ObjectSequences = new JSONTileSequence[map.ObjectSequences.Count];
            int objectFrameCount = this.ObjectCount;

            for (int i = 0; i < map.ObjectSequences.Count; i++)
            {
                TileSequence     seq     = map.ObjectSequences[i];
                JSONTileSequence seqJson = new JSONTileSequence(seq.Name.Replace(" ", ""), objectFrameCount + 1, seq.Frames.Count, seq.Lenght, seq.Iteration);
                this.ObjectSequences[i] = seqJson;

                objectFrameCount = objectFrameCount + seq.Frames.Count;
            }

            if (map.CollisionFilterGroupIndex + 1 <= sceneParent.CollisionFilterGroups.Count)
            {
                CollisionFilterGroup group = sceneParent.CollisionFilterGroups[map.CollisionFilterGroupIndex];
                this.CollisionCategoryBits = group.CategorieBit;
                this.CollisionMaskBits     = group.getMaskBits();
            }
            else
            {
                this.CollisionCategoryBits = 0;
                this.CollisionMaskBits     = 0;
            }
        }
Пример #12
0
        public void Draw(Graphics g, Point offsetPoint, string layerToShow, bool showCollision)
        {
            Point pDest = new Point(this.mapParent.Location.X + this.Location.X + offsetPoint.X, this.mapParent.Location.Y + this.Location.Y + offsetPoint.Y);

            if (layerToShow.Equals("ALL") || layerToShow.Equals("TEXTURE"))
            {
                //Dessiner l'image associée
                if (this.TileModelTexture != null)
                {
                    g.DrawImage(this.TileModelTexture.Image, new Rectangle(pDest, new Size(this.mapParent.TilesWidth, this.mapParent.TilesHeight)));
                }


                if (this.TileTextureSequence != null)
                {
                    if (this.mapParent.TextureSequences.Contains(this.TileTextureSequence) && this.TileTextureSequence.Frames.Count > 0)
                    {
                        g.DrawImage(this.TileTextureSequence.Frames[0].Image, new Rectangle(pDest, new Size(this.mapParent.TilesWidth, this.mapParent.TilesHeight)));
                    }
                    else
                    {
                        this.TileTextureSequence = null;
                    }
                }
            }


            if (layerToShow.Equals("ALL") || layerToShow.Equals("OBJECT"))
            {
                if (this.TileModelImageObject != null)
                {
                    g.DrawImage(this.TileModelImageObject.Image, new Rectangle(pDest, new Size(this.mapParent.TilesWidth, this.mapParent.TilesHeight)));
                }


                if (this.TileObjectSequence != null)
                {
                    if (this.mapParent.ObjectSequences.Contains(this.TileObjectSequence) && this.TileObjectSequence.Frames.Count > 0)
                    {
                        g.DrawImage(this.TileObjectSequence.Frames[0].Image, new Rectangle(pDest, new Size(this.mapParent.TilesWidth, this.mapParent.TilesHeight)));
                    }
                    else
                    {
                        this.TileObjectSequence = null;
                    }
                }
            }

            if (layerToShow.Equals("ALL") || layerToShow.Equals("EVENT"))
            {
                if (this.TileEvent != null)
                {
                    if (this.mapParent.TileEvents.Contains(this.TileEvent))
                    {
                        if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.collision)
                        {
                            g.DrawImage(Properties.Resources.collisionIcon2, new Rectangle(pDest, new Size(this.mapParent.TilesWidth / 2, this.mapParent.TilesHeight / 2)));
                        }
                        else if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.preCollision)
                        {
                            g.DrawImage(Properties.Resources.preCollisionIcon, new Rectangle(pDest, new Size(this.mapParent.TilesWidth / 2, this.mapParent.TilesHeight / 2)));
                        }
                        else if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.postCollision)
                        {
                            g.DrawImage(Properties.Resources.postCollisionIcon, new Rectangle(pDest, new Size(this.mapParent.TilesWidth / 2, this.mapParent.TilesHeight / 2)));
                        }
                        else if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.touch)
                        {
                            g.DrawImage(Properties.Resources.touchIcon, new Rectangle(pDest, new Size(this.mapParent.TilesWidth / 2, this.mapParent.TilesHeight / 2)));
                        }
                    }
                    else
                    {
                        this.TileEvent = null;
                    }
                }
            }

            if (showCollision == true)
            {
                if (this.IsCrossable == true)
                {
                    Brush brosse = new SolidBrush(Color.FromArgb(50, Color.LightBlue));

                    g.FillRectangle(brosse, pDest.X, pDest.Y, this.Width, this.Height);
                }
                else
                {
                    Brush brosse = new SolidBrush(Color.FromArgb(50, Color.Red));
                    g.FillRectangle(brosse, pDest.X, pDest.Y, this.Width, this.Height);
                }
            }
        }
Пример #13
0
        public void DrawGorgon(Point offsetPoint, string layerToShow, bool showCollision, float worldScale)
        {
            Point pDest = new Point((int)((this.mapParent.Location.X + this.Location.X + offsetPoint.X) * worldScale),
                                    (int)((this.mapParent.Location.Y + this.Location.Y + offsetPoint.Y) * worldScale));

            Rectangle rectDest = new Rectangle(pDest,
                                               new Size((int)((this.mapParent.TilesWidth * worldScale)),
                                                        (int)((this.mapParent.TilesHeight) * worldScale)));

            if (layerToShow.Equals("ALL") || layerToShow.Equals("TEXTURE"))
            {
                //Dessiner l'image associée
                if (this.TileModelTexture != null)
                {
                    GorgonLibrary.Graphics.Sprite sprite = this.TileModelTexture.GorgonSprite;
                    if (sprite != null && sprite.Image != null)
                    {
                        float imgScaleX = (float)this.mapParent.TilesWidth / (float)sprite.Image.Width;
                        float imgScaleY = (float)this.mapParent.TilesHeight / (float)sprite.Image.Height;

                        float finalXScale = worldScale * imgScaleX;
                        float finalYScale = worldScale * imgScaleY;
                        sprite.SetScale(finalXScale, finalYScale);

                        sprite.SetPosition(pDest.X, pDest.Y);
                        sprite.Draw();
                    }
                    else
                    {
                        this.TileModelTexture = null;
                    }
                }


                if (this.TileTextureSequence != null)
                {
                    if (this.mapParent.TextureSequences.Contains(this.TileTextureSequence) && this.TileTextureSequence.Frames.Count > 0)
                    {
                        GorgonLibrary.Graphics.Sprite sprite = this.TileTextureSequence.Frames[0].GorgonSprite;
                        if (sprite != null && sprite.Image != null)
                        {
                            float imgScaleX = (float)this.mapParent.TilesWidth / (float)sprite.Image.Width;
                            float imgScaleY = (float)this.mapParent.TilesHeight / (float)sprite.Image.Height;

                            float finalXScale = worldScale * imgScaleX;
                            float finalYScale = worldScale * imgScaleY;
                            sprite.SetScale(finalXScale, finalYScale);

                            sprite.SetPosition(pDest.X, pDest.Y);
                            sprite.Draw();
                        }
                    }
                    else
                    {
                        this.TileTextureSequence = null;
                    }
                }
            }


            if (layerToShow.Equals("ALL") || layerToShow.Equals("OBJECT"))
            {
                if (this.TileModelImageObject != null)
                {
                    GorgonLibrary.Graphics.Sprite sprite = this.TileModelImageObject.GorgonSprite;
                    if (sprite != null && sprite.Image != null)
                    {
                        float imgScaleX = (float)this.mapParent.TilesWidth / (float)sprite.Image.Width;
                        float imgScaleY = (float)this.mapParent.TilesHeight / (float)sprite.Image.Height;

                        float finalXScale = worldScale * imgScaleX;
                        float finalYScale = worldScale * imgScaleY;
                        sprite.SetScale(finalXScale, finalYScale);

                        sprite.SetPosition(pDest.X, pDest.Y);
                        sprite.Draw();
                    }
                    else
                    {
                        this.TileModelImageObject = null;
                    }
                }


                if (this.TileObjectSequence != null)
                {
                    if (this.mapParent.ObjectSequences.Contains(this.TileObjectSequence) && this.TileObjectSequence.Frames.Count > 0)
                    {
                        GorgonLibrary.Graphics.Sprite sprite = this.TileObjectSequence.Frames[0].GorgonSprite;
                        if (sprite != null && sprite.Image != null)
                        {
                            float imgScaleX = (float)this.mapParent.TilesWidth / (float)sprite.Image.Width;
                            float imgScaleY = (float)this.mapParent.TilesHeight / (float)sprite.Image.Height;

                            float finalXScale = worldScale * imgScaleX;
                            float finalYScale = worldScale * imgScaleY;
                            sprite.SetScale(finalXScale, finalYScale);

                            sprite.SetPosition(pDest.X, pDest.Y);
                            sprite.Draw();
                        }
                        else
                        {
                            this.TileObjectSequence = null;
                        }
                    }
                    else
                    {
                        this.TileObjectSequence = null;
                    }
                }
            }

            if (layerToShow.Equals("ALL") || layerToShow.Equals("EVENT"))
            {
                if (this.TileEvent != null)
                {
                    if (this.mapParent.TileEvents.Contains(this.TileEvent))
                    {
                        GorgonLibrary.Graphics.Sprite sprite = null;
                        if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.collision)
                        {
                            sprite = this.mapParent.CollisionEventSprite;
                        }
                        else if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.preCollision)
                        {
                            sprite = this.mapParent.PreCollisionEventSprite;
                        }
                        else if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.postCollision)
                        {
                            sprite = this.mapParent.PostCollisionEventSprite;
                        }
                        else if (this.TileEvent.Type == TilesMapping.TileEvent.TileEventType.touch)
                        {
                            sprite = this.mapParent.TouchEventSprite;
                        }

                        if (sprite != null)
                        {
                            float imgScaleX = (float)this.mapParent.TilesWidth / 2 / (float)sprite.Image.Width;
                            float imgScaleY = (float)this.mapParent.TilesHeight / 2 / (float)sprite.Image.Height;

                            float finalXScale = worldScale * imgScaleX;
                            float finalYScale = worldScale * imgScaleY;
                            sprite.SetScale(finalXScale, finalYScale);

                            sprite.SetPosition(pDest.X, pDest.Y);
                            sprite.Draw();
                        }
                    }
                    else
                    {
                        this.TileEvent = null;
                    }
                }
            }

            if (showCollision == true)
            {
                Color color;
                if (this.IsCrossable == true)
                {
                    color = Color.FromArgb(50, Color.LightBlue);
                }
                else
                {
                    color = Color.FromArgb(100, Color.Red);
                }


                Rectangle rectCollision = new Rectangle(this.mapParent.Location.X + this.Location.X + offsetPoint.X,
                                                        this.mapParent.Location.Y + this.Location.Y + offsetPoint.Y,
                                                        this.mapParent.TilesWidth, this.mapParent.TilesHeight);

                GorgonGraphicsHelper.Instance.FillRectangle(rectCollision, 1, color, worldScale, false);
            }
        }
Пример #14
0
 public void applyTextureSequenceOnTilePointed(Point p, TileSequence seq)
 {
     Tile tileTouched = this.getTileAtLocation(p);
     if (tileTouched != null)
     {
         tileTouched.setTextureSequence(seq);
     }
 }
Пример #15
0
        public void applyTextureSequenceOnAllTiles(TileSequence seq)
        {
            for (int i = 0; i < this.NbLines; i++)
            {
                for (int j = 0; j < this.NbColumns; j++)
                {
                    this.TabTiles[i, j].setTextureSequence(seq);

                }
            }
        }
Пример #16
0
        private void createSequenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.TilesSelection.ListModelsSelected.Count > 1 && this.mainForm.tilesMapEditor1.CurrentTilesMap != null)
            {

                TilesMap map = this.mainForm.tilesMapEditor1.CurrentTilesMap;
                if (map.TextureSequences == null)
                    map.TextureSequences = new List<TileSequence>();

                TileSequence seq = new TileSequence("textureSequence" + map.TextureSequences.Count, new List<TileModel>(this.TilesSelection.ListModelsSelected));

                this.mainForm.tilesMapEditor1.AddTextureSequence(seq);
            }
        }