public GridRect(GridRect b) { MinX = b.MinX; MinY = b.MinY; MaxX = b.MaxX; MaxY = b.MaxY; }
public GridRect(GridRect b) { minX = b.minX; minY = b.minY; maxX = b.maxX; maxY = b.maxY; }
// how do i create an entity? // large row: // beat finds empty row // we public static GraphicEntity1 New(GridRect rect, Board1 board) { var ge = new GameObject().AddComponent <GraphicEntity1>(); ge.Initialize(rect, board); return(ge); }
public override List <IExplicitShape <GridPoint2> > Execute(IEnumerable <IExplicitShape <GridPoint2> > input) { if (input == null) { return(null); } var inputList = input.ToList(); if (inputList.Count == 0) { return(inputList); //leave it empty } if (inputList.Count == 1) { //product of 1 shape with empty is empty. return(new List <IExplicitShape <GridPoint2> >()); } var shape1 = inputList[0]; var shape2 = inputList[1]; var scale = scaleFactor.GetGridPoint(); var shape = shape1.Product(shape2, scale); var storageRect = new GridRect( shape1.Bounds.Point.Mul(scale) - shape2.Bounds.Size, shape1.Bounds.Size.Mul(scale) + shape2.Bounds.Size * 2); return(new List <IExplicitShape <GridPoint2> > { shape.ToExplicit(storageRect) }); }
public void Transform(GridRect targetRect, float duration = 0) { // moves and resizes square var origin = rect; //Debug.Log($"GraphicEntity1: Transform {origin} -> {targetRect}"); var target = board.GridRectToRectParams(targetRect); // if target _LockProperty(GraphicEntityMutexFlag.Translation); board.LockTiles(targetRect, this); // if (duration.IsZero()) { // animatable.position = targetPosition; //} else { _RunAnimation(AnimationKeyPath.RelPosX, 0, animatable.position.x, duration, target.x); _RunAnimation(AnimationKeyPath.RelPosY, 0, animatable.position.y, duration, target.y); _RunAnimation(AnimationKeyPath.RelScaleX, 0, animatable.localScale.x, duration, target.width); _RunAnimation(AnimationKeyPath.RelScaleY, 0, animatable.localScale.y, duration, target.height); //} _UnlockProperty(GraphicEntityMutexFlag.Translation); board.UnlockTiles(origin); // relock in case we have overlap board.LockTiles(targetRect, this); rect = targetRect; }
public IEnumerable <GraphicEntity2> GraphicEntities(GridRect rect = null) { if (rect == null) { foreach (var g in graphicEntities) { if (g != null) { yield return(g); } } } else { for (int x = 0; x < rect.width; x++) { for (int y = 0; y < rect.height; y++) { Debug.Log($"GraphicEntities: x={x} y={y} {rect}"); var g = graphicEntities[x + rect.min.x, y + rect.min.y]; if (g != null) { yield return(g); } } } } }
public void Init(List <SkillConfig.SkillGrid> skillGrids, float gridSizeFactor, bool autoCalculateScale, float wholeScale) { Clear(); List <GridPos> gridPosList = new List <GridPos>(); foreach (SkillConfig.SkillGrid sg in skillGrids) { SkillGridIndicator sgi = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.SkillGridIndicator].AllocateGameObject <SkillGridIndicator>(RectTransform); sgi.Init(sg, gridSizeFactor); SkillGridIndicators.Add(sgi); gridPosList.Add(sg.GridPos); } GridRect rect = gridPosList.GetBoundingRectFromListGridPos(); if (autoCalculateScale) { int longerSide = Mathf.Max(rect.size.x, rect.size.z); float sizePerGrid = RectTransform.rect.size.x / longerSide * 0.9f; float scale = sizePerGrid / 20f; RectTransform.localScale = Vector3.one * scale; RectTransform.anchoredPosition = new Vector2(-rect.center.x + ((rect.size.x % 2 == 0) ? 0.5f : 0), -rect.center.z + ((rect.size.z % 2 == 0) ? 0.5f : 0)) * 20f * scale; } else { RectTransform.localScale = Vector3.one * wholeScale; RectTransform.anchoredPosition = new Vector2(-rect.center.x, -rect.center.z) * 20f * wholeScale; } }
protected override IExplicitShape <GridPoint2> Generate() { var points = vertices.Select(p => p.GetGridPoint()); var implicitShape = ImplicitShape.ConvexPolygon(points); var bounds = GridRect.Erode(ExplicitShape.GetBounds(points)); return(implicitShape.ToExplicit(bounds)); }
public override IExplicitShape <GridPoint2> Transform(IExplicitShape <GridPoint2> input) { var offset1 = offset.GetGridPoint(); var shape = input.Translate(offset1); var storageRect = GridRect.Translate(input.Bounds, offset1); return(shape.ToExplicit(storageRect)); }
public bool Equals(GridRect p) { if (ReferenceEquals(null, p)) { return(false); } return((MinX == p.MinX) && (MinY == p.MinY) && (MaxX == p.MaxX) && (MaxY == p.MaxY)); }
public PartialGridWPool(NodePool iNodePool, GridRect? iGridRect = null) : base() { if (iGridRect == null) m_gridRect = new GridRect(); else m_gridRect = iGridRect.Value; m_nodePool = iNodePool; }
public void Initialize(GridPos localGP, GridRect space, GridPosR.OrientationFlag adjacentConnection, GridPosR.OrientationFlag diagonalConnection) { LocalGridPosText.text = localGP.ToString(); LocalGridPos = localGP; BoxCollider.size = new Vector3(space.size.x, space.size.z, 1); BoxCollider.center = new Vector3((space.position.x + 0.5f) * space.size.x, (space.position.z - 0.5f) * space.size.z, 0); ImageBorderContainer.anchoredPosition = new Vector2(space.position.x * space.size.x, space.position.z * space.size.z); SetConnection(adjacentConnection, diagonalConnection); }
public bool Equals(GridRect p) { if (ReferenceEquals(null, p)) { return(false); } // Return true if the fields match: return((minX == p.minX) && (minY == p.minY) && (maxX == p.maxX) && (maxY == p.maxY)); }
public override bool Equals(System.Object obj) { // Unlikely to compare incorrect type so removed for performance //if (!(obj.GetType() == typeof(GridRect))) // return false; GridRect p = (GridRect)obj; // Return true if the fields match: return((minX == p.minX) && (minY == p.minY) && (maxX == p.maxX) && (maxY == p.maxY)); }
public void Initialize(GridRect rect, Board1 board) { //Debug.Log($"Creating GraphicEntity: {rect}"); this.board = board; this.rect = rect; board.LockTiles(rect, this); var rectParams = board.GridRectToRectParams(rect); animatable = NoteFactory.CreateRect(rectParams); }
public DynamicGridWPool(NodePool iNodePool) : base() { m_gridRect = new GridRect(); m_gridRect.minX = 0; m_gridRect.minY = 0; m_gridRect.maxX = 0; m_gridRect.maxY = 0; m_notSet = true; m_nodePool = iNodePool; }
public DynamicGridWPool(NodePool iNodePool) : base() { MGridRect = new GridRect(); MGridRect.MinX = 0; MGridRect.MinY = 0; MGridRect.MaxX = 0; MGridRect.MaxY = 0; mNotSet = true; mNodePool = iNodePool; }
public override bool Equals(System.Object obj) { GridRect p = (GridRect)obj; if (ReferenceEquals(null, p)) { return(false); } return((MinX == p.MinX) && (MinY == p.MinY) && (MaxX == p.MaxX) && (MaxY == p.MaxY)); }
/*** COMPARATORS ***/ public bool Contains(GridRect other) { if (other.min.x >= min.x && other.min.y >= min.y && other.max.x <= max.x && other.max.y <= min.y) { return(true); } return(false); }
public DynamicGrid(List <GridPos> iWalkableGridList = null) : base() { m_gridRect = new GridRect(); m_gridRect.MinX = 0; m_gridRect.MinY = 0; m_gridRect.MaxX = 0; m_gridRect.MaxY = 0; m_notSet = true; buildNodes(iWalkableGridList); }
public DynamicGridWPool(NodePool _nodePool) { gridRect = new GridRect { Left = 0, Top = 0, Right = 0, Bottom = 0 }; notSet = true; nodePool = _nodePool; }
public void Constructor_GridPosParam() { var rect = new GridRect(new GridRect(1, 2, 3, 4)); Assert.Multiple(() => { Assert.AreEqual(1, rect.Left); Assert.AreEqual(2, rect.Top); Assert.AreEqual(3, rect.Right); Assert.AreEqual(4, rect.Bottom); }); }
public void Constructor_Default() { var rect = new GridRect(); Assert.Multiple(() => { Assert.AreEqual(0, rect.Left); Assert.AreEqual(0, rect.Top); Assert.AreEqual(0, rect.Right); Assert.AreEqual(0, rect.Bottom); }); }
/*** Display ***/ public RectParams GridRectToRectParams(GridRect grid) { var minPos = bottomLeftAnchor + new Vector2(grid.min.x * (tileLength + gapLength), grid.min.y * (tileLength + gapLength)); var size = new Vector2(grid.width * tileLength + (grid.width - 1) * gapLength, grid.height * tileLength + (grid.height - 1) * gapLength); var center = minPos + size / 2f; return(new RectParams { x = center.x, y = center.y, width = size.x, height = size.y, color = Color.black }); }
GraphicEntity1 AddRectAtPosition(int minX, int minY, int width, int height, Color color) { GridRect emptyRect = new GridRect(minX, minY, width, height); if (emptyRect != null) { var ge = GraphicEntity1.New(emptyRect, board); ge.SetColor(color); ge.SetOpacity(1, Beat(1)); return(ge); } return(null); }
public PartialGridWPool(NodePool iNodePool, GridRect? iGridRect = null) : base() { if (iGridRect == null) { this.m_gridRect = new GridRect(); } else { this.m_gridRect = iGridRect.Value; } this.m_nodePool = iNodePool; }
public PartialGridWPool(NodePool iNodePool, GridRect?iGridRect = null) : base() { if (iGridRect == null) { m_gridRect = new GridRect(); } else { m_gridRect = iGridRect.Value; } m_nodePool = iNodePool; }
public PartialGridWPool(NodePool iNodePool, GridRect iGridRect = null) : base() { if (iGridRect == null) { MGridRect = new GridRect(); } else { MGridRect = iGridRect; } mNodePool = iNodePool; }
public Board1(int width, int height, float tileLength, float gapLength) { this.width = width; this.height = height; this.tileLength = tileLength; this.gapLength = gapLength; this.bottomLeftAnchor = new Vector2( width * tileLength + (width - 1) * gapLength, height * tileLength + (height - 1) * gapLength) / -2f; this.boardRect = new GridRect(0, 0, width, height); graphicEntities = new GraphicEntity1[width, height]; }
static IEnumerator Co_Render() { ClientLevelManager.Instance.CurrentClientLevel.gameObject.SetActive(false); ClientBattleManager.Instance.MechaContainerRoot.gameObject.SetActive(false); Camera camera = CameraManager.Instance.MainCamera; Quaternion oriRot = camera.transform.rotation; Quaternion topDownViewRot = Quaternion.Euler(90, 0, 0); float ori_FieldOfView = camera.fieldOfView; camera.fieldOfView = 6f; CameraFollow.NeedLerp = false; foreach (KeyValuePair <string, MechaComponentConfig> kv in ConfigManager.MechaComponentConfigDict) { string filename = Application.dataPath + "/../../Arts/MechaComponentScreenShots/" + kv.Key + ".png"; MechaComponentInfo mci = new MechaComponentInfo(kv.Value, Quality.Common); GridRect boundingRect = mci.IInventoryItemContentInfo_OriginalOccupiedGridPositions.GetBoundingRectFromListGridPos(); if (boundingRect.size.x != boundingRect.size.z) { camera.transform.rotation = topDownViewRot; } else { camera.transform.rotation = oriRot; } if (boundingRect.size.x == 1 && boundingRect.size.z == 1) { camera.fieldOfView = 6f; } else { camera.fieldOfView = 10f; } yield return(new WaitForSeconds(0.1f)); MechaComponent mc = MechaComponent.BaseInitialize_Editor(mci, null); mc.transform.rotation = Quaternion.Euler(0, mc.ScreenShotAngle, 0); CaptureScreenShot.CaptureTransparentScreenShot(camera, 800, 800, filename); DestroyImmediate(mc.gameObject); yield return(new WaitForSeconds(0.1f)); } camera.transform.rotation = oriRot; camera.fieldOfView = ori_FieldOfView; CameraFollow.NeedLerp = true; ClientLevelManager.Instance.CurrentClientLevel.gameObject.SetActive(true); ClientBattleManager.Instance.MechaContainerRoot.gameObject.SetActive(true); }
public void Set() { var rect = new GridRect(1, 2, 3, 4); rect.Set(5, 6, 7, 8); Assert.Multiple(() => { Assert.AreEqual(5, rect.Left); Assert.AreEqual(6, rect.Top); Assert.AreEqual(7, rect.Right); Assert.AreEqual(8, rect.Bottom); }); }
public void TestSetReleaseAndCheckOccupyFully() { int width = 4; int height = 4; this.gameboard.Initialise(this.CreateFakeConfig(width, height)); GridRect targetRect = new GridRect(0, 0, 4, 4); this.gameboard.SetOccupied(targetRect, true); this.gameboard.SetOccupied(targetRect, false); Assert.IsFalse(this.gameboard.IsOccupied(targetRect)); }
public bool Equals(GridRect p) { if (ReferenceEquals(null, p)) { return false; } // Return true if the fields match: return (minX == p.minX) && (minY == p.minY) && (maxX == p.maxX) && (maxY == p.maxY); }
public void SetGridRect(GridRect iGridRect) { m_gridRect = iGridRect; }
public void SetGridRect(GridRect iGridRect) { this.m_gridRect = iGridRect; }