private RotationInfo CreateRotated() { List <Vector2> list = Rotate(this.Points); RotationInfo info = new RotationInfo(list, this.collection, this.index + 1); return(info); }
public static RotationInfo Create(List <Vector2> points) { Collection collection = new Collection(points); RotationInfo info = collection.Get(0); return(info); }
public FigureInfo( Figure sample, Vector2Int localPoint, Transform transform, Color color, FigureAssetScope figureAssetScope, GameParameters parameters, CubesArray cubesArray, AtomCubePool atomCubePool) { this.Color = color; this.parameters = parameters; this.cubesArray = cubesArray; this.atomCubePool = atomCubePool; this.pos = localPoint; FigureAsset figureAsset = figureAssetScope.GetRandom(); Figure figure = Util.CreateLocal(sample, transform, this.pos.ToVector3Int()); figure.Color = color; figure.FigureAsset = figureAsset; this.cubesItems = figure.CreateCubes(atomCubePool); this.Figure = figure; List <Vector2> points = figureAsset.GetCubesPositions(0); this.rotationInfo = RotationInfo.Create(points); this.CheckStartPosition(); this.UpdatePos(); }
public bool CheckFigure(RotationInfo rotationInfo, Vector2Int newPos, bool checkCells) { RectInt rect = rotationInfo.Bounds; rect = rect.Offset(newPos); if (!this.Bounds.Contains(rect)) { return(false); } if (checkCells) { foreach (Vector2Int point in rotationInfo.Points0) { Vector2Int p = point + newPos; Cell cell = this.GetCell(p); if (cell == null) { continue; } if (cell.Type == CellType.Fixed) { return(false); } } } return(true); }
public Collection(List <Vector2> list) { RotationInfo info = new RotationInfo(list, this, 0); this.infos.Add(info); for (int i = 0; i < 3; i++) { info = info.CreateRotated(); this.infos.Add(info); } }
public void SetFigure(RotationInfo figureAsset, Vector2Int point) { this.RemoveFigure(); foreach (Vector2Int p in figureAsset.Points0) { Vector2Int pp = p + point; Cell cell = this.SetCell(pp, CellType.Figure); if (cell != null) { this.figureCells.Add(cell); } } }
public void Rotate(bool left) { if (this.rotateAction != null) { return; } this.rotationInfo = this.rotationInfo.GetRotated(left); this.UpdateCubeArray(); Vector2 position = this.GetPostion(); this.rotateAction = new RotateAction( figure: this.Figure, multiplier: left ? 1f : -1f, position: position, parameters: this.parameters.FigureRotation); this.rotateAction.Complete += () => this.rotateAction = null; }