Exemplo n.º 1
0
    public void SetQuantityBet(double bet, int index, float timeRun)
    {
        if (txtQuanityBet.Length <= 0)
        {
            return;
        }

        if (gameId == GameId.SLOT_MAFIA && index == 2)
        {
            VKDebug.LogColorRed(bet, "Mafia");
            txtQuanityBet[index].UpdateNumber(bet);
            txtQuanityBet[index].SetNumber(bet);
        }

        txtQuanityBet[index].StopValueChange();

        //if (bet - betEnd[index] < betSuggest && bet - betEnd[index] >= 0)
        //{
        //    bet = betEnd[index] + betSuggest;
        //    betEnd[index] = bet;
        //}
        //else if (bet - betEnd[index] < betSuggest && bet - betEnd[index] < 0)
        //{
        //    bet = betEnd[index] - betSuggest;
        //    betEnd[index] = bet;
        //}
        //else
        //{
        //    betEnd[index] = bet;
        //}

        txtQuanityBet[index].isMoney = true;
        txtQuanityBet[index].SetTimeRun(timeRun);
        txtQuanityBet[index].UpdateNumber(bet);
    }
Exemplo n.º 2
0
    private IEnumerator GetLinkDownload()
    {
        UnityWebRequest request = UnityWebRequest.Post(LinkGetCheck, "");

        yield return(request.SendWebRequest());

        if (request.isNetworkError || request.isHttpError)
        {
            VKDebug.LogError(request.error);
            popupStart.SetNotice("Kiểm tra kết nối. Kết nối server thật bại!");
        }
        else
        {
            if (keyUpdate != request.downloadHandler.text)
            {
                evn = Environment.review;
            }
            else
            {
            }
        }

        string uri = linkResource + GetEnvironment() + AssetBundleSetting.GetPlatform() + "gameconfig.txt";

        StartCoroutine(VKCommon.DownloadTextFromURL(uri, (string strConfig) =>
        {
            popupStart.SetNotice("Cập nhật dữ liệu...!");
            Database.Instance.LoadGameConfig(strConfig);
            AssetbundlesManager.Instance.assetSetting = Database.Instance.serverConfig.assetbundle;
            StartCoroutine(LoadYourAsyncScene());
        }));
    }
Exemplo n.º 3
0
    /// <summary>
    /// Buy Product
    /// </summary>
    /// <param name="productId">Id of IAP pack</param>
    /// <param name="callback">Buy callback, if callback is NULL, the defaut buy callback from InitializePurchasing will be use</param>
    public void BuyProductID(string productId, UnityAction <Product> callback = null)
    {
        if (IsInitialized())
        {
            Product product = m_StoreController.products.WithID(productId);

            if (product != null && product.availableToPurchase)
            {
                if (callback != null)
                {
                    // Override purchase callback
                    buyProductCallback = callback;
                }
                else
                {
                    buyProductCallback = buyProductCallbackDefault;
                }

                m_StoreController.InitiatePurchase(product);

                VKDebug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
            }
            else
            {
                VKDebug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
            }
        }
        else
        {
            VKDebug.Log("BuyProductID FAIL. Not initialized or Callback is null.");
        }
    }
    /// <summary>
    /// Returns an available object from the pool
    /// OR null in case the pool does not have any object available & can grow size is false.
    /// </summary>
    /// <param name="poolName"></param>
    /// <returns></returns>
    public GameObject GetObjectFromPool(string poolName, bool autoActive = true, int autoCreate = 0)
    {
        GameObject result = null;

        if (!poolDict.ContainsKey(poolName) && autoCreate > 0)
        {
            InitPool(poolName, autoCreate, PoolInflationType.INCREMENT);
        }

        if (poolDict.ContainsKey(poolName))
        {
            Pool pool = poolDict[poolName];
            result = pool.NextAvailableObject(autoActive);
            //scenario when no available object is found in pool
#if UNITY_EDITOR
            if (result == null)
            {
                VKDebug.LogWarning("[ResourceManager]:No object available in " + poolName);
            }
#endif
        }
#if UNITY_EDITOR
        else
        {
            VKDebug.LogError("[ResourceManager]:Invalid pool name specified: " + poolName);
        }
#endif
        return(result);
    }
    /// <summary>
    /// Return obj to the pool
    /// </summary>
    /// <param name="go"></param>
    public void ReturnObjectToPool(GameObject go)
    {
        PoolObject po = go.GetComponent <PoolObject>();

        if (po == null)
        {
#if UNITY_EDITOR
            VKDebug.LogWarning("Specified object is not a pooled instance: " + go.name);
#endif
        }
        else
        {
            Pool pool = null;
            if (poolDict.TryGetValue(po.poolName, out pool))
            {
                pool.ReturnObjectToPool(po);
            }
#if UNITY_EDITOR
            else
            {
                VKDebug.LogWarning("No pool available with name: " + po.poolName);
            }
#endif
        }
    }
Exemplo n.º 6
0
    public void NextTextField(VKButtonKeyboard bt)
    {
        if (bt.inputs != null && bt.inputs.Count > 0)
        {
            int max   = bt.inputs.Count;
            int index = bt.inputs.FindIndex(a => a.isFocused);

            VKDebug.LogWarning(index.ToString());
            if (index <= -1)
            {
                return;
            }
            else
            {
                index++;
                if (index >= max)
                {
                    index = 0;
                }

                VKDebug.LogWarning(index.ToString());
                EventSystem.current.SetSelectedGameObject(bt.inputs[index].gameObject, null);
            }
        }
    }
    protected void OnMethodCall(Hub hub, string method, params object[] args)
    {
        object[] copy = new object[args.Length];

        for (int i = 0; i < args.Length; i++)
        {
            Type t = args[i].GetType();
            if ((t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary <,>)) || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List <>)))
            {
                copy[i] = JsonConvert.SerializeObject(args[i]);
                VKDebug.LogColorRed(copy[i]);
            }
            else
            {
                copy[i] = args[i];
                VKDebug.LogColorRed(copy[i]);
            }
        }
        VKDebug.LogColorRed(method, "Call lua");
        xlua.InvokeXLua(method, copy);
        if (method == "startActionTimer")
        {
            VKDebug.LogColorRed(copy.Length, "so luong bien truyen cho LUA");
        }
    }
Exemplo n.º 8
0
    public void OnLoginReadCallBack(ILoginResult result)
    {
        string aToken = "";

        Debug.Log("error nay___________ " + result.Error);

        try
        {
            aToken = AccessToken.CurrentAccessToken.TokenString;
        }
        catch
        {
            VKDebug.LogError("Can't load token");
        }

        if (OnFacebookResult != null)
        {
            OnFacebookResult(FacebookAction.Login, result, aToken);
        }

        if (onFaceBookResultLua != null)
        {
            onFaceBookResultLua.Invoke(FacebookAction.Login, result, aToken);
        }
    }
Exemplo n.º 9
0
    public void InitLayer(string layerKey, float screenRatio)
    {
        // If Exist xlua when run Xlua
        xlua = gameObject.GetComponent <XLuaBehaviour>();
        if (xlua != null)
        {
            xlua.InvokeXLua("InitLayer", layerKey.ToString(), screenRatio);
        }

        isLayerAnimOpenDone = false;

        this.layerKey    = layerKey;
        canvas           = GetComponent <Canvas>();
        anim             = GetComponent <Animator>();
        graphicRaycaster = GetComponent <GraphicRaycaster>();

#if UNITY_EDITOR
        if (canvas == null)
        {
            VKDebug.LogError("Layer need a Canvas");
        }
        if (graphicRaycaster == null)
        {
            VKDebug.LogError("Layer need a GraphicRaycaster");
        }
#endif
    }
Exemplo n.º 10
0
 public void LoadGameConfig(string config)
 {
     if (!string.IsNullOrEmpty(config))
     {
         VKDebug.LogWarning("config " + config);
         serverConfig = JsonUtility.FromJson <ServerConfig>(config);
     }
 }
Exemplo n.º 11
0
    public override void OnWebServiceResponse(WebServiceCode.Code code, WebServiceStatus.Status status, string data)
    {
        switch (code)
        {
        case WebServiceCode.Code.GenCaptcha:
            if (status == WebServiceStatus.Status.OK)
            {
                captchaData = JsonUtility.FromJson <MCaptchaResponse>(data);

                StartCoroutine(VKCommon.LoadImageFromBase64(imageCaptach, captchaData.Data, 0f));
            }
            else
            {
                LPopup.OpenPopupTop("Thông báo", "Không lấy được Captcha. Hãy thử lại!");
            }
            break;

        case WebServiceCode.Code.TopupInfo:
            if (status == WebServiceStatus.Status.OK)
            {
                VKDebug.LogColorRed("TopupInfo", data);
                listInfoTopup = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CardCheck> >(data);


                isGetDataInfoSuccess = true;
                SetLayoutTypeCard();
            }
            break;

        case WebServiceCode.Code.Topup:
        {
            UILayerController.Instance.HideLoading();
            if (status == WebServiceStatus.Status.OK)
            {
                VKDebug.LogColorRed("Topup", data);

                var dataReponse = Newtonsoft.Json.JsonConvert.DeserializeObject <TopupResponse>(data);

                if (dataReponse.ErrorCode <= 0)
                {
                    LPopup.OpenPopupTop("Thông báo", dataReponse.Message);
                    GetCaptcha();
                }
                else
                {
                    Database.Instance.UpdateUserGold(dataReponse.Balance);
                    LPopup.OpenPopupTop("Thông báo", "Nạp thẻ thành công!");
                }
            }
            else
            {
                LPopup.OpenPopupTop("Thông báo", "Hãy kiểm tra lại kết nối!");
            }
            break;
        }
        }
    }
Exemplo n.º 12
0
    public override void HideLayer()
    {
        base.HideLayer();

        WebServiceController.Instance.OnWebServiceResponse -= OnWebServiceResponse;
        Database.Instance.OnUserUpdateGoldEvent            -= OnUserUpdateGold;
        Database.Instance.OnUserUpdateCoinEvent            -= OnUserUpdateCoin;

        VKDebug.LogColorRed("Hide Farm");
    }
    protected void HubUpdateJackpot(Hub hub, MethodCallMessage msg)
    {
        VKDebug.Log(msg.Arguments[0].ToString());
        jackpots = LitJson.JsonMapper.ToObject <Dictionary <string, double> >(msg.Arguments[0].ToString());

        if (OnSRSHubEvent != null)
        {
            OnSRSHubEvent.Invoke(SRSConst.UPDATE_JACKPOT, msg.Arguments);
        }
    }
Exemplo n.º 14
0
    public static void WriteBinaryToFile(string fileName, byte[] newData)
    {
        VKDebug.Log("Write Binary File To : " + fileName);
        FileStream   file = File.Create(GetPath(fileName));
        BinaryWriter bw   = new BinaryWriter(file);

        bw.Write(newData);
        bw.Close();
        file.Close();
    }
    public void HubCallAndResult(string method, Action <string> callback, params object[] args)
    {
        OnMethodResultDelegate onResult = (Hub hub, ClientMessage originalMessage, ResultMessage result) =>
        {
            VKDebug.LogColorRed("Lua Call reponse CallBack", method);
            callback(JsonConvert.SerializeObject(result.ReturnValue));
        };

        _hub.Call(method, onResult, args);
    }
Exemplo n.º 16
0
    protected void RaiseWebServiceResponse(WebServiceCode.Code code, WebServiceStatus.Status status, string data)
    {
        if (OnWebServiceResponse != null)
        {
            OnWebServiceResponse(code, status, data);
            VKDebug.Log("Reponse: " + code.ToString() + "  " + data, VKCommon.HEX_ORANGE);
        }

        onWebServiceResponseLua.Invoke(code, status, data);
    }
 public void ClearCache()
 {
     if (Caching.ClearCache())
     {
         VKDebug.Log("Successfully cleaned the cache.");
     }
     else
     {
         VKDebug.Log("Cache is being used.");
     }
 }
Exemplo n.º 18
0
 public void SetAvatar(int id)
 {
     try
     {
         imgIconUser.sprite = dataResourceLobby.listSpriteAvatar[id];
     }
     catch
     {
         VKDebug.LogColorRed("Khong co");
     }
 }
Exemplo n.º 19
0
    public void Add(VKButtonKeyboard bt)
    {
        if (!buttons.ContainsKey(bt.key))
        {
            buttons.Add(bt.key, new List <VKButtonKeyboard>());
        }

        buttons[bt.key].Insert(0, bt);
        AddCurrent(bt);
        VKDebug.LogWarning("Add VKButtonKeyboard");
    }
Exemplo n.º 20
0
 public void SetAvatar(int id)
 {
     try
     {
         imgAvartar.sprite = DataResourceLobby.instance.listSpriteAvatar[id];
     }
     catch
     {
         VKDebug.LogColorRed("Khong co");
     }
 }
Exemplo n.º 21
0
 public Product[] GetAllProducts()
 {
     if (IsInitialized())
     {
         return(m_StoreController.products.all);
     }
     else
     {
         VKDebug.Log("IAP is not Init, return null");
         return(null);
     }
 }
Exemplo n.º 22
0
 private void SaveTextureToFile(Texture2D texture, string filename)
 {
     try
     {
         System.IO.File.WriteAllBytes(Application.persistentDataPath + "/" + filename, texture.EncodeToPNG());
         VKDebug.LogColorRed("Save file Success");
     }
     catch
     {
         VKDebug.LogColorRed("Save file failer");
     }
 }
Exemplo n.º 23
0
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        m_StoreController        = controller;
        m_StoreExtensionProvider = extensions;

        if (initializedCallback != null)
        {
            initializedCallback();
        }

        VKDebug.Log("On Initialized Success");
    }
        protected override void Awake()
        {
            base.Awake();
            directionSign = 1;

            GridLayoutGroup layout = content.GetComponent <GridLayoutGroup>();

            if (layout != null && layout.constraint != GridLayoutGroup.Constraint.FixedRowCount)
            {
                VKDebug.LogError("[LoopHorizontalScrollRect] unsupported GridLayoutGroup constraint");
            }
        }
Exemplo n.º 25
0
    private void LoadEvent()
    {
        VKDebug.LogColorRed("Load Texture OFFline");

        var quanity = PlayerPrefs.GetInt(keyNumberEvent);

        for (int i = 0; i < quanity; i++)
        {
            var texture = LoadTextureFromFile(string.Format(keyNameSaveSprite, i));
            SpawnEvent(texture);
        }
        LoopNextEvents();
    }
Exemplo n.º 26
0
    /// <summary>
    /// Return obj to the pool
    /// </summary>
    /// <param name="t"></param>
    public void ReturnTransformToPool(Transform t)
    {
        if (t == null)
        {
#if UNITY_EDITOR
            VKDebug.LogError("[ResourceManager] try to return a null transform to pool!");
#endif
            return;
        }
        //set gameobject active flase to avoid a onEnable call when set parent
        t.gameObject.SetActive(false);
        t.SetParent(null, false);
        ReturnObjectToPool(t.gameObject);
    }
Exemplo n.º 27
0
    private void DownloadSuccess(Texture2D texture)
    {
        VKDebug.LogColorRed("Download Success");
        SpawnEvent(texture);

        SaveTextureToFile(texture, string.Format(keyNameSaveSprite, quanityDownloadSuccess));
        quanityDownloadSuccess++;

        if (quanityDownloadSuccess >= dataEventImage.links.Length)
        {
            SaveDataLocal();
            LoopNextEvents();
        }
    }
Exemplo n.º 28
0
 public void LoginSuccess(string token)
 {
     if (!Database.Instance.Account().IsOTP)
     {
         VKDebug.LogColorRed("Login Succes Non OTP");
         LoginSuccessWithOTP(true);
     }
     else
     {
         Database.Instance.tokenOTPLogin = token;
         UILayerController.Instance.ShowLayer(UILayerKey.LLogInWithOTP, DataResourceLobby.instance.listObjLayer[(int)IndexSourceGate.LLOGIN_WITH_OTP]);
         VKDebug.LogColorRed("Hien Layout Get OTP");
     }
 }
        protected override void SendImpl(string json)
        {
#if UNITY_EDITOR
            if (!string.IsNullOrEmpty(json))
            {
                VKDebug.Log(json, VKCommon.HEX_ORANGE);
            }
#endif

            if (wSocket != null && wSocket.IsOpen)
            {
                wSocket.Send(json);
            }
        }
Exemplo n.º 30
0
    private void DownloadImageEvent(MEventImage data)
    {
        if (!IsUpdateVersion(data))
        {
            LoadEvent();
            return;
        }

        for (int i = 0; i < data.links.Length; i++)
        {
            VKDebug.LogColorRed("Link Download", data.links[i]);
            StartCoroutine(DownloadImageFromURL(data.links[i]));
        }
    }