public virtual void Update(MapBase map) { if (!IsActive) return; var hitflag = false; for (int index = 0; index < map.Elements.Count; index++) { var obj = map.Elements[index]; if (obj.Equals(this)) continue; if (CheckHit(new Square(new Point(Top.X + Distance.X, Top.Y), Size), obj)) { OnHitEvent(obj); OnHitXEvent(obj); if (obj.IsSolid) { hitflag = true; break; } } } if (!hitflag) Top += new Size(Distance.X, 0); hitflag = false; foreach (var obj in map.Elements) { if (obj.Equals(this)) continue; if (CheckHit(new Square(new Point(Top.X, Top.Y + Distance.Y), Size), obj)) { OnHitEvent(obj); OnHitYEvent(obj); if (obj.IsSolid) { hitflag = true; break; } } } if (!hitflag) Top += new Size(0, Distance.Y); }
public MapElementBase AddTo(MapBase map) { Map = map; map.AddElement(this); return this; }