예제 #1
0
파일: V2DScreen.cs 프로젝트: yzqlwt/Swf2XNA
        public override void Initialize()
        {
            base.Initialize();

            V2DDefinition def = v2dWorld.GetDefinitionByName(this.definitionName);

            if (def != null)
            {
                for (int i = 0; i < def.Joints.Count; i++)
                {
                    this.AddJoint(def.Joints[i], this.X, this.Y);
                }
            }

            System.Reflection.MemberInfo inf   = this.GetType();
            System.Attribute[]           attrs = System.Attribute.GetCustomAttributes(inf);    // reflection
            foreach (System.Attribute attr in attrs)
            {
                if (attr is V2DScreenAttribute)
                {
                    V2DScreenAttribute a = (V2DScreenAttribute)attr;
                    if (a.gravityX != 0 | a.gravityY != 10)
                    {
                        Gravity = new Vector2(a.gravityX, a.gravityY);
                    }

                    useDebugDraw = a.debugDraw;
                }
            }
        }
예제 #2
0
        private void WriteDefinitions(V2DWorld v2dWorld)
        {
            foreach (Definition2D def in v2d.definitions)
            {
				V2DDefinition d;
				if (def is Text2D)
				{
					V2DText v2t = new V2DText();
					d = v2t;
					v2t.TextRuns = ((Text2D)def).TextRuns;
				}
				else
				{
					d = new V2DDefinition();
					d.V2DShapes.Clear();
					for (int i = 0; i < def.Shapes.Count; i++)
					{
						d.V2DShapes.Add(def.Shapes[i].GetV2DShape());
					}

					d.Instances.Clear();
					if (def.Children.Count > 0)
					{
						for (int i = 0; i < def.Children.Count; i++)
						{
							d.Instances.Add(GetV2DInstance(def.Children[i]));
						}
					}
				}

				v2dWorld.definitions.Add(d);
				d.Name = def.DefinitionName;
				d.Id = def.Id;
				d.LinkageName = def.LinkageName;// paths.ContainsKey(def.Id) ? paths[def.Id] : "";
				d.FrameCount = def.FrameCount;
				d.OffsetX = def.Bounds.Point.X;
				d.OffsetY = def.Bounds.Point.Y;
				d.Width = def.Bounds.Size.Width;
				d.Height = def.Bounds.Size.Height;

				d.Joints.Clear();
				if (def.Joints.Count > 0)
				{
					WriteJointData(d.Joints, def);
				}
            }
        }
예제 #3
0
        private V2DInstance CreateInstance(Instance inst, V2DDefinition def)
        {
            V2DInstance result = new V2DInstance();

            result.InstanceName = inst.Name;
            result.Definition = def;
            result.DefinitionName = def.Name;
            result.Depth = (int)inst.Depth;
            result.StartFrame = curVo.GetFrameFromMillisecondsGetFrame(inst.StartTime);
            result.TotalFrames = curVo.GetFrameFromMillisecondsGetFrame(inst.EndTime - inst.StartTime);
            Matrix m = inst.Transformations[0].Matrix;
            result.UserData = m;
            AddSymbolImage(inst, def);

            curDef.Instances.Add(result);
            return result;
        }
예제 #4
0
        private V2DDefinition CreateDefinition(Instance inst, IDefinition def)
        {
            V2DDefinition result = defs.Find(d => d.Name == def.Name);

            if (result == null)
            {
                result = new V2DDefinition();
                result.DefinitionName = def.Name;
                result.LinkageName = def.Name; // todo: find real linkageName
                result.Bounds = def.StrokeBounds;
                result.FrameCount = (int)tlDef.FrameCount;
                //ParseBodyImage(result, def, inst);
            }
            return result;
        }
예제 #5
0
        public void Init()
        {
            V2DDefinition ground = new V2DDefinition();
            ground.Name = V2D.ROOT_NAME;
            ground.FrameCount = 1;

            V2DInstance inst = new V2DInstance();
            inst.DefinitionName = ground.Name;
            inst.InstanceName = V2D.ROOT_NAME;
            inst.Definition = ground;
            inst.Transform = Matrix.Identitiy.GetDrawing2DMatrix().Elements;
            inst.TotalFrames = (int)curVo.GetFrameFromMilliseconds(curVo.Root.Duration);

            parentStack.Push(inst);
            root = inst;
        }