Exemple #1
0
        public CoronaSpriteSet CloneInstance()
        {
            CoronaSpriteSet newSet = new CoronaSpriteSet(this.Name);

            List <CoronaSpriteSheet> sheetUsed = new List <CoronaSpriteSheet>();

            for (int i = 0; i < this.Frames.Count; i++)
            {
                if (!sheetUsed.Contains(this.Frames[i].SpriteSheetParent))
                {
                    sheetUsed.Add(this.Frames[i].SpriteSheetParent);
                }
            }

            for (int i = 0; i < sheetUsed.Count; i++)
            {
                CoronaSpriteSheet sheet = new CoronaSpriteSheet(sheetUsed[i].Name);
                sheet.FramesFactor = sheetUsed[i].FramesFactor;

                for (int j = 0; j < sheetUsed[i].Frames.Count; j++)
                {
                    SpriteFrame frame = new SpriteFrame(sheetUsed[i].Frames[j].NomFrame, j, sheetUsed[i].Frames[j].Image, sheet);
                    sheet.addFrame(frame);
                }
            }

            return(null);
        }
Exemple #2
0
 public SpriteFrame(String nom, int index, String pathImage,CoronaSpriteSheet parent)
 {
     this.SpriteSheetParent = parent;
         this.Index = index;
         int id = nom.LastIndexOf(@"\") + 1;
         this.NomFrame = nom.Substring(id);
         this.pathImage = pathImage;
 }
Exemple #3
0
 //---------------------------------------------------
 //-------------------Constructeurs--------------------
 //---------------------------------------------------
 public SpriteFrame(String nom, int index, Image img,CoronaSpriteSheet parent)
 {
     this.SpriteSheetParent = parent;
         this.Index = index;
         int id = nom.LastIndexOf(@"\") + 1;
         this.NomFrame = nom.Substring(id);
         this.Image = img;
         this.ImageSize = img.Size;
 }
Exemple #4
0
        public SpriteFrame(String nom, int index, String pathImage, CoronaSpriteSheet parent)
        {
            this.SpriteSheetParent = parent;
            this.Index             = index;
            int id = nom.LastIndexOf(@"\") + 1;

            this.NomFrame  = nom.Substring(id);
            this.pathImage = pathImage;
        }
Exemple #5
0
        //---------------------------------------------------
        //-------------------Constructeurs--------------------
        //---------------------------------------------------

        public SpriteFrame(String nom, int index, Image img, CoronaSpriteSheet parent)
        {
            this.SpriteSheetParent = parent;
            this.Index             = index;
            int id = nom.LastIndexOf(@"\") + 1;

            this.NomFrame  = nom.Substring(id);
            this.Image     = img;
            this.ImageSize = img.Size;
        }
Exemple #6
0
        //----------------------------------------------------------
        //---------------Sprite SHEETS-----------------------
        //----------------------------------------------------------
        public void newSpriteSheet(CoronaSpriteSheet sheet)
        {
            if (this.ProjectRootNodeSelected != null && this.SceneSelected != null)
            {
                if (isSheetExistsInScene(this.SceneSelected, sheet) == false)
                {
                    GameElement sceneNode = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, this.SceneSelected);
                    GameElement node = new GameElement("SPRITESHEET", sheet.Name, sheet);
                    sceneNode.Nodes["SPRITESHEETS"].Nodes.Add(node);

                    if(!this.SceneSelected.SpriteSheets.Contains(sheet))
                        this.SceneSelected.SpriteSheets.Add(sheet);
                }

            }
        }
Exemple #7
0
        public bool isSheetExistsInScene(Scene scene,CoronaSpriteSheet sheet)
        {
            //Recueprer la node de la scene
            GameElement sceneNode = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, this.SceneSelected);

            for (int i = 0; i < sceneNode.Nodes["SPRITESHEETS"].Nodes.Count; i++)
            {
                CoronaSpriteSheet sheetInProject = (CoronaSpriteSheet)((GameElement)sceneNode.Nodes["SPRITESHEETS"].Nodes[i]).InstanceObjet;
                if (sheet.Name.Equals(sheetInProject.Name))
                    return true;
            }

            return false;
        }
Exemple #8
0
        private void newAssetBt_Click(object sender, EventArgs e)
        {
            if (this.CurrentAssetProject != null)
            {
                if (this.assetTypeListView.SelectedItems.Count > 0)
                {
                    string assetTypeSelected = this.assetTypeListView.SelectedItems[0].ToolTipText;
                    object objectCreated = null;
                    if (assetTypeSelected.Equals("Image"))
                    {
                        DisplayObject obj = new DisplayObject(new Bitmap(Properties.Resources.bmpFileIcon), new Point(0, 0), null);
                        obj.Name = "image" + this.CurrentAssetProject.ListObjects.Count;
                        this.CurrentAssetProject.ListObjects.Add(obj);
                        objectCreated = obj;

                    }
                    else if (assetTypeSelected.Equals("Sprite"))
                    {
                        DisplayObject obj = new DisplayObject(new CoronaSpriteSet(""), new Point(0, 0),null);
                        obj.Name = "sprite" + this.CurrentAssetProject.ListObjects.Count;
                        this.CurrentAssetProject.ListObjects.Add(obj);
                        objectCreated = obj;
                    }
                    else if (assetTypeSelected.Equals("Sprite Set"))
                    {
                        CoronaSpriteSet obj = new CoronaSpriteSet("Spriteset"+this.CurrentAssetProject.SpriteSets.Count);
                        this.CurrentAssetProject.SpriteSets.Add(obj);
                        objectCreated = obj;
                    }
                    else if (assetTypeSelected.Equals("Sprite Sheet"))
                    {
                        CoronaSpriteSheet obj = new CoronaSpriteSheet("Spritesheet" + this.CurrentAssetProject.SpriteSheets.Count);
                        this.CurrentAssetProject.SpriteSheets.Add(obj);
                        objectCreated = obj;
                    }
                    else if (assetTypeSelected.Equals("Audio"))
                    {
                        AudioObject obj = new AudioObject("", "Audio" + this.CurrentAssetProject.SpriteSheets.Count, 1, false, 1, "SOUND");
                        this.CurrentAssetProject.Audios.Add(obj);
                        objectCreated = obj;
                    }
                    else if (assetTypeSelected.Equals("Snippet"))
                    {
                        Snippet obj = new Snippet("snippet" + this.CurrentAssetProject.Snippets.Count,"", "", "", "", 1, "");
                        this.CurrentAssetProject.Snippets.Add(obj);
                        objectCreated = obj;
                    }
                    else if (assetTypeSelected.Equals("Font"))
                    {
                        if(this.CurrentAssetProject.Fonts == null)
                            this.CurrentAssetProject.Fonts = new List<FontItem>();

                        FontItem obj = new FontItem("font" + this.CurrentAssetProject.Fonts.Count, null);
                        this.CurrentAssetProject.Fonts.Add(obj);
                        objectCreated = obj;
                    }

                    if (objectCreated != null)
                    {
                        this.RefreshAssetListView();
                        this.openPanelFromObject(objectCreated);
                    }

                }

            }
        }
Exemple #9
0
        public void removeSpriteSheet(CoronaSpriteSheet sheet)
        {
            if (this.CurrentAssetProject != null)
            {
                List<CoronaSpriteSet> objToRemove = new List<CoronaSpriteSet>();
                //Chercher tous les sprite utilisant cette sprite set
                for (int i = 0; i < this.CurrentAssetProject.SpriteSets.Count; i++)
                {
                    CoronaSpriteSet obj = this.CurrentAssetProject.SpriteSets[i];
                    for (int j = 0; j < obj.Frames.Count; j++)
                    {
                        if (obj.Frames[j].SpriteSheetParent == sheet)
                        {
                            if(!objToRemove.Contains(obj))
                                objToRemove.Add(obj);
                        }
                    }
                }

                for (int i = 0; i < objToRemove.Count; i++)
                {
                    CoronaSpriteSet obj = objToRemove[i];
                    this.removeSpriteSet(obj);
                }

                objToRemove.Clear();

                for (int i = 0; i < sheet.Frames.Count; i++)
                {
                    SpriteFrame obj = sheet.Frames[i];
                    obj.Image.Dispose();
                    obj = null;
                }
                sheet.Frames.Clear();

                this.CurrentAssetProject.SpriteSheets.Remove(sheet);

            }
        }
Exemple #10
0
        public void openSpriteSheetManagerFromObject(CoronaSpriteSheet spriteSheet)
        {
            hideAllObjectsPanel();

            //Si le tab est deja ouvert
            SpriteSheetManagerPanel panel = null;
            UserControl page = getObjectPanelFromObject(spriteSheet);
            if (page != null)
            {
                page.Visible = true;
                panel = (SpriteSheetManagerPanel)page;
            }
            //Sinn
            else
            {
                //Create a spite manager panel
                panel = new SpriteSheetManagerPanel();
                panel.init(this, spriteSheet);
                panel.Dock = DockStyle.Fill;
                panel.Tag = spriteSheet;
                addNewControlToObjectsPanel(panel);
                panel.Visible = true;
            }

            panel.DisplayObjectProperties();
        }
Exemple #11
0
        public CoronaSpriteSet CloneInstance()
        {
            CoronaSpriteSet newSet = new CoronaSpriteSet(this.Name);

            List<CoronaSpriteSheet> sheetUsed = new List<CoronaSpriteSheet>();

            for (int i = 0; i < this.Frames.Count; i++)
            {
                if (!sheetUsed.Contains(this.Frames[i].SpriteSheetParent))
                    sheetUsed.Add(this.Frames[i].SpriteSheetParent);
            }

            for (int i = 0; i < sheetUsed.Count; i++)
            {
                CoronaSpriteSheet sheet = new CoronaSpriteSheet(sheetUsed[i].Name);
                sheet.FramesFactor = sheetUsed[i].FramesFactor;

                for (int j = 0; j < sheetUsed[i].Frames.Count; j++)
                {
                    SpriteFrame frame = new SpriteFrame(sheetUsed[i].Frames[j].NomFrame, j, sheetUsed[i].Frames[j].Image, sheet);
                    sheet.addFrame(frame);
                }

            }

            return null;
        }
 public SpriteSheetPropertyConverter(CoronaSpriteSheet sheet, AssetManagerForm MainForm,SpriteSheetManagerPanel sheetManager)
 {
     this.sheet = sheet;
     this.MainForm = MainForm;
     this.sheetManager = sheetManager;
 }
        public bool IsSpriteSheetUsedByProject(CoronaSpriteSheet sheet, CoronaObject sourceObject)
        {
            if (this.currentProject != null)
            {
                for (int i = 0; i < this.currentProject.Scenes.Count; i++)
                {
                    Scene scene = this.currentProject.Scenes[i];
                    for (int j = 0; j < scene.Layers.Count; j++)
                    {
                        CoronaLayer layer = scene.Layers[j];
                        for (int k = 0; k < layer.CoronaObjects.Count; k++)
                        {

                            bool res = this.IsSpriteSheetUsedByObject(layer.CoronaObjects[k], sheet, sourceObject);
                            if (res == true)
                                return true;
                        }
                    }
                }
            }

            return false;
        }
        public bool IsSpriteSheetUsedByObject(CoronaObject obj, CoronaSpriteSheet sheet, CoronaObject sourceObject)
        {
            if (obj != null)
            {
                if (obj.isEntity == true)
                {
                    CoronaEntity entity = obj.Entity;
                    for (int l = 0; l < entity.CoronaObjects.Count; l++)
                    {
                        CoronaObject child = entity.CoronaObjects[l];
                        bool res = this.IsSpriteSheetUsedByObject(child, sheet, sourceObject);
                        if (res == true)
                            return true;
                    }
                }
                else
                {
                    if (obj == sourceObject) return false;
                    if (obj.DisplayObject != null)
                    {

                        if (obj.DisplayObject.SpriteSet != null)
                        {
                            List<CoronaSpriteSheet> sheetUsedByObject = this.GetSpriteSheetsUsedFromSpriteSet(obj.DisplayObject.SpriteSet);
                            for (int i = 0; i < sheetUsedByObject.Count; i++)
                            {
                                CoronaSpriteSheet sheetUsed = sheetUsedByObject[i];
                                if (sheet.Name.Equals(sheetUsed.Name))
                                    return true;
                            }

                        }
                    }
                }
            }

            return false;
        }
        public void init(AssetManagerForm mainForm,CoronaSpriteSheet sheet)
        {
            this.mainForm = mainForm;
            this.sheet = sheet;

            if (this.sheet != null)
            {

                this.calculateSizeBt_Click(null, null);
                refreshFramesListView();
                this.DisplayObjectProperties();
            }
        }