Ejemplo n.º 1
0
        public static void SpawnBranch(GameObject splatterBranchPrefab, Transform branchParent,
                                       MonoBehaviour particleProvider, SplatterSettings settings, Vector3 position,
                                       Vector3?direction, Color?color)
        {
            float nbVar       = Random.Range(-settings.numBranchesVariance, settings.numBranchesVariance);
            int   numBranches = Mathf.RoundToInt(settings.numBranchesMean + nbVar);

            for (int i = 0; i < numBranches; i++)
            {
                Color   c   = SplatterUtils.GetRandomColor(settings, color);
                Vector3 dir = SplatterUtils.GetRandomDirection(settings, direction);
                float   centerDisplacement = Random.value * settings.centerPositionRange;
                Vector2 centerAngle        = Random.onUnitSphere;
                position.x += centerAngle.x * centerDisplacement;
                if (settings.orientation == OrientationMode.Vertical)
                {
                    position.y += centerAngle.y * centerDisplacement;
                }
                else
                {
                    position.z += centerAngle.y * centerDisplacement;
                }
                float scale = settings.scaleMean + Random.Range(-settings.scaleVariance, settings.scaleVariance);
                if (scale < 0f)
                {
                    scale = 0f;
                }

                var branchPrefab = SimplePool.Spawn(splatterBranchPrefab, Vector3.zero, Quaternion.identity);
                branchPrefab.transform.parent = branchParent;
                var branch = branchPrefab.GetComponent <BaseBranch>();
                branch.SetParticleProvider(particleProvider);
                branch.ResetAndStart(settings, position, scale, dir, c);
            }
        }
Ejemplo n.º 2
0
        override public void Spawn(SplatterSettings settings, Vector3 position, Vector3?direction, Color?color)
        {
            // Find SplatterArea at position.
            SplatterArea area = null;

            foreach (var a in areas)
            {
                if (a.rectTransform.rect.Contains(position - a.rectTransform.position))
                {
                    area = a;
                    break;
                }
            }
            // If no area found, return.
            if (area == null)
            {
                return;
            }

            SplatterUtils.SpawnBranch(splatterBranchPrefab, transform, area, settings, position, direction, color);
        }
Ejemplo n.º 3
0
 override public void Spawn(SplatterSettings settings, Vector3 position, Vector3?direction, Color?color)
 {
     SplatterUtils.SpawnBranch(splatterBranchPrefab, transform, particles, settings, position, direction, color);
 }