public void AddObject(Actor actor) { Type cls = actor.GetType(); if (CollectionUtils.Contains(cls,this.collisionClasses)) { this.collisionChecker.AddObject(actor); } else { LinkedList classSet = (LinkedList) this.freeObjects.Get(cls); if (classSet == null) { classSet = new LinkedList(); this.freeObjects.Put(cls, classSet); } CollectionUtils.Add(classSet,actor); } }
private void PrepareForCollision(Actor actor, Type cls) { this.MakeCollisionObjects(actor.GetType(), false); this.MakeCollisionObjects(cls, true); }
public void UpdateObjectSize(Actor o) { lock (typeof(CollisionManager)) { if (!this.freeObjects.ContainsKey(o.GetType())) { this.collisionChecker.UpdateObjectSize(o); } } }
public void UpdateObjectLocation(Actor o, float oldX, float oldY) { lock (typeof(CollisionManager)) { if (!this.freeObjects.ContainsKey(o.GetType())) { this.collisionChecker.UpdateObjectLocation(o, oldX, oldY); } } }
public void RemoveObject(Actor o) { lock (typeof(CollisionManager)) { LinkedList classSet = (LinkedList) this.freeObjects.Get(o .GetType()); if (classSet != null) { classSet.Remove(o); } else { this.collisionChecker.RemoveObject(o); } } }
/// <summary> /// 获得含有指定角色碰撞的List集合 /// </summary> /// /// <param name="actor"></param> /// <returns></returns> public IList GetCollisionObjects(Actor actor) { if (isClose) { return null; } return GetCollisionObjects(actor.GetType()); }