public void OnClickEnd(
        ClickSource clickSource)
    {
        VelociGripper velociGripper = clickSource.GetComponent <VelociGripper>();

        velociGripper.ReleaseObject();
    }
    public void OnClickBegin(
        ClickSource clickSource)
    {
        VelociGripper velociGripper = clickSource.GetComponent <VelociGripper>();

        velociGripper.GripObject(this.gameObject);
    }
Esempio n. 3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (enableClickSound == true)
     {
         ClickSource.PlayOneShot(clickSound);
     }
 }
Esempio n. 4
0
    public void EnterClickScope(
        ClickSource clickSource)
    {
        // If a second click source (such as the other hand) is beginning a click,
        // force ourselves to cleanly leave the prior click to avoid any fighting, such
        // as being grabbed by two controllers at once.
        if (ActiveClickSource != null)
        {
            if (DebugEnabled)
            {
                Debug.LogFormat("A second click source is incoming while we're already clicked. Forcing an early termination on the first click-source.");
            }

            ActiveClickSource.TryTerminateClick();

            if (ActiveClickSource != null)
            {
                throw new System.InvalidOperationException("Failed to leave a prior click before entering a new click. This might happen if click-respondants pull shenanigans.");
            }
        }

        if (DebugEnabled)
        {
            Debug.LogFormat("Entering a click-scope under <b>{0}</b>.", clickSource);
        }

        ActiveClickSource = clickSource;

        gameObject.SendMessage(
            "OnClickBegin",
            clickSource,
            SendMessageOptions.DontRequireReceiver);
    }
    public void OnClickBegin(
        ClickSource clickSource)
    {
        OnInstantClick(clickSource);

        // Enforce the instant-action behavior by immediately freeing ourselves.
        clickSource.TryTerminateClick();
    }
    private void LoadGameDialogWindow(int windowId)
    {
        var scrollPosition = Vector2.zero;

        if (!IsSaveGameDirExist())
        {
            return;
        }

        var saves = GetAllSaveFiles();

        if (saves.Length == 0)
        {
            return;
        }

        GUILayout.BeginArea(new Rect(10, 25, 175, 150));
        GUILayout.BeginScrollView(scrollPosition);

        foreach (var save in saves)
        {
            GUILayout.BeginHorizontal("box", GUILayout.Height(25));
            if (GUILayout.Button(Path.GetFileNameWithoutExtension(save)))
            {
                ClickSource.PlayOneShot(clickSound);
                Debug.Log("Load Game Button pressed");
                Debug.Log("Save File : " + Path.GetFileName(save));

                var saveData = ReadFile(Path.GetFileNameWithoutExtension(save));

                if (string.IsNullOrEmpty(saveData))
                {
                    return;
                }

                SaveGameData.Data = GameData.Deserialize(saveData);

                SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            }

            GUILayout.EndHorizontal();
        }

        GUILayout.EndScrollView();
        GUILayout.EndArea();

        if (GUI.Button(new Rect(5, 220,
                                _pauseDialogWindowRect.width - 10, 35),
                       "НАЗАД"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Back to PauseMenu Button pressed");
            showLoadGameDialog = false;
            showPauseDialog    = true;
        }
    }
Esempio n. 7
0
    public void SaveSettings()
    {
        ClickSource.PlayOneShot(clickSound);

        if (SettingsHelper.CheckSettings(settings))
        {
            SettingsHelper.WriteSettingsToFile(settings);
        }

        SettingsData.Settings = settings;

        // ReSharper disable StringLiteralTypo
        ToastManager.Show("Настройки сохранены", 1f);
    }
    private void SaveGameDialogWindow(int windowId)
    {
        stringToEdit = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd h-mm");

        var guiStyle = GUI.skin.box;

        guiStyle.alignment = TextAnchor.MiddleCenter;

        GUI.Label(
            new Rect(10, 20, _pauseDialogWindowRect.width - 10, 30),
            "Название файла:",
            new GUIStyle
        {
            //richText = enabled,
            alignment = TextAnchor.MiddleCenter,
            fontSize  = Screen.height * 2 / 100,
            normal    = { textColor = new Color32(235, 235, 235, 255) }
        });


        stringToEdit = GUI.TextField(
            new Rect(5, 60, _pauseDialogWindowRect.width - 10, 75),
            stringToEdit, 25, guiStyle);

        if (GUI.Button(
                new Rect(5, 180, _pauseDialogWindowRect.width - 10, 35),
                "СОХРАНИТЬ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Savegame Button pressed");

            MenuEvents.SaveGame(stringToEdit);

            showSaveGameDialog = false;
            showPauseDialog    = true;
        }
        else if (GUI.Button(new Rect(5, 220, _pauseDialogWindowRect.width - 10, 35), "НАЗАД"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Back to PauseMenu Button pressed");
            showSaveGameDialog = false;
            showPauseDialog    = true;
        }
    }
    public void OnClickBegin(
        ClickSource clickSource)
    {
        var progressCondition = GetComponent <ProgressCondition>();

        bool clickIsAccepted = (
            (progressCondition == null) ||
            progressCondition.ConditionIsTrue);

        if (clickIsAccepted &&
            (SpawneePrefab != null))
        {
            Vector3 spawneePosition =
                Vector3.Lerp(
                    transform.position,
                    clickSource.transform.position,
                    0.5f);

            Quaternion spawneeOrientation = transform.rotation;

            GameObject spawnee = GameObject.Instantiate(SpawneePrefab);

            spawnee.transform.parent = SpawneeParent;

            spawnee.transform.position   = spawneePosition;
            spawnee.transform.rotation   = spawneeOrientation;
            spawnee.transform.localScale = SpawneePrefab.transform.localScale;

            if (ForwardClickToSpawnee)
            {
                var spawneeClickTarget = spawnee.GetComponent <ClickTarget>();

                if (spawneeClickTarget)
                {
                    clickSource.ForceClickOnTarget(spawneeClickTarget);
                }
            }
        }
    }
Esempio n. 10
0
    public void OnClickBegin(
        ClickSource clickSource)
    {
        var progressStorage = ProgressStorage.LocalPlayerProgressStorage;

        float newProgressValue;

        switch (ChangeType)
        {
        case ProgressChangeType.Assign:
            newProgressValue = ProgressValue;
            break;

        case ProgressChangeType.Increment:
            newProgressValue =
                (progressStorage.GetProgressValueAsFloat(ProgressName) + ProgressValue);
            break;

        default:
            throw new System.ComponentModel.InvalidEnumArgumentException(ChangeType.ToString());
        }

        progressStorage.SetProgressValueAsFloat(ProgressName, newProgressValue);
    }
Esempio n. 11
0
    public void LeaveClickScope(
        ClickSource clickSource)
    {
        if (clickSource != ActiveClickSource)
        {
            throw new System.InvalidOperationException(
                      string.Format(
                          "Being asked to leave a click that we were not engaged in. Prior click-source was <b>{0}</b>, and new click-source is <b>{1}</b>",
                          ((ActiveClickSource != null) ? ActiveClickSource.name : "NULL"),
                          clickSource.name));
        }

        if (DebugEnabled)
        {
            Debug.LogFormat("Leaving a click-scope under <b>{0}</b>.", clickSource);
        }

        gameObject.SendMessage(
            "OnClickEnd",
            clickSource,
            SendMessageOptions.DontRequireReceiver);

        ActiveClickSource = null;
    }
Esempio n. 12
0
    private void OptionsDialogWindow(int windowId)
    {
        GUI.Label(
            new Rect(10, 20, _pauseDialogWindowRect.width - 10, 30),
            "Громкость:",
            new GUIStyle
        {
            //richText = enabled,
            alignment = TextAnchor.MiddleCenter,
            fontSize  = Screen.height * 2 / 100,
            normal    = { textColor = new Color32(235, 235, 235, 255) }
        });
        GUI.Label(
            new Rect(10, 35, _pauseDialogWindowRect.width - 10, 30),
            AudioSliderValue.ToString(CultureInfo.CurrentCulture),
            new GUIStyle
        {
            //richText = enabled,
            alignment = TextAnchor.MiddleCenter,
            fontSize  = Screen.height * 2 / 100,
            normal    = { textColor = new Color32(235, 235, 235, 255) }
        });
        AudioSliderValue = GUI.HorizontalSlider(new Rect(15, 60, 170, 40),
                                                AudioSliderValue, 0.0F, 1.0F);
        GUI.Label(
            new Rect(10, 85, _pauseDialogWindowRect.width - 10, 30),
            "Сложность ИИ:",
            new GUIStyle
        {
            //richText = enabled,
            alignment = TextAnchor.MiddleCenter,
            fontSize  = Screen.height * 2 / 100,
            normal    = { textColor = new Color32(235, 235, 235, 255) }
        });
        if (GUI.Button(new Rect(15, 115, 40, 40), "<"))
        {
            if (Difficulty != Engine.Difficulty.Easy)
            {
                Difficulty--;
            }
        }
        GUI.Label(
            new Rect(10, 120, _pauseDialogWindowRect.width - 10, 30),
            Difficulty.ToString(),
            new GUIStyle
        {
            //richText = enabled,
            alignment = TextAnchor.MiddleCenter,
            fontSize  = Screen.height * 2 / 100,
            normal    = { textColor = new Color32(235, 235, 235, 255) }
        });
        if (GUI.Button(new Rect(145, 115, 40, 40), ">"))
        {
            if (Difficulty != Engine.Difficulty.VeryHard)
            {
                Difficulty++;
            }
        }

        if (GUI.Button(new Rect(5, 180, _pauseDialogWindowRect.width - 10, 35),
                       "ПРИМЕНИТЬ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Apply Button pressed");
            AudioListener.volume = AudioSliderValue;
            if (SettingsData.Settings != null)
            {
                SettingsData.Settings.Difficulty = Difficulty;
            }
            StaticEvents.SettingsChangeEvent(Difficulty);
        }
        else if (GUI.Button(new Rect(5, 220, _pauseDialogWindowRect.width - 10, 35),
                            "НАЗАД"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Back to PauseMenu Button pressed");
            showOptionDialog = false;
            showPauseDialog  = true;
        }
    }
Esempio n. 13
0
 public override void OnInstantClick(
     ClickSource clickSource)
 {
     Debug.LogWarning("TODO: KABOOM!");
 }
Esempio n. 14
0
 public override void OnInstantClick(
     ClickSource clickSource)
 {
     Debug.LogWarning("TODO: Reset the spawner.");
 }
 public abstract void OnInstantClick(ClickSource clickSource);
Esempio n. 16
0
 /// <summary>
 /// Initialize a new instance of the MenuClickEventArgs class.
 /// </summary>
 public MenuClickEventArgs(ClickSource source)
 {
     // Remember source
     _source = source;
 }
Esempio n. 17
0
    private void PauseDialogWindow(int windowId)
    {
        if (GUI.Button(
                new Rect(5, 20, _pauseDialogWindowRect.width - 10, 35),
                "ГЛАВНОЕ МЕНЮ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("MainMenu LoadScene Button pressed");
            SceneManager.LoadScene("MainMenuScene");
        }

        if (GUI.Button(
                new Rect(5, 60, _pauseDialogWindowRect.width - 10, 35),
                "ЗАНОВО"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Restart Game Button pressed");

            menuEnabled = !menuEnabled;

            MenuEvents.RestartGame();
        }

        if (GUI.Button(
                new Rect(5, 100, _pauseDialogWindowRect.width - 10, 35),
                "СОХРАНИТЬ ИГРУ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Save Game Button pressed");
            showPauseDialog    = false;
            showSaveGameDialog = true;
        }

        if (GUI.Button(
                new Rect(5, 140, _pauseDialogWindowRect.width - 10, 35),
                "ЗАГРУЗИТЬ ИГРУ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Load Game Button pressed");
            showPauseDialog    = false;
            showLoadGameDialog = true;
        }

        if (GUI.Button(
                new Rect(5, 180, _pauseDialogWindowRect.width - 10, 35),
                "ОПЦИИ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Option Button pressed");
            showOptionDialog = true;
            showPauseDialog  = false;
        }
        else if (GUI.Button(
                     new Rect(5, 220, _pauseDialogWindowRect.width - 10, 35),
                     "ВЫЙТИ ИЗ ИГРЫ"))
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Quit Game Button pressed");
            Application.Quit();
        }
    }