//Display Object Image Corona Object public CoronaObject(Point location, Image image) { Events = new List<CoronaEvent>(); Timers = new List<CoronaTimer>(); this.PhysicsBody = new PhysicsBody(this); this.PathFollow = new PathFollow(this); DisplayObject = new DisplayObject(image, location, this); this.isSelected = false; isVisible = true; onStartFunction = "function() \n\n end"; onPauseFunction = " function() \n\n end"; onDeleteFunction = "function() \n\n end"; this.IsHandledByTilesMap = false; }
public PhysicsBody cloneBody(CoronaObject objectParent) { PhysicsBody newBody = new PhysicsBody(objectParent); newBody.Mode = this.Mode; newBody.CollisionGroupIndex = this.CollisionGroupIndex; if (this.isCustomizedBody == true) { for (int i = 0; i < this.BodyElements.Count; i++) { BodyElement elem = this.BodyElements[i]; if (elem.Type.Equals("CIRCLE")) { BodyElement newElem = new BodyElement(i, elem.Name, elem.Bounce, elem.Density, elem.Friction, elem.LocationCircle, elem.Radius); newElem.CollisionGroupIndex = elem.CollisionGroupIndex; newBody.BodyElements.Add(newElem); } else { //Create a new bodyElement List<Point> bodyShape = elem.BodyShape.ToList(); BodyElement newElem = new BodyElement(i, elem.Name, elem.Bounce, elem.Density, elem.Friction, bodyShape); newElem.CollisionGroupIndex = elem.CollisionGroupIndex; newBody.BodyElements.Add(newElem); } } newBody.isCustomizedBody = true; } else { newBody.Bounce = this.Bounce; newBody.Density = this.Density; newBody.Friction = this.Friction; newBody.isCustomizedBody = false; } newBody.isFixedRotation = this.isFixedRotation; return newBody; }
//--------------------------------------------------- //-------------------Constructeurs-------------------- //--------------------------------------------------- public PhysicBodyLuaGenerator(PhysicsBody body) { this.body = body; this.objName = body.objectParent.DisplayObject.Name.Replace(" ", ""); }
public CoronaObject(DisplayObject displayObj) { Events = new List<CoronaEvent>(); Timers = new List<CoronaTimer>(); this.PhysicsBody = new PhysicsBody(this); this.PathFollow = new PathFollow(this); DisplayObject = displayObj; this.DisplayObject.CoronaObjectParent = this; this.isSelected = false; isVisible = true; onStartFunction = "function() \n\n end"; onPauseFunction = "function() \n\n end"; onDeleteFunction = "function() \n\n end"; this.IsHandledByTilesMap = false; }
public void buildToLua(BackgroundWorker worker, bool isCustomBuild, float XRatio, float YRatio, bool isDebug) { if (this.project != null) { try { float moyenneRatio = (XRatio + YRatio) / 2; //Report progress worker.ReportProgress(10); if (Directory.Exists(this.project.BuildFolderPath)) { Directory.Delete(this.project.BuildFolderPath, true); } Directory.CreateDirectory(this.project.BuildFolderPath); //Report progress worker.ReportProgress(20); CreateConfigLua(isCustomBuild, XRatio, YRatio); CreateBuildSettings(); //Report progress worker.ReportProgress(30); createMain(isDebug); //Report progress worker.ReportProgress(40); ImageResizer ImageResizer = new ImageResizer(this.project); if (!ImageResizer.GenerateIconFile()) { MessageBox.Show("can't create Icon!"); } if (isCustomBuild == false) { if (!ImageResizer.GenerateImageFile()) { MessageBox.Show("can't create Images!"); } } else { if (!ImageResizer.generateImageFilesWithRatio(XRatio, YRatio)) { MessageBox.Show("can't create Images!"); } } //Report progress worker.ReportProgress(50); CreateLuaLangue(this.project); //Report progress worker.ReportProgress(60); //Importer les fichiers necessaires List <string> filenames = this.getLuaFilesUsed(isDebug); if (filenames != null) { for (int i = 0; i < filenames.Count; i++) { File.Copy(this.PATH_REPOSITORY_DIR + "\\" + filenames[i], this.project.BuildFolderPath + "\\" + filenames[i].Replace("Krea Remote\\", ""), true); } } for (int i = 0; i < project.Scenes.Count; i++) { Scene scene = project.Scenes[i]; if (scene.isEnabled == true) { for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; if (layer.isEnabled == true) { for (int k = 0; k < layer.CoronaObjects.Count; k++) { CoronaObject objectToBuild = layer.CoronaObjects[k]; if (objectToBuild.isEnabled == true) { if (objectToBuild.isEntity == false) { PhysicsBody ph = objectToBuild.PhysicsBody; if (ph.Mode != PhysicsBody.PhysicBodyMode.Inactive) { string objName = objectToBuild.DisplayObject.Name.Replace(" ", ""); //Creer le fichier lua associé PhysicBodyLuaGenerator gen = new PhysicBodyLuaGenerator(ph); gen.writeToLua(new DirectoryInfo(project.BuildFolderPath), XRatio, YRatio); if (File.Exists(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua")) { File.Delete(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua"); } } } else { for (int l = 0; l < objectToBuild.Entity.CoronaObjects.Count; l++) { CoronaObject child = objectToBuild.Entity.CoronaObjects[l]; if (child.isEnabled == true) { PhysicsBody ph = child.PhysicsBody; if (ph.Mode != PhysicsBody.PhysicBodyMode.Inactive) { string objName = child.DisplayObject.Name.Replace(" ", ""); //Creer le fichier lua associé PhysicBodyLuaGenerator gen = new PhysicBodyLuaGenerator(ph); gen.writeToLua(new DirectoryInfo(project.BuildFolderPath), XRatio, YRatio); if (File.Exists(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua")) { File.Delete(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua"); } } } } } } } } } } } CopyFolder(this.project.SourceFolderPath, this.project.BuildFolderPath); } catch (Exception ex) { MessageBox.Show("Build Failed!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Build Failed ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }