public void OnPointerEnter(PointerEventData eventData)
 {
     if (onHover != null)
     {
         onHover.Invoke(eventData, true);
     }
 }
Exemple #2
0
 public override void OnPointerEnter(PointerEventData eventData)
 {
     if (onHover != null)
     {
         onHover.Invoke(gameObject, true);
     }
 }
Exemple #3
0
 public override void Start()
 {
     if (ThrowEventOnStart)
     {
         OnValueChangedEvent.Invoke(Toggled);
         OnValueChanged?.Invoke(Toggled);
     }
 }
Exemple #4
0
 public override void Start()
 {
     if (ThrowEventOnStart)
     {
         OnValueChangedEvent.Invoke(CurrentValue);
         OnValueChanged?.Invoke(CurrentValue);
     }
 }
Exemple #5
0
    public void ShowBanner(AdPlacementType placementType = AdPlacementType.Banner, BoolDelegate onAdLoaded = null)
    {
        if (isShowingBanner)
        {
            Debug.Log("AdsManager: A banner is already being shown"); return;
        }
        if (DoNotShowAds(placementType))
        {
            onAdLoaded?.Invoke(false);
            return;
        }
        ;
        StartCoroutine(CoShowBanner(placementType, onAdLoaded));

        /*switch (CurrentAdNetwork)
         * {
         *  case CustomMediation.AD_NETWORK.Unity:
         *      UnityAdsManager.ShowBanner(CustomMediation.GetUnityPlacementId(placementType));
         *      break;
         *  case CustomMediation.AD_NETWORK.FAN:
         *      FacebookAudienceNetworkHelper.instance.ShowBanner(CustomMediation.GetFANPlacementId(placementType));
         *      break;
         * }
         * showingBanners.Add(CurrentAdNetwork);*/
    }
Exemple #6
0
 //Condition Failure => return Success
 //Behavior Failure => return Success
 //Behavior Success => return Success
 public static Composite ExecuteReturnAlwaysSuccess(BoolDelegate condition, CreateBehavior behavior)
 {
     return
     new DecoratorContinue(ret => condition.Invoke(null),
         new PrioritySelector(
             behavior.Invoke(null),
             new Zeta.TreeSharp.Action(ret => RunStatus.Success)
         )
     );
 }
Exemple #7
0
 public static Composite ExecuteReturnAlwaysSuccess(BoolDelegate condition, CreateBehavior behavior)
 {
     return
         (new DecoratorContinue(ret => condition.Invoke(null),
                                new PrioritySelector(
                                    behavior.Invoke(null),
                                    new Zeta.TreeSharp.Action(ret => RunStatus.Success)
                                    )
                                ));
 }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objs"></param>
        /// <param name="del"></param>
        /// <returns></returns>
        public static bool FOR_EACH_CK(T[] objs, BoolDelegate del)
        {
            int c = objs.Length;

            for (int i = 0; i < c; ++i)
            {
                if (!del.Invoke(objs[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #9
0
 public void ShowBanner(AdPlacement.Type placementType, BannerTransform bannerTransform, BoolDelegate onAdLoaded = null)
 {
     if (isShowingBanner)
     {
         Debug.Log("AdsManager: A banner is already being shown"); return;
     }
     if (DoNotShowAds(placementType))
     {
         onAdLoaded?.Invoke(false);
         return;
     }
     ;
     StartCoroutine(CoShowBanner(placementType, bannerTransform, onAdLoaded));
 }
        /// <summary>
        /// Method that will wait until the given booldelegate is true or until the max wait time is reached. If max wait time reached it returns false
        /// </summary>
        /// <param name="delegateToWaitFor">
        /// The delegate to wait for.
        /// </param>
        /// <param name="maxWaitTime">
        /// The max wait time.
        /// </param>
        /// <returns>
        /// If max wait time reached it returns false. If delegate is true before reaching that treshold it returns true
        /// </returns>
        public static bool ToBeTrue(BoolDelegate delegateToWaitFor, int maxWaitTime = 10)
        {
            DateTime startTime = DateTime.Now;

            do
            {
                try
                {
                    if (delegateToWaitFor.Invoke())
                    {
                        return(true);
                    }
                }
                catch
                {
                    // catch any exception
                }

                Thread.Sleep(50);
            }while (startTime.AddSeconds(maxWaitTime) > DateTime.Now);

            return(false);
        }
 private void HandlePlayerChangedDirection(bool direction)
 {
     OnPlayerChangeDirection?.Invoke(direction);
 }
Exemple #12
0
 private void OnSelect(bool selected)
 {
     onSelect?.Invoke(gameObject, selected);
 }
Exemple #13
0
 private void OnPress(bool isPressed)
 {
     onPress?.Invoke(gameObject, isPressed);
 }
Exemple #14
0
 private void OnHover(bool isOver)
 {
     onHover?.Invoke(gameObject, isOver);
 }
Exemple #15
0
 //Condition Failure => return Success
 //Behavior Failure => return Failure
 //Behavior Success =>return Success
 public static Composite ExecuteReturnSuccessOrBehaviorResult(BoolDelegate condition, CreateBehavior behavior)
 {
     return new DecoratorContinue(ret => condition.Invoke(null), behavior.Invoke(null));
 }
Exemple #16
0
    IEnumerator CoShowBanner(AdPlacementType placementType = AdPlacementType.Banner, BoolDelegate onAdLoaded = null)
    {
        bool isSuccess = false;
        WaitForSecondsRealtime checkInterval = new WaitForSecondsRealtime(0.3f);

        var adPriority = GetAdsNetworkPriority(placementType);

        for (int i = 0; i < adPriority.Count; i++)
        {
            bool checkAdNetworkDone = false;
            var  adsHelper          = GetAdsNetworkHelper(adPriority[i]);
            if (adsHelper == null)
            {
                continue;
            }
            adsHelper.ShowBanner(placementType,
                                 (success) => { checkAdNetworkDone = true; isSuccess = success; onAdLoaded?.Invoke(success); });
            while (!checkAdNetworkDone)
            {
                yield return(checkInterval);
            }
            if (isSuccess)
            {
                //showingBanners.Add(CurrentAdNetwork);
                isShowingBanner = true;
                break;
            }
        }
    }
    protected override void ComputeVelocity()
    {
        if (isPaused)
        {
            return;
        }
        Vector2 move = Vector2.zero;

        move.x = Input.GetAxis("Horizontal");

        if (Mathf.Abs(move.x) > 0.025f)
        {
            bool flipSprite = (spriteRenderer.flipX ? (move.x > 0.01f) : (move.x < 0.01f));
            if (flipSprite)
            {
                OnChangeDirection?.Invoke(!spriteRenderer.flipX);
                spriteRenderer.flipX = !spriteRenderer.flipX;
                bulletOrigin.transform.localPosition = new Vector3(Mathf.Abs(bulletOrigin.transform.localPosition.x) * (spriteRenderer.flipX ? -1 : 1), bulletOrigin.transform.localPosition.y, bulletOrigin.transform.localPosition.z);
            }
        }

        bool isWalking = Mathf.Abs(move.x) > 0f;

        animator.SetBool("IsWalking", isWalking);

        if (!grounded)
        {
            float positionY = transform.position.y;
            // TODO: second part of IF is hacky way to stop ground bounce from being read as !grounded + falling
            // only really fixes if the map stays flat
            if (lastPosition.y != positionY && positionY > -0.80f)
            {
                bool isJumping = positionY > lastPosition.y;
                animator.SetBool("IsFalling", !isJumping);
                animator.SetBool("IsJumping", isJumping);
            }
        }
        else
        {
            animator.SetBool("IsFalling", false);
            animator.SetBool("IsJumping", false);
        }


        if (lastWalkingStatus != isWalking)
        {
            if (isWalking)
            {
                OnStartRunning?.Invoke();
            }
            else
            {
                OnStopRunning?.Invoke();
            }
        }

        if (grounded && !lastGrounded)
        {
            OnLanding?.Invoke();
        }

        float recoil = isFiring ? maxSpeed / 2f : maxSpeed;

        targetVelocity    = move * recoil;
        lastGrounded      = grounded;
        lastPosition      = transform.position;
        lastWalkingStatus = isWalking;
    }
Exemple #18
0
 //Condition Failure => return Success
 //Behavior Failure => return Failure
 //Behavior Success =>return Success
 public static Composite ExecuteReturnSuccessOrBehaviorResult(BoolDelegate condition, CreateBehavior behavior)
 {
     return(new DecoratorContinue(ret => condition.Invoke(null), behavior.Invoke(null)));
 }