示例#1
0
文件: Camera.cs 项目: nadar71/Krea
        public void setObjectFocusedByCamera(CoronaObject obj)
        {
            //Creer deux variables si elles n'existent pas deja
            bool isCreated = false;

            for (int i = 0; i < this.sceneParent.vars.Count; i++)
            {
                CoronaVariable var = this.sceneParent.vars[i];
                if (var.Name.Equals("LastPosX_Focus") || var.Name.Equals("LastPosY_Focus"))
                {
                    isCreated = true;
                    break;
                }
            }

            if (isCreated == false)
            {
                CoronaVariable var_LastPosX = new CoronaVariable("Text", true, "LastPosX_Focus", "nil");
                CoronaVariable var_LastPosY = new CoronaVariable("Text", true, "LastPosY_Focus", "nil");

                this.sceneParent.vars.Add(var_LastPosX);
                this.sceneParent.vars.Add(var_LastPosY);
            }

            this.objectFocusedByCamera = obj;
        }
 public BodyElementPropertyConverter(BodyElement bodyElement, System.Windows.Forms.ListViewItem viewItem,CoronaObject objectParent,Form1 mainForm)
 {
     this.bodyElement = bodyElement;
     this.viewItem = viewItem;
     this.selectedObject = objectParent;
     this.mainForm = mainForm;
 }
示例#3
0
 //---------------------------------------------------
 //-------------------Constructeurs--------------------
 //---------------------------------------------------
 public CoronaEntity(string name, CoronaObject objectParent)
 {
     this.Name = name;
     this.objectParent = objectParent;
     Jointures = new List<CoronaJointure>();
     CoronaObjects = new List<CoronaObject>();
 }
示例#4
0
        //---------------------------------------------------
        //-------------------Methodes------------------------
        //---------------------------------------------------
        public void init(Form1 mainForm, CoronaJointure joint)
        {
            this.joint = joint;
            this.mainForm = mainForm;

            if (this.joint.type.Equals("DISTANCE"))
            {
                this.frequencyNumUpDw.Value = System.Convert.ToInt32(joint.frequency);
                this.dampingRatioNumUpDw.Value = System.Convert.ToInt32(joint.dampingRatio);

                this.nameObj1TxtBx.Text = joint.coronaObjA.DisplayObject.Name;
                this.nameObj2TxtBx.Text = joint.coronaObjB.DisplayObject.Name;

                this.objA = joint.coronaObjA;
                this.objB = joint.coronaObjB;

                this.modePanel = "MODIFY";
            }
            else
            {
                this.modePanel = "NEW";
                this.frequencyNumUpDw.Value = 0;
                this.dampingRatioNumUpDw.Value = 0;

                this.nameObj1TxtBx.Text = "";
                this.nameObj2TxtBx.Text = "";

            }
        }
示例#5
0
        //---------------------------------------------------
        //-------------------Methodes------------------------
        //---------------------------------------------------
        public void init(Form1 mainForm, CoronaJointure joint)
        {
            this.joint = joint;
            this.mainForm = mainForm;
            this.modePanel = "NEW";

            if (this.joint.type.Equals("PISTON"))
            {
                this.isMotorEnabledChkBx.Checked = joint.isMotorEnable;
                this.isLimitedChkBx.Checked = joint.isLimitEnabled;

                this.motorSpeedNumUpDw.Value = System.Convert.ToInt32(joint.motorSpeed);
                this.maxMotorForceNumUpDw.Value = System.Convert.ToInt32(joint.maxMotorForce);

                this.nameObj1TxtBx.Text = joint.coronaObjA.DisplayObject.Name;
                this.nameObj2TxtBx.Text = joint.coronaObjB.DisplayObject.Name;

                this.axisDistanceTxtBx.Text = joint.axisDistance.ToString();

                this.objA = joint.coronaObjA;
                this.objB = joint.coronaObjB;

                this.anchorPoint = joint.AnchorPointA;
                this.axisDistance = joint.axisDistance;
                this.modePanel = "MODIFY";

            }
        }
示例#6
0
 // Weld Init
 //
 public void InitWeldJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point _AnchorPoint)
 {
     type         = "WELD";
     coronaObjA   = _coronaObjA;
     coronaObjB   = _coronaObjB;
     AnchorPointA = _AnchorPoint;
     this.name    = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
 }
示例#7
0
        //---------------------------------------------------
        //-------------------Constructeurs------------------------
        //---------------------------------------------------
        public PhysicsBody(CoronaObject objectParent)
        {
            BodyElements = new List<BodyElement>();
            this.objectParent = objectParent;

            this.Mode = PhysicBodyMode.Inactive;
            isCustomizedBody = false;
        }
示例#8
0
 public ActionCommand(ActionType actionCommandType, CoronaObject obj,object propToModify,object valueAffected, bool isUndo)
 {
     this.ActionCommandType = actionCommandType;
     this.obj = obj;
     this.IsUndo = isUndo;
     this.valueAffected = valueAffected;
     this.propToModify = propToModify;
 }
示例#9
0
        public PathFollow cloneInstance(CoronaObject parent)
        {
            PathFollow path = new PathFollow(parent);
            path.Path.AddRange(this.Path);

            path.isCurve = this.isCurve;
            path.isCyclic = this.isCyclic;
            path.isEnabled = this.isEnabled;
            path.removeOnComplete = this.removeOnComplete;
            return path;
        }
示例#10
0
        public CoronaEntity cloneEntity(CoronaObject objectParent)
        {
            string newName = objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(this.Name);

            CoronaEntity newEntity = new CoronaEntity(newName, objectParent);

            objectParent.Entity = newEntity;
            ////Copier toutes les objets
            for (int i = 0; i < this.CoronaObjects.Count; i++)
            {
                CoronaObject obj = this.CoronaObjects[i].cloneObject(this.CoronaObjects[i].LayerParent, true, true);

                newEntity.addObject(obj);
            }

            //Recreer toutes les jointures
            for (int i = 0; i < this.Jointures.Count; i++)
            {
                CoronaJointure currentJoint = this.Jointures[i];

                int indexOfOBJA = -1;
                int indexOfOBJB = -1;

                if (currentJoint.coronaObjA != null)
                {
                    indexOfOBJA = this.CoronaObjects.IndexOf(currentJoint.coronaObjA);
                }

                if (currentJoint.coronaObjB != null)
                {
                    indexOfOBJB = this.CoronaObjects.IndexOf(currentJoint.coronaObjB);
                }

                CoronaObject newOBJA = null;
                CoronaObject newOBJB = null;

                if (indexOfOBJA > -1)
                {
                    newOBJA = newEntity.CoronaObjects[indexOfOBJA];
                }

                if (indexOfOBJB > -1)
                {
                    newOBJB = newEntity.CoronaObjects[indexOfOBJB];
                }

                CoronaJointure newJoint = currentJoint.clone(newOBJA, newOBJB, currentJoint.layerParent);
                newEntity.Jointures.Add(newJoint);
            }


            return(newEntity);
        }
示例#11
0
 // Pulley Init
 //
 public void InitPulleyJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point objAnchorA, Point objAnchorB,
                                Point _AnchorPointA, Point _AnchorPointB)
 {
     type = "PULLEY";
     this.ObjectAnchorPointA = objAnchorA;
     this.ObjectAnchorPointB = objAnchorB;
     coronaObjA   = _coronaObjA;
     coronaObjB   = _coronaObjB;
     AnchorPointA = _AnchorPointA;
     AnchorPointB = _AnchorPointB;
     this.name    = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
 }
示例#12
0
        // Friction Init
        //
        public void InitFrictionJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point _AnchorPoint,
                                         Double _maxForce, Double _maxTorque)
        {
            type         = "FRICTION";
            coronaObjA   = _coronaObjA;
            coronaObjB   = _coronaObjB;
            AnchorPointA = _AnchorPoint;

            maxForce  = _maxForce;
            maxTorque = _maxTorque;
            this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#13
0
 public void Init(Form1 mainForm, CoronaJointure joint )
 {
     this.MainForm = mainForm;
     this.cJoint = joint;
     this.modePanel="NEW";
     if(this.cJoint.type.Equals("TOUCH")){
         this.objTb.Text = cJoint.coronaObjA.DisplayObject.Name;
         this.obj = cJoint.coronaObjA;
         this.anchorPointTb.Text = cJoint.AnchorPointA.ToString();
         this.anchorPoint = cJoint.AnchorPointA;
         this.modePanel="MODIFY";
     }
 }
示例#14
0
        // Distance Init
        //
        public void InitDistanceJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point anchorA, Point anchorB,
                                         Double _dampingRatio, Double _frequency)
        {
            //crateA, crateB, crateA.x,crateA.y, crateB.x,crateB.y
            type         = "DISTANCE";
            coronaObjA   = _coronaObjA;
            coronaObjB   = _coronaObjB;
            AnchorPointA = anchorA;
            AnchorPointB = anchorB;
            dampingRatio = _dampingRatio;
            frequency    = _frequency;

            this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#15
0
        public DisplayObject(CoronaSpriteSet spriteSet, Point location, CoronaObject coronaObjectParent)
        {
            this.type      = "SPRITE";
            Alpha          = 1.0F;
            this.SpriteSet = spriteSet;
            this.SpriteSet.DisplayObjectParent = this;

            this.surfaceRect = new Rectangle(location, new Size(50, 50));


            InitialRect             = this.surfaceRect;
            this.CoronaObjectParent = coronaObjectParent;
            this.GradientColor      = new GradientColor();

            this.CurrentFrame = SpriteSet.indexFrameDep;
        }
示例#16
0
        //***********************************
        // Init Jointure
        //***********************************

        // Pivot Init
        //
        public void InitPivotJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB,
                                      Point _AnchorPoint, bool _isMotorEnabled, bool _isLimitEnabled, Double _motorSpeed, Double _maxMotorTorque,
                                      Double _upperLimit, Double _lowerLimit)
        {
            type           = "PIVOT";
            coronaObjA     = _coronaObjA;
            coronaObjB     = _coronaObjB;
            isMotorEnable  = _isMotorEnabled;
            isLimitEnabled = _isLimitEnabled;
            motorSpeed     = _motorSpeed;
            maxMotorTorque = _maxMotorTorque;
            upperLimit     = _upperLimit;
            lowerLimit     = _lowerLimit;
            AnchorPointA   = new Point(_AnchorPoint.X, _AnchorPoint.Y);
            this.name      = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#17
0
        // Wheel Init (WAIT FOR CORONA SDK PATH BEFORE USE IT!) ==> bug with maxMotorForce
        //
        public void InitWheelJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point _axisDistance, Point anchorA,
                                      bool _isMotorEnabled, Double _motorSpeed, Double _maxMotorTorque)
        {
            type         = "WHEEL";
            coronaObjA   = _coronaObjA;
            coronaObjB   = _coronaObjB;
            AnchorPointA = anchorA;

            axisDistance = _axisDistance;

            isMotorEnable = _isMotorEnabled;

            motorSpeed     = _motorSpeed;
            maxMotorTorque = _maxMotorTorque;

            this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#18
0
        public DisplayObject(Image img, Point location, CoronaObject coronaObjectParent)
        {
            this.surfaceRect      = new Rectangle();
            this.surfaceRect.Size = img.Size;

            this.surfaceRect.Location = location;
            InitialRect = this.surfaceRect;

            this.Name  = "";
            this.type  = "IMAGE";
            this.image = img;

            CurrentFrame = 0;
            Alpha        = 1.0F;

            this.GradientColor      = new GradientColor();
            this.CoronaObjectParent = coronaObjectParent;
        }
示例#19
0
        // Piston Init
        //
        public void InitPistonJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point _axisDistance, Point anchorA,
                                       bool _isMotorEnabled, bool _isLimitEnabled, Double _motorSpeed, Double _maxMotorForce,
                                       Double _upperLimit, Double _lowerLimit)
        {
            type           = "PISTON";
            coronaObjA     = _coronaObjA;
            coronaObjB     = _coronaObjB;
            AnchorPointA   = anchorA;
            axisDistance   = _axisDistance;
            isMotorEnable  = _isMotorEnabled;
            isLimitEnabled = _isLimitEnabled;
            motorSpeed     = _motorSpeed;
            maxMotorForce  = _maxMotorForce;
            upperLimit     = _upperLimit;
            lowerLimit     = _lowerLimit;

            this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#20
0
        //---------------------------------------------------
        //-------------------Mthodes--------------------
        //---------------------------------------------------
        public void addObject(CoronaObject obj)
        {
            obj.LayerParent = this.objectParent.LayerParent;
            obj.EntityParent = this;

            if (obj.isEntity == false)
            {
                string objName = this.objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(obj.DisplayObject.Name);
                obj.DisplayObject.Name = objName;
            }
            else
            {
                string objName = this.objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(obj.Entity.Name);
                obj.Entity.Name = objName;
            }

            this.CoronaObjects.Add(obj);
        }
示例#21
0
        public DisplayObject(Image img, Point location, CoronaObject coronaObjectParent)
        {
            this.surfaceRect = new Rectangle();
            this.surfaceRect.Size = img.Size;

            this.surfaceRect.Location = location;
            InitialRect = this.surfaceRect;

            this.Name = "";
            this.type = "IMAGE";
            this.image = img;

            CurrentFrame = 0;
            Alpha = 1.0F;

            this.GradientColor = new GradientColor();
            this.CoronaObjectParent = coronaObjectParent;
        }
示例#22
0
        public void Init(Form1 mainForm, CoronaJointure joint)
        {
            this.MainForm = mainForm;
            this.cJoint = joint;
            this.modePanel = "NEW";
            if (this.cJoint.type.Equals("FRICTION"))
            {
                this.obj1Tb.Text = cJoint.coronaObjA.DisplayObject.Name;
                objA = cJoint.coronaObjA;
                this.obj2Tb.Text = cJoint.coronaObjB.DisplayObject.Name;
                objB = cJoint.coronaObjB;
                anchorPoint = cJoint.AnchorPointA;

                this.maxForceNup.Value = Convert.ToInt32(cJoint.maxForce);
                this.maxTorqueNup.Value = Convert.ToInt32(cJoint.maxTorque);
                this.modePanel = "MODIFY";
            }
        }
        public SpriteSequencePropertyEditor(CoronaObject obj,
            IWindowsFormsEditorService editorServiceParam )
        {
            editorService = editorServiceParam;
            InitializeComponent();

            // Add all groups from the scene
            List<CoronaSpriteSetSequence> sequences = obj.DisplayObject.SpriteSet.Sequences;
            this.Items.Add("DEFAULT");
            for (int i = 0; i < sequences.Count; i++)
            {
                CoronaSpriteSetSequence sequence = sequences[i];
                this.Items.Add(sequence.Name);

            }

            this.Refresh();
        }
示例#24
0
        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;
        }
示例#25
0
        public CoronaEntity cloneEntity(CoronaObject objectParent)
        {
            string newName = objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(this.Name);

            CoronaEntity newEntity = new CoronaEntity(newName,objectParent);
            objectParent.Entity = newEntity;
            ////Copier toutes les objets
            for (int i = 0; i < this.CoronaObjects.Count; i++)
            {
                CoronaObject obj = this.CoronaObjects[i].cloneObject(this.CoronaObjects[i].LayerParent,true,true);

                newEntity.addObject(obj);
            }

            //Recreer toutes les jointures
            for (int i = 0; i < this.Jointures.Count; i++)
            {
                CoronaJointure currentJoint = this.Jointures[i];

                int indexOfOBJA = -1;
                int indexOfOBJB = -1;

                if(currentJoint.coronaObjA != null)
                    indexOfOBJA = this.CoronaObjects.IndexOf(currentJoint.coronaObjA);

                if(currentJoint.coronaObjB != null)
                    indexOfOBJB = this.CoronaObjects.IndexOf(currentJoint.coronaObjB);

                CoronaObject newOBJA = null;
                CoronaObject newOBJB = null;

                if(indexOfOBJA>-1)
                    newOBJA = newEntity.CoronaObjects[indexOfOBJA];

                if(indexOfOBJB>-1)
                    newOBJB = newEntity.CoronaObjects[indexOfOBJB];

                CoronaJointure newJoint = currentJoint.clone(newOBJA, newOBJB, currentJoint.layerParent);
                newEntity.Jointures.Add(newJoint);

            }

            return newEntity;
        }
示例#26
0
        public DisplayObject(GorgonLibrary.Graphics.Sprite gorgonSprite, Point location, CoronaObject coronaObjectParent)
        {
            this.surfaceRect = new Rectangle();
            this.GorgonSprite = gorgonSprite;

            this.surfaceRect.Size = new Size(GorgonSprite.Image.Width, GorgonSprite.Image.Height) ;

            this.surfaceRect.Location = location;
            InitialRect = this.surfaceRect;

            this.Name = "";
            this.type = "IMAGE";

            CurrentFrame = 0;
            Alpha = 1.0F;

            this.GradientColor = new GradientColor();
            this.CoronaObjectParent = coronaObjectParent;
        }
示例#27
0
        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);
        }
示例#28
0
        public DisplayObject(GorgonLibrary.Graphics.Sprite gorgonSprite, Point location, CoronaObject coronaObjectParent)
        {
            this.surfaceRect  = new Rectangle();
            this.GorgonSprite = gorgonSprite;

            this.surfaceRect.Size = new Size(GorgonSprite.Image.Width, GorgonSprite.Image.Height);

            this.surfaceRect.Location = location;
            InitialRect = this.surfaceRect;

            this.Name = "";
            this.type = "IMAGE";


            CurrentFrame = 0;
            Alpha        = 1.0F;

            this.GradientColor      = new GradientColor();
            this.CoronaObjectParent = coronaObjectParent;
        }
示例#29
0
        //---------------------------------------------------
        //-------------------Mthodes--------------------
        //---------------------------------------------------
        public void addObject(CoronaObject obj)
        {
            obj.LayerParent  = this.objectParent.LayerParent;
            obj.EntityParent = this;


            if (obj.isEntity == false)
            {
                string objName = this.objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(obj.DisplayObject.Name);
                obj.DisplayObject.Name = objName;
            }
            else
            {
                string objName = this.objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(obj.Entity.Name);
                obj.Entity.Name = objName;
            }


            this.CoronaObjects.Add(obj);
        }
示例#30
0
        // Wheel Init
        //
        public void InitWheelJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point anchorPoint, Point _axisDistance,
                                      bool _isMotorEnabled, bool _isLimitEnabled, Double _motorSpeed, Double _motorForce,
                                      Double _upperLimit, Double _lowerLimit)
        {
            type = "WHEEL";
            this.AnchorPointA = anchorPoint;
            coronaObjA        = _coronaObjA;
            coronaObjB        = _coronaObjB;


            axisDistance = _axisDistance;

            isMotorEnable      = _isMotorEnabled;
            isLimitEnabled     = _isLimitEnabled;
            this.maxMotorForce = _motorForce;
            motorSpeed         = _motorSpeed;
            upperLimit         = _upperLimit;
            lowerLimit         = _lowerLimit;
            this.name          = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#31
0
        //---------------------------------------------------
        //-------------------Methodes------------------------
        //---------------------------------------------------
        public void addCoronaObject(CoronaObject obj,bool incrementName)
        {
            obj.setSelected(false);
            obj.LayerParent = this;

            if (incrementName == true)
            {
                if (obj.isEntity == false)
                {
                    string objName = this.SceneParent.projectParent.IncrementObjectName(obj.DisplayObject.Name);
                    obj.DisplayObject.Name = objName;
                }
                else
                {
                    string objName = this.SceneParent.projectParent.IncrementObjectName(obj.Entity.Name);
                    obj.Entity.Name = objName;
                }
            }

            this.CoronaObjects.Add(obj);
        }
示例#32
0
        public DisplayObject(Figure fig, CoronaObject coronaObjectParent)
        {
            this.Name   = "Figure";
            this.type   = "FIGURE";
            this.Figure = fig;
            this.Figure.DisplayObjectParent = this;

            if (this.Figure.ShapeType.Equals("RECTANGLE"))
            {
                Rect rect = this.Figure as Rect;
                this.surfaceRect = rect.getBounds(new Matrix());
            }
            else if (this.Figure.ShapeType.Equals("CIRCLE"))
            {
                Cercle cercle = this.Figure as Cercle;
                this.surfaceRect = cercle.getBounds(new Matrix());
            }
            else if (this.Figure.ShapeType.Equals("LINE"))
            {
                Line line = this.Figure as Line;

                this.surfaceRect = line.getBounds(new Matrix());
            }
            else if (this.Figure.ShapeType.Equals("TEXT"))
            {
                Texte text = this.Figure as Texte;
                this.surfaceRect = new Rectangle(text.Position,
                                                 System.Windows.Forms.TextRenderer.MeasureText(text.txt,
                                                                                               new Font(text.font2.FamilyName, text.font2.Size, text.font2.Style)));
            }
            else if (this.Figure.ShapeType.Equals("CURVE"))
            {
                CourbeBezier courbe = this.Figure as CourbeBezier;
                this.surfaceRect = courbe.getBounds(new Matrix());
            }

            Alpha = 1.0F;
            this.GradientColor      = new GradientColor();
            this.CoronaObjectParent = coronaObjectParent;
        }
示例#33
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);
        }
示例#34
0
        public TransformBox(CoronaObject obj)
        {
            this.objectParent = obj;

            if (obj.isEntity == false)
            {
                if (obj.DisplayObject.Type.Equals("FIGURE"))
                {
                    Figure fig = obj.DisplayObject.Figure;
                    if (fig.ShapeType.Equals("LINE"))
                    {
                        currentLine = (Line)fig;
                        this.hotSpotsLine = new List<Rectangle>();
                        isLine = true;
                    }
                    else if (fig.ShapeType.Equals("CURVE"))
                    {
                        currentCurve = (CourbeBezier)fig;
                        this.hotSpotsLine = new List<Rectangle>();
                        isCurve = true;
                    }
                }
            }
        }
示例#35
0
        public void clearProject()
        {
            //Relacher tous les composants graphiques
            for (int i = 0; i < this.Scenes.Count; i++)
            {
                Scene scene = this.Scenes[i];

                for (int j = 0; j < scene.Layers.Count; j++)
                {
                    CoronaLayer layer = scene.Layers[j];

                    for (int h = 0; h < layer.CoronaObjects.Count; h++)
                    {
                        CoronaObject obj = layer.CoronaObjects[h];

                        obj = null;
                    }

                    layer = null;
                }

                scene = null;
            }
        }
示例#36
0
        public void Init(Form1 mainForm, CoronaJointure joint)
        {
            this.MainForm = mainForm;
            this.cJoint = joint;
            modePanel = "NEW";

            if (this.cJoint.type.Equals("WHEEL")) {
                this.objA = cJoint.coronaObjA;
                obj1Tb.Text = objA.DisplayObject.Name;
                this.objB = cJoint.coronaObjB;
                obj2Tb.Text = objB.DisplayObject.Name;

                this.axisDistance = cJoint.axisDistance;
                axisDistanceTb.Text = axisDistance.ToString();

                this.setAnchorPoint(cJoint.AnchorPointA);

                motorSpeedNup.Value = Convert.ToInt32(cJoint.motorSpeed);

                motorForceNup.Value = Convert.ToInt32( cJoint.maxMotorTorque);

                modePanel = "MODIFY";
            }
        }
示例#37
0
 private void goCreationStep3(CoronaObject objB)
 {
     if (objB != null)
     {
         this.setObjectB(objB);
         this.mainForm.sceneEditorView1.SetEditCursor();
         this.mainForm.guideCreationJoint.Text = "SELECT ANCHOR POINT A";
         CreationStep = 3;
     }
     else
     {
         MessageBox.Show("Error during joint creation ! Object B not selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         goCreationStep2(this.objA);
     }
 }
示例#38
0
        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);
            }
        }
示例#39
0
        //---------------------------------------------------
        //-------Protocole de creation  jointures------------
        //---------------------------------------------------
        public void startCreationJoint()
        {
            this.mainForm.setModeJoint();
            this.mainForm.sceneEditorView1.SetDefaultCursor();
            this.mainForm.guideCreationJoint.Text = "SELECT OBJECT A";
            this.objA = null;
            this.objB = null;

            this.anchorPointA = Point.Empty;
            this.anchorPointB = Point.Empty;

            CreationStep = 1;
        }
示例#40
0
 private void goCreationStep2(CoronaObject objA)
 {
     if (objA != null)
     {
         this.setObjectA(objA);
         this.mainForm.guideCreationJoint.Text = "SELECT OBJECT B";
         CreationStep = 2;
     }
     else
     {
         MessageBox.Show("Error during joint creation ! Object A not selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.startCreationJoint();
     }
 }
示例#41
0
 public void setObjectA(CoronaObject obj)
 {
     this.objA = obj;
     this.nameObj1TxtBx.Text = this.objA.DisplayObject.Name;
 }
示例#42
0
 public void setObjectB(CoronaObject obj)
 {
     this.objB = obj;
     this.nameObj2TxtBx.Text = this.objB.DisplayObject.Name;
 }
示例#43
0
        // Wheel Init (WAIT FOR CORONA SDK PATH BEFORE USE IT!) ==> bug with maxMotorForce
        //
        public void InitWheelJointure( CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point _axisDistance,Point anchorA,
            bool _isMotorEnabled, Double _motorSpeed, Double _maxMotorTorque)
        {
            type = "WHEEL";
            coronaObjA = _coronaObjA;
            coronaObjB = _coronaObjB;
            AnchorPointA = anchorA;

            axisDistance = _axisDistance;

            isMotorEnable = _isMotorEnabled;

            motorSpeed = _motorSpeed;
            maxMotorTorque = _maxMotorTorque;

            this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#44
0
        public bool IsNameExistsInProject(string objName)
        {
            for (int i = 0; i < this.Scenes.Count; i++)
            {
                Scene scene = this.Scenes[i];
                if (scene.Name.Equals(objName))
                {
                    return(true);
                }

                for (int j = 0; j < scene.Layers.Count; j++)
                {
                    CoronaLayer layer = scene.Layers[j];
                    if (layer.Name.Equals(objName))
                    {
                        return(true);
                    }

                    if (layer.TilesMap != null)
                    {
                        if (layer.TilesMap.TilesMapName.Equals(objName))
                        {
                            return(true);
                        }
                    }

                    for (int k = 0; k < layer.CoronaObjects.Count; k++)
                    {
                        CoronaObject obj = layer.CoronaObjects[k];
                        if (obj.isEntity == false)
                        {
                            if (obj.DisplayObject.Name.Equals(objName))
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            if (obj.Entity.Name.Equals(objName))
                            {
                                return(true);
                            }

                            for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++)
                            {
                                CoronaObject child = obj.Entity.CoronaObjects[l];
                                if (child.DisplayObject.Name.Equals(objName))
                                {
                                    return(true);
                                }
                            }
                        }
                    }

                    for (int k = 0; k < layer.Controls.Count; k++)
                    {
                        if (layer.Controls[k].ControlName.Equals(objName))
                        {
                            return(true);
                        }
                    }
                }
            }



            return(false);
        }
示例#45
0
 // Touch Init
 public void InitTouchJointure( CoronaObject _coronaObj, Point _Target)
 {
     //myJoint = physics.newJoint( "touch", crate, targetX,targetY )
     type = "TOUCH";
     coronaObjA = _coronaObj;
     AnchorPointA = _Target;
     this.name = this.type + "_" + _coronaObj.DisplayObject.Name;
 }
示例#46
0
 // Weld Init
 //
 public void InitWeldJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point _AnchorPoint)
 {
     type = "WELD";
     coronaObjA = _coronaObjA;
     coronaObjB = _coronaObjB;
     AnchorPointA = _AnchorPoint;
     this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
 }
示例#47
0
        //---------------------------------------------------
        //-------------------Methodes------------------------
        //---------------------------------------------------
        public List <string> getLuaFilesUsed(bool isDebug)
        {
            if (this.project != null)
            {
                bool fpsAnalyser        = false;
                bool fStarPathFinding   = false;
                bool generator          = false;
                bool joystick           = false;
                bool mobileEditorEngine = false;
                bool pathFollow         = false;
                bool rosetta            = true;
                bool tilesmap           = false;
                bool entity             = false;


                List <string> fileNames = new List <string>();

                for (int i = 0; i < this.project.Scenes.Count; i++)
                {
                    Scene scene = this.project.Scenes[i];
                    if (scene.isEnabled == true)
                    {
                        if (scene.Name.Equals("mapeditormobile"))
                        {
                            mobileEditorEngine = true;
                        }

                        if (scene.IsFPSVisible == true)
                        {
                            fpsAnalyser = true;
                        }

                        for (int j = 0; j < scene.Layers.Count; j++)
                        {
                            CoronaLayer layer = scene.Layers[j];
                            if (layer.isEnabled == true)
                            {
                                if (layer.TilesMap != null)
                                {
                                    if (layer.TilesMap.isEnabled == true)
                                    {
                                        tilesmap = true;

                                        if (layer.TilesMap.IsPathFindingEnabled == true)
                                        {
                                            fStarPathFinding = true;
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < layer.Controls.Count; k++)
                            {
                                CoronaControl control = layer.Controls[k];
                                if (control.isEnabled == true)
                                {
                                    if (control.Type == CoronaControl.ControlType.joystick)
                                    {
                                        joystick = true;
                                        break;
                                    }
                                }
                            }

                            for (int k = 0; k < layer.CoronaObjects.Count; k++)
                            {
                                CoronaObject obj = layer.CoronaObjects[k];
                                if (obj.isEnabled == true)
                                {
                                    if (obj.isEntity == false)
                                    {
                                        if (obj.PathFollow.isEnabled == true)
                                        {
                                            pathFollow = true;
                                        }

                                        if (obj.isGenerator == true)
                                        {
                                            generator = true;
                                        }
                                    }
                                    else
                                    {
                                        entity = true;

                                        if (obj.isGenerator == true)
                                        {
                                            generator = true;
                                        }

                                        for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++)
                                        {
                                            CoronaObject child = obj.Entity.CoronaObjects[l];
                                            if (child.isEnabled == true)
                                            {
                                                if (child.PathFollow.isEnabled == true)
                                                {
                                                    pathFollow = true;
                                                }

                                                if (child.isGenerator == true)
                                                {
                                                    generator = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                fileNames.Add("object.lua");
                fileNames.Add("camera.lua");
                fileNames.Add("soundengine.lua");
                if (fpsAnalyser == true)
                {
                    fileNames.Add("graph.lua");
                    fileNames.Add("perfanalyser.lua");
                }

                if (fStarPathFinding == true)
                {
                    fileNames.Add("fstar.lua");
                }
                if (generator == true)
                {
                    fileNames.Add("generator.lua");
                }
                if (joystick == true)
                {
                    fileNames.Add("joystick.lua");
                }
                if (mobileEditorEngine == true)
                {
                    fileNames.Add("mobileeditorengine.lua");
                }
                if (pathFollow == true)
                {
                    fileNames.Add("pathfollow.lua");
                }
                if (rosetta == true)
                {
                    fileNames.Add("rosetta.lua");
                }
                if (tilesmap == true)
                {
                    fileNames.Add("tilesmap.lua");
                }
                if (entity == true)
                {
                    fileNames.Add("entity.lua");
                }

                if (Settings1.Default.RemoteControlEnabled == true && isDebug == false)
                {
                    fileNames.Add("Krea Remote\\remotecontroler.lua");
                }

                //if (isDebug == true)
                //{
                //    fileNames.Add("mobdebug.lua");
                //}



                return(fileNames);
            }
            return(null);
        }
示例#48
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);
        }
示例#49
0
        private List <string> getAllFontsUsed(CoronaGameProject project)
        {
            if (project != null)
            {
                List <string> list = new List <string>();
                for (int i = 0; i < project.Scenes.Count; i++)
                {
                    Scene scene = this.project.Scenes[i];
                    for (int j = 0; j < scene.Layers.Count; j++)
                    {
                        CoronaLayer layer = scene.Layers[j];
                        for (int k = 0; k < layer.CoronaObjects.Count; k++)
                        {
                            CoronaObject obj = layer.CoronaObjects[k];
                            if (obj.isEntity == false)
                            {
                                if (obj.DisplayObject.Figure != null)
                                {
                                    Figure fig = obj.DisplayObject.Figure;
                                    if (fig.ShapeType.Equals("TEXT"))
                                    {
                                        Texte  txt      = fig as Texte;
                                        string fontName = txt.font2.getFontNameForAndroid();
                                        if (!list.Contains(fontName))
                                        {
                                            list.Add(fontName);

                                            string fontsfolder = System.Environment.GetFolderPath(
                                                System.Environment.SpecialFolder.Fonts);

                                            FontNameGetter fontNameGetter = new FontNameGetter();
                                            string         res            = fontNameGetter.GetFontFileName(new DirectoryInfo(fontsfolder), txt.font2);
                                            if (File.Exists(res))
                                            {
                                                string fileDest = project.BuildFolderPath + "\\" + fontName + ".ttf";
                                                File.Copy(res, fileDest, true);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++)
                                {
                                    CoronaObject child = obj.Entity.CoronaObjects[l];

                                    if (child.DisplayObject.Figure != null)
                                    {
                                        Figure fig = child.DisplayObject.Figure;
                                        if (fig.ShapeType.Equals("TEXT"))
                                        {
                                            Texte  txt      = fig as Texte;
                                            string fontName = txt.font2.getFontNameForAndroid();
                                            if (!list.Contains(fontName))
                                            {
                                                list.Add(fontName);

                                                string fontsfolder = System.Environment.GetFolderPath(
                                                    System.Environment.SpecialFolder.Fonts);

                                                FontNameGetter fontNameGetter = new FontNameGetter();
                                                string         res            = fontNameGetter.GetFontFileName(new DirectoryInfo(fontsfolder), txt.font2);
                                                if (File.Exists(res))
                                                {
                                                    string fileDest = project.BuildFolderPath + "\\" + fontName + ".ttf";
                                                    File.Copy(res, fileDest, true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(list);
            }
            return(null);
        }
示例#50
0
        public static void exportEntity(Form1 mainForm, CoronaObject entity, string directoryName, BackgroundWorker worker)
        {
            worker.ReportProgress(20);
            string entitySerialzedDirectory = directoryName + "\\" + entity.Entity.Name;

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

            Directory.CreateDirectory(entitySerialzedDirectory);

            FileStream fs = File.Create(directoryName + "\\" + entity.Entity.Name + ".kre");
            MemoryStream ms = SerializerHelper.SerializeBinary(entity);

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

            CoronaEntity entityObject = entity.Entity;
            for (int k = 0; k < entityObject.CoronaObjects.Count; k++)
            {
                CoronaObject child = entityObject.CoronaObjects[k];
                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(entitySerialzedDirectory + "\\Images"))
                                Directory.CreateDirectory(entitySerialzedDirectory + "\\Images");

                            File.Copy(filename, entitySerialzedDirectory + "\\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 l = 0; l < set.Frames.Count; l++)
                            {
                                if (!spriteSheetsUsed.Contains(set.Frames[l].SpriteSheetParent))
                                    spriteSheetsUsed.Add(set.Frames[l].SpriteSheetParent);

                            }

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

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

                            }
                        }
                    }
                }
            }

            worker.ReportProgress(80);
        }
示例#51
0
        // Wheel Init
        //
        public void InitWheelJointure(CoronaObject _coronaObjA, CoronaObject _coronaObjB, Point anchorPoint,Point _axisDistance,
    bool _isMotorEnabled, bool _isLimitEnabled, Double _motorSpeed, Double _motorForce,
    Double _upperLimit, Double _lowerLimit)
        {
            type = "WHEEL";
            this.AnchorPointA = anchorPoint;
            coronaObjA = _coronaObjA;
            coronaObjB = _coronaObjB;

            axisDistance = _axisDistance;

            isMotorEnable = _isMotorEnabled;
            isLimitEnabled = _isLimitEnabled;
            this.maxMotorForce = _motorForce;
            motorSpeed = _motorSpeed;
            upperLimit = _upperLimit;
            lowerLimit = _lowerLimit;
            this.name = this.type + "_" + _coronaObjA.DisplayObject.Name + "_" + _coronaObjB.DisplayObject.Name;
        }
示例#52
0
        public static void exportObject(Form1 mainForm, CoronaObject obj, string directoryName, BackgroundWorker worker)
        {
            worker.ReportProgress(20);

            //Create FIrst directory
            string finalDirectory = directoryName + "\\" + obj.DisplayObject.Name;
            if (Directory.Exists(finalDirectory))
                Directory.Delete(finalDirectory, true);

            Directory.CreateDirectory(finalDirectory);

            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(finalDirectory + "\\Images"))
                            Directory.CreateDirectory(finalDirectory + "\\Images");

                        File.Copy(filename, finalDirectory + "\\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 i = 0; i < set.Frames.Count; i++)
                        {
                            if (!spriteSheetsUsed.Contains(set.Frames[i].SpriteSheetParent))
                                spriteSheetsUsed.Add(set.Frames[i].SpriteSheetParent);

                        }

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

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

                        }
                    }
                }
            }

            FileStream fs = File.Create(finalDirectory + "\\" + obj.DisplayObject.Name + ".kro");

            MemoryStream ms = SerializerHelper.SerializeBinary(obj);

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

            worker.ReportProgress(80);
        }
示例#53
0
        public String getPhysicsParams(CoronaObject objParent, float XRatio, float YRatio)
        {
            string paramsPhysics = "";

            float moyenneRatio = (XRatio + YRatio) / 2;

            if (this.isCustomizedBody == true)
            {
                for (int i = 0; i < this.BodyElements.Count; i++)
                {
                    BodyElement elem = this.BodyElements[i];

                    if (i > 0)
                    {
                        paramsPhysics += ",\n";
                    }

                    paramsPhysics += "{ ";

                    //Recuperer les properties

                    /*  paramsPhysics += ("bounce =" + ((float)elem.Bounce / moyenneRatio)).Replace(",", ".") + ",";
                     * paramsPhysics += ("density =" + ((float)elem.Density/ moyenneRatio)).Replace(",", ".") + ",";
                     * paramsPhysics += ("friction =" + ((float)elem.Friction / moyenneRatio)).Replace(",", ".");
                     * paramsPhysics += ",filter = " + this.getCollisionFilter();*/

                    paramsPhysics += "bounce =" + elem.Bounce.ToString().Replace(",", ".") + ",";
                    paramsPhysics += "density =" + elem.Density.ToString().Replace(",", ".") + ",";
                    paramsPhysics += "friction =" + elem.Friction.ToString().Replace(",", ".");
                    paramsPhysics += ",isSensor =" + elem.IsSensor.ToString().ToLower() + ",";

                    if (elem.CollisionGroupIndex > 0)
                    {
                        paramsPhysics += "filter = " + this.getCollisionFilter(elem.CollisionGroupIndex);
                    }
                    else
                    {
                        paramsPhysics += "filter = " + this.getCollisionFilter(this.CollisionGroupIndex);
                    }

                    if (elem.Type.Equals("CIRCLE"))
                    {
                        if (elem.Radius > 0)
                        {
                            paramsPhysics += ",radius =" + (elem.Radius * moyenneRatio).ToString().Replace(",", ".");
                        }
                    }
                    else
                    {
                        if (objParent.DisplayObject.Type.Equals("FIGURE") && (objParent.DisplayObject.Figure.ShapeType.Equals("CURVE") || objParent.DisplayObject.Figure.ShapeType.Equals("LINE")))
                        {
                            //Recuperer la shape du body si elle existe
                            if (elem.BodyShape.Count > 1)
                            {
                                paramsPhysics += ",shape = {";
                                for (int j = 0; j < elem.BodyShape.Count; j++)
                                {
                                    if (j != 0)
                                    {
                                        paramsPhysics += ",\n";
                                    }

                                    Point p = elem.BodyShape[j];

                                    paramsPhysics += ((float)(p.X - BodyElements[0].BodyShape[0].X) * XRatio).ToString().Replace(",", ".") + "," +
                                                     ((float)(p.Y - BodyElements[0].BodyShape[0].Y) * YRatio).ToString().Replace(",", ".");
                                }

                                paramsPhysics += "}";
                            }
                        }
                        else
                        {
                            //Recuperer la shape du body si elle existe
                            if (elem.BodyShape.Count > 1)
                            {
                                paramsPhysics += ",shape = {";
                                for (int j = 0; j < elem.BodyShape.Count; j++)
                                {
                                    if (j != 0)
                                    {
                                        paramsPhysics += ",\n";
                                    }

                                    Point p = elem.BodyShape[j];

                                    paramsPhysics += ((float)((p.X - objParent.DisplayObject.SurfaceRect.Width / 2) * moyenneRatio)).ToString().Replace(",", ".") + "," +
                                                     ((float)((p.Y - objParent.DisplayObject.SurfaceRect.Height / 2) * moyenneRatio)).ToString().Replace(",", ".");
                                }

                                paramsPhysics += "}";
                            }
                        }
                    }

                    paramsPhysics += "}";
                }
            }
            else
            {
                paramsPhysics += "{ ";

                //Recuperer les properties
                paramsPhysics += ("bounce =" + Bounce).Replace(",", ".") + ",";
                paramsPhysics += ("density =" + Density).Replace(",", ".") + ",";
                paramsPhysics += ("friction =" + Friction).Replace(",", ".");
                paramsPhysics += ",filter = " + this.getCollisionFilter(this.CollisionGroupIndex);

                if (objParent.DisplayObject.Type.Equals("FIGURE") && objParent.DisplayObject.Figure.ShapeType.Equals("CIRCLE"))
                {
                    Cercle cercle = objParent.DisplayObject.Figure as Cercle;
                    paramsPhysics += ",radius =" + ((float)cercle.Rayon * moyenneRatio).ToString().Replace(",", ".");
                }
                else if (this.Radius > 0)
                {
                    paramsPhysics += ",radius =" + ((float)this.Radius * XRatio).ToString().Replace(",", ".");
                }
                else
                {
                    float halfContentWidth  = (float)this.objectParent.DisplayObject.SurfaceRect.Width / (float)2 * (float)XRatio;
                    float halfContentHeight = (float)this.objectParent.DisplayObject.SurfaceRect.Height / (float)2 * (float)YRatio;
                    paramsPhysics += ",shape = {" + (-halfContentWidth).ToString().Replace(",", ".") + "," + (-halfContentHeight).ToString().Replace(",", ".") + "," +
                                     (halfContentWidth).ToString().Replace(",", ".") + "," + (-halfContentHeight).ToString().Replace(",", ".") + "," +
                                     (halfContentWidth).ToString().Replace(",", ".") + "," + (halfContentHeight).ToString().Replace(",", ".") + "," +
                                     (-halfContentWidth).ToString().Replace(",", ".") + "," + (halfContentHeight).ToString().Replace(",", ".") + "}";
                }

                paramsPhysics += "}";
            }



            return(paramsPhysics);
        }