public TilemapObject(Behaviours.Positionable relatedComponent, uint x, uint y, uint width, uint height, SolidnessStatus solidness) { if (relatedComponent == null) { throw new NullReferenceException("Related component for tile object must not be null"); } if (width < 1 || width > MAX_WIDTH || height < 1 || height > MAX_HEIGHT) { throw new InvalidDimensionsException(width, height); } if (x + width >= MAX_WIDTH || y + height >= MAX_HEIGHT) { throw new InvalidPositionException(x, y); } X = x; Y = y; RelatedComponent = relatedComponent; Width = width; Height = height; Solidness = solidness; Movement = null; Map = null; }
public void SetSolidness(SolidnessStatus newSolidness) { if (tilemapObject != null && !paused) { tilemapObject.SetSolidness(newSolidness); } }
public void SetSolidness(SolidnessStatus newSolidness) { if (Map == null) { return; } if (OccupianceChanges(Solidness, newSolidness)) { CancelMovement(); DecrementBody(); Solidness = newSolidness; IncrementBody(); } else { Solidness = newSolidness; } TriggerEvent("OnSolidnessChanged", Solidness); }
private static bool OccupianceChanges(SolidnessStatus oldStatus, SolidnessStatus newStatus) { return((Occupies(oldStatus) != Occupies(newStatus)) || (MakesHole(oldStatus) != MakesHole(newStatus))); }
private static bool Traverses(SolidnessStatus solidness) { // Solid objects cannot traverse/overlap others. return(solidness != SolidnessStatus.Solid); }
private static bool Occupies(SolidnessStatus solidness) { // Ghost objects will not occupy space return(solidness == SolidnessStatus.Solid || solidness == SolidnessStatus.SolidForOthers); }
private static bool MakesHole(SolidnessStatus solidness) { // Holes will occupy in the opposite way return(solidness == SolidnessStatus.Hole); }