Beispiel #1
0
    public static void MinusValue(double value, int unit, double valueMinus, int unitMinus, out double valueOut, out int unitOut)
    {
        if (unit < unitMinus)
        {
            LogGame.Log("[Minus] Error minus.");

            value = 0;
            unit  = 0;
        }
        else
        {
            if (unit - unitMinus <= 5)
            {
                value = value - valueMinus * Math.Pow(0.001, unit - unitMinus);
            }
        }

        if (value < 0.0)
        {
            value = 0;
            unit  = 0;
        }

        FixNumber(ref value, ref unit);

        valueOut = value;
        unitOut  = unit;
    }
Beispiel #2
0
    /// <summary>
    /// Returns to pool.
    /// </summary>
    /// <param name="param">Parameter.</param>
    public void ReturnToPool(CardBehaviour param)
    {
        // TODO: Check if this is not null.
        if (param != null)
        {
            // TODO: Disable the gameobject.
            //param.gameObject.SetActive (false);

            // TODO: Check if this exists in the list. Just remove this param.
            if (ItemProperties.Contains(param))
            {
                LogGame.DebugLog(string.Format("[Pool System] Card Was Found {0}", param.name));

                // TODO: Remove this param.
                ItemProperties.Remove(param);
            }

            // TODO: Set default parent transform.
            param.transform.SetParent(transform);

            param.transform.localPosition = Contains.Vector3Null;

            // TODO: Add this param to the list of cards.
            ItemProperties.Add(param);
        }
    }
    private static LoadingManager ExecuteLoading(string scene, System.Action onStart, System.Action onEnd, string message)
    {
        if (LoadingManager.InstanceAwake() != null)
        {
            return(LoadingManager.Instance
                   .RegisterEvent(onStart, onEnd)
                   .Execute(scene, true, true, message));
        }

        if (!ReferenceEquals(onStart, null))
        {
            onStart();
        }

        UnityEngine.SceneManagement.SceneManager.LoadScene(scene);

        if (!ReferenceEquals(onEnd, null))
        {
            onEnd();
        }

        LogGame.Log("[Loading Manager] Loading with default scene load system!");

        return(null);
    }
    public ActionEventDispatcher RegisterEvent(ActionEnums.ActionID actionID, System.Action action)
    {
        if (_PoolEvent.TryGetValue(ActionEnums.GetActionString(actionID), out paramOut))
        {
            paramOut += delegate(object _a)
            {
                action();
            };

            _PoolEvent[ActionEnums.GetActionString(actionID)] = paramOut;
        }
        else
        {
            paramOut += delegate(object _a)
            {
                action();
            };

            _PoolEvent.Add(ActionEnums.GetActionString(actionID), paramOut);
        }

        LogGame.Log(string.Format("[Action Manager] Register the new event with ID: {0}",
                                  ActionEnums.GetActionString(actionID)));

        return(this);
    }
Beispiel #5
0
    public virtual void OnDisable()
    {
        if (UpdateSystem.Instance == null)
        {
            return;
        }

        if (IsRegisterUpdateSystem)
        {
            UpdateSystem.Instance.RemoveUpdate(this);

            LogGame.DebugLog(string.Format("[System Register] Remove Listener Update Completed!"));
        }

        if (IsRegisterFixedUpdateSystem)
        {
            UpdateSystem.Instance.RemoveFixedUpdate(this);

            LogGame.DebugLog(string.Format("[System Register] Remove Listener Fixed Update Completed!"));
        }

        if (IsReigisterLateUpdateSystem)
        {
            UpdateSystem.Instance.RemoveLatedUpdate(this);

            LogGame.DebugLog(string.Format("[System Register] Remove Listener Lated Update Completed!"));
        }
    }
Beispiel #6
0
    private static void LoadScene()
    {
        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != SceneEnums.GetSceneString(SceneEnums.SceneID.SceneInit))
        {
            UnityEditor.EditorUtility.DisplayDialog("Warning", string.Format("Please running the game from the scene with name: {0}", SceneEnums.GetSceneString(SceneEnums.SceneID.SceneInit)), "OK");
        }

        LogGame.Log("[Helper] Check the status of scene!");
    }
Beispiel #7
0
    private void DefaultToggle()
    {
        // TODO: Check the reference.
        if (!object.ReferenceEquals(UIMusic, null) && !object.ReferenceEquals(UITextMusic, null))
        {
            // TODO: Check the state of music.
            if (Contains.IsMusicOn)
            {
                // TODO: Set the default position UI;
                UIMusic.transform.DOLocalMoveX(80, 0f);

                // TODO: Set the text will be displayed.
                UITextMusic.text = Contains.TextON;
            }
            else
            {
                // TODO: Set the default position UI;
                UIMusic.transform.DOLocalMoveX(-80, 0f);

                // TODO: Set the text will be displayed.
                UITextMusic.text = Contains.TextOFF;
            }
        }
        else
        {
            // TODO: Write the log.
            LogGame.DebugLog("[SETTINGS] Music button was null.");
        }

        // TODO: Check the reference.
        if (!object.ReferenceEquals(UISound, null) && !object.ReferenceEquals(UITextSound, null))
        {
            // TODO: Check the state of sound.
            if (Contains.IsSoundOn)
            {
                // TODO: Set the default position UI;
                UISound.transform.DOLocalMoveX(80, 0f);

                // TODO: Set the text will be displayed.
                UITextSound.text = Contains.TextON;
            }
            else
            {
                // TODO: Set the default position UI;
                UISound.transform.DOLocalMoveX(-80, 0f);

                // TODO: Set the text will be displayed.
                UITextSound.text = Contains.TextOFF;
            }
        }
        else
        {
            // TODO: Write the log.
            LogGame.DebugLog("[SETTINGS] Sound button was null.");
        }
    }
Beispiel #8
0
    private void DoFailedRewardVideo()
    {
        if (OnFailedRewardVideo != null)
        {
            OnFailedRewardVideo();
            OnFailedRewardVideo = null;
        }

        LogGame.Log("[Ad Manager] Reward Video Is Failed!");
    }
    public static void RefreshRewardVideo(this MonoBehaviour mono)
    {
        if (AdsManager.InstanceAwake() == null)
        {
            LogGame.Error("[Ad Manager] Ad Manager Is Null!");
            return;
        }

        AdsManager.Instance.RefreshRewardVideo();
    }
Beispiel #10
0
    public static ActionEventDispatcher PostActionEvent(this MonoBehaviour mono, ActionEnums.ActionID actionID, object param = null)
    {
        if (ReferenceEquals(ActionEventDispatcher.InstanceAwake(), null))
        {
            LogGame.Error("[Action Event] Action Event Dispatcher Is Null!");
            return(null);
        }

        return(ActionEventDispatcher.Instance.PostEvent(actionID, param));;
    }
Beispiel #11
0
    public static ActionEventDispatcher RegisterActionEvent(this MonoBehaviour mono, ActionEnums.ActionID actionID, System.Action callback)
    {
        if (ReferenceEquals(ActionEventDispatcher.InstanceAwake(), null))
        {
            LogGame.Error("[Action Event] Action Event Dispatcher Is Null!");
            return(null);
        }

        return(ActionEventDispatcher.Instance.RegisterEvent(actionID, callback));;
    }
Beispiel #12
0
    private void DoCompletedRewardVideo()
    {
        if (OnCompletedRewardVideo != null)
        {
            OnCompletedRewardVideo();
            OnCompletedRewardVideo = null;
        }

        LogGame.Log("[Ad Manager] Reward Video Is Completed!");
    }
    public static bool IsRewardVideoAvailable(this MonoBehaviour mono)
    {
        if (AdsManager.InstanceAwake() == null)
        {
            LogGame.Error("[Ad Manager] Ad Manager Is Null!");

            return(false);
        }

        return(AdsManager.Instance.IsRewardVideoAvailable);
    }
    public static void DisableBanner(this MonoBehaviour mono)
    {
        if (AdsManager.InstanceAwake() == null)
        {
            LogGame.Error("[Ad Manager] Ad Manager Is Null!");

            return;
        }

        AdsManager.Instance.HideBanner();
    }
Beispiel #15
0
        /// <summary>
        /// Check the condition to win this game.
        /// </summary>
        public bool IsConditionWining()
        {
            if (ResultZone.Instance.IsFullCards())
            {
                LogGame.DebugLog("[Spider Solitaire] Completed game.");

                return(true);
            }

            return(false);
        }
Beispiel #16
0
    public static void PostTapAnyWhere(this MonoBehaviour mono)
    {
        if (ReferenceEquals(TutorialManager.InstanceAwake(), null))
        {
            LogGame.Log("[Tutorial Manager] Tutorial is null.");

            return;
        }

        TutorialManager.Instance.PostTapAnyWhere();
    }
Beispiel #17
0
    public static void ExecuteTutorial(this MonoBehaviour mono, TutorialEnums.TutorialId id)
    {
        if (ReferenceEquals(TutorialManager.InstanceAwake(), null))
        {
            LogGame.Log("[Tutorial Manager] Tutorial is null.");

            return;
        }

        TutorialManager.Instance.ExecuteTutorial(id);
    }
Beispiel #18
0
        /// <summary>
        /// Check the condition to win this game.
        /// </summary>
        public bool IsConditionWining()
        {
            if (PlayingZone.Instance.IsEmptyAllCards() && HintZone.Instance.IsEmptyAllCards())
            {
                LogGame.DebugLog("[Spider Solitaire] Completed game.");

                return(true);
            }

            return(false);
        }
    public static MissionEventDispatcher RegisterMissionEvent(this MonoBehaviour mono, MissionEnums.MissionId missionId, System.Action <object> callback)
    {
        if (ReferenceEquals(MissionEventDispatcher.InstanceAwake(), null))
        {
            LogGame.Error("[Mission Event] Mission Event Dispatcher Is Null!");
            return(null);
        }

        return(MissionEventDispatcher.Instance.RegisterEvent(missionId, callback));

        ;
    }
    public static void SetStateSound(bool IsEnable)
    {
        // =============================== SET THE STATE OF SOUND ================================ //

        if (ReferenceEquals(SoundManager.InstanceAwake(), null))
        {
            LogGame.Log("[Sound Manager] Sound Manager is null ... ");

            return;
        }

        SoundManager.Instance.SetStateSound(IsEnable);
    }
Beispiel #21
0
    public static void SetStateTutorial(this MonoBehaviour mono, TutorialEnums.TutorialId id, bool isCompleted)
    {
        PlayerData.SaveTutorial(id, isCompleted);

        if (ReferenceEquals(TutorialManager.InstanceAwake(), null))
        {
            LogGame.Log("[Tutorial Manager] Tutorial is null.");

            return;
        }

        TutorialManager.Instance.SetStateCompleted(isCompleted);
    }
Beispiel #22
0
    private void Init()
    {
        // =============================== INIT THE AD ================================ //

        MobileAds.Initialize(_AppId);

        reward = RewardBasedVideoAd.Instance;
        banner = new BannerView(_BannerId, AdSize.Banner, AdPosition.Bottom);

        LogGame.Log("[Ad Manager] Init Event Completed!");

        RefreshRemoveAds();
    }
    public static void PlayAudioMusic(this MonoBehaviour mono, AudioEnums.MusicId musicId, bool IsLoop = false, bool IsReset = true)
    {
        // =============================== PLAY THE MUSIC ================================ //

        if (ReferenceEquals(SoundManager.InstanceAwake(), null))
        {
            LogGame.Log("[Sound Manager] Sound Manager is null ... ");

            return;
        }

        SoundManager.Instance.PlayMusic(musicId, IsLoop, IsReset);

        LogGame.Log("[Sound Manager] Play The Music of Game ... ");
    }
    public static void PlayAudioSound(this MonoBehaviour mono, AudioEnums.SoundId soundId)
    {
        // =============================== PLAY THE SOUND ================================ //

        if (ReferenceEquals(SoundManager.InstanceAwake(), null))
        {
            LogGame.Log("[Sound Manager] Sound Manager is null ... ");

            return;
        }

        SoundManager.Instance.PlaySound(soundId);

        LogGame.Log("[Sound Manager] Play the sound of game ... ");
    }
Beispiel #25
0
    /// <summary>
    /// Instances the dialog.
    /// </summary>
    /// <returns>The dialog.</returns>
    /// <param name="dialog">Dialog.</param>
    protected GameObject InstanceDialog(DialogInterface dialog)
    {
        if (ReferenceEquals(dialog, null))
        {
            LogGame.DebugLog("[Dialog System] Can't find the dialog.");

            return(null);
        }

        var param = Instantiate(dialog.gameObject, this.transform) as GameObject;

        param.gameObject.SetActive(false);

        return(param);
    }
Beispiel #26
0
    /// <summary>
    /// Load this instance.
    /// </summary>
    public static void Load()
    {
        Debug.Log("--- Load ---");
        var stringGetEasy = PlayerValueEasy;

        var stringGetMedium = PlayerValueMedium;

        var stringGetHard = PlayerValueHard;

        // TODO: Check if this empty.
        if (string.IsNullOrEmpty(stringGetEasy))
        {
            // TODO: Create the new properties.
            playerPropertiesEasy = new PlayerProperties();
        }
        else
        {
            // TODO: Get the properties.
            playerPropertiesEasy = JsonUtility.FromJson <PlayerProperties> (stringGetEasy);
        }

        // TODO: Check if this empty.
        if (string.IsNullOrEmpty(stringGetMedium))
        {
            // TODO: Create the new properties.
            playerPropertiesMedium = new PlayerProperties();
        }
        else
        {
            // TODO: Get the properties.
            playerPropertiesMedium = JsonUtility.FromJson <PlayerProperties> (stringGetMedium);
        }

        // TODO: Check if this empty.
        if (string.IsNullOrEmpty(stringGetHard))
        {
            // TODO: Create the new properties.
            playerPropertiesHard = new PlayerProperties();
        }
        else
        {
            // TODO: Get the properties.
            playerPropertiesHard = JsonUtility.FromJson <PlayerProperties> (stringGetHard);
        }


        LogGame.DebugLog("LOADING...");
    }
    public static void ExecuteRewardAds(this MonoBehaviour mono, System.Action OnCompleted, System.Action OnFailed)
    {
        if (AdsManager.InstanceAwake() == null)
        {
            if (OnFailed != null)
            {
                OnFailed();
            }

            LogGame.Error("[Ad Manager] Ad Manager Is Null!");

            return;
        }

        AdsManager.Instance.RegisterEvent(OnCompleted, OnFailed);
        AdsManager.Instance.ShowRewardVideo();
    }
    public static MissionEventDispatcher PostMissionEvent(this MonoBehaviour mono, MissionEnums.MissionId missionId, object param = null)
    {
        if (PlayerData.Level < GameConfig.UnlockMissionLevel)
        {
            return(null);
        }

        if (ReferenceEquals(MissionEventDispatcher.InstanceAwake(), null))
        {
            LogGame.Error("[Mission Event] Mission Event Dispatcher Is Null!");
            return(null);
        }

        return(MissionEventDispatcher.Instance.PostEvent(missionId, param));

        ;
    }
    public MissionEventDispatcher RemoveEvent(MissionEnums.MissionId missionId, System.Action <object> action)
    {
        if (_PoolEvent.TryGetValue(MissionEnums.GetKey(missionId), out paramOut))
        {
            paramOut -= action;

            _PoolEvent[MissionEnums.GetKey(missionId)] = paramOut;

            LogGame.Log(string.Format("[Mission Manager] Remove the event with ID: {0}",
                                      MissionEnums.GetKey(missionId)));
        }
        else
        {
            LogGame.Log(string.Format("[Mission Manager] Not Found the event with ID: {0}",
                                      MissionEnums.GetKey(missionId)));
        }

        return(this);
    }
    public MissionEventDispatcher PostEvent(MissionEnums.MissionId missionId, object param)
    {
        if (!_PoolEvent.TryGetValue(MissionEnums.GetKey(missionId), out paramOut))
        {
            return(this);
        }

        if (ReferenceEquals(paramOut, null))
        {
            _PoolEvent.Remove(MissionEnums.GetKey(missionId));
            return(this);
        }

        paramOut(param);

        LogGame.Log(string.Format("[Action Manager] Post the event with ID: {0}",
                                  MissionEnums.GetKey(missionId)));
        return(this);
    }