Exemple #1
0
 /// <summary>
 /// Get all the bytes by PATH.
 /// </summary>
 public byte[] ReadAllBytes(string path, RequestCallback callback = null)
 {
     byte[] data = TryCacheData(path);
     if (data == null)
     {
         data = TryStreamingAssets(path);
     }
     if (data == null)
     {
         if (callback != null)
         {
             if (requestCallback == null)
             {
                 requestCallback = callback;
             }
             else
             {
                 JCS_Debug.LogWarning("Override request callback is denied");
             }
         }
         AddDownloadTarget(path);
         data = REQ_KEY;  // Set to `wait` key!
     }
     return(data);
 }
Exemple #2
0
        /// <summary>
        /// Set the object into the scene layer in the scene.
        /// </summary>
        /// <param name="jcsOlo"> object u want to set to that specific scene layer </param>
        /// <param name="orderLayerIndex"> index of scene layer </param>
        public void SetObjectParentToOrderLayerByOrderLayerIndex(ref JCS_OrderLayerObject jcsOlo, int orderLayerIndex)
        {
            if (jcsOlo == null)
            {
                JCS_Debug.LogWarning(
                    "The 'JCS_OrderLayerObject' object you trying to set is null references...");
                return;
            }

            // get the order layer by order layer index!
            JCS_OrderLayer jcsol = GetOrderLayerByOrderLayerIndex(orderLayerIndex);

            if (jcsol == null)
            {
                JCS_Debug.LogWarning(
                    "Did not find the layer you willing to set to..., Layer Index: " + orderLayerIndex);
                return;
            }

            // set parent
            jcsOlo.transform.SetParent(jcsol.transform);

            // set order layer to the pass in object.
            jcsOlo.SetOrderLayer(orderLayerIndex);
        }
Exemple #3
0
        /// <summary>
        /// Send a choice to current status.
        /// </summary>
        /// <param name="index"> index of the selection call. </param>
        /// <param name="msg"> message display in textbox </param>
        public void SendChoice(int index, string msg)
        {
            if (mSelectBtn.Length <= index)
            {
                JCS_Debug.LogWarning(
                    "Select button call is out of range...");
                return;
            }

            if (mSelectBtn[index] == null)
            {
                JCS_Debug.LogWarning(
                    "There are space in the array but does no assign the value...");
                return;
            }

            // set the text to the button.
            mSelectMessage[index] = msg;

            // active the button.
            SelectBtnActive(index, true);

            // Reset button selection group to make the selection
            // pointer/effect to the first selection!
            ResetButtonSelectionGroup();
        }
        /// <summary>
        /// Start the dialogue, in other word same as start a conversation.
        /// </summary>
        /// <param name="script">
        /// Script to use to run the dialogue.
        /// </param>
        public void ActiveDialogue(JCS_DialogueScript script)
        {
            mDialogueScript = script;

            if (mActive)
            {
                JCS_Debug.LogError(
                    "Dialogue System is already active... Failed to active another one.");
                return;
            }

            // check if the script attached is available?
            if (DialogueScript == null)
            {
                JCS_Debug.LogWarning("Can't run dialogue system without the dialogue script");
                return;
            }

            // reset the action, so it will always start
            // from the beginning.
            mDialogueScript.ResetAction();

            // active panel
            PanelActive(true);

            // otherwise active the dialogue
            mActive = true;

            // run the first action.
            RunAction();

            // Play the active dialogue sound.
            JCS_SoundManager.instance.GetGlobalSoundPlayer().PlayOneShot(mActiveSound);
        }
Exemple #5
0
        /// <summary>
        /// Fix the percentage of the liquid bar shown.
        /// </summary>
        private void FixPercentage()
        {
            if (mCurrentValue < mMinValue || mCurrentValue > mMaxValue)

            {
                JCS_Debug.LogWarning("Value should with in min(" + mMinValue +
                                     ") ~ max(" + mMaxValue + ") value");
                return;
            }

            float realValue         = mMaxValue - mMinValue;
            float currentPercentage = mCurrentValue / realValue;

            float realDistance = (mMaxPos - mMinPos) * currentPercentage;

            switch (GetAlign())
            {
            case JCS_Align.ALIGN_LEFT:
            case JCS_Align.ALIGN_RIGHT:
                mMaskTargetPosition.x = mMinPos + realDistance;
                break;

            case JCS_Align.ALIGN_BOTTOM:
            case JCS_Align.ALIGN_TOP:
                mMaskTargetPosition.y = mMinPos + realDistance;
                break;
            }
        }
Exemple #6
0
        private IEnumerator GetData()
        {
            UnityWebRequest www = UnityWebRequest.Get(requestURL);

            yield return(www.SendWebRequest());

            bool success = false;

            if (www.isNetworkError || www.isHttpError)
            {
                if (JCS_GameSettings.instance.DEBUG_MODE)
                {
                    JCS_Debug.LogWarning(www.error);
                }
            }
            else
            {
                mResultData = www.downloadHandler.data;
                WriteFileAsCache(requestPath, mResultData);

                success = true;
            }

            if (requestCallback != null)
            {
                requestCallback.Invoke(requestPath, success);
            }
            requestCallback = null;

            downloadList.Remove(requestPath);
            requesting = false;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="secondSearch"></param>
        /// <returns></returns>
        public JCS_LogText ExecuteOneFromPool(bool secondSearch = false)
        {
            if (mNumberOfHandle == 0)
            {
                return(null);
            }

            JCS_LogText logText;

            // loop through and see any not active
            // log text we can use in the pool
            for (int index = mLastSpawnPos;
                 index < mNumberOfHandle;
                 ++index)
            {
                logText = mLogTexts.at(index);

                // if not active, meaning we can
                // active the log text
                if (!logText.isActive())
                {
                    // set the last spawn count
                    mLastSpawnPos = index;

                    return(logText);
                }
            }

            // if we get here mean we cycle once but we
            // did not spawn a text!
            // so reset the spawn pos and
            // try to search agian until we find one!
            mLastSpawnPos = 0;

            // if function call the second time,
            // and try to call the third time,
            // exit the function call.
            // so prevent "stack overflow
            // search/infinite function call".
            // IMPORTANT(JenChieh): it wont spawn damage text this time,
            // if this happens.
            if (secondSearch)
            {
#if (UNITY_EDITOR)
                if (JCS_GameSettings.instance.DEBUG_MODE)
                {
                    JCS_Debug.LogWarning(
                        "Prevent, stack overflow function call.");
                }
#endif
                return(null);
            }

            // dangerious, use carefully!
            // make sure u have enough number of handle
            // or else the program might crash? (too many delay?)
            return(ExecuteOneFromPool(true));
        }
 public void SetGlobalMobileMouseEvent(JCS_MobileMouseEvent mme)
 {
     if (mMobileMouseEvent != null)
     {
         JCS_Debug.LogWarning("You are trying to override an existing `mobile mouse event`");
         return;
     }
     this.mMobileMouseEvent = mme;
 }
        /* Setter & Getter */

        public void SetGlobalSlideInput(JCS_SlideInput si)
        {
            if (mSlideInput != null)
            {
                JCS_Debug.LogWarning("You are trying to override an existing `slide input`");
                return;
            }
            this.mSlideInput = si;
        }
        private void Update()
        {
            if (mLightning == null)
            {
                JCS_Debug.LogWarning("Lightning effect without white screen invalid");
                return;
            }

            DoEffect();
        }
        public JCS_SlideInput GetGlobalSlideInput()
        {
#if UNITY_EDITOR
            if (JCS_GameSettings.instance.DEBUG_MODE)
            {
                JCS_Debug.LogWarning("You tried to access global slide input but doesn't exists");
                return(null);
            }
#endif
            return(this.mSlideInput);
        }
Exemple #12
0
        /// <summary>
        /// Initialize the text box.
        /// </summary>
        private void InitTextBox()
        {
            // check if text box null references...
            if (mTextBox == null)
            {
                JCS_Debug.LogWarning("You have the dialogue system in the scene, but u did not assign a text box... Try to delete it?");
                return;
            }

            mTextBox.transform.SetParent(this.transform);
        }
        public JCS_MobileMouseEvent GetGlobalMobileMouseEvent()
        {
#if UNITY_EDITOR
            if (JCS_GameSettings.instance.DEBUG_MODE)
            {
                JCS_Debug.LogWarning("You tried to access global mobile mouse event but doesn't exists");
                return(null);
            }
#endif
            return(this.mMobileMouseEvent);
        }
Exemple #14
0
        /* Variables */

        /* Setter & Getter */

        /* Functions */

        private void Awake()
        {
            // only the root object can do this.
            if (this.transform.parent == null)
            {
                DontDestroyOnLoad(this.gameObject);
            }
            else
            {
                JCS_Debug.LogWarning("Only the root object can be use DontDestoryOnLoad");
            }
        }
Exemple #15
0
        /// <summary>
        /// Light the indicator that corresponds to the PAGE.
        /// </summary>
        /// <param name="page"> Target page we want the indicator to notify the user. </param>
        public void SetPage(int page)
        {
            SetSprite(mInactiveSprite);

            if (!JCS_Util.WithInArrayRange(page, mIndicators))
            {
                JCS_Debug.LogWarning("Page indicators out of range exception");
                return;
            }

            mIndicators[page].sprite = mActiveSprite;
        }
Exemple #16
0
        /* Functions */

        /// <summary>
        /// Default function to call this, so we dont have to
        /// search the function depends on name.
        ///
        /// * Good for organize code and game data file in Unity.
        /// </summary>
        public override void JCS_OnClickCallback()
        {
            if (mRewardCallback == null)
            {
                JCS_Debug.LogWarning("Active default reward function, please fill the reward callback!");
                return;
            }

            // start reward video.
            JCS_AdvertisementManager.instance.StartDelayRewardVideo(
                mDelayTime,
                mRewardCallback);
        }
        /// <summary>
        /// Get the joystick button name by joystick button label.
        /// </summary>
        /// <param name="label"> joystick button label </param>
        /// <returns> name of the joystick button. </returns>
        public static string GetJoystickButtonName(JCS_JoystickButton label)
        {
            switch (label)
            {
            case JCS_JoystickButton.NONE: return("");

            case JCS_JoystickButton.HOME_BUTTON: return(HOME_BUTTON);

            case JCS_JoystickButton.START_BUTTON: return(JOYSTICK_BUTTON_START);

            case JCS_JoystickButton.BACK_BUTTON: return(JOYSTICK_BUTTON_BACK);

            case JCS_JoystickButton.BUTTON_A: return(JOYSTICK_BUTTON_A);

            case JCS_JoystickButton.BUTTON_B: return(JOYSTICK_BUTTON_B);

            case JCS_JoystickButton.BUTTON_X: return(JOYSTICK_BUTTON_X);

            case JCS_JoystickButton.BUTTON_Y: return(JOYSTICK_BUTTON_Y);

            case JCS_JoystickButton.LEFT_TRIGGER: return(JOYSTICK_BUTTON_LT);

            case JCS_JoystickButton.RIGHT_TRIGGER: return(JOYSTICK_BUTTON_RT);

            case JCS_JoystickButton.LEFT_BUMPER: return(JOYSTICK_BUTTON_LB);

            case JCS_JoystickButton.RIGHT_BUMPER: return(JOYSTICK_BUTTON_RB);

            case JCS_JoystickButton.BUTTON_UP: return(JOYSTICK_BUTTON_UP);

            case JCS_JoystickButton.BUTTON_DOWN: return(JOYSTICK_BUTTON_DOWN);

            case JCS_JoystickButton.BUTTON_LEFT: return(JOYSTICK_BUTTON_LEFT);

            case JCS_JoystickButton.BUTTON_RIGHT: return(JOYSTICK_BUTTON_RIGHT);

            case JCS_JoystickButton.STICK_RIGHT_X: return(STICK_RIGHT_X);

            case JCS_JoystickButton.STICK_RIGHT_Y: return(STICK_RIGHT_Y);

            case JCS_JoystickButton.STICK_LEFT_X: return(STICK_LEFT_X);

            case JCS_JoystickButton.STICK_LEFT_Y: return(STICK_LEFT_Y);
            }


            // this should not happens.
            JCS_Debug.LogWarning(@"Try to get the name with unknown joystick 
button is not allow...");
            return("");
        }
        /* Functions */

        private void Awake()
        {
            this.mTransformTweener   = this.GetComponent <JCS_TransformTweener>();
            this.mAdjustTimerTrigger = this.GetComponent <JCS_AdjustTimeTrigger>();

#if UNITY_EDITOR
            if (mPoints.Count == 0)
            {
                JCS_Debug.LogWarning("Path action with 0 path point is not valid");
            }
#endif

            mAdjustTimerTrigger.actions = DoPath;
        }
        /* Functions */

        private void Awake()
        {
            this.mGoStraightAction   = this.GetComponent <JCS_3DGoStraightAction>();
            this.mLookAtAction       = this.GetComponent <JCS_3DLookAtAction>();
            this.mAdjustTimerTrigger = this.GetComponent <JCS_AdjustTimeTrigger>();

            this.mAdjustTimerTrigger.actions = DoPath;

#if UNITY_EDITOR
            if (mPoints.Count == 0)
            {
                JCS_Debug.LogWarning("Path action with 0 path point is not valid");
            }
#endif

            GetNextPoint();
        }
Exemple #20
0
        /// <summary>
        /// Spawn one damage text.
        /// </summary>
        /// <param name="damage"> damage number </param>
        /// <param name="pos"> spawn position </param>
        public void SpawnDamageTextFromPool(
            int damage,
            Vector3 pos,
            AudioClip hitSound,
            bool secondSearch = false)
        {
            if (mNumberOfHandle == 0)
            {
                return;
            }

            JCS_DamageText dt = null;

            for (int index = mLastSpawnPos; index < mNumberOfHandle; ++index)
            {
                dt = mDamageTexts.at(index);
                // if not active, meaning we can spawn the text
                if (!dt.isActive())
                {
                    dt.SpawnDamageText(damage, pos);

                    // Hit Sound is the part of SFX sound
                    PlayHitSound(hitSound);

                    // set the last spawn count
                    mLastSpawnPos = index;

                    // Look at the camera once!
                    if (mFaceCamera)
                    {
                        dt.transform.LookAt(Camera.main.transform.position);

                        dt.transform.Rotate(0.0f, 180.0f, 0.0f);
                    }

                    return;
                }
            }

            // if we get here mean we cycle once but we
            // did not spawn a text!
            // so reset the spawn pos and
            // try to search agian until we find one!
            mLastSpawnPos = 0;

            // if function call the second time,
            // and try to call the third time,
            // exit the function call.
            // so prevent "stack overflow
            // search/infinite function call".
            // IMPORTANT(JenChieh): it wont spawn damage text this time,
            // if this happens.
            if (secondSearch)
            {
#if (UNITY_EDITOR)
                if (JCS_GameSettings.instance.DEBUG_MODE)
                {
                    JCS_Debug.LogWarning("Prevent, stack overflow function call.");
                }
#endif
                return;
            }

            // dangerious, use carefully!
            // make sure u have enough number of handle
            // or else the program might crash? (too many delay?)
            SpawnDamageTextFromPool(damage, pos, hitSound, true);
        }
Exemple #21
0
        /// <summary>
        /// Initalize all the button.
        /// </summary>
        private void InitBtnsSet()
        {
            if (mOkBtn != null)
            {
                mOkBtn.SetSystemCallback(OkBtnCallback);
            }

            if (mNoBtn != null)
            {
                mNoBtn.SetSystemCallback(NoBtnCallback);
            }

            if (mYesBtn != null)
            {
                mYesBtn.SetSystemCallback(YesBtnCallback);
            }

            if (mNextBtn != null)
            {
                mNextBtn.SetSystemCallback(NextBtnCallback);
            }

            if (mPreviousBtn != null)
            {
                mPreviousBtn.SetSystemCallback(PreviousBtnCallback);
            }

            if (mExitBtn != null)
            {
                mExitBtn.SetSystemCallback(ExitBtnCallback);
            }

            if (mAcceptBtn != null)
            {
                mAcceptBtn.SetSystemCallback(AcceptBtnCallback);
            }

            if (mDeclineBtn != null)
            {
                mDeclineBtn.SetSystemCallback(DeclineBtnCallback);
            }

            for (int index = 0;
                 index < mSelectBtn.Length;
                 ++index)
            {
                JCS_Button btn = mSelectBtn[index];

                if (btn == null)
                {
                    continue;
                }

                btn.SetSystemCallback(SelectionInt, index);

                if (mMakeHoverSelect)
                {
                    if (btn.ButtonSelection == null)
                    {
                        JCS_Debug.LogWarning(@"Cannot make hover select 
because button selection is not attach to all selections in the list...");
                    }
                    else
                    {
                        EventTrigger eventTrigger = btn.GetComponent <EventTrigger>();
                        if (eventTrigger == null)
                        {
                            eventTrigger = btn.gameObject.AddComponent <EventTrigger>();
                        }

                        JCS_Utility.AddEventTriggerEvent(
                            eventTrigger,
                            EventTriggerType.PointerEnter,
                            mButtonSelectionGroup.SelectSelection,
                            btn.ButtonSelection);
                    }
                }
            }
        }