Ejemplo n.º 1
0
        //========================================
        //      Self-Define
        //------------------------------
        //----------------------
        // Public Functions

        /// <summary>
        /// Spawn a random transform.
        /// </summary>
        public void SpawnATransform()
        {
            int spawnIndex = JCS_Random.Range(0, mSpawnList.Count);

            // check null ref.
            if (mSpawnList[spawnIndex] == null)
            {
                JCS_Debug.Log(
                    "Cannot spawn a null reference. Plz check the spawn list if there are transform attach or empty slot.");
                return;
            }

            // spawn a object
            Transform objSpawned = (Transform)JCS_Utility.SpawnGameObject(
                mSpawnList[spawnIndex],
                this.transform.position);


            // randomize the position a bit.
            Vector3 randPos = JCS_Utility.ApplyRandVector3(
                // use the current spawner position.
                objSpawned.transform.position,
                new Vector3(mRandPosRangeX, mRandPosRangeY, mRandPosRangeZ),
                new JCS_Bool3(mRandPosX, mRandPosY, mRandPosZ));

            // randomize the rotation a bit.
            Vector3 randRot = JCS_Utility.ApplyRandVector3(
                // use the current spawner position.
                objSpawned.transform.eulerAngles,
                new Vector3(mRandRotRangeX, mRandRotRangeY, mRandRotRangeZ),
                new JCS_Bool3(mRandRotationX, mRandRotationY, mRandRotationZ));

            // randomize the rotation a bit.
            Vector3 randScale = JCS_Utility.ApplyRandVector3(
                // use the current spawner position.
                objSpawned.transform.localScale,
                new Vector3(mRandScaleRangeX, mRandScaleRangeY, mRandScaleRangeZ),
                new JCS_Bool3(mRandScaleX, mRandScaleY, mRandScaleZ));

            objSpawned.transform.position    = randPos;
            objSpawned.transform.eulerAngles = randRot;
            objSpawned.transform.localScale  = randScale;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        private void DoDegreeChangeEffect()
        {
            if (!mDegreeChangeEffect)
            {
                return;
            }

            mDegreeTimer += Time.deltaTime;

            if (mDegreeTimer < mTimeToDegreeChange)
            {
                return;
            }

            // prepare random
            Vector3 randVal = new Vector3(
                mRandDegreeRangeX,
                mRandDegreeRangeY,
                mRandDegreeRangeZ);

            JCS_Bool3 checkers = new JCS_Bool3(
                mRandDegreeX,
                mRandDegreeY,
                mRandDegreeZ);

            // apply it.
            transform.eulerAngles = JCS_Utility.ApplyRandVector3(transform.eulerAngles, randVal, checkers);

            // reset timer
            mDegreeTimer = 0;

            // conitnue the effect then dont disable the effect!
            if (!mContinousDegreeChange)
            {
                // end the effect!
                mDegreeChangeEffect = false;
            }
        }