Esempio n. 1
0
        public Camera(Scene sceneParent, Rectangle surfaceFocus, Rectangle cameraFollowLimitRectangle)
        {
            this.sceneParent = sceneParent;

            this.SurfaceFocus = surfaceFocus;
            this.CameraFollowLimitRectangle = cameraFollowLimitRectangle;

            isSurfaceFocusVisible = true;
        }
Esempio n. 2
0
 //---------------------------------------------------
 //-------------------Methodes-------------------
 //---------------------------------------------------
 public bool DO(Scene scene)
 {
     byte[] sceneSerialized = this.serializeScene(scene);
     if (sceneSerialized != null)
     {
         this.pushIntoStackUndo(sceneSerialized);
         this.ScenesStackRedo.Clear();
         return true;
     }
     else
         return false;
 }
Esempio n. 3
0
        //---------------------------------------------------
        //-------------------Constructeurs-------------------
        //---------------------------------------------------
        public CoronaLayer(int index,Scene sceneParent)
        {
            SceneParent = sceneParent;

            this.IndexLayer = index;

            this.Name = "Layer" + sceneParent.Layers.Count;
            this.Name = this.SceneParent.projectParent.IncrementObjectName(this.Name);
            this.CoronaObjects = new List<CoronaObject>();
            this.Controls = new List<CoronaControl>();
            this.Jointures = new List<CoronaJointure>();
            this.Widgets = new List<CoronaWidget>();
            this.Entities = new List<CoronaEntity>();
        }
Esempio n. 4
0
        public void Init(Scene scene)
        {
            if (scene != null)
            {
                this.filterGroupsListBx.Items.Clear();

                for (int i = 0; i < scene.CollisionFilterGroups.Count; i++)
                {
                    this.filterGroupsListBx.Items.Add(scene.CollisionFilterGroups[i]);
                }

                this.currentScene = scene;
                this.CollisionableGroupsBuffer = GetAllCollisionableItems();

                initGrid();
            }
        }
Esempio n. 5
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. 6
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.SceneSelected != null)
            {
               DialogResult result = MessageBox.Show("Are you sure to remove this stage from the project ?",
                                "Removing stage " + this.SceneSelected.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

               if (result == DialogResult.Yes)
               {
                   GameElement elem = this.getNodeFromObjectInstance(this.treeViewElements.Nodes, this.SceneSelected);

                   this.MainForm.cgEeditor1.closeFile(this.ProjectSelected.SourceFolderPath + "\\" + this.SceneSelected.Name + ".lua");
                   File.Delete(this.ProjectSelected.SourceFolderPath + "\\" + this.SceneSelected.Name + ".lua");
                   this.MainForm.CurrentProject.Scenes.Remove(this.SceneSelected);

                   this.MainForm.sceneEditorView1.GraphicsContentManager.CleanSceneGraphics(this.SceneSelected, true, true);

                   this.SceneSelected = null;
                   elem.Remove();
                   elem = null;

                   this.MainForm.sceneEditorView1.setModeNormal();

                   //Try to get last scene
                   if (this.ProjectSelected.Scenes.Count > 0)
                   {
                       GameElement nodeScene = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, this.ProjectSelected.Scenes[0]);
                       if (nodeScene != null)
                       {
                           this.treeViewElements_NodeMouseClick(null,new TreeNodeMouseClickEventArgs(nodeScene,MouseButtons.Left,1,0,0));
                       }
                   }

               }
            }
        }
Esempio n. 7
0
 public void clearTreeView()
 {
     this.LayerSelected = null;
     this.SceneSelected = null;
     CoronaObjectSelected = null;
     this.JointureSelected = null;
     this.nodeTemp = null;
     this.treeViewElements.Nodes.Clear();
 }
Esempio n. 8
0
        public void removeScene(GameElement elem)
        {
            //Recuperer la scene
            Scene scene = (Scene)elem.InstanceObjet;
            if (scene != null)
            {
                this.MainForm.CurrentProject.Scenes.Remove(scene);

                if (this.SelectedNodes.Contains(elem))
                    this.SelectedNodes.Remove(elem);

                isRemovingNode = true;
                elem.Remove();
                isRemovingNode = false;
            }

            this.SceneSelected = null;
            GorgonLibrary.Gorgon.Go();
        }
Esempio n. 9
0
        public void setModeSceneEditor(Scene scene)
        {
            ////Afficher ou non la check box d'affichage de la tilesmap si necessaire
            //bool res = false;
            //for (int i = 0; i < scene.Layers.Count; i++)
            //{
            //    if (scene.Layers[i].TilesMap != null)
            //    {
            //        res = true;
            //        break;
            //    }
            //}

            //this.mainForm.scenePreview1.showTilesMapChkBx.Visible = res;

            this.objectsSelected.Clear();

            this.mainForm.getElementTreeView().SceneSelected = scene;
            this.CurentCalque = "STAGE";

            this.SetScrollMax();

            this.scrollView(scene.CurrentSceneViewLocation.X, scene.CurrentSceneViewLocation.Y);
            for (int i = 0; i < scene.projectParent.Scenes.Count; i++)
            {
                if (scene == scene.projectParent.Scenes[i])
                {
                    this.indexSceneSelected = i;
                    break;
                }

            }

            this.indexLayerSelected = -1;
            GorgonLibrary.Gorgon.Go();
        }
Esempio n. 10
0
 //---------------------------------------------------
 //-------------------Constructeurs-------------------
 //---------------------------------------------------
 public ScenePropertyConverter(Scene scene, Form1 MainForm)
 {
     this.sceneSelected = scene;
     this.MainForm = MainForm;
 }
Esempio n. 11
0
 public void CleanSceneGraphics(Scene scene, bool removeAsset, bool checkIntegrity)
 {
     for (int i = 0; i < scene.Layers.Count; i++)
     {
         this.CleanLayerGraphics(scene.Layers[i], removeAsset, checkIntegrity);
     }
 }
Esempio n. 12
0
        //----------------------------------------------------------
        //----------------SCENE-----------------------
        //----------------------------------------------------------
        public void newScene(Scene scene)
        {
            if (this.ProjectRootNodeSelected != null)
            {
                this.SceneSelected = scene;

                GameElement node = new GameElement("STAGE", scene.Name, scene);
                node.ExpandAll();
                this.ProjectRootNodeSelected.Nodes.Insert(scene.projectParent.Scenes.Count, node);

                if (scene.projectParent.isEnabled == false)
                {
                    scene.isEnabled = true;
                }

                node.Checked = scene.isEnabled;
              /*  //Ajouter une node pour les spritesheets  ---------------------------------------------
                TreeNode nodeSpriteSheets = new TreeNode("SpriteSheets");
                nodeSpriteSheets.Name = "SPRITESHEETS";
                nodeSpriteSheets.ImageIndex = 5;
                nodeSpriteSheets.SelectedImageIndex = 5;
                node.Nodes.Add(nodeSpriteSheets);

                for (int i = 0; i < scene.SpriteSheets.Count; i++)
                {
                    CoronaSpriteSheet sheet = scene.SpriteSheets[i];
                    GameElement nodeSheet = new GameElement("SPRITESHEET", sheet.Name, sheet);
                    nodeSpriteSheets.Nodes.Add(nodeSheet);
                }

                //Ajouter une node pour les spriteSets ---------------------------------------------
                TreeNode nodeSpriteSets = new TreeNode("SpriteSets");
                nodeSpriteSets.Name = "SPRITESETS";
                nodeSpriteSets.ImageIndex = 4;
                nodeSpriteSets.SelectedImageIndex = 4;
                node.Nodes.Add(nodeSpriteSets);

                for (int i = 0; i < scene.SpriteSets.Count; i++)
                {
                    CoronaSpriteSet set = scene.SpriteSets[i];
                    GameElement nodeSet = new GameElement("SPRITESET", set.Name, set);
                    nodeSpriteSets.Nodes.Add(nodeSet);
                }*/

                //Recreer les layer
                for (int i = 0; i < scene.Layers.Count; i++)
                {
                    if(scene.Layers[i].Entities == null)
                        scene.Layers[i].Entities = new List<CoronaEntity>();

                    this.newLayer(scene, scene.Layers[i]);
                }

                this.treeViewElements_NodeMouseClick(null, new TreeNodeMouseClickEventArgs(node, MouseButtons.Left, 1, 0, 0));

            }
        }
Esempio n. 13
0
        private String createFunctions(Scene scene,String contentToWrite)
        {
            for (int j = 0; j < scene.functions.Count; j++)
            {
                contentToWrite += "-- User Function : " + scene.functions[j].Name + "\n--\n";
                contentToWrite += scene.functions[j].Code + "\n";
            }

            return contentToWrite;
        }
Esempio n. 14
0
        private String createVars(Scene scene,String contentToWrite)
        {
            for (int j = 0; j < scene.vars.Count; j++)
            {
                CoronaVariable cVars = scene.vars[j];

                //Construction of variable lua code
                String buf = "";
                if (cVars.isLocal) buf += "local ";
                buf += cVars.Name;
                if (!cVars.InitValue.Equals("")) buf += " = " + cVars.InitValue;

                contentToWrite += buf + "\n";
            }

            return contentToWrite;
        }
Esempio n. 15
0
        private String createAllTimers(Scene scene, String contentToWrite)
        {
            //Pour tous les layers
            for (int i = 0; i < scene.Layers.Count; i++)
            {
                for (int j = 0; j < scene.Layers[i].CoronaObjects.Count; j++)
                {
                    CoronaObject obj = scene.Layers[i].CoronaObjects[j];

                    //Creer les timers associés à chaque object
                    for (int h = 0; h < obj.Timers.Count; h++)
                    {
                        CoronaTimer timer = obj.Timers[h];
                        string objName = obj.DisplayObject.Name;

                        //Creer la function et la rattacher a l'objet
                        contentToWrite +=  objName + "." + timer.Name + "Handle = " + timer.Handle + "\n";

                        //Lancer l'event
                        contentToWrite +=  objName + "." + timer.Name + "= timer.performWithDelay("+timer.Delay+","+
                                                                                                       objName + "." + timer.Name + "Handle,"+
                                                                                                      timer.Iteration+")\n";
                    }
                }
            }

            return contentToWrite;
        }
Esempio n. 16
0
        private String createAllEvents(Scene scene, String contentToWrite)
        {
            //Pour tous les layers
            for (int i = 0; i < scene.Layers.Count; i++)
            {
                for (int j = 0; j < scene.Layers[i].CoronaObjects.Count; j++)
                {
                    CoronaObject obj = scene.Layers[i].CoronaObjects[j];

                    //Creer les events associé à chaque object
                    for (int h = 0; h < obj.Events.Count; h++)
                    {
                        CoronaEvent cEvent = obj.Events[h];
                        string objName = obj.DisplayObject.Name.Replace(" ", "");

                        contentToWrite += "local " + objName + "_" + cEvent.Name +
                             " = {eventName = \"" + cEvent.Name + "\",\n" +
                              " eventType = \"" + cEvent.Type + "\",\n" +
                             " handle = " + cEvent.Handle + "\n" +
                             "}";

                        //Lancer l'event
                        contentToWrite += objName + ":createEventListener("+ objName + "_" + cEvent.Name+")";
                    }
                }
            }

            return contentToWrite;
        }
Esempio n. 17
0
        public string createJSONConfigFile(Scene sceneParent, string folderDest, float xRatio, float yRatio)
        {
            string fileNameDest = folderDest +"\\"+this.TilesMapName+"jsonconfig.json";

            JSONTileMap jsonMap = new JSONTileMap(this,sceneParent,xRatio,yRatio);
            jsonMap.serialize(folderDest,this);

            //Create the last modified file time for this tilesmap
            int year = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int day = DateTime.Now.Day;
            int hour = DateTime.Now.Hour;
            int minute = DateTime.Now.Minute;
            int second = DateTime.Now.Second;

            int result = getSecondsFromDateSince2000(year, month, day, hour, minute, second);

            File.WriteAllText(folderDest + "\\" + this.TilesMapName.ToLower() + "lastmodifiedtime.txt", result.ToString());

            return fileNameDest;
        }
Esempio n. 18
0
        public bool isSpriteSetExistsInScene(Scene scene, CoronaSpriteSet set)
        {
            //Recueprer la node de la scene
            GameElement sceneNode = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, this.SceneSelected);

            for (int i = 0; i < sceneNode.Nodes["SPRITESETS"].Nodes.Count; i++)
            {
                CoronaSpriteSet setInProject = (CoronaSpriteSet)((GameElement)sceneNode.Nodes["SPRITESETS"].Nodes[i]).InstanceObjet;
                if (set.Name.Equals(setInProject.Name))
                    return true;
            }

            return false;
        }
Esempio n. 19
0
        public Scene addSceneToProject(string sceneName)
        {
            if (CurrentProject != null)
            {

                Scene scene1 = new Scene(new Size(2000,2000), this.CurrentProject.Orientation,this.CurrentProject);
                if (sceneName != null && !sceneName.Equals(""))
                    scene1.Name = sceneName.ToLower();
                else
                    scene1.Name = "scene" + this.CurrentProject.Scenes.Count;

                scene1.Name = this.CurrentProject.IncrementObjectName(scene1.Name);
                scene1.createLuaFile();

                //Ouvrir le fichier dans l'editeur de code
                this.cgEeditor1.OpenFileInEditor(this.CurrentProject.SourceFolderPath + "\\" + scene1.Name + ".lua");

                scene1.CurrentSceneViewLocation = new Point(scene1.Camera.SurfaceFocus.Location.X - (this.sceneEditorView1.surfacePictBx.Width / 3),
                    scene1.Camera.SurfaceFocus.Location.Y - (this.sceneEditorView1.surfacePictBx.Height / 3));
                this.gameElementTreeView1.newScene(scene1);
                this.CurrentProject.Scenes.Add(scene1);

                this.newLayerBt_Click(null, null);

                return scene1;
            }
            return null;
        }
Esempio n. 20
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. 21
0
        private byte[] serializeScene(Scene scene)
        {
            try
            {
                MemoryStream memStream1 = new MemoryStream();

                BinaryFormatter formatter = new BinaryFormatter();

                formatter.Serialize(memStream1, scene);

                byte[] bytes = memStream1.GetBuffer();

                memStream1.Close();

                return bytes;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable do save Scene State !\n Undo Impossible ! \n" + ex.Message);
                return null;
            }
        }
Esempio n. 22
0
        public void RefreshSceneLuaCode(Scene scene,bool isCustomBuild,float XRatio, float YRatio)
        {
            this.sceneSelected = scene;
            try
            {
                OpenFileInEditor(scene.projectParent.SourceFolderPath + "\\" + scene.Name + ".lua");
                if (this.ActiveDocument != null && scene != null)
                {

                    this.ActiveDocument.Scintilla.IsReadOnly = false;
                    this.ActiveDocument.Scintilla.UndoRedo.IsUndoEnabled = false;

                    scene.prepareForBuild();
                    //Enregistrer la lingne courante
                    int currentLineNumber = this.ActiveDocument.Scintilla.CurrentPos;

                    //--- Get all breakPoints
                    List<int> markedLines = new List<int>();
                    foreach (Line line in this.ActiveDocument.Scintilla.Lines)
                    {
                        int mask = this.ActiveDocument.Scintilla.Markers.GetMarkerMask(line);
                        if (mask != 0)
                        {
                            markedLines.Add(line.Number);
                        }

                    }

                    this.BuildRequires(scene.generateRequiresLua());

                    //this.BuildGlobalVars(scene.generateGlobalVarsLua());

                    String codeDeclarationsVariables = scene.generateDeclarationsLua(XRatio, YRatio) + "\n" + scene.generateLocalVarsLua();
                    this.BuildLocalVars(codeDeclarationsVariables);

                    //Build the create scene (disp objects)
                    String codeInitializeComponents = scene.generateInitializeComponentLua(isCustomBuild,XRatio, YRatio);
                    this.BuildInitializeComponent(codeInitializeComponents);

                    //Build the  Will enter scene ( timers, listeners, generators ...)
                    String codeWillEnterScene = scene.buildWillEnterScene(XRatio,YRatio);
                    this.BuildWillEnterScene(codeWillEnterScene);

                    //Build the Did exit scene ( timers, listeners, generators ...)
                    String codeDidExitScene = scene.buildDidExitScene();
                    this.BuildDidExitScene(codeDidExitScene);

                    //Build the destroy scene (disp objects)
                    String codeCleanScene = scene.buildCleanScene();
                    this.BuildDestroyScene(codeCleanScene);

                    this.ActiveDocument.Scintilla.CurrentPos = currentLineNumber;

                    //Reinstaller les breakpoints
                    for (int i = 0; i < markedLines.Count; i++)
                    {
                        this.ActiveDocument.Scintilla.Lines[markedLines[i]].AddMarker(0);
                    }

                    this.ActiveDocument.Save();

                    this.ActiveDocument.Scintilla.UndoRedo.IsUndoEnabled = true;

                    refreshFunctionsNavigationContent(this.ActiveDocument.Scintilla);
                    this.AutoCompletionEngine.RefreshDynamicList();

                    if (this.luaSyntaxCheckerBt.Checked == true)
                        checkLuaSyntax();

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during lua code generation!\n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
Esempio n. 23
0
 public void selectSceneFileTab(Scene scene)
 {
     foreach(DocumentForm doc in this.dockPanel.Documents)
     {
         if(doc.Text.Equals(scene.Name +".lua"))
         {
             doc.Select();
             doc.Show(dockPanel);
             break;
         }
     }
 }
Esempio n. 24
0
        public static void exportStage(Form1 mainForm,Scene scene, string directoryName, BackgroundWorker worker)
        {
            worker.ReportProgress(20);
            string sceneSerializedDirectory = directoryName + "\\" + scene.Name;

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

            Directory.CreateDirectory(sceneSerializedDirectory);

            FileStream fs = File.Create(sceneSerializedDirectory + "\\" + scene.Name + ".krs");
            MemoryStream ms = SerializerHelper.SerializeBinary(scene);

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

            if (File.Exists(mainForm.CurrentProject.SourceFolderPath + "\\" + scene.Name + ".lua"))
            {
                File.Copy(mainForm.CurrentProject.SourceFolderPath + "\\" + scene.Name + ".lua", sceneSerializedDirectory + "\\" + scene.Name + ".lua", true);
            }

            for (int i = 0; i < scene.Layers.Count; i++)
            {
                CoronaLayer layer = scene.Layers[i];
                if (layer.TilesMap != null)
                {
                    string mapResourcesDirectory = mainForm.CurrentProject.ProjectPath + "\\Resources\\TileMaps\\" + layer.TilesMap.TilesMapName;
                    if (Directory.Exists(mapResourcesDirectory))
                    {
                        Directory.CreateDirectory(sceneSerializedDirectory + "\\TileMaps\\" + layer.TilesMap.TilesMapName);

                        string[] files = Directory.GetFiles(mapResourcesDirectory);
                        for (int j = 0; j < files.Length; j++)
                        {
                            string fileNameOnly = Path.GetFileName(files[j]);
                            File.Copy(files[j], sceneSerializedDirectory + "\\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, sceneSerializedDirectory + "\\" + layer.TilesMap.TilesMapName.ToLower() + "textures.json", true);

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

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

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

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

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

                }

                for (int m = 0; m < layer.CoronaObjects.Count; m++)
                {
                    CoronaObject obj = layer.CoronaObjects[m];
                    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(sceneSerializedDirectory + "\\Images"))
                                            Directory.CreateDirectory(sceneSerializedDirectory + "\\Images");

                                        File.Copy(filename, sceneSerializedDirectory + "\\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(sceneSerializedDirectory + "\\SpriteSheets\\" + sheet.Name))
                                            {
                                                Directory.CreateDirectory(sceneSerializedDirectory + "\\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], sceneSerializedDirectory + "\\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(sceneSerializedDirectory + "\\Images"))
                                        Directory.CreateDirectory(sceneSerializedDirectory + "\\Images");

                                    File.Copy(filename, sceneSerializedDirectory + "\\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(sceneSerializedDirectory + "\\SpriteSheets\\" + sheet.Name))
                                        {
                                            Directory.CreateDirectory(sceneSerializedDirectory + "\\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], sceneSerializedDirectory + "\\SpriteSheets\\" + sheet.Name + "\\" + fileNameOnly, true);
                                        }

                                    }
                                }
                            }
                        }
                    }
                }

                for (int m = 0; m < layer.Controls.Count; m++)
                {
                    Corona_Classes.Controls.CoronaControl control = layer.Controls[m];
                    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, sceneSerializedDirectory + "\\Images\\" + joy.joystickName + "_inner.png");

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

                    }
                }
            }

            worker.ReportProgress(80);
        }
Esempio n. 25
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;
            }
        }