public ObjectField GetRandomDropObject() { //random object var newDropObject = ObjectField.GetRandomObject(); //rotate random int rotateCount = Random.Range(0, 4); for (int i = 0; i < rotateCount; i++) { newDropObject = newDropObject.RotateRight(); } return(newDropObject); }
public void RotateDropObject() { if (IsDropObjectActive) { if (CanDropObjectRotate()) { var oldPoints = GetDropObjectRelativePoints(); objectField = objectField.RotateRight(); var newPoints = GetDropObjectRelativePoints(); ChangeObjectEvent?.Invoke(oldPoints, newPoints); } } }
public void SetDropObject(ObjectField newObject) { var newObjectPoints = newObject.GetRelativePoints() .Select(el => el + new PointField(spawnPoint - new Vector2Int(0, newObject.Size.y / 2))).ToArray(); var occupiedPoints = newObjectPoints.Where(HasPoint).ToArray(); if (occupiedPoints.Length > 0) { CantCreateObjectEvent?.Invoke(); return; } objectField = newObject; positionObjectField = spawnPoint - new Vector2Int(0, newObject.Size.y / 2); CreateObjectEvent?.Invoke(GetDropObjectRelativePoints()); }
public void SetRandomDropObject() { SetDropObject(ObjectField.GetRandomObject()); }
public void Clear() { objectField = null; playField.Clear(); }