Ejemplo n.º 1
0
        public void UpdateSliceAnimations()
        {
            if (animationPairs.Count < 1)
            {
                return;
            }

            if (PointSlicerSlash.GetList().Count > 0)
            {
                return;
            }

            Pair2D animationPair = animationPairs.First();

            Slicing.LinearSliceAll(animationPair, sliceLayer);

            Vector3 position = animationPair.A.ToVector2();

            position.z = -1;

            GameObject particleGameObject = Instantiate(particlePrefab, position, Quaternion.Euler(0, 0, (float)Vector2D.Atan2(animationPair.A, animationPair.B) * Mathf.Rad2Deg));

            PointSlicerSlash particle = particleGameObject.GetComponent <PointSlicerSlash>();

            particle.moveTo = animationPair.B;

            animationPairs.Remove(animationPair);
        }
Ejemplo n.º 2
0
        private void LinearSlice(Pair2D slice)
        {
            List <Slice2D> results = Slicing.LinearSliceAll(slice, null);

            if (addForce == false)
            {
                return;
            }

            // Adding Physics Forces
            float sliceRotation = (float)Vector2D.Atan2(slice.B, slice.A);

            foreach (Slice2D id in results)
            {
                foreach (GameObject gameObject in id.GetGameObjects())
                {
                    Rigidbody2D rigidBody2D = gameObject.GetComponent <Rigidbody2D> ();
                    if (rigidBody2D == null)
                    {
                        continue;
                    }
                    foreach (Vector2D p in id.GetCollisions())
                    {
                        rigidBody2D.AddForceAtPosition(new Vector2(Mathf.Cos(sliceRotation) * addForceAmount, Mathf.Sin(sliceRotation) * addForceAmount), p.ToVector2());
                    }
                }
            }
        }
        private void ComplexSlice(List <Vector2D> slice)
        {
            List <Slice2D> results = Slicing.ComplexSliceAll(slice, null);

            if (addForce == false)
            {
                return;
            }

            foreach (Slice2D id in results)
            {
                AddForce.ComplexSlice(id, addForceAmount);
            }
        }
        private void LinearSlice(Pair2D slice)
        {
            List <Slice2D> results = Slicing.LinearSliceAll(slice, null);

            if (addForce == false)
            {
                return;
            }

            // Adding Physics Forces
            foreach (Slice2D id in results)
            {
                AddForce.LinearSlice(id, addForceAmount);
            }
        }