public static GameObject GetFromPlane(int row, int col, PlanePosition.PlaneType type) { Vector2 start = CoordsToVec2(row, col); Collider2D[] hits = Physics2D.OverlapBoxAll(start, Vector2.one * 0.1f, 0.0f); foreach (Collider2D hit in hits) { GameObject obj = hit.gameObject; PlanePosition p = obj.GetComponent <PlanePosition>(); if (p && p.Matches(row, col, type)) { return(obj); } } return(null); }
private void SpawnInPlane(GameObject obj, int row, int col, GameObject[,] plane) { // TODO: this is silly but I don't want to think about it right now PlanePosition.PlaneType t = PlanePosition.PlaneType.Ground; float yOffset = 0.0f; if (plane == actionPlane) { t = PlanePosition.PlaneType.Action; yOffset = 0.5f; } obj.transform.position = new Vector3(col, -row + yOffset, 0); plane[col, row] = obj; PlanePosition pos = obj.GetComponent <PlanePosition>(); if (pos) { pos.Set(row, col, t); } NetworkServer.Spawn(obj); }
public static GameObject GetFromPlane(Vector2Int index, PlanePosition.PlaneType type) { return(GetFromPlane(index.y, index.x, type)); }