//========================================
        //      Unity's function
        //------------------------------
        protected void Awake()
        {
            mTargetList = new JCS_Vector <JCS_Player>();

            mAudioListener = this.GetComponent <AudioListener>();

            // find the camera in the scene first
            mJCS_2DCamera = (JCS_2DCamera)FindObjectOfType(typeof(JCS_2DCamera));

            // if still null spawn a default one!
            if (mJCS_2DCamera == null)
            {
                JCS_Debug.LogError("There is not JCS_2DCamera attach to, spawn a default one!");

                // Spawn a Default one!
                this.mJCS_2DCamera = JCS_Utility.SpawnGameObject(
                    JCS_2DCamera.JCS_2DCAMERA_PATH,
                    transform.position,
                    transform.rotation).GetComponent <JCS_2DCamera>();
            }

            mJCS_2DCamera.SetFollowTarget(this.transform);

            // record down the fild of view
            mTargetFieldOfView = mJCS_2DCamera.fieldOfView;
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize damage text to the array.
        /// </summary>
        private void InitDamageTextToArray()
        {
            mDamageTexts = new JCS_Vector <JCS_DamageText>(mNumberOfHandle);

            if (mDamageText == null)
            {
                return;
            }

            for (int count = 0; count < mNumberOfHandle; ++count)
            {
                // spawn a new game object,
                // and get the component
                JCS_DamageText dt = JCS_Utility.SpawnGameObject(
                    mDamageText,
                    mDamageText.transform.position,
                    mDamageText.transform.rotation) as JCS_DamageText;

                // add to array
                mDamageTexts.set(count, dt);

                // set parent
                dt.transform.SetParent(this.transform);
            }
        }
Esempio n. 3
0
        private void Start()
        {
            // pop the fade screen.
            string path = JCS_GameSettings.FADE_SCREEN_PATH;

            this.mFadeScreen = JCS_Utility.SpawnGameObject(path).GetComponent <JCS_FadeScreen>();
        }
        /// <summary>
        /// Spawn all particle base on the count.
        /// </summary>
        public void SpawnParticles()
        {
            // check if particles already spawned?
            if (mParticleSpawned)
            {
                return;
            }

            if (mParticle == null)
            {
                JCS_Debug.Log(
                    "No particle assign!");
                return;
            }

            for (int index = 0;
                 index < mNumOfParticle;
                 ++index)
            {
                JCS_Particle trans = (JCS_Particle)JCS_Utility.SpawnGameObject(mParticle);
                mParticles.push(trans);

                // disable the object
                trans.gameObject.SetActive(false);

                if (mSetChild)
                {
                    // set parent
                    trans.transform.SetParent(this.transform);
                }
            }

            mParticleSpawned = true;
        }
Esempio n. 5
0
        /**
         * Utils
         */

        /// <summary>
        /// Create the Game Object during editing time.
        /// </summary>
        /// <returns></returns>
        private static GameObject CreateHierarchyObject(string settingPath)
        {
            // spawn the game object.
            GameObject hierarchyObj = JCS_Utility.SpawnGameObject(settingPath);

            // take away clone sign.
            hierarchyObj.name = hierarchyObj.name.Replace("(Clone)", "");

            return(hierarchyObj);
        }
Esempio n. 6
0
        //** In Game Dialogue (Game Layer)

        /// <summary>
        /// Spawn the setting dialogue.
        /// </summary>
        public static void PopSettingDialogue()
        {
            if (!CheckIfOkayToSpawnDialogue(JCS_DialogueType.PLAYER_DIALOGUE))
            {
                return;
            }

            JCS_Utility.SpawnGameObject(SETTING_PANEL);

            //PauseGame(true);
        }
Esempio n. 7
0
        /// <summary>
        /// Spawn the talke dialogue.
        /// </summary>
        public static void PopTalkDialogue()
        {
            if (!CheckIfOkayToSpawnDialogue(JCS_DialogueType.PLAYER_DIALOGUE))
            {
                return;
            }

            JCS_Utility.SpawnGameObject(TALK_DIALOGUE);

            PauseGame(true);
        }
Esempio n. 8
0
        //** (Application Layer)

        /// <summary>
        /// Spawn the connect dialgoue.
        /// </summary>
        public static void PopIsConnectDialogue()
        {
            if (!CheckIfOkayToSpawnDialogue(JCS_DialogueType.SYSTEM_DIALOGUE))
            {
                return;
            }

            JCS_Utility.SpawnGameObject(IS_CONNECT_DIALOGUE);

            PauseGame(true);
        }
Esempio n. 9
0
        /// <summary>
        /// Pop the JCS_BlackSlideScreen object.
        /// </summary>
        public static void PopJCSBlackSlideScreen()
        {
            string path             = JCS_UISettings.BLACK_SLIDE_SCREEN_PATH;
            JCS_BlackSlideScreen bs = JCS_Utility.SpawnGameObject(path).GetComponent <JCS_BlackSlideScreen>();

            if (bs == null)
            {
                JCS_Debug.LogError("GameObject without \"JCS_BlackScreen\" Component attached!!!");
                return;
            }

            JCS_SceneManager.instance.SetJCSBlackSlideScreen(bs);
        }
        /// <summary>
        /// Pop one single dialogue.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        private JCS_DialogueObject PopDialogue(JCS_DialogueObject obj)
        {
            if (obj == null)
            {
                return(null);
            }

            obj = (JCS_DialogueObject)JCS_Utility.SpawnGameObject(obj);
            obj.ShowDialogue();
            obj.SetKeyCode(KeyCode.None);

            return(obj);
        }
Esempio n. 11
0
        /// <summary>
        /// Spawn a white screen.
        /// </summary>
        public static void PopJCSWhiteScreen()
        {
            string          path = JCS_UISettings.WHITE_SCREEN_PATH;
            JCS_WhiteScreen ws   = JCS_Utility.SpawnGameObject(path).GetComponent <JCS_WhiteScreen>();

            if (ws == null)
            {
                JCS_Debug.LogError("GameObject without `JCS_WhiteScreen` Component attached!!!");
                return;
            }

            JCS_SceneManager.instance.SetJCSWhiteScreen(ws);
        }
Esempio n. 12
0
        //========================================
        //      Unity's function
        //------------------------------
        private void Awake()
        {
            InitCamera();

            //
            if (mPanelHolder == null)
            {
                // spawn a default one!
                this.mPanelHolder = JCS_Utility.SpawnGameObject(
                    mPanelHolderPath,
                    transform.position,
                    transform.rotation).GetComponent <JCS_SlideScreenPanelHolder>();
            }
        }
Esempio n. 13
0
        /* Functions */

        private void Awake()
        {
            instance = this;

            // Spawn the four aspect screen panels.
            this.mTopASP    = JCS_Utility.SpawnGameObject(mResizableScreenPanelPath).GetComponent <JCS_ResizableScreenPanel>();
            this.mBottomASP = JCS_Utility.SpawnGameObject(mResizableScreenPanelPath).GetComponent <JCS_ResizableScreenPanel>();
            this.mLeftASP   = JCS_Utility.SpawnGameObject(mResizableScreenPanelPath).GetComponent <JCS_ResizableScreenPanel>();
            this.mRightASP  = JCS_Utility.SpawnGameObject(mResizableScreenPanelPath).GetComponent <JCS_ResizableScreenPanel>();

            // Set the ASP direction.
            this.mTopASP.PlaceDirection    = JCS_2D4Direction.TOP;
            this.mBottomASP.PlaceDirection = JCS_2D4Direction.BOTTOM;
            this.mLeftASP.PlaceDirection   = JCS_2D4Direction.LEFT;
            this.mRightASP.PlaceDirection  = JCS_2D4Direction.RIGHT;
        }
Esempio n. 14
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;
        }
        /// <summary>
        /// Pop all the dialogues in the array.
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private JCS_DialogueObject[] PopDialogue(JCS_DialogueObject[] list)
        {
            if (list.Length == 0)
            {
                return(null);
            }

            for (int index = 0; index < list.Length; ++index)
            {
                if (list[index] == null)
                {
                    continue;
                }

                list[index] = (JCS_DialogueObject)JCS_Utility.SpawnGameObject(list[index]);
                list[index].HideDialogue();
            }

            return(list);
        }
Esempio n. 16
0
        /// <summary>
        /// Algorithm to do the main action from this event.
        /// </summary>
        public void SpawnObjects()
        {
            Transform spawnTrans = null;

            for (int counter = 0;
                 counter < mObjectsToSpawn;
                 ++counter)
            {
                // get the random object from the list.
                spawnTrans = mObjectList.GetRandomObjectFromList();

                // check if null.
                if (spawnTrans == null)
                {
                    JCS_Debug.LogError(
                        "Spawning object detect that are null references... Could not spawn the object!");

                    break;
                }


                // spawn the object by transform.
                // and get the object which we just spawned.
                spawnTrans = (Transform)JCS_Utility.SpawnGameObject(spawnTrans, this.transform.position);

                // apply random position
                spawnTrans.transform.position = RandTransform(spawnTrans.position);

                // apply random rotation
                spawnTrans.transform.eulerAngles = RandDegree(spawnTrans.eulerAngles);

                JCS_ApplyDamageTextToLiveObjectAction adtaThis    = this.GetComponent <JCS_ApplyDamageTextToLiveObjectAction>();
                JCS_ApplyDamageTextToLiveObjectAction adtaSpawned = spawnTrans.GetComponent <JCS_ApplyDamageTextToLiveObjectAction>();
                if (adtaThis != null && adtaSpawned != null)
                {
                    // copy the apply damage text information to spawned object!
                    adtaSpawned.CopyToThis(adtaThis);
                }
            }
        }
        //========================================
        //      Self-Define
        //------------------------------
        //----------------------
        // Public Functions

        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

        /// <summary>
        /// Spawn the text pool base on number of handle.
        /// </summary>
        private void SpawnTextPool()
        {
            if (mLogText == null)
            {
                JCS_Debug.LogReminders(
                    "No log text assign in the text pool...");

                return;
            }


            // NOTE(JenChieh): this might change in
            // the future.
            // Get the log system from the
            // same transfrom/node.
            JCS_IGLogSystem logSystem = this.GetComponent <JCS_IGLogSystem>();


            mLogTexts = new JCS_Vector <JCS_LogText>(mNumberOfHandle);

            for (int count = 0;
                 count < mNumberOfHandle;
                 ++count)
            {
                // spawn a new game object,
                // and get the component
                JCS_LogText logText = (JCS_LogText)JCS_Utility.SpawnGameObject(mLogText);

                // add to array
                mLogTexts.set(count, logText);

                // set parent
                JCS_Utility.SetParentWithoutLosingInfo(logText.transform, this.transform);

                // NOTE(JenChieh): this might change in
                // the future.
                // set the log system if there is one.
                logText.SetIGLogSystem(logSystem);
            }
        }
Esempio n. 18
0
        private static void SerializeToJCSUnity2D()
        {
            // create settings
            CreateJCSSettings();

            // create managers
            CreateJCSManagers();

            Create2DCamera();

            // BGM player
            CreateJCSBGMPlayer();

            // create canvas
            GameObject canvasObj = CreateJCSCanvas();

            string     desc_path = "JCSUnity_Resources/GUI/Plz delete this desc text.";
            GameObject desc_obj  = JCS_Utility.SpawnGameObject(desc_path);

            desc_obj.name = desc_obj.name.Replace("(Clone)", "");
            desc_obj.transform.SetParent(canvasObj.transform);
            desc_obj.transform.localPosition = new Vector3(-703, 198, 0);
        }
Esempio n. 19
0
        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

        //////////// 2D //////////////////////////

        /// <summary>
        /// Iniialize the camera.
        /// </summary>
        private void InitCamera()
        {
            if (mJCS_2DCamera == null)
            {
                JCS_Debug.LogError("There is not JCS_2DCamera attach to, spawn a default one!");

                // Spawn a Default one!
                this.mJCS_2DCamera = JCS_Utility.SpawnGameObject(
                    JCS_2DCamera.JCS_2DCAMERA_PATH,
                    transform.position,
                    transform.rotation).GetComponent <JCS_2DCamera>();
            }

            // if still null, setting error!!
            if (mJCS_2DCamera == null)
            {
                JCS_Debug.LogError("The object spawn does not have the \"JCS_2DCamera\" components...");
                return;
            }

            // set target to follow!
            mJCS_2DCamera.SetFollowTarget(this.transform);
        }
Esempio n. 20
0
        private static void SerializeToJCSUnity2D()
        {
            // create settings
            CreateJCSSettings();

            // create managers
            CreateJCSManagers();

            Create2DCamera();

            // BGM player
            CreateJCSBGMPlayer();

            // create canvas
            GameObject canvasObj = CreateJCSCanvas();

            const string desc_path = "JCSUnity_Resources/GUI/Describe Panel";
            GameObject   desc_obj  = JCS_Utility.SpawnGameObject(desc_path);

            desc_obj.name = desc_obj.name.Replace("(Clone)", "");
            desc_obj.transform.SetParent(canvasObj.transform);
            desc_obj.transform.localPosition = Vector3.zero;
        }
Esempio n. 21
0
        /// <summary>
        /// Create new linked node object by N count.
        /// </summary>
        /// <param name="n"> Number of linked object to create. </param>
        /// <param name="startIndex"> Starting index to create. </param>
        /// <returns> List of created linked object. </returns>
        public List <JCS_TransformLinkedObject> NewLinked(int n = 1, int startIndex = 0)
        {
            if (mClone == null)
            {
                JCS_Debug.LogReminder("Can't create new linked node without the clone");
                return(null);
            }

            if (n <= 0)
            {
                JCS_Debug.LogReminder("Can't create new linked node N lower than 1");
                return(null);
            }

            var lst = new List <JCS_TransformLinkedObject>();

            int maxIndex = startIndex + n;

            for (int index = startIndex; index < maxIndex; ++index)
            {
                var newNode = JCS_Utility.SpawnGameObject(mClone) as JCS_TransformLinkedObject;

                // Set to it centers.
                {
                    newNode.transform.SetParent(this.transform);
                    newNode.transform.localPosition = Vector3.zero;
                    newNode.transform.localScale    = Vector3.one;
                }

                lst.Add(newNode);
                mManagedList.Insert(index, newNode);
            }

            OrganizedLinked();

            return(lst);
        }
        //========================================
        //      Self-Define
        //------------------------------
        //----------------------
        // Public Functions

        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

        /// <summary>
        /// Do the spawning.
        /// </summary>
        private void DoSpawn()
        {
            for (int index = 0;
                 index < mSpawnCount;
                 ++index)
            {
                Transform newTrans = (Transform)JCS_Utility.SpawnGameObject(mTransformPool.GetRandomObject());

                if (mSamePosition)
                {
                    newTrans.position = this.transform.position;
                }
                if (mSameRotation)
                {
                    newTrans.rotation = this.transform.rotation;
                }
                if (mSameScale)
                {
                    newTrans.localScale = this.transform.localScale;
                }

                // Random Effect
                if (mRandPos)
                {
                    AddRandomPosition(newTrans);
                }
                if (mRandRot)
                {
                    AddRandomRotation(newTrans);
                }
                if (mRandScale)
                {
                    AddRandomScale(newTrans);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Shoot a bullet.
        /// </summary>
        /// <param name="bulletSpeed"></param>
        /// <param name="pos"></param>
        /// <param name="direction"></param>
        /// <param name="damages"></param>
        /// <param name="index"></param>
        /// <param name="inSequence"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public JCS_Bullet Shoot(float bulletSpeed, Vector3 pos, bool direction, int[] damages, int index = 0, bool inSequence = false, Transform target = null)
        {
            if (mPlayer != null)
            {
                if (mPlayer.CharacterState != JCS_2DCharacterState.NORMAL)
                {
                    return(null);
                }
            }

            int hit = damages.Length;

            Vector3 spawnPos = pos + mSpanwPointOffset;

            spawnPos = RandTransform(spawnPos);

            JCS_Bullet bullet = (JCS_Bullet)JCS_Utility.SpawnGameObject(mBullet, spawnPos, mSpawnPoint.rotation);

            // no object spawns
            if (bullet == null)
            {
                return(null);
            }

            // set the attacker.
            SetAttackerInfo(bullet);

            float tempBulletSpeed = bulletSpeed;

            // default: facing left
            if (!direction)
            {
                tempBulletSpeed = -tempBulletSpeed;
            }

            // set bullet speed
            bullet.MoveSpeed = tempBulletSpeed;

            // Do devication Effect
            DeviationEffect(bullet.transform);

            if (bullet is JCS_2DBullet)
            {
                bullet.GetComponent <JCS_3DGoStraightAction>().MoveSpeed = bulletSpeed;
            }


            if (mTrackSoot &&
                target != null)
            {
                JCS_2DTrackAction ta = bullet.GetComponent <JCS_2DTrackAction>();
                if (ta != null)
                {
                    ta.TargetTransform = target;

                    // set to center
                    float newIndex = index - (hit / 2.0f);

                    // apply effect
                    ta.Index = newIndex;
                }
            }

            if (mAbilityFormat != null)
            {
                JCS_ApplyDamageTextToLiveObjectAction adta = bullet.GetComponent <JCS_ApplyDamageTextToLiveObjectAction>();
                if (adta != null)
                {
                    // set the Ability Format
                    adta.AbilityFormat = mAbilityFormat;
                    adta.Hit           = hit;

                    adta.DamageApplying = damages;

                    // if hit equal to 0,
                    // meaning this bullet is in the sequence
                    if (inSequence)
                    {
                        adta.InSequence = true;
                    }

                    adta.TargetTransform = target;
                }
            }

            // part of the SFX
            mRandomMultiSoundAction.PlayRandomSound();

            return(bullet);
        }
Esempio n. 24
0
        /* Functions */

        private void Awake()
        {
            if (instance != null)
            {
                string black_screen_name = JCS_UISettings.BLACK_SCREEN_NAME;
                string white_screen_name = JCS_UISettings.WHITE_SCREEN_NAME;

                // cuz the transform list will change while we set the transform to
                // the transform,
                List <Transform> readyToSetList = new List <Transform>();

                Transform tempTrans = instance.transform;
                // so record all the transform
                for (int index = 0; index < tempTrans.childCount; ++index)
                {
                    Transform child = tempTrans.GetChild(index);
                    if (child.name == black_screen_name ||
                        child.name == (black_screen_name + "(Clone)"))
                    {
                        continue;
                    }

                    if (child.name == white_screen_name ||
                        child.name == (white_screen_name + "(Clone)"))
                    {
                        continue;
                    }

                    if (child.name == "JCS_IgnorePanel")
                    {
                        continue;
                    }

                    // TODO(JenChieh): optimize this?
                    if (child.GetComponent <JCS_IgnoreDialogueObject>() != null)
                    {
                        continue;
                    }

                    // add to set list ready to set to the new transform as parent
                    readyToSetList.Add(child);
                }

                // set to the new transform
                foreach (Transform trans in readyToSetList)
                {
                    // set parent to the new canvas in the new scene
                    trans.SetParent(this.transform);
                }

                // Delete the old one
                DestroyImmediate(instance.gameObject);
            }


            // attach the new one
            instance = this;

            this.mAppRect = this.GetComponent <RectTransform>();
            this.mCanvas  = this.GetComponent <Canvas>();

            if (JCS_UISettings.instance.RESIZE_UI)
            {
                // resizable UI in order to resize the UI correctly
                JCS_ResizeUI rui = JCS_Utility.SpawnGameObject(RESIZE_UI_PATH).GetComponent <JCS_ResizeUI>();
                rui.transform.SetParent(this.transform);
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Drop an item.
        /// </summary>
        /// <param name="item"> item u want to spawn </param>
        /// <param name="index"> index to know the force this is pushing to. </param>
        /// <param name="isEven"> is the index even number? </param>
        /// <param name="isGravity"> do gravity effect. </param>
        /// <param name="spreadEffect"> do spread effect. </param>
        /// <param name="rotateDrop"> rotate while dropping. </param>
        /// <param name="waveEffect"> do wave effect while on the ground. </param>
        /// <param name="destroyFade"> while picking it up will fade and destroy. </param>
        private void DropAnItem(
            JCS_Item item,
            int index,
            bool isEven,
            bool isGravity,
            bool spreadEffect,
            bool rotateDrop,
            bool waveEffect,
            bool destroyFade)
        {
            JCS_Item jcsi = (JCS_Item)JCS_Utility.SpawnGameObject(
                item,
                this.transform.position,
                this.transform.rotation);

            bool isEvenIndex = ((index % 2) == 0) ? true : false;

            if (isGravity)
            {
                JCS_OneJump jcsoj = jcsi.gameObject.AddComponent <JCS_OneJump>();

                float gapDirection = mSpreadGap;
                if (isEvenIndex)
                {
                    gapDirection = -mSpreadGap;
                }

                jcsoj.BounceBackfromWall = BounceBackfromWall;

                float gapForce = 0;

                if (spreadEffect)
                {
                    if (isEven)
                    {
                        if (!isEvenIndex)
                        {
                            gapForce = (gapDirection * (index - 1)) + gapDirection;
                        }
                        else
                        {
                            gapForce = (gapDirection * (index)) + gapDirection;
                        }
                    }
                    // if total is odd
                    else
                    {
                        if (isEvenIndex)
                        {
                            gapForce = (gapDirection * (index));
                        }
                        else
                        {
                            gapForce = (gapDirection * (index)) + gapDirection;
                        }
                    }
                }

                float jumpForce = mJumpForce;
                if (mRandomizeJumpForce)
                {
                    jumpForce += JCS_Random.Range(-mRandomizeJumpForceForce, mRandomizeJumpForceForce);
                }

                jcsoj.DoForce(gapForce, jumpForce, mIncludeDepth);

                if (rotateDrop)
                {
                    JCS_ItemRotation jcsir = jcsi.gameObject.AddComponent <JCS_ItemRotation>();
                    jcsir.RotateSpeed = mRotateSpeed;
                    jcsir.Effect      = true;

                    // if z axis interact in game
                    if (mIncludeDepth)
                    {
                        // add one more axis.
                        JCS_ItemRotation jcsir2 = jcsi.gameObject.AddComponent <JCS_ItemRotation>();
                        jcsir2.RotateSpeed     = JCS_Random.Range(-mRotateSpeed, mRotateSpeed);
                        jcsir2.Effect          = true;
                        jcsir2.RotateDirection = JCS_Vector3Direction.UP;
                    }
                }
            }

            if (waveEffect)
            {
                JCS_3DConstWaveEffect jcscw = jcsi.gameObject.AddComponent <JCS_3DConstWaveEffect>();
                jcscw.Effect = true;
            }

            if (destroyFade)
            {
                JCS_DestroyObjectWithTime jcsao = jcsi.gameObject.AddComponent <JCS_DestroyObjectWithTime>();
                jcsao.GetFadeObject().FadeTime  = mFadeTime;
                jcsao.DestroyTime = mDestroyTime;

                // set the object type the same.
                jcsao.GetFadeObject().SetObjectType(item.GetObjectType());

                jcsao.GetFadeObject().UpdateUnityData();
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Drop an item.
        /// </summary>
        /// <param name="item"> item u want to spawn </param>
        /// <param name="index"> index to know the force this is pushing to. </param>
        /// <param name="isEven"> is the index even number? </param>
        /// <param name="isGravity"> do gravity effect. </param>
        /// <param name="spreadEffect"> do spread effect. </param>
        /// <param name="rotateDrop"> rotate while dropping. </param>
        /// <param name="waveEffect"> do wave effect while on the ground. </param>
        /// <param name="destroyFade"> while picking it up will fade and destroy. </param>
        private void DropAnItem(
            JCS_Item item,
            int index,
            bool isEven,
            bool isGravity,
            bool spreadEffect,
            bool rotateDrop,
            bool waveEffect,
            bool destroyFade)
        {
            JCS_Item newItem = (JCS_Item)JCS_Utility.SpawnGameObject(
                item,
                this.transform.position,
                this.transform.rotation);

            bool isEvenIndex = ((index % 2) == 0) ? true : false;

            if (isGravity)
            {
                JCS_OneJump oj = newItem.gameObject.AddComponent <JCS_OneJump>();

                float gapDirection = mSpreadGap;
                if (isEvenIndex)
                {
                    gapDirection = -mSpreadGap;
                }

                oj.BounceBackfromWall = BounceBackfromWall;

                float gapForce = 0;

                if (spreadEffect)
                {
                    if (isEven)
                    {
                        if (!isEvenIndex)
                        {
                            gapForce = (gapDirection * (index - 1)) + gapDirection;
                        }
                        else
                        {
                            gapForce = (gapDirection * (index)) + gapDirection;
                        }
                    }
                    // if total is odd
                    else
                    {
                        if (isEvenIndex)
                        {
                            gapForce = (gapDirection * (index));
                        }
                        else
                        {
                            gapForce = (gapDirection * (index)) + gapDirection;
                        }
                    }
                }

                float jumpForce = mJumpForce;
                if (mRandomizeJumpForce)
                {
                    jumpForce += JCS_Random.Range(-mRandomizeJumpForceForce, mRandomizeJumpForceForce);
                }

                oj.DoForce(gapForce, jumpForce, mIncludeDepth);

                if (rotateDrop)
                {
                    JCS_ItemRotation irx = newItem.gameObject.AddComponent <JCS_ItemRotation>();
                    irx.RotateSpeed     = JCS_Random.Range(-mRotateSpeed, mRotateSpeed);
                    irx.Effect          = true;
                    irx.RotateDirection = JCS_Vector3Direction.FORWARD;

                    // if z axis interact in game
                    if (mIncludeDepth)
                    {
                        // add rotation on y axis.
                        JCS_ItemRotation iry = newItem.gameObject.AddComponent <JCS_ItemRotation>();
                        iry.RotateSpeed     = JCS_Random.Range(-mRotateSpeed, mRotateSpeed);
                        iry.Effect          = true;
                        iry.RotateDirection = JCS_Vector3Direction.UP;

                        // add rotation on z axis.
                        JCS_ItemRotation irz = newItem.gameObject.AddComponent <JCS_ItemRotation>();
                        irz.RotateSpeed     = JCS_Random.Range(-mRotateSpeed, mRotateSpeed);
                        irz.Effect          = true;
                        irz.RotateDirection = JCS_Vector3Direction.RIGHT;
                    }
                }
            }

            if (waveEffect)
            {
                JCS_3DConstWaveEffect cwe = newItem.gameObject.AddComponent <JCS_3DConstWaveEffect>();
                cwe.SetObjectType(newItem.GetObjectType());
                cwe.Effect = true;
            }

            if (destroyFade)
            {
                JCS_DestroyObjectWithTime dowt = newItem.gameObject.AddComponent <JCS_DestroyObjectWithTime>();
                dowt.FadeTime    = mFadeTime;
                dowt.DestroyTime = mDestroyTime;

                Renderer[] renderers = newItem.GetComponentsInChildren <Renderer>();

                foreach (Renderer rdr in renderers)
                {
                    JCS_FadeObject fo = rdr.gameObject.AddComponent <JCS_FadeObject>();

                    dowt.FadeObjects.Add(fo);

                    // set the object type the same.
                    fo.SetObjectType(item.GetObjectType());
                    fo.UpdateUnityData();
                }
            }
        }