Ejemplo n.º 1
0
        /// <summary>
        /// Call this to start a new Generic Reward Animation
        /// </summary>
        /// <param name="_animationElement"></param>
        /// <param name="_quantity"></param>
        /// <param name="_origin"></param>
        /// <param name="_destination"></param>
        /// <param name="_delay"></param>
        public Guid NewGenericRewardAnimation(Item _item, ItemAnimationData _itemAnimationScriptable, int _quantity, Vector3 _origin, Vector3 _destination, float _delay = 0)
        {
            if (_quantity <= 0)
            {
                return(Guid.Empty);
            }

            ItemAnimation itemAnimationData = new ItemAnimation()
            {
                guid          = Guid.NewGuid(),
                itemId        = _item.id,
                sprite        = _item.icon,
                color         = _item.color,
                animationData = _itemAnimationScriptable,
                quantity      = _quantity,
                destination   = _destination,
                compt         = _quantity
            };

            List <ItemParticlesAnimation> items = new List <ItemParticlesAnimation>();

            ItemParticlesAnimation particle;

            for (int i = 0; i < _quantity; i++)
            {
                particle = GetUnusedOrCreate();
                particle.transform.position   = _origin;
                particle.transform.localScale = Vector3.zero;
                particle.itemAnimationData    = itemAnimationData;
                particle.SetUp();
                particle.gameObject.SetActive(true);
                items.Add(particle);
            }

            StartCoroutine(StartAppearing(itemAnimationData, items));

            return(itemAnimationData.guid);
        }
Ejemplo n.º 2
0
        public Guid NewGenericRewardAnimation(Item _item, ItemAnimationData _itemAnimationScriptable, int _quantity, Transform _origin, Vector3 _destination, float _delay = 0)
        {
            Vector3 originPositon = GetAnimationSourceUIPosition(_origin);

            return(NewGenericRewardAnimation(_item, _itemAnimationScriptable, _quantity, originPositon, _destination, _delay));
        }
Ejemplo n.º 3
0
        private Vector3 DispersionAroundCircle(Vector3 _pointToPlace, Vector3 _lastPosition, int _numbers, ItemAnimationData _animation)
        {
            float   radAngle = (360f / _numbers) + Random.Range(0f, (_animation.dispersion * 360f)) * Mathf.Deg2Rad;
            Vector3 rotated  = new Vector3(Mathf.Cos(radAngle), Mathf.Sin(radAngle), 0f);
            Vector3 offset   = rotated * Random.Range(_animation.disc.radiusMin * _animation.disc.radiusFactor, _animation.disc.radiusMax * _animation.disc.radiusFactor);

            return(_pointToPlace + offset);
        }
        public override void OnInspectorGUI()
        {
            if (myTarget == null)
            {
                myTarget = (ItemAnimationData)target;
            }

            if (isLoaded == false)
            {
                isLoaded = true;
                string[] _temp = Enum.GetNames(typeof(Ease));

                curveTypes    = new string[_temp.Length + 1];
                curveTypes[0] = "Custom";
                _temp.CopyTo(curveTypes, 1);

                uiReverse = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/VoodooPackages/GenericItemAnimation/Sprites/reverse.png",
                                                                     typeof(Texture2D));
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField("Appearing", EditorStyles.boldLabel);

            GUILayout.Space(10);
            EditorGUILayout.LabelField("Radius");
            myTarget.disc.radiusMin    = EditorGUILayout.FloatField("  min", myTarget.disc.radiusMin);
            myTarget.disc.radiusMax    = EditorGUILayout.FloatField("  max", myTarget.disc.radiusMax);
            myTarget.disc.radiusFactor = EditorGUILayout.FloatField("  factor", myTarget.disc.radiusFactor);


            GUILayout.Space(10);
            myTarget.dispersion = EditorGUILayout.Slider("Dispersion", myTarget.dispersion, 0f, 1f);

            GUILayout.Space(10);
            myTarget.delayAppearing = EditorGUILayout.FloatField("Delay Appearing", myTarget.delayAppearing);


            GUILayout.Space(10);
            EditorGUILayout.LabelField("Speed");

            ShowCurveSelector(myTarget.speedAppearing);

            GUILayout.Space(10);
            EditorGUILayout.LabelField("Scale");

            ShowCurveSelector(myTarget.scaleAppearing);

            myTarget.startScaleAppearing = EditorGUILayout.Vector3Field("Start Scale", myTarget.startScaleAppearing);
            myTarget.endScaleAppearing   = EditorGUILayout.Vector3Field("End Scale", myTarget.endScaleAppearing);


            GUILayout.Space(10);


            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);
            GUILayout.Space(20);
            myTarget.delayAfterAppear = EditorGUILayout.FloatField("Delay between phases", myTarget.delayAfterAppear);
            GUILayout.Space(20);
            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            GUILayout.Space(10);
            EditorGUILayout.LabelField("Grouping", EditorStyles.boldLabel);

            myTarget.delayGrouping = EditorGUILayout.FloatField("Delay Grouping", myTarget.delayGrouping);

            EditorGUI.BeginChangeCheck();
            myTarget.allTogether = EditorGUILayout.Toggle("All Rewards together", myTarget.allTogether);
            GUILayout.Space(10);

            if (EditorGUI.EndChangeCheck())
            {
                Repaint();
                return;
            }

            if (myTarget.allTogether == false)
            {
                myTarget.delayBetweenRewards =
                    EditorGUILayout.FloatField("Delay between rewards", myTarget.delayBetweenRewards);

                GUILayout.Space(10);
            }

            GUILayout.Space(10);
            EditorGUILayout.LabelField("Speed");
            ShowCurveSelector(myTarget.speedGrouping);

            GUILayout.Space(10);
            EditorGUILayout.LabelField("Scale");
            ShowCurveSelector(myTarget.scaleGrouping);
            myTarget.endScaleGrouping = EditorGUILayout.Vector3Field("End Scale", myTarget.endScaleGrouping);

            EditorUtility.SetDirty(myTarget);
        }