Esempio n. 1
0
 public void ReturnToGame()
 {
     UIAudioPlayer.PlayPositive();
     GameSystem.Instance.StartTimer();
     gameObject.SetActive(false);
     Controller.Instance.DisplayCursor(false);
 }
Esempio n. 2
0
    private void Close()
    {
        base.gameObject.SetActive(false);
        this.SetCanvasActive(true);
        UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Click);
        if (this.m_ChangeEffect)
        {
            PostProcessManager.Get().SetWeight(PostProcessManager.Effect.InGameMenu, 0f);
        }
        MenuScreen menuScreen = this.m_Screen as MenuScreen;

        if (menuScreen != null && !menuScreen.m_IsIngame)
        {
            Time.timeScale = 1f;
        }
        EventSystem current = EventSystem.current;

        if (current != null)
        {
            current.SetSelectedGameObject(null);
        }
        InputsManager.Get().UnregisterReceiver(this);
        IYesNoDialogOwner screen = this.m_Screen;

        if (screen == null)
        {
            return;
        }
        screen.OnCloseDialog();
    }
Esempio n. 3
0
 public override void OnPointerClick(PointerEventData eventData)
 {
     base.OnPointerClick(eventData);
     if (this.CanPlaySound() && this.m_ClickClip)
     {
         UIAudioPlayer.Play(this.m_ClickClip);
     }
 }
Esempio n. 4
0
 public override void OnDrag(PointerEventData data)
 {
     base.OnDrag(data);
     if (this.m_DragClip && UISliderEx.s_LastDragSound < Time.realtimeSinceStartup - 0.1f)
     {
         UIAudioPlayer.Play(this.m_DragClip);
         UISliderEx.s_LastDragSound = Time.realtimeSinceStartup;
     }
 }
Esempio n. 5
0
    public void OpenEpisode()
    {
        if (LevelSelectionUI.Instance.IsEmpty())
        {
            return;
        }

        UIAudioPlayer.PlayPositive();
        gameObject.SetActive(false);
        LevelSelectionUI.Instance.DisplayEpisode();
    }
Esempio n. 6
0
    public void OkButtonClicked()
    {
        UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Click);
        IYesNoDialogOwner screen = this.m_Screen;

        if (screen != null)
        {
            screen.OnOkFromDialog();
        }
        this.Close();
    }
Esempio n. 7
0
    public static void Play(AudioClip clip)
    {
        UIAudioPlayer instance = UIAudioPlayer.Instance;

        if (instance != null && instance.CanPlaySound())
        {
            AudioSource source = UIAudioPlayer.Instance.GetSource();
            if (source == null)
            {
                return;
            }
            source.PlayOneShot(clip);
        }
    }
Esempio n. 8
0
 protected override void DoStateTransition(Selectable.SelectionState state, bool instant)
 {
     base.DoStateTransition(state, instant);
     if (state == Selectable.SelectionState.Highlighted)
     {
         UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Focus);
         return;
     }
     if (state == Selectable.SelectionState.Pressed)
     {
         UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Click);
         this.Select();
     }
 }
Esempio n. 9
0
 protected override void DoStateTransition(Selectable.SelectionState state, bool instant)
 {
     base.DoStateTransition(state, instant);
     if (state == Selectable.SelectionState.Highlighted)
     {
         this.m_HL.color = this.m_HL_HighlightColor;
         UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Focus);
         return;
     }
     if (state == Selectable.SelectionState.Pressed)
     {
         UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Click);
         return;
     }
     this.m_HL.color = this.m_HL_DefaultColor;
 }
    public void Init()
    {
        for (int i = 0; i < GameDatabase.Instance.episodes.Length; ++i)
        {
            var ep = GameDatabase.Instance.episodes[i];

            Button b = Instantiate(ButtonPrefab);
            Text   t = b.GetComponentInChildren <Text>();

            t.text = $"Episode {i + 1}";

            var i1 = i;
            b.onClick.AddListener(() => { UIAudioPlayer.PlayPositive(); OpenEpisode(i1); });
            b.transform.SetParent(ButtonListPlace);

            m_EpisodeButtons.Add(b);

            m_LevelButtons.Add(new List <Button>());

            for (int j = 0; j < ep.scenes.Length; ++j)
            {
                Button levelB = Instantiate(ButtonPrefab);
                t = levelB.GetComponentInChildren <Text>();

                var j1 = j;
                levelB.onClick.AddListener(() =>
                {
#if UNITY_EDITOR
                    EditorSceneManager.LoadSceneInPlayMode(ep.scenes[j1], new LoadSceneParameters());
#else
                    SceneManager.LoadScene(ep.scenes[j1]);
#endif
                    Time.timeScale = 1;
                });

                t.text = $"Level {j + 1}";

                levelB.transform.SetParent(ButtonListPlace);
                m_LevelButtons[i].Add(levelB);
            }
        }
    }
Esempio n. 11
0
    public static void Play(UIAudioPlayer.UISoundType type)
    {
        if (type >= UIAudioPlayer.UISoundType._Count)
        {
            return;
        }
        UIAudioPlayer instance = UIAudioPlayer.Instance;

        if (instance != null && instance.CanPlaySound())
        {
            AudioClip audioClip = UIAudioPlayer.Instance.m_StandardSounds[(int)type];
            if (audioClip != null)
            {
                AudioSource source = UIAudioPlayer.Instance.GetSource();
                if (source == null)
                {
                    return;
                }
                source.PlayOneShot(audioClip);
            }
        }
    }
Esempio n. 12
0
 public void NextLevel()
 {
     UIAudioPlayer.PlayPositive();
     GameSystem.Instance.NextLevel();
 }
Esempio n. 13
0
 public void PlaySound()
 {
     UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Click);
 }
 void BackToEpisode()
 {
     DisplayEpisode();
     UIAudioPlayer.PlayNegative();
 }
 void BackToPause()
 {
     UIAudioPlayer.PlayNegative();
     gameObject.SetActive(false);
     PauseMenu.Instance.Display();
 }
Esempio n. 16
0
 void Awake()
 {
     m_Source = GetComponent <AudioSource>();
     Instance = this;
 }
Esempio n. 17
0
 public void OnButtonEnter()
 {
     CursorManager.Get().SetCursor(CursorManager.TYPE.MouseOver);
     UIAudioPlayer.Play(UIAudioPlayer.UISoundType.Focus);
 }
Esempio n. 18
0
 public void OpenEpisode()
 {
     UIAudioPlayer.PlayPositive();
     gameObject.SetActive(false);
     LevelSelectionUI.Instance.DisplayEpisode();
 }
Esempio n. 19
0
    // --------------------------------
    void Start()
    {
        _uiCamera  = transform.root.GetComponentInChildren <Camera>();
        _inventory = GameManager.Player.GetComponent <InventoryManager>();

        // wheelcenter
        Vector3 wheelCenter = _uiCamera.ViewportToWorldPoint(new Vector3(1.0f, 1.0f, 7.0f));

        _weaponWheel = (GameObject)Instantiate(WeaponWheelPrefab, wheelCenter, Quaternion.identity);
        _weaponWheel.transform.parent = transform;
        _weaponWheel.GetComponent <Renderer>().enabled = true;


        _itemWheel = (GameObject)Instantiate(ItemWheelPrefab, wheelCenter, Quaternion.identity);
        _itemWheel.transform.parent = transform;
        _itemWheel.GetComponent <Renderer>().enabled = false;

        _craftingBackdrop = (GameObject)Instantiate(CraftingBackdropPrefab, Vector3.zero, Quaternion.identity);
        _craftingBackdrop.transform.parent = transform;
        _craftingBackdrop.GetComponent <Renderer>().enabled = false;

        // position crafting button in screen coords.
        CraftButtonPos  = _uiCamera.ViewportToWorldPoint(CraftButtonPos);
        _craftingButton = (GameObject)Instantiate(CraftButtonPrefab, CraftButtonPos, Quaternion.identity);
        _craftingButton.transform.parent = transform;
        _craftingButton.GetComponent <Renderer>().enabled = false;


        _currentItem = 0;

        _state       = CraftingMenuState.CraftingMenu_Closed;
        _timeInState = 0.0f;


        // *** position all item quads and their counts at proper rotations for texture replacement ***
        _itemQuads      = new GameObject[5];
        _itemCountQuads = new GameObject[5];

        Vector3 quadPos = wheelCenter + Vector3.left * ItemWheelRadius;

        _itemQuads [0] = (GameObject)Instantiate(ItemQuadPrefab, quadPos, Quaternion.identity);
        _itemQuads [0].transform.parent = _weaponWheel.transform;
        quadPos             = wheelCenter + Vector3.left * ItemCountRadius;
        _itemCountQuads [0] = (GameObject)Instantiate(ItemCountQuadPrefab, quadPos, Quaternion.identity);
        _itemCountQuads [0].transform.parent = _weaponWheel.transform;

        // pi/8
        quadPos        = wheelCenter + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 8.0f, 0.0f) * ItemWheelRadius;
        _itemQuads [1] = (GameObject)Instantiate(ItemQuadPrefab, quadPos, Quaternion.identity);
        _itemQuads [1].transform.parent = _weaponWheel.transform;
        quadPos             = wheelCenter + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 8.0f, 0.0f) * ItemCountRadius;
        _itemCountQuads [1] = (GameObject)Instantiate(ItemCountQuadPrefab, quadPos, Quaternion.identity);
        _itemCountQuads [1].transform.parent = _weaponWheel.transform;

        // pi/4
        quadPos        = wheelCenter + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 4.0f, 0.0f) * ItemWheelRadius;
        _itemQuads [2] = (GameObject)Instantiate(ItemQuadPrefab, quadPos, Quaternion.identity);
        _itemQuads [2].transform.parent = _weaponWheel.transform;
        quadPos             = wheelCenter + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 4.0f, 0.0f) * ItemCountRadius;
        _itemCountQuads [2] = (GameObject)Instantiate(ItemCountQuadPrefab, quadPos, Quaternion.identity);
        _itemCountQuads [2].transform.parent = _weaponWheel.transform;

        // 3 pi / 8
        quadPos        = wheelCenter + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI * 3.0f / 8.0f, 0.0f) * ItemWheelRadius;
        _itemQuads [3] = (GameObject)Instantiate(ItemQuadPrefab, quadPos, Quaternion.identity);
        _itemQuads [3].transform.parent = _weaponWheel.transform;
        quadPos             = wheelCenter + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI * 3.0f / 8.0f, 0.0f) * ItemCountRadius;
        _itemCountQuads [3] = (GameObject)Instantiate(ItemCountQuadPrefab, quadPos, Quaternion.identity);
        _itemCountQuads [3].transform.parent = _weaponWheel.transform;


        // pi / 2
        quadPos        = wheelCenter + Vector3.down * ItemWheelRadius;
        _itemQuads [4] = (GameObject)Instantiate(ItemQuadPrefab, quadPos, Quaternion.identity);
        _itemQuads [4].transform.parent = _weaponWheel.transform;
        quadPos             = wheelCenter + Vector3.down * ItemCountRadius;
        _itemCountQuads [4] = (GameObject)Instantiate(ItemCountQuadPrefab, quadPos, Quaternion.identity);
        _itemCountQuads [4].transform.parent = _weaponWheel.transform;



        _lastClickedQuad = null;
        _draggingQuad    = null;

        // *** translate GUI positionings into screen coords ***
        ItemDescriptionBounds = new Rect(ItemDescriptionBounds.x * Screen.width,
                                         ItemDescriptionBounds.y * Screen.height,
                                         ItemDescriptionBounds.width * Screen.width,
                                         ItemDescriptionBounds.height * Screen.height);

        // crafting points get translated into screen res coords for checking distance from mouse pointer
        for (int i = 0; i <= CraftingPoints.Length - 1; i++)
        {
            CraftingPoints [i] = new Vector3(CraftingPoints [i].x * Screen.width,
                                             CraftingPoints [i].y * Screen.height,
                                             7.0f);
        }

        _craftingSlots = new GameObject[CraftingPoints.Length];
        for (int i = 0; i <= _craftingSlots.Length - 1; i++)
        {
            _craftingSlots [i] = null;
        }

        CraftingDropDistance *= Screen.width;

        //instantiate sound
        _sound = gameObject.GetComponentInChildren <UIAudioPlayer>();
    }