public Stack(int startingPrisms) { _startingPrisms = Math.Max(1, startingPrisms); _prisms = Enumerable.Range(0, _startingPrisms) .Select(i => RectangularPrismFactory.MakeStandard(new Vector3(0, i * RectangularPrismFactory.TileHeight, 0))) .ToList(); }
public void StartOver(int prismCount) { _prisms.Clear(); foreach (var prism in Enumerable.Range(0, prismCount) .Select(i => RectangularPrismFactory.MakeStandard( new Vector3(0, i * RectangularPrismFactory.TileHeight, 0)))) { _prisms.Add(prism); } }
public RectangularPrism CreateNextUnboundPrism() { var top = Top; return(RectangularPrismFactory.Make( new Size3(top.Size.X, top.Size.Y, top.Size.Z), new Vector3( top.Position.X, _prisms.Count * RectangularPrismFactory.TileHeight, top.Position.Z), SceneColors.NextPrismColor())); }
public PrismOverlapResult OverlapWith(RectangularPrism other, PrismBounceAxis prismBounceAxis) { if (prismBounceAxis == PrismBounceAxis.X) { if (Math.Abs(Right - other.Right) <= PerfectPlayTolerance) { return(new PrismOverlapResult.PerfectLanding( copyWithPosition(new Vector3(other.Position.X, Position.Y, Position.Z)))); } if (Left < other.Left && Right <= other.Left) { return(new PrismOverlapResult.TotalMiss()); } if (other.Right < Right && other.Right <= Left) { return(new PrismOverlapResult.TotalMiss()); } if (Left < other.Left) { var hangerSize = new Size3( other.Left - Left, RectangularPrismFactory.TileHeight, Size.Z); var landedSize = new Size3( Size.X - hangerSize.X, RectangularPrismFactory.TileHeight, Size.Z); return(new PrismOverlapResult.Mixed( RectangularPrismFactory.Make( hangerSize, new Vector3(Left + hangerSize.X / 2f, Position.Y, Position.Z), Color), RectangularPrismFactory.Make( landedSize, new Vector3(Position.X + hangerSize.X / 2f, Position.Y, Position.Z), Color))); } else { var hangerSize = new Size3( Right - other.Right, RectangularPrismFactory.TileHeight, Size.Z); var landedSize = new Size3( Size.X - hangerSize.X, RectangularPrismFactory.TileHeight, Size.Z); return(new PrismOverlapResult.Mixed( RectangularPrismFactory.Make( hangerSize, new Vector3(Right - hangerSize.X / 2f, Position.Y, Position.Z), Color), RectangularPrismFactory.Make( landedSize, new Vector3(Position.X - hangerSize.X / 2f, Position.Y, Position.Z), Color))); } } //Front/Back if (Math.Abs(Front - other.Front) <= PerfectPlayTolerance) { return(new PrismOverlapResult.PerfectLanding( copyWithPosition(new Vector3(Position.X, Position.Y, other.Position.Z)))); } if (Front < other.Front && Front <= other.Back) { return(new PrismOverlapResult.TotalMiss()); } if (other.Front < Front && other.Front <= Back) { return(new PrismOverlapResult.TotalMiss()); } if (other.Front < Front) { var hangerSize = new Size3( Size.X, RectangularPrismFactory.TileHeight, Front - other.Front); var landedSize = new Size3( Size.X, RectangularPrismFactory.TileHeight, Size.Z - hangerSize.Z); return(new PrismOverlapResult.Mixed( RectangularPrismFactory.Make( hangerSize, new Vector3(Position.X, Position.Y, Front - hangerSize.Z / 2f), Color), RectangularPrismFactory.Make( landedSize, new Vector3(Position.X, Position.Y, Position.Z - hangerSize.Z / 2f), Color))); } else { var hangerSize = new Size3( Size.X, RectangularPrismFactory.TileHeight, other.Back - Back); var landedSize = new Size3( Size.X, RectangularPrismFactory.TileHeight, Size.Z - hangerSize.Z); return(new PrismOverlapResult.Mixed( RectangularPrismFactory.Make( hangerSize, new Vector3(Position.X, Position.Y, Back + hangerSize.Z / 2f), Color), RectangularPrismFactory.Make( landedSize, new Vector3(Position.X, Position.Y, Position.Z + hangerSize.Z / 2f), Color))); } }