예제 #1
0
        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);
        }
예제 #2
0
        public void RotateDropObject()
        {
            if (IsDropObjectActive)
            {
                if (CanDropObjectRotate())
                {
                    var oldPoints = GetDropObjectRelativePoints();

                    objectField = objectField.RotateRight();

                    var newPoints = GetDropObjectRelativePoints();

                    ChangeObjectEvent?.Invoke(oldPoints, newPoints);
                }
            }
        }
예제 #3
0
        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());
        }
예제 #4
0
 public void SetRandomDropObject()
 {
     SetDropObject(ObjectField.GetRandomObject());
 }
예제 #5
0
 public void Clear()
 {
     objectField = null;
     playField.Clear();
 }