Example #1
0
        private void Start()
        {
            //Randomize total scale
            var scale = Scale + _rng.PlusMinus(ScaleRange);

            transform.localScale = new Vector3(scale, scale, scale);

            //Randomize orientation of mesh
            var meshTransform = transform.GetChild(0).GetChild(0);

            meshTransform.localRotation = Quaternion.Euler(180f * _rng.nextNormalizedFloat,
                                                           180f * _rng.nextNormalizedFloat,
                                                           180f * _rng.nextNormalizedFloat);
        }
Example #2
0
        private void SpawnGravBombs(int count, float scale)
        {
            //We want the bombs to be roughly evenly distributed, so we'll use radial coordinates and distribute at multiple angles
            //We'll then alternate toward smaller and larger radial biases

            const float innerRadius        = 40;
            const float innerRadiusScatter = 15;
            const float outerRadius        = 90;
            const float outerRadiusScatter = 30;

            const float innerAngleScatter = 30 * (Mathf.PI / 180);
            const float outerAngleScatter = 60 * (Mathf.PI / 180);

            float yNominal = 10 + scale / 4;
            float yScatter = 12 + scale / 2;

            var  w0       = _rng.nextNormalizedFloat * (2 * Mathf.PI);
            var  dw       = (2 * Mathf.PI) / count;
            bool innerOdd = _rng.nextBool;

            for (int i = 0; i < count; i++)
            {
                var inner         = (i & 1) == 1 ? innerOdd : !innerOdd;
                var radiusNominal = inner ? innerRadius : outerRadius;
                var radiusScatter = inner ? innerRadiusScatter : outerRadiusScatter;
                var angleScatter  = inner ? innerAngleScatter : outerAngleScatter;
                angleScatter /= count;

                var r = radiusNominal + _rng.PlusMinus(radiusScatter);
                var w = w0 + i * dw + _rng.PlusMinus(angleScatter);

                var x = r * Mathf.Cos(w);
                var z = r * Mathf.Sin(w);
                var y = yNominal + _rng.PlusMinus(yScatter);
                GravBombEffect.Spawn(new Vector3(x, y, z), scale);
            }
        }