public static void CreateObject()
    {
        switch (Action)
        {
        case ActionType.Dot:
            if (SelectedObjects.Count == 2)
            {
                CreateWithShapeRotation(CreateDot);
            }

            ResetAction();

            break;

        case ActionType.Line:
            if (SelectedObjects.Count == 2)
            {
                CreateWithShapeRotation(CreateLine);
            }

            ResetAction();

            break;

        case ActionType.ParallelLine:
            if (SelectedObjects.Count == 2)
            {
                CreateWithShapeRotation(CreateParallelLine);
            }

            ResetAction();

            break;

        case ActionType.CrossSection:
            if (SelectedObjects.Count > 2)
            {
                CreateWithShapeRotation(t => CreateCrossSection());

                ResetAction();
            }

            GameOkButton.Enable(false);

            break;

        case ActionType.Check:
            bool result = Check();

            ResetAction();
            if (result)
            {
                SendLevelCompleted();
            }

            break;
        }
    }
Beispiel #2
0
    private void Start()
    {
        if (CheckButtonsNotAssigned())
        {
            Debug.LogError("You must set buttons in the inspector");
            enabled = false;
            return;
        }

        _dotButton.onClick.AddListener(() =>
        {
            HandleButtonClick(_dotButton, ActionType.Dot);
        });

        _lineButton.onClick.AddListener(() =>
        {
            HandleButtonClick(_lineButton, ActionType.Line);
        });

        _parallelLineButton.onClick.AddListener(() =>
        {
            HandleButtonClick(_parallelLineButton, ActionType.ParallelLine);
        });

        _rotateButton.onClick.AddListener(() =>
        {
            CreateNewConstructionHelper.ResetAction();

            var shape = GameObject.Find($"{Game.CurrentLevelData.Type.ToString()}Core");

            shape.transform.localRotation = Quaternion.identity;
            shape.transform.Rotate(-8, -12, 0.5f);
        });

        _crossSectionButton.onClick.AddListener(() =>
        {
            HandleButtonClick(_crossSectionButton, ActionType.CrossSection);

            GameOkButton.Enable(CreateNewConstructionHelper.Action == ActionType.CrossSection);
        });

        _checkButton.onClick.AddListener(() =>
        {
            CreateNewConstructionHelper.ResetAction();

            CreateNewConstructionHelper.Action = ActionType.Check;
            CreateNewConstructionHelper.CreateObject();
        });

        _createButton.onClick.AddListener(CreateNewConstructionHelper.CreateObject);
    }