Exemple #1
0
    IEnumerator DoActive(MixedNumberWidget widget)
    {
        var trans = widget.transform;

        var vel   = new Vector2(Random.Range(velocityMin.x, velocityMax.x), Random.Range(velocityMin.y, velocityMax.y));
        var accel = new Vector2(Random.Range(accelMin.x, accelMax.x), Random.Range(accelMin.y, accelMax.y));

        var curTime = 0f;

        while (curTime < delay)
        {
            yield return(null);

            var deltaTime = Time.deltaTime;

            curTime += deltaTime;

            Vector2 curPos = trans.position;
            curPos += vel * deltaTime;

            trans.position = curPos;

            vel += accel * deltaTime;
        }

        mPool.Release(widget.gameObject);
    }
Exemple #2
0
        public static void ReleaseByGroup(string group, Transform entity)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                pc.Release(entity);
            }
        }
        public static void ReleaseFromGroup(string group, PoolDataController pdc)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                pc.Release(pdc);
            }
        }
        public static void ReleaseAuto(PoolDataController poolCtrl)
        {
            PoolController pc = GetPool(poolCtrl.group);

            if (pc != null)
            {
                pc.Release(poolCtrl);
            }
            else
            {
                poolCtrl.gameObject.SetActive(false);
            }
        }
        public static void ReleaseAuto(GameObject entity)
        {
            //NOTE: don't really need to destroy
            PoolDataController pdc = entity.GetComponent <PoolDataController>();

            if (pdc != null)
            {
                PoolController pc = GetPool(pdc.group);
                if (pc != null)
                {
                    pc.Release(pdc);
                }
                else
                {
                    entity.SetActive(false);
                }
            }
            else
            {
                entity.SetActive(false);
            }
        }
Exemple #6
0
    public void Show(bool aShow)
    {
        if (mIsShow != aShow)
        {
            mIsShow = aShow;

            if (mIsShow)
            {
                gameObject.SetActive(true);

                //add widgets
                var blocks = GameData.instance.blocks;
                for (int i = 0; i < blocks.Length; i++)
                {
                    var blockInfo = blocks[i];

                    if (GameMapController.instance.PaletteCount(blockInfo.name) > 0)
                    {
                        AddNewPaletteItem(blockInfo, false);
                    }
                }

                //ensure we are positioned properly
                switch (GameMapController.instance.mode)
                {
                case GameMapController.Mode.Play:
                    toggleButton.transform.localScale = new Vector3(-1f, 1f, 1f);
                    animator.ResetTake(mTakeEditShowId);
                    break;

                case GameMapController.Mode.Edit:
                    toggleButton.transform.localScale = new Vector3(1f, 1f, 1f);
                    animator.ResetTake(mTakeEditHideId);
                    break;
                }

                GameMapController.instance.paletteUpdateCallback       += OnGamePaletteUpdate;
                GameMapController.instance.modeChangeCallback          += OnGameModeChange;
                GameMapController.instance.blockSelectedChangeCallback += OnGameBlockSelectChanged;
            }
            else
            {
                GameMapController.instance.paletteUpdateCallback       -= OnGamePaletteUpdate;
                GameMapController.instance.modeChangeCallback          -= OnGameModeChange;
                GameMapController.instance.blockSelectedChangeCallback -= OnGameBlockSelectChanged;

                //clear up widgets
                for (int i = 0; i < mActiveWidgets.Count; i++)
                {
                    if (mActiveWidgets[i])
                    {
                        mActiveWidgets[i].releaseCallback -= OnWidgetRelease;
                        widgetPool.Release(mActiveWidgets[i].gameObject);
                    }
                }

                mActiveWidgets.Clear();

                gameObject.SetActive(false);
            }
        }
    }