private void LoadObjectInfos(ContentReader input, Entity entity, int count) { for (int i = 0; i < count; i++) { string name = input.ReadString(); string type = input.ReadString(); int w = input.ReadInt32(); int h = input.ReadInt32(); Entity.ObjectInfo info = new Entity.ObjectInfo(name, SpriterUtils.GetObjectInfoFor(type), new Dimension(w, h), new List <FileReference>()); entity.AddInfo(info); // todo frameja? ei näy dokkarissa } }
public void DrawBones(SpriterAnimationPlayer player) { SetColor(Color.Red); IEnumerator <Bone> it = player.BoneIterator(); while (it.MoveNext()) { Bone bone = it.Current; TimelineKey key = player.GetKeyFor(bone); if (!key.Active) { continue; } Entity.ObjectInfo info = player.GetObjectInfoFor(bone); Dimension size = info.Size; DrawBone(bone, size); } }
private void LoadTimelines(ContentReader input, SpriterAnimation anim, Entity entity, int count) { for (int id = 0; id < count; id++) { string name = input.ReadString(); string objtype = input.ReadString(); int keyCount = input.ReadInt32(); Entity.ObjectType type = SpriterUtils.GetObjectInfoFor(objtype); Entity.ObjectInfo info = entity.GetInfo(name); if (info == null) { info = new Entity.ObjectInfo(name, type, new Dimension(0f, 0f), new List <FileReference>()); } Timeline timeline = new Timeline(id, name, info, keyCount); anim.AddTimeline(timeline); LoadTimelineKeys(input, timeline, keyCount); } }
/// <summary> /// Returns whether the given area collides with the box of the given bone or object. </summary> /// <param name="boneOrObject"> the bone or object </param> /// <param name="area"> the rectangular area </param> /// <returns> <code>true</code> if the area collides with the bone or object </returns> public virtual bool CollidesFor(Bone boneOrObject, Rectangle area) { Entity.ObjectInfo info = GetObjectInfoFor(boneOrObject); this.PrevBBox.CalcFor(boneOrObject, info); return(this.PrevBBox.IsInside(area)); }
/// <summary> /// Returns whether the given point at x,y lies inside the box of the given bone or object. </summary> /// <param name="boneOrObject"> the bone or object </param> /// <param name="x"> the x value of the point </param> /// <param name="y"> the y value of the point </param> /// <returns> <code>true</code> if x,y lies inside the box of the given bone or object </returns> /// <exception cref="NullPointerException"> if no object info for the given bone or object exists </exception> public virtual bool CollidesFor(Bone boneOrObject, float x, float y) { Entity.ObjectInfo info = GetObjectInfoFor(boneOrObject); this.PrevBBox.CalcFor(boneOrObject, info); return(this.PrevBBox.Collides(boneOrObject, info, x, y)); }
/// <summary> /// Calculates and returns a <seealso cref="Box"/> for the given bone or object. </summary> /// <param name="boneOrObject"> the bone or object to calculate the bounding box for </param> /// <returns> the box for the given bone or object </returns> /// <exception cref="NullPointerException"> if no object info for the given bone or object exists </exception> public virtual Box GetBox(Bone boneOrObject) { Entity.ObjectInfo info = GetObjectInfoFor(boneOrObject); this.PrevBBox.CalcFor(boneOrObject, info); return(this.PrevBBox); }