Exemple #1
0
    private void Start()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        unityPlayer     = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        currentActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
        vibrator        = currentActivity.Call <AndroidJavaObject>("getSystemService", "vibrator");
#endif
        button   = GetComponent <Button>();
        uibutton = GetComponent <UIbutton>();
        long[] parameters = { delay,                          patternDurationInMilliseconds, sleepDurationInMilliseconds,
                              pattern2DurationInMilliseconds, sleep2DurationInMilliseconds };
        if (button && !uibutton)
        {
            switch (hapticType)
            {
            case HapticType.Normal:
                button.onClick.AddListener(Vibrate);
                break;

            case HapticType.Duration:
                button.onClick.AddListener(delegate { Vibrate(durationInMilliSeconds); });
                break;

            case HapticType.Pattern:
                button.onClick.AddListener(delegate { Vibrate(parameters, repetitions); });
                break;

            default:
#if UNITY_ANDROID && !UNITY_EDITOR
                Handheld.Vibrate();
#endif
                break;
            }
        }
    }
Exemple #2
0
 void Start()
 {
     AnyButton = GameObject.Find("Canvas").GetComponentsInChildren <Button>();
     foreach (Button UIbutton in AnyButton)
     {
         UIbutton.onClick.AddListener(() => Debug.Log("AnyButtonPressed"));
         UIbutton.GetComponent <Image>().alphaHitTestMinimumThreshold = AlphaThreshold;
     }
 }
Exemple #3
0
    private void Awake()
    {
        _controller = gameObject.GetComponent <CharacterController>();
        _mainCamera = Camera.main;
        uiManager   = ServiceLocator.Get <UIManager>();
        agent       = GetComponent <NavMeshAgent>();
        agent.speed = moveSpeed;

        poisonUIbutton     = ServiceLocator.Get <UIManager>()?.poisonImg.GetComponent <UIbutton>();
        intimidateUIbutton = ServiceLocator.Get <UIManager>()?.intimidateImg.GetComponent <UIbutton>();
        ultUIbutton        = ServiceLocator.Get <UIManager>()?.ultImg.GetComponent <UIbutton>();

        animator = GetComponent <Animator>();
    }
Exemple #4
0
 public static void callUpdateAmmoAmount(int index, int ammount)
 {
     if (buttonList[index] is UIbutton)
     {
         UIbutton      tmp  = (UIbutton)buttonList[index];
         buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
         dets.updateAmmoAmmount(ammount);
     }
     else if (buttonList[index] is UITrigger)
     {
         UITrigger     tmp  = (UITrigger)buttonList[index];
         buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
         dets.updateAmmoAmmount(ammount);
     }
 }
Exemple #5
0
 public static int getAmmo(XboxKey key)
 {
     for (int i = 0; i < buttonList.Count; i++)
     {
         if (buttonList[i] is UIbutton)
         {
             UIbutton tmp = (UIbutton)buttonList[i];
             if (tmp.key == key)
             {
                 return(tmp.ammo);
             }
         }
     }
     return(-1);
 }
Exemple #6
0
 public static bool getAble(XboxKey key)
 {
     for (int i = 0; i < buttonList.Count; i++)
     {
         if (buttonList[i] is UIbutton)
         {
             UIbutton tmp = (UIbutton)buttonList[i];
             if (tmp.key == key)
             {
                 return(tmp.isAble);
             }
         }
     }
     Debug.Log("Couldn't find, returning false");
     return(false);
 }
Exemple #7
0
 public static void callReload(XboxKey key)
 {
     Debug.Log("Reloading!");
     for (int i = 0; i < buttonList.Count; i++)
     {
         if (buttonList[i] is UIbutton)
         {
             UIbutton tmp = (UIbutton)buttonList[i];
             if (tmp.key == key)
             {
                 buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
                 dets.reload();
                 break;
             }
         }
     }
 }
Exemple #8
0
 public static int resetAmmo(XboxKey key)
 {
     for (int i = 0; i < buttonList.Count; i++)
     {
         if (buttonList[i] is UIbutton)
         {
             UIbutton tmp = (UIbutton)buttonList[i];
             if (tmp.key == key)
             {
                 tmp.ammo      = tmp.fullAmmo;
                 buttonList[i] = tmp;
                 callUpdateAmmoAmount(i, tmp.fullAmmo);
                 return(tmp.ammo);
             }
         }
     }
     return(-1);
 }