Esempio n. 1
0
 //----------------------------------------------------------
 //--------------------- CONSTRUCTEURS ----------------------
 //----------------------------------------------------------
 public WidgetTabBar(string name,CoronaLayer layerParent)
     : base(name,WidgetType.tabBar,layerParent)
 {
     Buttons = new List<TabBarButton>();
     GradientForTup = new GradientColor();
     GradientForTup.isEnabled = false;
 }
Esempio n. 2
0
        public void CleanLayerGraphics(CoronaLayer layer, bool removeAsset, bool checkIntegrity)
        {
            if (layer.TilesMap != null)
                this.CleanTileMap(layer.TilesMap, removeAsset, checkIntegrity);

            for (int k = 0; k < layer.CoronaObjects.Count; k++)
            {
                CoronaObject obj = layer.CoronaObjects[k];
                if (obj.isEntity == true)
                {
                    for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++)
                    {
                        CoronaObject child = obj.Entity.CoronaObjects[l];
                        this.CleanSprite(child, removeAsset, checkIntegrity);
                    }
                }
                else
                {
                    this.CleanSprite(obj, removeAsset, checkIntegrity);
                }

            }

            for (int k = 0; k < layer.Controls.Count; k++)
            {
                CoronaControl control = layer.Controls[k];
                this.CleanSprite(control, removeAsset);
            }
        }
Esempio n. 3
0
        //---------------------------------------------------
        //-------------------Constructeurs--------------------
        //---------------------------------------------------
        public JoystickControl(CoronaLayer layerParent)
            : base(ControlType.joystick, layerParent.Name + "_joystick"+layerParent.Controls.Count)
        {
            this.joystickName = layerParent.Name + "_joystick" + layerParent.Controls.Count;
            this.layerParent = layerParent;

            this.outerImage = null;
            this.innerImage = null;

            this.outerRadius = 30;
            this.outerAlpha = 1;
            this.innerRadius = 15;
            this.innerAlpha = 1;

            this.joystickLocation = new Point(0,0);
            this.joystickAlpha = 1;
            this.joystickFade = true;
            this.joystickFadeDelay = 2000;
            this.ghost = 150;
        }
Esempio n. 4
0
        public CoronaLayer newLayer()
        {
            CoronaLayer layer = new CoronaLayer(this.Layers.Count, this);

            this.Layers.Add(layer);

            return layer;
        }
Esempio n. 5
0
        public CoronaLayer Clone()
        {
            try
            {
                CoronaLayer newLayer = new CoronaLayer(this.SceneParent.Layers.Count,this.SceneParent);

                //Clone all Objects
                for (int i = 0;i<this.CoronaObjects.Count;i++)
                {
                    CoronaObject currentObj = this.CoronaObjects[i];
                    CoronaObject newObj = currentObj.cloneObject(newLayer,true,true);
                }

                //Clone all Joints
                for (int i = 0;i<this.Jointures.Count;i++)
                {
                    CoronaJointure currentJoint = this.Jointures[i];

                    //FindCoronaObjects
                    string objNameA = currentJoint.coronaObjA.DisplayObject.Name;
                    string objNameB ="";
                    CoronaObject objA = null;
                    CoronaObject objB = null;
                    if(currentJoint.coronaObjB != null)
                    {
                        objNameB=currentJoint.coronaObjB.DisplayObject.Name;
                    }

                    for (int j = 0; j < newLayer.CoronaObjects.Count; j++)
                    {
                        CoronaObject currentObj = newLayer.CoronaObjects[j];
                        if(currentObj.DisplayObject.Name.Equals(objNameA))
                            objA = currentObj;
                        else if(currentObj.DisplayObject.Name.Equals(objNameB))
                            objB = currentObj;
                    }

                    CoronaJointure newJoint = currentJoint.clone(objA,objB,newLayer);
                    newLayer.Jointures.Add(newJoint);
                }

                //Clone all controls
                for (int i = 0;i<this.Controls.Count;i++)
                {
                    CoronaControl currentControl = this.Controls[i];
                    CoronaControl newControl = currentControl.Clone(newLayer,false);
                    newLayer.Controls.Add(newControl);
                }

                //-------------- WARNING: CLONE WIDGETS TO DO ----------------------------
                //-------------- WARNING: CLONE TILESMAP TO DO ----------------------------

                return newLayer;
            }
            catch(Exception ex)
            {
                MessageBox.Show("Error:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return null;
            }
        }
Esempio n. 6
0
        //----------------------------------------------------------
        //----------------LAYER-----------------------
        //----------------------------------------------------------
        public void newLayer(Scene scene,CoronaLayer layer)
        {
            this.LayerSelected = layer;
            this.CoronaObjectSelected = null;
            this.LayerSelected.deselectAllObjects();
            GameElement node = new GameElement("LAYER",layer.Name, layer);
            if (scene.projectParent.isEnabled == false)
            {
                layer.isEnabled = true;
            }

            node.Checked = layer.isEnabled;

            GameElement sceneNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, scene);
            if (sceneNode != null)
            {

                sceneNode.Nodes.Add(node);

                //Ajouter les jointures
                TreeNode nodeJoints = new TreeNode("Joints");

                nodeJoints.Name = "JOINTS";
                nodeJoints.ImageIndex = 8;
                nodeJoints.SelectedImageIndex = 8;
                node.Nodes.Add(nodeJoints);
                this.HideCheckBox(this.treeViewElements, nodeJoints);
                for (int i = 0; i < layer.Jointures.Count; i++)
                {
                    this.newJoint(layer.Jointures[i], false, null);
                }

                //Ajouter une tiles map si existante
                if (layer.TilesMap != null)
                {
                    layer.TilesMap.LayerParent = layer;
                    this.newTilesMap(layer.TilesMap);

                }

                //Ajouter tous les objet du layer
                for (int i = 0; i < layer.CoronaObjects.Count; i++)
                {
                    this.newCoronaObject(layer.CoronaObjects[i]);
                    this.CoronaObjectSelected = null;
                }

                //Ajouter tous les Controls du layer

                for (int i = 0; i < layer.Controls.Count; i++)
                {
                    this.newCoronaControl(layer.Controls[i]);
                }

                //Ajouter tous les Widgets du layer

                for (int i = 0; i < layer.Widgets.Count; i++)
                {
                    this.newCoronaWidget(layer.Widgets[i]);
                }

                node.Expand();
            }

            sceneNode.Expand();
        }
Esempio n. 7
0
        private void treeViewElements_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (hasChecked == false)
            {
                try
                {
                    bool isCustomBuild = this.MainForm.IsCustomBuild;
                    float XRatio = 1;
                    float YRatio = 1;
                    if (isCustomBuild == true)
                    {
                        XRatio = (float)this.MainForm.currentTargetResolution.Resolution.Width / (float)this.MainForm.CurrentProject.width;
                        YRatio = (float)this.MainForm.currentTargetResolution.Resolution.Height / (float)this.MainForm.CurrentProject.height;
                    }

                    //Recuperer la node Project root
                    ProjectRootNodeSelected = getRootNode(e.Node);
                    ProjectSelected = (CoronaGameProject)ProjectRootNodeSelected.Tag;

                    //Si il y a deja un panel Physic d'ouvert : Le fermer

                    if (this.MainForm.CurrentObjectPhysicEditorPanel != null)
                        if (this.MainForm.getMapEditorPage().Controls.Contains(this.MainForm.CurrentObjectPhysicEditorPanel))
                        {
                            this.MainForm.getMapEditorPage().Controls.Remove(this.MainForm.CurrentObjectPhysicEditorPanel);
                        }

                    //SI la node selectionnée est un game element

                    if (e.Node == this.ProjectRootNodeSelected)
                    {
                        ProjectPropertyConverter converter = new ProjectPropertyConverter(this.ProjectSelected, this.MainForm);

                        this.MainForm.propertyGrid1.SelectedObject = converter;
                    }
                    if (e.Node.Name.Equals("GAME_ELEMENT"))
                    {
                        //Faire le traitement de selection
                        GameElement nodeSelected = (GameElement)e.Node;

                        if (nodeSelected.NodeType.Equals("STAGE"))
                        {

                            this.SceneSelected = ((Scene)nodeSelected.InstanceObjet);
                            this.MainForm.sceneEditorView1.objectsSelected.Clear();
                            this.MainForm.sceneEditorView1.setModeSceneEditor(this.SceneSelected);

                            //Deselect others
                            if (this.LayerSelected != null)
                            {
                                this.LayerSelected.deselectAllObjects();
                                this.LayerSelected.deselectAllControls();
                            }

                            this.LayerSelected = null;
                            this.CoronaObjectSelected = null;

                            //Afficher les proprietes du layer dans le property grid
                            ScenePropertyConverter sceneConverter = new ScenePropertyConverter(this.SceneSelected, this.MainForm);
                            this.MainForm.propertyGrid1.SelectedObject = sceneConverter;

                            //Mettre a jour le fichier lua
                            this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio);
                        }
                        else if (nodeSelected.NodeType.Equals("LAYER"))
                        {

                            //Deselect others
                            if (this.LayerSelected != null)
                            {
                                this.LayerSelected.deselectAllObjects();
                                this.LayerSelected.deselectAllControls();
                            }

                            this.LayerSelected = ((CoronaLayer)nodeSelected.InstanceObjet);
                            this.LayerSelected.deselectAllObjects();
                            this.LayerSelected.deselectAllControls();
                            this.MainForm.sceneEditorView1.objectsSelected.Clear();

                            this.SceneSelected = this.LayerSelected.SceneParent;
                            this.CoronaObjectSelected = null;

                            this.MainForm.sceneEditorView1.setModeLayerEditor(this.LayerSelected);

                            //Afficher les proprietes du layer dans le property grid
                            LayerPropertyConverter layerConverter = new LayerPropertyConverter(this.LayerSelected, this.MainForm);
                            this.MainForm.propertyGrid1.SelectedObject = layerConverter;

                            //Mettre a jour le fichier lua
                            //this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio);
                        }
                        else if (nodeSelected.NodeType.Equals("OBJECT") || nodeSelected.NodeType.Equals("ENTITY"))
                        {

                            CoronaObject obj = ((CoronaObject)nodeSelected.InstanceObjet);

                            //Selectionner le layer parent
                            this.LayerSelected = obj.LayerParent;

                            if (nodeSelected.NodeType.Equals("ENTITY"))
                            {
                                this.MainForm.SetModeEntity();
                                //this.LayerSelected.deselectAllObjects();
                            }
                            else
                                this.MainForm.SetModeObject();

                            //Fermer le layer et la scene
                            this.SceneSelected = this.LayerSelected.SceneParent;

                            this.CoronaObjectSelected = obj;

                            //Mettre a jour le fichier lua
                            //this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio);

                            /*if (this.MainForm.isFormLocked == false)
                                this.MainForm.sceneEditorView1.surfacePictBx.Refresh();*/
                        }
                        else if (nodeSelected.NodeType.Equals("TILESMAP"))
                        {
                            this.MainForm.SetModeObject();
                            TilesMap map = ((TilesMap)nodeSelected.InstanceObjet);

                            //Selectionner le layer parent
                            this.CoronaObjectSelected = null;

                            this.LayerSelected = (CoronaLayer)((GameElement)nodeSelected.Parent).InstanceObjet;
                            this.SceneSelected = this.LayerSelected.SceneParent;

                            //Deselect all objects
                            this.LayerSelected.deselectAllObjects();

                            //Afficher les proprietes de l'objet dans le property grid
                            TilesMapPropertyConverter mapConverter = new TilesMapPropertyConverter(map, this.MainForm);
                            this.MainForm.propertyGrid1.SelectedObject = mapConverter;

                            if (this.MainForm.isFormLocked == false)
                                GorgonLibrary.Gorgon.Go();

                        }
                        else if (nodeSelected.NodeType.Equals("CONTROL"))
                        {
                            this.MainForm.SetModeControl();
                            CoronaControl control = ((CoronaControl)nodeSelected.InstanceObjet);
                            this.ControlSelected = control;
                            if (control.type == CoronaControl.ControlType.joystick)
                            {

                                JoystickControl joy = (JoystickControl)control;
                                JoystickPropertyConverter joyConverter = new JoystickPropertyConverter(joy, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = joyConverter;

                            }
                        }
                        else if (nodeSelected.NodeType.Equals("WIDGET"))
                        {
                            CoronaWidget widget = ((CoronaWidget)nodeSelected.InstanceObjet);
                            this.WidgetSelected = widget;
                            widget.Type = CoronaWidget.WidgetType.tabBar;
                            if (widget.Type == CoronaWidget.WidgetType.tabBar)
                            {

                                TabBarPropertyConverter converter = new TabBarPropertyConverter(widget, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;

                            }
                            else if (widget.Type == CoronaWidget.WidgetType.pickerWheel)
                            {

                                WidgetPickerWheel pickerW = (WidgetPickerWheel)widget;
                                this.MainForm.propertyGrid1.SelectedObject = pickerW;

                            }
                        }
                        else if (nodeSelected.NodeType.Equals("JOINT"))
                        {

                            CoronaJointure joint = nodeSelected.InstanceObjet as CoronaJointure;

                            this.MainForm.setModeJoint();

                            //Selectionner le layer parent
                            this.CoronaObjectSelected = null;
                            this.JointureSelected = joint;
                            this.LayerSelected = joint.layerParent;
                            this.LayerSelected.JointureSelected = joint;
                            this.SelectedNodes.Add(nodeSelected);

                            this.MainForm.sceneEditorView1.setModeLayerEditor(joint.layerParent);
                            //Ouvrir le property converter correspondant au joint
                            if (this.JointureSelected.type.Equals("DISTANCE"))
                            {
                                DistancePropertyConverter converter = new DistancePropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("FRICTION"))
                            {
                                FrictionPropertyConverter converter = new FrictionPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("PISTON"))
                            {
                                PistonPropertyConverter converter = new PistonPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("PIVOT"))
                            {
                                PivotPropertyConverter converter = new PivotPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("WELD"))
                            {
                                WeldPropertyConverter converter = new WeldPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("WHEEL"))
                            {
                                WheelPropertyConverter converter = new WheelPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("PULLEY"))
                            {
                                PulleyPropertyConverter converter = new PulleyPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }
                            else if (this.JointureSelected.type.Equals("TOUCH"))
                            {
                                TouchPropertyConverter converter = new TouchPropertyConverter(this.JointureSelected, this.MainForm);
                                this.MainForm.propertyGrid1.SelectedObject = converter;
                            }

                            //Mettre a jour le fichier lua
                            this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio);

                        }
                        else if (nodeSelected.NodeType.Equals("AUDIO"))
                        {

                            this.AudioObjectSelected = (AudioObject)nodeSelected.InstanceObjet;
                        }
                        else if (nodeSelected.NodeType.Equals("SNIPPET"))
                        {
                            this.SnippetSelected = (Snippet)nodeSelected.InstanceObjet;
                            this.MainForm.cgEeditor1.RefreshSnippetLuaCode(this.ProjectSelected);
                        }
                        else if (nodeSelected.NodeType.Equals("FONT"))
                        {
                            this.FontSelected = (FontItem)nodeSelected.InstanceObjet;
                        }

                        //------------Verifier si le clic est un clic droit
                        if (e.Button == System.Windows.Forms.MouseButtons.Right)
                        {

                            if (nodeSelected.NodeType.Equals("STAGE"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.menuScene;
                                this.treeViewElements.ContextMenuStrip.Show();
                                this.LayerSelected = null;
                            }
                            else if (nodeSelected.NodeType.Equals("LAYER"))
                            {

                                this.treeViewElements.ContextMenuStrip = this.menuLayer;
                                this.treeViewElements.ContextMenuStrip.Show();

                            }
                            else if (nodeSelected.NodeType.Equals("OBJECT") || nodeSelected.NodeType.Equals("ENTITY"))
                            {

                                CoronaObject obj = ((CoronaObject)nodeSelected.InstanceObjet);

                                activerBoutonsNecessairesMenuObject(obj);

                                this.treeViewElements.ContextMenuStrip = this.menuObject;
                                this.treeViewElements.ContextMenuStrip.Show();

                            }
                            else if (nodeSelected.NodeType.Equals("CONTROL"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.menuControl;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else if (nodeSelected.NodeType.Equals("WIDGET"))
                            {
                                CoronaWidget widget = (CoronaWidget)nodeSelected.InstanceObjet;
                                if (widget.Type == CoronaWidget.WidgetType.tabBar)
                                {
                                    this.treeViewElements.ContextMenuStrip = this.menuWidgetTabBar;
                                    this.treeViewElements.ContextMenuStrip.Show();
                                }
                                else if (widget.Type == CoronaWidget.WidgetType.pickerWheel)
                                {
                                    this.treeViewElements.ContextMenuStrip = this.menuWidgetPickerWheel;
                                    this.treeViewElements.ContextMenuStrip.Show();
                                }

                            }
                            else if (nodeSelected.NodeType.Equals("SPRITESHEET") || nodeSelected.NodeType.Equals("SPRITESET"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.menuSpriteSetSheet;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else if (nodeSelected.NodeType.Equals("JOINT"))
                            {

                                this.treeViewElements.ContextMenuStrip = this.menuJointures;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else if (nodeSelected.NodeType.Equals("AUDIO"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.menuAudio;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else if (nodeSelected.NodeType.Equals("TILESMAP"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.menuTilesmap;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else if (nodeSelected.NodeType.Equals("SNIPPET"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.menuSnippets;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else if (nodeSelected.NodeType.Equals("FONT"))
                            {
                                this.treeViewElements.ContextMenuStrip = this.fontMenu;
                                this.treeViewElements.ContextMenuStrip.Show();
                            }
                            else
                                this.treeViewElements.ContextMenuStrip = null;
                        }

                        else
                            this.treeViewElements.ContextMenuStrip = null;
                    }
                    else if (e.Node.Name.Equals("PROJECT"))
                    {
                        //Verifier si le clic est un clic droit
                        if (e.Button == System.Windows.Forms.MouseButtons.Right)
                        {
                            this.treeViewElements.ContextMenuStrip = this.menuProject;
                            this.treeViewElements.ContextMenuStrip.Show();
                        }
                    }
                    else
                        this.treeViewElements.ContextMenuStrip = null;

                }
                catch (Exception ex)
                {
                    Application.Exit();
                }
            }
        }
Esempio n. 8
0
 public void clearTreeView()
 {
     this.LayerSelected = null;
     this.SceneSelected = null;
     CoronaObjectSelected = null;
     this.JointureSelected = null;
     this.nodeTemp = null;
     this.treeViewElements.Nodes.Clear();
 }
Esempio n. 9
0
        public static void exportLayer(Form1 mainForm, CoronaLayer layer, string directoryName, BackgroundWorker worker)
        {
            worker.ReportProgress(20);

            string layerSerializedDirectory = directoryName+"\\"+layer.Name;

            if (Directory.Exists(layerSerializedDirectory))
                Directory.Delete(layerSerializedDirectory, true);

             Directory.CreateDirectory(layerSerializedDirectory);

            FileStream fs = File.Create(layerSerializedDirectory + "\\" + layer.Name + ".krl");
            MemoryStream ms = SerializerHelper.SerializeBinary(layer);

            worker.ReportProgress(40);
            fs.Write(ms.GetBuffer(), 0, (int)ms.Length);
            ms.Flush();
            fs.Close();
            worker.ReportProgress(60);

            if (layer.TilesMap != null)
            {
                string mapResourcesDirectory = mainForm.CurrentProject.ProjectPath + "\\Resources\\TileMaps\\" + layer.TilesMap.TilesMapName;
                if (Directory.Exists(mapResourcesDirectory))
                {
                    Directory.CreateDirectory(layerSerializedDirectory+"\\TileMaps\\"+ layer.TilesMap.TilesMapName);

                    string[] files = Directory.GetFiles(mapResourcesDirectory);
                    for (int i = 0; i < files.Length; i++)
                    {
                        string fileNameOnly = Path.GetFileName(files[i]);
                        File.Copy(files[i], layerSerializedDirectory + "\\TileMaps\\" + layer.TilesMap.TilesMapName + "\\" + fileNameOnly);
                    }
                }

                layer.TilesMap.createJSONConfigFile(layer.SceneParent, mainForm.CurrentProject.SourceFolderPath, 1, 1);

                string path1 = mainForm.CurrentProject.SourceFolderPath + "\\" + layer.TilesMap.TilesMapName.ToLower() + "textures.json";
                string path2 = mainForm.CurrentProject.SourceFolderPath + "\\" + layer.TilesMap.TilesMapName.ToLower() + "objects.json";
                string path3 = mainForm.CurrentProject.SourceFolderPath + "\\" + layer.TilesMap.TilesMapName.ToLower() + "collisions.json";
                string path4 = mainForm.CurrentProject.SourceFolderPath + "\\" + layer.TilesMap.TilesMapName.ToLower() + "texturesequences.json";
                string path5 = mainForm.CurrentProject.SourceFolderPath + "\\" + layer.TilesMap.TilesMapName.ToLower() + "objectsequences.json";
                string path6 = mainForm.CurrentProject.SourceFolderPath + "\\" + layer.TilesMap.TilesMapName.ToLower() + "events.json";

                if (File.Exists(path1))
                    File.Copy(path1, layerSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "textures.json", true);

                if (File.Exists(path2))
                    File.Copy(path2, layerSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "objects.json", true);

                if (File.Exists(path3))
                    File.Copy(path3, layerSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "collisions.json", true);

                if (File.Exists(path4))
                    File.Copy(path4, layerSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "texturesequences.json", true);

                if (File.Exists(path5))
                    File.Copy(path5, layerSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "objectsequences.json", true);

                if (File.Exists(path6))
                    File.Copy(path6, layerSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "events.json", true);

            }

            for (int i = 0; i < layer.CoronaObjects.Count; i++)
            {
                CoronaObject obj = layer.CoronaObjects[i];
                if (obj.isEntity == true)
                {
                    CoronaEntity entity = obj.Entity;
                    for (int j = 0; j < entity.CoronaObjects.Count; j++)
                    {
                        CoronaObject child = entity.CoronaObjects[j];
                        if (child.DisplayObject != null)
                        {
                            if (child.DisplayObject.Type.Equals("IMAGE"))
                            {

                                string filename = Path.Combine(mainForm.CurrentProject.ProjectPath + "\\Resources\\Images", child.DisplayObject.OriginalAssetName + ".png");
                                if (File.Exists(filename))
                                {
                                    if (!Directory.Exists(layerSerializedDirectory + "\\Images"))
                                        Directory.CreateDirectory(layerSerializedDirectory + "\\Images");

                                    File.Copy(filename, layerSerializedDirectory + "\\Images\\" + child.DisplayObject.OriginalAssetName + ".png", true);
                                }

                            }
                            else if (child.DisplayObject.Type.Equals("SPRITE"))
                            {
                                CoronaSpriteSet set = child.DisplayObject.SpriteSet;
                                if (set != null)
                                {
                                    List<CoronaSpriteSheet> spriteSheetsUsed = new List<CoronaSpriteSheet>();
                                    for (int k = 0; k < set.Frames.Count; k++)
                                    {
                                        if (!spriteSheetsUsed.Contains(set.Frames[k].SpriteSheetParent))
                                            spriteSheetsUsed.Add(set.Frames[k].SpriteSheetParent);

                                    }

                                    for (int k = 0; k < spriteSheetsUsed.Count; k++)
                                    {
                                        CoronaSpriteSheet sheet = spriteSheetsUsed[k];
                                        string sheetDirectory = Path.Combine(mainForm.CurrentProject.ProjectPath + "\\Resources\\SpriteSheets", sheet.Name);
                                        if (!Directory.Exists(layerSerializedDirectory + "\\SpriteSheets\\" + sheet.Name))
                                        {
                                            Directory.CreateDirectory(layerSerializedDirectory + "\\SpriteSheets\\" + sheet.Name);
                                        }

                                        string[] files = Directory.GetFiles(sheetDirectory);
                                        for (int l = 0; l < files.Length; l++)
                                        {
                                            string fileNameOnly = Path.GetFileName(files[l]);
                                            File.Copy(files[l], layerSerializedDirectory + "\\SpriteSheets\\" + sheet.Name + "\\" + fileNameOnly, true);
                                        }

                                    }
                                }
                            }
                        }
                    }
                }
                else
                {

                    if (obj.DisplayObject != null)
                    {
                        if (obj.DisplayObject.Type.Equals("IMAGE"))
                        {

                            string filename = Path.Combine(mainForm.CurrentProject.ProjectPath + "\\Resources\\Images", obj.DisplayObject.OriginalAssetName + ".png");
                            if (File.Exists(filename))
                            {
                                if (!Directory.Exists(layerSerializedDirectory + "\\Images"))
                                    Directory.CreateDirectory(layerSerializedDirectory + "\\Images");

                                File.Copy(filename, layerSerializedDirectory + "\\Images\\" + obj.DisplayObject.OriginalAssetName + ".png", true);
                            }

                        }
                        else if (obj.DisplayObject.Type.Equals("SPRITE"))
                        {
                            CoronaSpriteSet set = obj.DisplayObject.SpriteSet;
                            if (set != null)
                            {
                                List<CoronaSpriteSheet> spriteSheetsUsed = new List<CoronaSpriteSheet>();
                                for (int j = 0; j < set.Frames.Count; j++)
                                {
                                    if (!spriteSheetsUsed.Contains(set.Frames[j].SpriteSheetParent))
                                        spriteSheetsUsed.Add(set.Frames[j].SpriteSheetParent);

                                }

                                for (int j = 0; j < spriteSheetsUsed.Count; j++)
                                {
                                    CoronaSpriteSheet sheet = spriteSheetsUsed[j];
                                    string sheetDirectory = Path.Combine(mainForm.CurrentProject.ProjectPath + "\\Resources\\SpriteSheets", sheet.Name);
                                    if (!Directory.Exists(layerSerializedDirectory + "\\SpriteSheets\\" + sheet.Name))
                                    {
                                        Directory.CreateDirectory(layerSerializedDirectory + "\\SpriteSheets\\" + sheet.Name);
                                    }

                                    string[] files = Directory.GetFiles(sheetDirectory);
                                    for (int k = 0; k < files.Length; k++)
                                    {
                                        string fileNameOnly = Path.GetFileName(files[k]);
                                        File.Copy(files[k], layerSerializedDirectory + "\\SpriteSheets\\" + sheet.Name + "\\" + fileNameOnly, true);
                                    }

                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < layer.Controls.Count; i++)
            {
                Corona_Classes.Controls.CoronaControl control = layer.Controls[i];
                if (control.type == Corona_Classes.Controls.CoronaControl.ControlType.joystick)
                {
                    Corona_Classes.Controls.JoystickControl joy = control as Corona_Classes.Controls.JoystickControl;

                    string innerImage = mainForm.CurrentProject.ProjectPath + "\\Resources\\Images\\" + joy.joystickName + "_inner.png";
                    if (File.Exists(innerImage))
                        File.Copy(innerImage, layerSerializedDirectory + "\\Images\\" + joy.joystickName + "_inner.png");

                    string outerImage = mainForm.CurrentProject.ProjectPath + "\\Resources\\Images\\" + joy.joystickName + "_outer.png";
                    if (File.Exists(outerImage))
                        File.Copy(outerImage, layerSerializedDirectory + "\\Images\\" + joy.joystickName + "_outer.png");

                }
            }

            worker.ReportProgress(80);
        }
Esempio n. 10
0
 public abstract CoronaControl Clone(CoronaLayer layerDest,bool incrementName);
Esempio n. 11
0
        public CoronaObject cloneObject(CoronaLayer layerDest,bool incrementName,bool keepPosition)
        {
            if (this.isEntity == true)
            {
                CoronaObject newEntity = new CoronaObject(true);
                newEntity.isEnabled = this.isEnabled;
                layerDest.addCoronaObject(newEntity, incrementName);
                newEntity.Entity = this.Entity.cloneEntity(newEntity);

                return newEntity;

            }
            else if(this.EntityParent != null)
            {
                if (this.displayObject != null)
                {

                    //Dupliquer le displayObject
                    DisplayObject newDisplayObject = this.DisplayObject.cloneInstance(keepPosition);

                    CoronaObject newObject = new CoronaObject(newDisplayObject);
                    newObject.displayObject.Name = layerDest.SceneParent.projectParent.IncrementObjectName(newDisplayObject.Name);

                    if (newObject != null)
                    {

                        //Copier le body
                        if (this.PhysicsBody != null)
                        {
                            newObject.PhysicsBody = this.PhysicsBody.cloneBody(newObject);
                        }

                        newObject.isDraggable = this.isDraggable;

                        //Copier les events de l'objet
                        newObject.onStartFunction = this.onStartFunction;
                        newObject.onPauseFunction = this.onPauseFunction;
                        newObject.onDeleteFunction = this.onDeleteFunction;

                        StringBuilder sb = new StringBuilder();
                        //Retirer le nom des functions et les ajuster au nom de l'objet
                        //---POUR START

                        sb.Append(newObject.onStartFunction);
                        newObject.onStartFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name);
                        sb.Clear();

                        //---POUR PAUSE

                        sb.Append(newObject.onPauseFunction);
                        newObject.onPauseFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name);
                        sb.Clear();

                        //---POUR DELETE

                        sb.Append(newObject.onDeleteFunction);
                        newObject.onDeleteFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name);
                        sb.Clear();

                        if (this.isGenerator == true)
                        {
                            newObject.isGenerator = true;
                            newObject.generatorDelay = this.generatorDelay;
                            newObject.generatorIteration = this.generatorIteration;
                            newObject.generatorEmissionType = this.generatorEmissionType;
                            newObject.FadeInEnabled = this.FadeInEnabled;
                            newObject.FadeInSpeed = this.FadeInSpeed;
                            newObject.FadeOutEnabled = this.FadeOutEnabled;
                            newObject.FadeOutSpeed = this.FadeOutSpeed;
                            newObject.RemoveOnCompleteFadeOut = this.RemoveOnCompleteFadeOut;
                            newObject.DelayBetweenFades = this.DelayBetweenFades;
                            newObject.GeneratorXImpulse = this.GeneratorXImpulse;
                            newObject.GeneratorYImpulse = this.GeneratorYImpulse;
                        }

                        newObject.displayObject.GradientColor.isEnabled = this.displayObject.GradientColor.isEnabled;
                        newObject.displayObject.GradientColor.color1 = this.displayObject.GradientColor.color1;
                        newObject.displayObject.GradientColor.color2 = this.displayObject.GradientColor.color2;
                        newObject.displayObject.GradientColor.direction = this.displayObject.GradientColor.direction;
                        newObject.displayObject.Alpha = this.displayObject.Alpha;

                        newObject.PathFollow = this.PathFollow.cloneInstance(newObject);
                        newObject.displayObject.Rotation = this.displayObject.Rotation;

                        newObject.isDraggable = this.isDraggable;

                        return newObject;
                    }

                }
            }
            else
            {
                if (this.displayObject != null)
                {

                    //Dupliquer le displayObject
                    DisplayObject newDisplayObject = this.DisplayObject.cloneInstance(keepPosition);

                    CoronaObject newObject = new CoronaObject(newDisplayObject);

                    if (newObject != null)
                    {
                        newObject.isEnabled = this.isEnabled;
                        //Copier le layer parent
                        layerDest.addCoronaObject(newObject, incrementName);
                        newObject.displayObject.OriginalAssetName = this.displayObject.OriginalAssetName;

                        //Copier le body
                        if (this.PhysicsBody != null)
                        {
                            newObject.PhysicsBody = this.PhysicsBody.cloneBody(newObject);
                        }

                        //Copier les events de l'objet
                        newObject.onStartFunction = this.onStartFunction;
                        newObject.onPauseFunction = this.onPauseFunction;
                        newObject.onDeleteFunction = this.onDeleteFunction;

                        StringBuilder sb = new StringBuilder();
                        //Retirer le nom des functions et les ajuster au nom de l'objet
                        //---POUR START

                        sb.Append(newObject.onStartFunction);
                        newObject.onStartFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name);
                        sb.Clear();

                        //---POUR PAUSE

                        sb.Append(newObject.onPauseFunction);
                        newObject.onPauseFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name);
                        sb.Clear();

                        //---POUR DELETE

                        sb.Append(newObject.onDeleteFunction);
                        newObject.onDeleteFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name);
                        sb.Clear();

                        if (this.isGenerator == true)
                        {
                            newObject.isGenerator = true;
                            newObject.generatorDelay = this.generatorDelay;
                            newObject.generatorIteration = this.generatorIteration;
                            newObject.generatorEmissionType = this.generatorEmissionType;
                            newObject.FadeInEnabled = this.FadeInEnabled;
                            newObject.FadeInSpeed = this.FadeInSpeed;
                            newObject.FadeOutEnabled = this.FadeOutEnabled;
                            newObject.FadeOutSpeed = this.FadeOutSpeed;
                            newObject.RemoveOnCompleteFadeOut = this.RemoveOnCompleteFadeOut;
                            newObject.DelayBetweenFades = this.DelayBetweenFades;
                            newObject.GeneratorXImpulse = this.GeneratorXImpulse;
                            newObject.GeneratorYImpulse = this.GeneratorYImpulse;

                        }

                        newObject.displayObject.GradientColor.isEnabled = this.displayObject.GradientColor.isEnabled;
                        newObject.displayObject.GradientColor.color1 = this.displayObject.GradientColor.color1;
                        newObject.displayObject.GradientColor.color2 = this.displayObject.GradientColor.color2;
                        newObject.displayObject.GradientColor.direction = this.displayObject.GradientColor.direction;
                        newObject.displayObject.Alpha = this.displayObject.Alpha;

                        newObject.PathFollow = this.PathFollow.cloneInstance(newObject);
                        newObject.displayObject.Rotation = this.displayObject.Rotation;

                        newObject.isDraggable = this.isDraggable;
                        return newObject;
                    }

                }
            }

            return null;
        }
Esempio n. 12
0
        public override CoronaControl Clone(CoronaLayer layerDest,bool incrementName)
        {
            JoystickControl newControl = new JoystickControl(layerDest);
            newControl.isEnabled = this.isEnabled;
            if(incrementName ==true)
            {
                int res = -1;
                if (int.TryParse(this.joystickName.Substring(this.joystickName.Length - 1), out res) == true)
                    newControl.joystickName = joystickName.Substring(0, joystickName.Length - 1) + (res + 1).ToString();
                else
                    newControl.joystickName = this.joystickName + 1;

                newControl.ControlName = this.ControlName;
            }
            else
            {
                newControl.joystickName = this.joystickName;
                newControl.ControlName = this.ControlName;
            }

            newControl.ghost = this.ghost;
            newControl.innerAlpha = this.innerAlpha;
            newControl.outerAlpha = this.outerAlpha;
            newControl.outerRadius = this.outerRadius;
            newControl.innerRadius = this.innerRadius;

            if(this.innerImage != null)
                 newControl.innerImage = new Bitmap(this.innerImage);

            if (this.outerImage != null)
                newControl.outerImage = new Bitmap(this.outerImage);

            newControl.joystickLocation = new Point(this.joystickLocation.X,this.joystickLocation.Y);
            newControl.joystickAlpha = this.joystickAlpha;
            newControl.joystickFade = this.joystickFade;
            newControl.joystickFadeDelay = this.joystickFadeDelay;

            return newControl;
        }
Esempio n. 13
0
        //---------------------------------------------------
        //-------------------Constructors--------------------
        //---------------------------------------------------
        public TilesMap(string name,Point location,int nbLines, int nbColumns, int tilesWidth, int tilesHeight,CoronaLayer layerParent)
        {
            this.TilesMapName = name;
            this.Location = location;
            this.NbLines = nbLines;
            this.NbColumns = nbColumns;
            this.TilesWidth = tilesWidth;
            this.TilesHeight = tilesHeight;

            this.colMin = 0;
            this.lineMin = 0;
            this.colMax = nbColumns;
            this.lineMax = nbLines;

            this.TileModelsTextureUsed = new List<TileModel>();
            this.TileModelsObjectsUsed = new List<TileModel>();
            TextureSequences = new List<TileSequence>();
            ObjectSequences = new List<TileSequence>();
            TileEvents = new List<TileEvent>();
            this.LayerParent = layerParent;
            createTilesTab();

            this.UpdateTileMapGraphicsContent();
        }
Esempio n. 14
0
        public CoronaJointure clone(CoronaObject objA, CoronaObject objB,CoronaLayer layerParent)
        {
            CoronaJointure newJoint = new CoronaJointure(layerParent);
            newJoint.isEnabled = this.isEnabled;
            newJoint.coronaObjA = objA;
            newJoint.coronaObjB = objB;
            newJoint.type = this.type;

            if(objB != null)
                newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name + "_" + objB.DisplayObject.Name;
            else
                newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name;

            newJoint.AnchorPointA = new Point(this.AnchorPointA.X, this.AnchorPointA.Y);
            newJoint.AnchorPointB = new Point(this.AnchorPointB.X, this.AnchorPointB.Y);

            newJoint.ObjectAnchorPointA = new Point(this.ObjectAnchorPointA.X, this.ObjectAnchorPointA.Y);
            newJoint.ObjectAnchorPointB = new Point(this.ObjectAnchorPointB.X, this.ObjectAnchorPointB.Y);

            newJoint.axisDistance = new Point(this.axisDistance.X, this.axisDistance.Y);

            newJoint.motorSpeed = this.motorSpeed;
            newJoint.maxMotorForce = this.maxMotorForce;
            newJoint.maxMotorTorque = this.maxMotorTorque;
            newJoint.isMotorEnable = this.isMotorEnable;
            newJoint.isLimitEnabled = this.isLimitEnabled;
            newJoint.upperLimit = this.upperLimit;
            newJoint.lowerLimit = this.lowerLimit;

            newJoint.frequency = this.frequency;
            newJoint.maxForce = this.maxForce;
            newJoint.maxTorque = this.maxTorque;

            return newJoint ;
        }
Esempio n. 15
0
        public void setModeLayerEditor(CoronaLayer layer)
        {
            this.objectsSelected.Clear();
            layer.deselectAllObjects();
            layer.deselectAllControls();
            this.mainForm.getElementTreeView().SceneSelected = layer.SceneParent;
            this.CurentCalque = "LAYER";

            this.indexLayerSelected = layer.IndexLayer;
            GorgonLibrary.Gorgon.Go();
        }
Esempio n. 16
0
 //***********************************
 // Constructor
 //***********************************
 public CoronaJointure(CoronaLayer layerParent)
 {
     this.type = "NONE";
     this.layerParent = layerParent;
 }
Esempio n. 17
0
        public void removeLayer(GameElement layerNode)
        {
            if (this.SceneSelected != null)
            {
                CoronaLayer layer = this.getLayerFromNode(layerNode);
                if (layer != null)
                {

                    //this.MainForm.UndoRedo.DO(this.SceneSelected);

                    this.SceneSelected.Layers.Remove(layer);

                    this.MainForm.sceneEditorView1.GraphicsContentManager.CleanLayerGraphics(layer, true, true);

                    //Remove all
                    isRemovingNode = true;
                    layerNode.Remove();
                    isRemovingNode = false;
                }
                this.LayerSelected = null;

                this.MainForm.propertyGrid1.SelectedObject = null;

                if (this.MainForm.isFormLocked == false)
                    GorgonLibrary.Gorgon.Go();

            }
        }
Esempio n. 18
0
 //----------------------------------------------------------
 //--------------------- CONSTRUCTEURS ----------------------
 //----------------------------------------------------------
 public CoronaWidget(string name, WidgetType type, CoronaLayer layerParent)
 {
     this.Name = name;
     this.Type = type;
     this.LayerParent = layerParent;
 }
Esempio n. 19
0
 //----------------------------------------------------------
 //--------------------- CONSTRUCTEURS ----------------------
 //----------------------------------------------------------
 public WidgetPickerWheel(string name, CoronaLayer layerParent)
     : base(name,WidgetType.pickerWheel,layerParent)
 {
     this.Columns = new List<PickerWheelColumn>();
 }