Exemplo n.º 1
0
            public bool Write(BinaryWriter bw, u32 of1, u32 of2)
            {
                // text offset
                Text.Fixup(of1, of2);
                bw.Write(Text.offset);
                // flags
                Flags.Write(bw);
                foreach (Attribute a in Attributes)
                {
                    a.Name.Fixup(of1, of2);
                    a.Value.Fixup(of1, of2);
                    a.Write(bw);
                }

                switch (Flags.RawInfo)
                {
                case 0:
                    bw.Write(Offset);
                    break;

                case 1:
                    End.Fixup(of1, of2);
                    bw.Write(End.offset);
                    bw.Write(Offset);
                    break;

                case 2:
                case 6:
                    End.Fixup(of1, of2);
                    bw.Write(End.offset);
                    if (Flags.Children > 0)
                    {
                        bw.Write(Offset);
                    }
                    break;

                case 3:
                case 7:
                    Inner.Fixup(of1, of2);
                    End2.Fixup(of1, of2);
                    bw.Write(Inner.offset);
                    bw.Write(End2.offset);
                    if (Flags.Children > 0)
                    {
                        bw.Write(Offset);
                    }
                    break;

                default:
                    //Console.WriteLine("Unsupported info");
                    break;
                }

                return(true);
            }
Exemplo n.º 2
0
        public override Coordinate GetExtremityInDirection(Coordinate dir)
        {
            Coordinate ext = base.GetExtremityInDirection(dir);

            if (End1.Contains(ext))
            {
                return(End1.GetExtremityInDirection(dir));
            }
            if (End2.Contains(ext))
            {
                return(End2.GetExtremityInDirection(dir));
            }
            return(ext);
        }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            var   x      = End1.Position - End2.Position;
            float length = x.Length();

            if (length <= TargetLength)
            {
                return;
            }

            x = (x / length) * (length - TargetLength);
            var dv    = End2.Velocity - End1.Velocity;
            var force = Stiffness * x - dv * Damping;

            End1.ApplyForce(-force);
            End2.ApplyForce(force);
        }
Exemplo n.º 4
0
        public override void Write(Utf8JsonWriter writer)
        {
            base.Write(writer);

            if (End1 != null)
            {
                writer.WritePropertyName(End1PropertyName);
                writer.WriteStartObject();
                End1.Write(writer);
                writer.WriteEndObject();
            }

            if (End2 != null)
            {
                writer.WritePropertyName(End2PropertyName);
                writer.WriteStartObject();
                End2.Write(writer);
                writer.WriteEndObject();
            }
        }
Exemplo n.º 5
0
 public override bool Contains(Coordinate pos)
 {
     return(base.Contains(pos) || End1.Contains(pos) || End2.Contains(pos));
 }
Exemplo n.º 6
0
 public override int GetRightX()
 {
     return(Math.Max(End1.GetRightX(), End2.GetRightX()));
 }
Exemplo n.º 7
0
 public override int GetLeftX()
 {
     return(Math.Min(End1.GetLeftX(), End2.GetLeftX()));
 }
Exemplo n.º 8
0
 public override int GetBottomY()
 {
     return(Math.Min(End1.GetBottomY(), End2.GetBottomY()));
 }
Exemplo n.º 9
0
 public override int GetTopY()
 {
     return(Math.Max(End1.GetTopY(), End2.GetTopY()));
 }
Exemplo n.º 10
0
 public override string ToString()
 {
     return("RoundedRectangle [" + base.ToString() + ", " + End1.ToString() + ", " + End2.ToString() + "]");
 }
Exemplo n.º 11
0
 public override int GetHashCode()
 {
     return(base.GetHashCode() + End1.GetHashCode() + End2.GetHashCode());
 }