Example #1
0
    private void LoadEquippedData()
    {
        _txtState.text = "Loading shop init data...";
        if (!PlayerPrefs.HasKey(Constant.SHOPINIT))
        {
            StartCoroutine(ServerAdapter.LoadShopInit(result =>
            {
                if (result.StartsWith("Error"))
                {
                    Debug.LogError("Load shopinit failed!");
                }
                else
                {
                    PlayerPrefs.SetString(Constant.SHOPINIT, result);

                    SplitDataFromServe.ReadShopInitData(result);
                    StartCoroutine(CharacterItemInGame.Instance.ExecuteGetMonsterResource());
                }
            }));
        }
        else
        {
            SplitDataFromServe.ReadShopInitData(PlayerPrefs.GetString(Constant.SHOPINIT));
            StartCoroutine(CharacterItemInGame.Instance.ExecuteGetMonsterResource());
        }
    }
Example #2
0
    IEnumerator LoadDataDetailHero(int _idhero, string _idcode)
    {
        StartCoroutine(ServerAdapter.ListSkillOfHero(_idhero, _idcode, result =>
        {
            if (result.StartsWith("Error"))
            {
                Debug.Log("Do nothing");
            }
            else
            {
                SplitDataFromServe.ReadSkillHeroData(result.ToString());
            }
        }));


        yield return(StartCoroutine(ServerAdapter.LoadDetailHero(_idcode, _idhero, result =>
        {
            if (result.StartsWith("Error"))
            {
                Debug.Log("Do nothing");
                ShowPopupError(6);
            }
            else
            {
                SplitDataFromServe.ReadDetailDataHeroCurrentPlay(result);
                SplitDataFromServe.ReadItemInBagData(result);
                StartCoroutine(SceneLoader._instance.LoadNewScene(2));
            }
        })));
    }
Example #3
0
    public void ChangeNameHero()
    {
        string newName = _nameHero.text;

        if (!string.IsNullOrEmpty(newName) && newName.Length >= 6 && newName.Length <= 20)
        {
            StartCoroutine(ServerAdapter.ChangeName(newName, CharacterInfo._instance._baseProperties.idCodeHero, CharacterInfo._instance._baseProperties.idHero, result =>
            {
                if (result.StartsWith("Error"))
                {
                    MainMenuUI._instance.ShowErrorPopup(9);
                }
                else
                {
                    SplitDataFromServe._heroCurrentPLay.name     = newName;
                    CharacterInfo._instance._baseProperties.name = newName;
                    _changeNamePanel.SetActive(false);
                    nameText.text = CharacterInfo._instance._baseProperties.name.ToString();
                    this.PostEvent(EventID.OnPropertiesChange);
                    //SplitDataFromServe.ReadInitData(result);
                }
            }));
        }
        else
        {
            MainMenuUI._instance.ShowErrorPopup(8);
        }
    }
Example #4
0
 public void BtnUpgradeCombine()
 {
     if (isRollingInforce)
     {
         return;
     }
     if (_numberCombine > 0)
     {
         if (CharacterInfo._instance._baseProperties.Gold < _numberGoldNeeded)
         {
             Debug.LogError("Không có vàng mà đòi đú");
         }
         else
         {
             isRollingInforce = true;
             _timeRolling     = _effectPatternUpgrade._timeRolling;
             isHaveResult     = false;
             _resultUpgrade   = string.Empty;
             _effectPatternUpgrade.StartRolling();
             StartCoroutine(ServerAdapter.UpgradeCombineRunestone(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                  int.Parse(_itemRuneMaterial.getValue("idhg").ToString()), _numberMaterialRunstoneNeed, _numberGoldNeeded,
                                                                  result =>
             {
                 isHaveResult   = true;
                 _resultUpgrade = result;
             }));
         }
     }
 }
 public void BtnAddingRunestone()
 {
     if (isRollingInforce)
     {
         return;
     }
     if (_mainEquip != null && _itemRunstone != null)
     {
         isRollingInforce = true;
         _timeRolling     = _effectPatternUpgrade._timeRolling;;
         isHaveResult     = false;
         _resultUpgrade   = string.Empty;
         _effectPatternUpgrade.StartRolling();
         if (_mainEquip.typeItem == TypeEquipmentCharacter.Avatar)
         {
             StartCoroutine(ServerAdapter.UpgradeAddingRunestoneAvatar(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                       _mainEquip.idItem, int.Parse(_itemRunstone.getValue("idhg").ToString()),
                                                                       result =>
             {
                 isHaveResult   = true;
                 _resultUpgrade = result;
             }));
         }
         else
         {
             StartCoroutine(ServerAdapter.UpgradeAddingRunestone(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                 _mainEquip.idItem, int.Parse(_itemRunstone.getValue("idhg").ToString()),
                                                                 result =>
             {
                 isHaveResult   = true;
                 _resultUpgrade = result;
             }));
         }
     }
 }
Example #6
0
    internal IEnumerator LoginByDefault()
    {
        _txtState.text = "Verifying account...";
        yield return(new WaitForSeconds(1));

        string deviceID     = SystemInfo.deviceUniqueIdentifier;
        int    typePlatform = 0;

#if UNITY_ANROID || UNITY_EDITOR
        typePlatform = 0;
#elif UNITY_IOS
        typePlatform = 1;
#endif
        string defaultName     = string.Format("Guest{0}", deviceID.Substring(0, 6));
        string defaultUserName = PlayerPrefs.GetString(Constant.USER_NAME);
        string defaultPassword = PlayerPrefs.GetString(Constant.PASSWORD);

        yield return(StartCoroutine(ServerAdapter.Login(defaultUserName, defaultPassword, defaultName, deviceID, typePlatform, result =>
        {
            if (result.StartsWith("Error"))
            {
                isHaveError = true;
                dataError = result;
                ShowPopupError(5);
            }
            else
            {
                ReadDataAccount(result);
            }
        })));
    }
Example #7
0
 public void GetGoldByGems(int _gems)
 {
     if (CharacterInfo._instance._baseProperties.Diamond >= _gems)
     {
         StartCoroutine(ServerAdapter.ReduceCustomValue(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, "diamond", _gems, result1 =>
         {
             if (result1.StartsWith("Error"))
             {
                 Debug.Log("Do nothing");
             }
             else
             {
                 StartCoroutine(ServerAdapter.AddCustomValue(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, "gold", 5000, result2 =>
                 {
                     if (result2.StartsWith("Error"))
                     {
                         Debug.Log("Do nothing");
                     }
                     else
                     {
                         CharacterInfo._instance._baseProperties.Gold    += 5000;
                         CharacterInfo._instance._baseProperties.Diamond -= _gems;
                         this.PostEvent(EventID.OnPropertiesChange);
                     }
                 }));
             }
         }));
     }
 }
Example #8
0
    public void BtnReinforceEquipment()
    {
        if (isRollingInforce)
        {
            return;
        }
        if (_mainEquip == null)
        {
            //TextNotifyScript.instance.SetData("Please insert the Equipment into reinforcement window!");
            return;
        }
        if (_numberAlchemyMaterial <= 0)
        {
            TextNotifyScript.instance.SetData("Not enough material to upgrade!");
            return;
        }
        isRollingInforce = true;
        _timeRolling     = _effectPatternUpgrade._timeRolling;
        isHaveResult     = false;
        _resultUpgrade   = string.Empty;
        _effectPatternUpgrade.StartRolling();

        if (isSpecialUpgrade)
        {
            if (_mainEquip.typeItem == TypeEquipmentCharacter.Avatar)
            {
                StartCoroutine(ServerAdapter.UpgradeReinforceAvatar(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                    _mainEquip.idItem, int.Parse(_itemAlchemyMaterial.getValue("idhg").ToString()),
                                                                    (_LuckyMaterial == null ? 0 : int.Parse(_LuckyMaterial.getValue("idht").ToString())),
                                                                    result =>
                {
                    isHaveResult   = true;
                    _resultUpgrade = result;
                }));
            }
            else
            {
                StartCoroutine(ServerAdapter.UpgradeReinforceBook(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                  _mainEquip.idItem, int.Parse(_itemAlchemyMaterial.getValue("idhg").ToString()),
                                                                  (_LuckyMaterial == null ? 0 : int.Parse(_LuckyMaterial.getValue("idht").ToString())),
                                                                  result =>
                {
                    isHaveResult   = true;
                    _resultUpgrade = result;
                }));
            }
        }
        else
        {
            StartCoroutine(ServerAdapter.UpgradeReinforceEquipment(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                   _mainEquip.idItem, int.Parse(_itemAlchemyMaterial.getValue("idhg").ToString()),
                                                                   (_LuckyMaterial == null ? 0 : int.Parse(_LuckyMaterial.getValue("idht").ToString())),
                                                                   result =>
            {
                isHaveResult   = true;
                _resultUpgrade = result;
            }));
        }
    }
Example #9
0
    //IEnumerator LoadImgItem(Image _img, int _idInitItem, int _typeItem)
    //{
    //    if (_typeItem == 1)
    //    {
    //        yield return StartCoroutine(ControllerItemsInGame._instance.GetIconForEquipmentByID(_idInitItem, value => _img.sprite = value));
    //    }
    //    else if (_typeItem == 2)
    //    {
    //        yield return StartCoroutine(ControllerItemsInGame._instance.GetIconForItemByID(_idInitItem, value => _img.sprite = value));
    //    }
    //    else if (_typeItem == 3)
    //    {
    //        yield return StartCoroutine(ControllerItemsInGame._instance.GetIconForGemsByID(_idInitItem, value => _img.sprite = value));
    //    }
    //}


    void SellItem()
    {
        if (isGem)
        {
            StartCoroutine(ServerAdapter.SellGem(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, idHeroItem, _numberSell,
                                                 result =>
            {
                if (result.StartsWith("Error"))
                {
                    TextNotifyScript.instance.SetData(result);
                }
                else
                {
                    var N = JSON.Parse(result);
                    if (N["quantity"].AsInt == 0)
                    {
                        SplitDataFromServe._listGemInBag.Remove(_itemCached);
                    }
                    else
                    {
                        _itemCached.setValue("quantity", _maxQuantity - _numberSell);
                    }

                    CharacterInfo._instance._baseProperties.Gold += N["goldplus"].AsInt;

                    this.PostEvent(EventID.OnPropertiesChange);

                    _myStorage.DisplayGemInBag(true);
                }
            }));
        }
        else
        {
            StartCoroutine(ServerAdapter.SellItem(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, idHeroItem, _numberSell,
                                                  result =>
            {
                if (result.StartsWith("Error"))
                {
                    TextNotifyScript.instance.SetData(result);
                }
                else
                {
                    if (_numberSell == _maxQuantity)
                    {
                        SplitDataFromServe._listItemInBag.Remove(_itemCached);
                    }
                    else
                    {
                        _itemCached.setValue("quantity", _maxQuantity - _numberSell);
                    }
                    CharacterInfo._instance._baseProperties.Gold += _numberSell * _pricePerOne;
                    this.PostEvent(EventID.OnPropertiesChange);

                    _myStorage.DisplayItemInBag(true);
                }
            }));
        }
        ClosePopup();
    }
Example #10
0
            public void  Dispose()
            {
                ClientAdapter.Dispose();
                ServerAdapter.Dispose();
                ((IDisposable)Graph).Dispose();

                GeneralUtils.AbortThread(NegotiationThread);
            }
Example #11
0
    public void AddAttributePoint(int id)
    {
        if (CharacterInfo._instance._baseProperties.AttributePoint >= 1)
        {
            switch (id)
            {
            case 0:
                StartCoroutine(ServerAdapter.AddAttributePoint(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, 1, "vitality", result =>
                {
                    if (result.StartsWith("Error"))
                    {
                        Debug.Log("Do nothing");
                    }
                    else
                    {
                        CharacterInfo._instance._baseProperties.AttributePoint--;
                        CharacterInfo._instance._baseProperties.Vitality++;
                        UpdateTxtValueProperties();
                    }
                }));
                break;

            case 1:
                StartCoroutine(ServerAdapter.AddAttributePoint(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, 1, "strength", result =>
                {
                    if (result.StartsWith("Error"))
                    {
                        Debug.Log("Do nothing");
                    }
                    else
                    {
                        CharacterInfo._instance._baseProperties.AttributePoint--;
                        CharacterInfo._instance._baseProperties.Strength++;
                        UpdateTxtValueProperties();
                    }
                }));
                break;

            case 2:
                StartCoroutine(ServerAdapter.AddAttributePoint(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, 1, "intelligence", result =>
                {
                    if (result.StartsWith("Error"))
                    {
                        Debug.Log("Do nothing");
                    }
                    else
                    {
                        CharacterInfo._instance._baseProperties.AttributePoint--;
                        CharacterInfo._instance._baseProperties.Intelligence++;
                        UpdateTxtValueProperties();
                    }
                }));
                break;
            }
        }
    }
Example #12
0
    IEnumerator LoadDataDetailEnemyHero(int _idhero, string _idcode)
    {
        StartCoroutine(ServerAdapter.ListSkillOfHero(_idhero, _idcode, result =>
        {
            if (result.StartsWith("Error"))
            {
                Debug.Log("Do nothing");
            }
            else
            {
                SplitDataFromServe.ReadEnemySkillData(result.ToString());
            }
        }));

        WWWForm form = new WWWForm();

        form.AddField("idh", _idhero);
        form.AddField("idcode", _idcode);
        WWW w = new WWW(Constant.urlRequest + "/api/hero/detail", form);

        yield return(w);

        string data = w.text;
        var    N    = JSONNode.Parse(data);

        if (Boolean.Parse(N["return"]))
        {
            SplitDataFromServe.ReadDetailDataHeroEnemyPlay(N["data"].ToString());
            GameObject enemy = Instantiate(CharacterItemInGame.Instance._characterPrefabs[ConvertIdClassToClassName(SplitDataFromServe._heroEnemyPlay.idclass).ToString()]);
            enemy.transform.position   = new Vector3(5.5f, -2f, 0f);
            enemy.transform.localScale = new Vector3(-1f, 1f, 1f);
            _enemyCharacter            = enemy.AddComponent <CharacterPlayer>();
            CharacterPlayer.LoadCharacterEnemy(_enemyCharacter);
            //enemy.AddComponent<AnimationController>();
            enemy.SetActive(false);
            WaitingRoomUI.Instance.SetLog("Load data nhan vat thanh cong");
            if (!SocketIOController.Instance.isReconnect)
            {
                WaitingRoomUI.Instance.SetLog("Tao timeout confirm load nhan vat thanh cong");
                this.PostEvent(EventID.CreateTimeoutConfirmLoadData);
            }
            if (SocketIOController.Instance.isReconnect)
            {
                this.PostEvent(EventID.ReconnectBattleScene);
            }
            WatingRoomController.Instance.state_waitingroom = STATEINWAITING.CONFIRM_LOADDATA;
        }
        else if (!Boolean.Parse(N["return"]))
        {
            Debug.Log("Do nothing");
        }
        // if Master create timeout for done B request
        // if Slave send done slave, create timeout for done A response
    }
Example #13
0
 public void GetDiamond(int _numberDiamond)
 {
     StartCoroutine(ServerAdapter.AddCustomValue(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, "diamond", _numberDiamond, result => {
         if (result.StartsWith("Error"))
         {
             Debug.Log("Do nothing");
         }
         else
         {
             CharacterInfo._instance._baseProperties.Diamond += 5000;
             this.PostEvent(EventID.OnPropertiesChange);
         }
     }));
 }
Example #14
0
    public void ChangeEquipment()
    {
        /* 3 class cần tham gia thay đổi
         * EquipmentsCharacer cần mặc trang bị mới
         * PlayerBag cần nhận thêm trang bị cũ
         * FittingRoomController cần update hình ảnh
         */
        int id = _lastIndexSelected;

        if (_equipmentsCharacter == null)
        {
            _equipmentsCharacter = CharacterInfo._instance._myEquipments;
        }
        if (_equipmentsCharacter.IsCanEquipItem(_myEquipItems[id]))
        {
            StartCoroutine(ServerAdapter.ExecuteChangeEquipment(_myEquipItems[id], result =>
            {
                if (result.StartsWith("Error"))
                {
                    TextNotifyScript.instance.SetData(result);
                }
                else
                {
                    //Debug.Log(_myTypeBag);
                    _tempItem = _equipmentsCharacter.MappingTypeItemToItem(_myTypeBag);
                    //Debug.Log(_tempItem);
                    if (_tempItem != null)
                    {
                        SplitDataFromServe._listEquipmentInBag.Add(_tempItem);
                        //CharacterInfo._instance._baseProperties.RemoveBonusItem(_tempItem);
                    }
                    _equipmentsCharacter.EquipItem(_myTypeBag, _myEquipItems[id]);
                    if (_myEquipItems[id].typeItem == TypeEquipmentCharacter.OffhandWeapon)
                    {
                        _myEquipItems[id].typeItem = TypeEquipmentCharacter.Weapon;
                    }
                    SplitDataFromServe._listEquipmentInBag.Remove(_myEquipItems[id]);
                    //CharacterInfo._instance._baseProperties.AddBonusItem(_myEquipItems[id]);

                    ItemInforController.instance.MakeEvent("UpdateEquipment");
                    this.gameObject.SetActive(false);
                }
            }));
        }
        else
        {
            MainMenuUI._instance.ShowErrorPopup(7);
        }
    }
Example #15
0
 public void GetFreeGold()
 {
     StartCoroutine(ServerAdapter.AddCustomValue(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, "gold", 5000, result =>
     {
         if (result.StartsWith("Error"))
         {
             Debug.Log("Do nothing");
         }
         else
         {
             CharacterInfo._instance._baseProperties.Gold += 5000;
             this.PostEvent(EventID.OnPropertiesChange);
         }
     }));
 }
Example #16
0
    IEnumerator ConnectServer()
    {
        _txtState.text = "Connecting to getway server...";
        yield return(new WaitForSeconds(1));

        isNeedUpdateVersion = false;
        int _currentVersion = PlayerPrefs.GetInt("CURRENT_VERSION", 1);

        yield return(StartCoroutine(ServerAdapter.CheckServer(result =>
        {
            if (result.StartsWith("Error"))
            {
                isHaveError = true;
                dataError = result;
            }
            else
            {
                var N = CoreLib.JSON.Parse(result);
                if (N["version"] != null)
                {
                    int _serverVersion = N["version"].AsInt;
                    if (_serverVersion != _currentVersion)
                    {
                        isNeedUpdateVersion = true;
                    }
                }
                if (N["notify"] != null)
                {
                    _dataNotify = N["notify"].Value;
                    //if (_serverVersion > 1)
                    _myPopupNotify.SetActive(true);
                    //else _btnNotifyPopup.SetActive(false);
                }
                if (N["status"] != null)
                {
                    if (N["status"].Value.Equals("maintain"))
                    {
                        isHaveError = true;
                        dataError = "Server is maintaining. Please come back later!";
                    }
                }
            }
        })));
    }
Example #17
0
 public void GetRewardAutofarm()
 {
     StartCoroutine(ServerAdapter.GetRewardFromMonster(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, 10, 100, result => {
         if (result.StartsWith("Error"))
         {
             Debug.Log("do nothing");
         }
         else
         {
             Debug.Log(result);
             var N = JSONNode.Parse(result);
             int numberItemEquipReceved          = N.Count;
             EquipItemReward[] _listItemReceived = new EquipItemReward[numberItemEquipReceved];
             for (int i = 0; i < numberItemEquipReceved; i++)
             {
                 _listItemReceived[i] = JsonUtility.FromJson <EquipItemReward>(N[i].ToString());
             }
         }
     }));
 }
Example #18
0
    public void BtnDismantleEquipment()
    {
        if (isRollingInforce)
        {
            return;
        }
        if (_mainEquip != null)
        {
            isRollingInforce = true;
            _timeRolling     = _effectPatternUpgrade._timeRolling;
            isHaveResult     = false;
            _resultUpgrade   = string.Empty;
            _effectPatternUpgrade.StartRolling();

            StartCoroutine(ServerAdapter.UpgradeDismantleEquipment(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                                   _mainEquip.idItem, result =>
            {
                isHaveResult   = true;
                _resultUpgrade = result;
            }));
        }
    }
Example #19
0
    internal IEnumerator LoginByAccount(string user, string pass, Action <bool> isLoginComplete)
    {
        _txtState.text = "Verifying account...";
        yield return(new WaitForSeconds(1));

        string deviceID = SystemInfo.deviceUniqueIdentifier;

        yield return(StartCoroutine(ServerAdapter.SwitchAccount(user, pass, deviceID, result =>
        {
            if (result.StartsWith("Error"))
            {
                isHaveError = true;
                dataError = result;
                ShowPopupError(5);
                isLoginComplete(false);
            }
            else
            {
                isLoginComplete(true);
                ReadDataAccount(result);
            }
        })));
    }
Example #20
0
 IEnumerator LoadInitData()
 {
     _txtState.text = "Loading game init data...";
     if (!PlayerPrefs.HasKey(Constant.AllINIT))
     {
         yield return(StartCoroutine(ServerAdapter.LoadInitData(result =>
         {
             if (result.StartsWith("Error"))
             {
                 Debug.LogError("Load Init data failed!");
             }
             else
             {
                 PlayerPrefs.SetString(Constant.AllINIT, result);
                 SplitDataFromServe.ReadInitData(result);
             }
         })));
     }
     else
     {
         SplitDataFromServe.ReadInitData((PlayerPrefs.GetString(Constant.AllINIT)));
     }
     yield return(null);
 }
Example #21
0
    public void OnDrop(PointerEventData eventData)
    {
        if (GetDropObject(eventData) != null && GetDropObject(eventData).tag == "Skill")
        {
            Debug.Log("switch skill slot");
            Sprite   dropSprite     = gameObject.GetComponent <Image>().sprite;
            Sprite   dragSprite     = GetDropObject(eventData).GetComponent <Image>().sprite;
            NewSkill dropSkill      = gameObject.GetComponent <DropHandle>().dataSkill;
            NewSkill dragSkill      = GetDropObject(eventData).GetComponent <DragHandeler>().dataSkill;
            int      indexDropSkill = PlayerPrefs.GetInt(gameObject.GetComponent <DropHandle>().dataSkill.data["idhk"].Value);
            int      indexDragSkill = PlayerPrefs.GetInt(GetDropObject(eventData).GetComponent <DragHandeler>().dataSkill.data["idhk"].Value);

            PlayerPrefs.SetInt(GetDropObject(eventData).GetComponent <DropHandle>().dataSkill.data["idhk"].Value, indexDropSkill);
            PlayerPrefs.SetInt(gameObject.GetComponent <DropHandle>().dataSkill.data["idhk"].Value, indexDragSkill);
            this.gameObject.GetComponent <Image>().sprite          = dragSprite;
            GetDropObject(eventData).GetComponent <Image>().sprite = dropSprite;
            this.gameObject.GetComponent <DragHandeler>().SetDataSkill(dragSkill);
            this.gameObject.GetComponent <DropHandle>().SetDataSkill(dragSkill);
            GetDropObject(eventData).GetComponent <DragHandeler>().SetDataSkill(dropSkill);
            GetDropObject(eventData).GetComponent <DropHandle>().SetDataSkill(dropSkill);
        }
        else if (GetDropObject(eventData) != null && GetDropObject(eventData).tag == "SkillInList")
        {
            Sprite   dragSprite     = GetDropObject(eventData).GetComponent <Image>().sprite;
            NewSkill dragSkill      = GetDropObject(eventData).GetComponent <DragHandeler>().dataSkill;
            NewSkill dropSkill      = gameObject.GetComponent <DropHandle>().dataSkill;
            int      indexDropSkill = PlayerPrefs.GetInt(gameObject.GetComponent <DropHandle>().dataSkill.data["idhk"].Value);
            if (dragSkill.data["idInit"].AsInt != dropSkill.data["idInit"].AsInt && !checkHeroWearedSkill(dragSkill))
            {
                StartCoroutine(ServerAdapter.UnEquipSkill(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, dropSkill.data["idhk"].AsInt, result =>
                {
                    Debug.Log(result.ToString());
                    if (result.StartsWith("Error"))
                    {
                        Debug.Log("Do nothing");
                    }
                    else
                    {
                        Debug.Log("remove old skill ok");
                        foreach (NewSkill _tempSkill in SplitDataFromServe._heroSkill)
                        {
                            if (dropSkill.data["idhk"].AsInt == _tempSkill.data["idhk"].AsInt)
                            {
                                _tempSkill.addField("typewear", 0);
                                break;
                            }
                        }
                        StartCoroutine(ServerAdapter.EquipSkill(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, dragSkill.data["idhk"].AsInt, result1 =>
                        {
                            Debug.Log(result1.ToString());
                            if (result1.StartsWith("Error"))
                            {
                                Debug.Log("Do nothing");
                            }
                            else
                            {
                                Debug.Log("change skill ok");
                                foreach (NewSkill _tempSkill in SplitDataFromServe._heroSkill)
                                {
                                    if (dragSkill.data["idhk"].AsInt == _tempSkill.data["idhk"].AsInt)
                                    {
                                        _tempSkill.addField("typewear", 1);
                                        break;
                                    }
                                }
                                PlayerPrefs.DeleteKey(dropSkill.data["idhk"].Value);
                                PlayerPrefs.SetInt(dragSkill.data["idhk"].Value, indexDropSkill);
                                this.gameObject.GetComponent <Image>().sprite = dragSprite;
                                this.gameObject.GetComponent <DragHandeler>().SetDataSkill(dragSkill);
                                this.gameObject.GetComponent <DropHandle>().SetDataSkill(dragSkill);
                            }
                        }));
                    }
                }));
            }
            else
            {
                Debug.Log("Do nothing");
            }
        }
    }
Example #22
0
    void ExecuteBuyItemFuction()
    {
#if UNITY_EDITOR
        Debug.Log("BUY item " + ShopUI._instance._cachedIDItemBuy);
#endif
        StartCoroutine(ServerAdapter.BuyItemInShop(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, ShopUI._instance._cachedIDItemBuy, qtt, result =>
        {
            if (result.StartsWith("Error"))
            {
                Debug.Log("do nothing");
            }
            else
            {
                var N = JSON.Parse(result);

                if (idCurrency == 0)
                {
                    CharacterInfo._instance._baseProperties.Gold -= price * qtt;
                }
                else if (idCurrency == 1)
                {
                    CharacterInfo._instance._baseProperties.Diamond -= price * qtt;
                }

                if (N["typeid"].Value == "gem")//đây là runstone
                {
                    Item _boughtItem = new Item(N["idhg"].AsInt, N["idig"].AsInt, N["quantity"].AsInt, 1, N["sellprice"].AsInt, N["uplevel"].AsInt);
                    bool existedItem = false;
                    foreach (Item _temp in SplitDataFromServe._listGemInBag)
                    {
                        if (int.Parse(_temp.getValue("idig").ToString()) == int.Parse(_boughtItem.getValue("idit").ToString()))
                        {
                            _temp.setValue("quantity", int.Parse(_boughtItem.getValue("quantity").ToString()));
                            existedItem = true;
                            break;
                        }
                    }
                    if (!existedItem)
                    {
                        SplitDataFromServe._listGemInBag.Add(_boughtItem);
                    }
                }
                else if (N["typeid"].Value == "item")// đây là item
                {
                    Item _boughtItem = new Item(N["idht"].AsInt, N["idit"].AsInt, cachedItem.getValue("name").ToString(), N["quantity"].AsInt, int.Parse(cachedItem.getValue("price").ToString()), N["levelrequired"].AsInt, cachedItem.getValue("descripton").ToString(), int.Parse(cachedItem.getValue("price").ToString()));
                    bool existedItem = false;
                    foreach (Item _temp in SplitDataFromServe._listItemInBag)
                    {
                        if (int.Parse(_temp.getValue("idit").ToString()) == int.Parse(_boughtItem.getValue("idit").ToString()))
                        {
                            _temp.setValue("quantity", int.Parse(_boughtItem.getValue("quantity").ToString()));
                            existedItem = true;
                            break;
                        }
                    }

                    if (!existedItem)
                    {
                        SplitDataFromServe._listItemInBag.Add(_boughtItem);
                    }
                }

                this.PostEvent(EventID.OnPropertiesChange);
                _numberItemBound.SetActive(false);
                _acceptItemBound.SetActive(true);
                if (qtt == 1)
                {
                    numberItemGet.gameObject.SetActive(false);
                }
                else if (qtt > 1)
                {
                    numberItemGet.gameObject.SetActive(true);
                    numberItemGet.text = qtt.ToString();
                }
            }
        }));
    }
Example #23
0
 public void Disconnect()
 {
     ServerAdapter.Disconnect(this);
 }
Example #24
0
    private void BtnItemInforClick()
    {
        string param = ItemInforController.Message;

        if (!isActiveStorageUI)
        {
            return;
        }

        if (param.Equals("UseItem"))
        {
            StartCoroutine(ServerAdapter.UseItemInShop(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero,
                                                       int.Parse(SplitDataFromServe._listItemInBag[idItemSelected].getValue("idht").ToString()), 1,
                                                       result =>
            {
                if (result.StartsWith("Error"))
                {
                    TextNotifyScript.instance.SetData(result);
                }
                else
                {
                    var N      = SimpleJSON.JSON.Parse(result);
                    int idItem = int.Parse(SplitDataFromServe._listItemInBag[idItemSelected].getValue("idit").ToString());
                    if (idItem == 31)          //dùng thẻ protect
                    {
                        long timeSticks      = long.Parse(N["timeprotection"].Value);
                        DateTime _timeActive = new DateTime(timeSticks * 10000000 + new DateTime(1969, 12, 31, 12, 0, 0).Ticks);
                        _rewardItem.SetData("Used Item: " + SplitDataFromServe._listItemInBag[idItemSelected].getValue("name").ToString(), "Time Active: " + _timeActive.ToLocalTime());
                    }
                    else if (idItem >= 65 && idItem <= 68)          //dùng thẻ
                    {
                        long timeSticks      = long.Parse(N["timedaypremium"].Value);
                        DateTime _timeActive = new DateTime(timeSticks * 10000000 + new DateTime(1969, 12, 31, 12, 0, 0).Ticks);
                        _rewardItem.SetData("Used Item: " + SplitDataFromServe._listItemInBag[idItemSelected].getValue("name").ToString(), "Time Active: " + _timeActive.ToLocalTime());
                    }
                    else if (idItem == 70)         //reset skill point
                    {
                        SplitDataFromServe._heroSkill.Clear();
                        int numberSkillPoint = N["skillpoint"].AsInt;
                        CharacterInfo._instance._skillPoints += numberSkillPoint;
                        _rewardItem.SetData("Used Item: " + SplitDataFromServe._listItemInBag[idItemSelected].getValue("name").ToString(), "Skill point return: " + numberSkillPoint);
                    }
                    SplitDataFromServe.SubItemInBag(idItemSelected, 1);
                    DisplayItemInBag();
                }
            }));
        }
        else if (param.Equals("SellItem"))
        {
            _infoItemPanel.SetData(false, SplitDataFromServe._listItemInBag[idItemSelected], _listSlotItem[idItemSelected]._iconImg.sprite);
        }
        else if (param.Equals("UpdateEquipment"))
        {
            DisplayEquipmentInBag();
        }
        else if (param.Equals("SellEquipment"))//Chọn đồ
        {
            if (SplitDataFromServe._listEquipmentInBag[idItemSelected].typeItem == TypeEquipmentCharacter.Buff)
            {
                StartCoroutine(ServerAdapter.SellBuff(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, SplitDataFromServe._listEquipmentInBag[idItemSelected].idItem,
                                                      result =>
                {
                    if (result.StartsWith("Error"))
                    {
                        TextNotifyScript.instance.SetData(result);
                    }
                    else
                    {
                        var N = SimpleJSON.JSON.Parse(result);
                        CharacterInfo._instance._baseProperties.Gold += N["plusgold"].AsInt;
                        this.PostEvent(EventID.OnPropertiesChange);

                        SplitDataFromServe._listEquipmentInBag.RemoveAt(idItemSelected);
                        DisplayEquipmentInBag();
                    }
                }));
            }
            else
            {
                StartCoroutine(ServerAdapter.SellEquipment(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, SplitDataFromServe._listEquipmentInBag[idItemSelected].idItem,
                                                           result =>
                {
                    if (result.StartsWith("Error"))
                    {
                        TextNotifyScript.instance.SetData(result);
                    }
                    else
                    {
                        var N = SimpleJSON.JSON.Parse(result);
                        CharacterInfo._instance._baseProperties.Gold += N["plusgold"].AsInt;
                        this.PostEvent(EventID.OnPropertiesChange);

                        SplitDataFromServe._listEquipmentInBag.RemoveAt(idItemSelected);
                        DisplayEquipmentInBag();
                    }
                }));
            }
        }
        else if (param.Equals("ReplaceEquipmentFromBag"))
        {
            _myEquipment = SplitDataFromServe._listEquipmentInBag[idItemSelected];
            isCanUse     = true;
            _myTypeBag   = _myEquipment.typeItem;
            if (_myEquipment.levelRequired <= _myCurrentLevel && SplitDataFromServe._listSuitableEquipment.Contains(_myEquipment.idTypeEquipment))
            {
                if (_myEquipment.typeItem == TypeEquipmentCharacter.Weapon)
                {
                    if (!CharacterInfo._instance._baseProperties._classCharacter.Equals(MappingData.GetSuitableClassForWeapon(_myEquipment.idTypeEquipment)))
                    {
                        isCanUse = false;
                    }
                }
            }
            else
            {
                isCanUse = false;
            }

            //Debug.Log("is can use this equipment " + isCanUse);
            if (isCanUse)
            {
                StartCoroutine(ServerAdapter.ExecuteChangeEquipment(_myEquipment, result =>
                {
                    if (result.StartsWith("Error"))
                    {
                        TextNotifyScript.instance.SetData(result);
                    }
                    else
                    {
                        _tempItem = _equipmentsCharacter.MappingTypeItemToItem(_myTypeBag);
                        if (_tempItem != null)
                        {
                            SplitDataFromServe._listEquipmentInBag.Add(_tempItem);
                        }
                        _equipmentsCharacter.EquipItem(_myTypeBag, _myEquipment);
                        SplitDataFromServe._listEquipmentInBag.Remove(_myEquipment);
                        //CharacterInfo._instance._baseProperties.AddBonusItem(_myEquipItems[id]);
                        DisplayEquipmentInBag();
                    }
                }));
            }
        }
    }
Example #25
0
    public void BtnStartGame()
    {
        string _txtInput = _nameInputField.text.Trim();

        if (_txtInput.Length < 6)
        {
            _txtMessage.text = "Please enter a password at least 6 characters!";
        }
        else
        {
            _txtMessage.text = "Checking name...";
            StartCoroutine(ServerAdapter.CheckNameCreateHero(_txtInput, result =>
            {
                if (result.StartsWith("Error"))
                {
                    _txtMessage.text = result;
                }
                else
                {
                    _txtMessage.text = "Creating hero...";
                    int idih         = -1;
                    for (int i = 0; i < SplitDataFromServe._heroInits.Length; i++)
                    {
                        if (SplitDataFromServe._heroInits[i].name == listClass[lastIdHeroSelected])
                        {
                            idih = int.Parse(SplitDataFromServe._heroInits[lastIdHeroSelected].idih);
                            break;
                        }
                    }
                    if (idih == -1)
                    {
                        _txtMessage.text = "Id class hero is wrong!";
                    }
                    else
                    {
                        StartCoroutine(ServerAdapter.ExecuteCreateHero(idih, _txtInput, result2 =>
                        {
                            if (result2.StartsWith("Error"))
                            {
                                _txtMessage.text = result2;
                            }
                            else
                            {
                                _txtMessage.text = "Create your hero successfully!";
                                var N            = JSON.Parse(result2);
                                PlayerPrefabsController.SetStringData(Constant.IDHERO_CURRENTPLAY, N["hero"]["idh"].Value);
                                StartCoroutine(ServerAdapter.LoadDetailHero(N["hero"]["idcode"].Value, int.Parse(N["hero"]["idh"].Value), result3 =>
                                {
                                    if (result3.StartsWith("Error"))
                                    {
                                        _txtMessage.text = result;
                                    }
                                    else
                                    {
                                        SplitDataFromServe.ReadDetailDataHeroCurrentPlay(result3);
                                        Debug.Log("Load scene MainMenu");
                                        StartCoroutine(SceneLoader._instance.LoadNewScene(2));
                                    }
                                }));
                            }
                        }));
                    }
                }
            }));
        }
    }
Example #26
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (SplitDataFromServe._heroSkill.Contains(dataSkill) && !dataSkill.data["type"].Value.Equals("passive"))
     {
         if (itemBeingDragged != null)
         {
             string tempIdhk = this.dataSkill.data["idhk"].Value;
             if (eventData.pointerEnter.tag.Equals("SkillSlot") && !this.gameObject.tag.Equals("SkillInList"))
             {
                 Transform finishDrag = eventData.pointerEnter.transform;
                 if (eventData.pointerEnter.transform.childCount == 0)
                 {
                     this.transform.parent     = null;
                     this.transform.parent     = finishDrag;
                     this.transform.localScale = Vector3.one;
                     this.GetComponent <RectTransform>().localPosition = Vector3.zero;
                     PlayerPrefs.SetInt(this.dataSkill.data["idhk"].Value, int.Parse(finishDrag.name));
                     Destroy(itemBeingDragged);
                     itemBeingDragged = null;
                 }
                 else
                 {
                     Destroy(itemBeingDragged);
                     itemBeingDragged = null;
                 }
             }
             else if (eventData.pointerEnter.tag.Equals("SkillSlot") && this.gameObject.tag.Equals("SkillInList"))
             {
                 Transform finishDrag = eventData.pointerEnter.transform;
                 //Debug.Log("wear skill");
                 StartCoroutine(ServerAdapter.EquipSkill(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, this.dataSkill.data["idhk"].AsInt, result =>
                 {
                     Debug.Log(result.ToString());
                     if (result.StartsWith("Error"))
                     {
                         //Debug.Log("Do nothing");
                         Destroy(itemBeingDragged);
                         itemBeingDragged = null;
                     }
                     else
                     {
                         Debug.Log("wear ok skill level " + this.dataSkill.data["level"].AsInt);
                         GameObject skillObj       = Instantiate(Resources.Load("Prefabs/Skill") as GameObject);
                         skillObj.transform.parent = finishDrag;
                         PlayerPrefs.SetInt(this.dataSkill.data["idhk"].Value, finishDrag.GetSiblingIndex());
                         skillObj.transform.localPosition = Vector3.zero;
                         skillObj.GetComponent <RectTransform>().localScale = new Vector3(1f, 1f, 1f);
                         skillObj.transform.GetComponent <Image>().sprite   = Resources.Load <Sprite>("Textures/skillAss/" + this.dataSkill.data["sprite"].Value);
                         skillObj.AddComponent <DragHandeler>().dataSkill   = this.dataSkill;
                         skillObj.AddComponent <DropHandle>().dataSkill     = this.dataSkill;
                         skillObj.tag = "Skill";
                         foreach (NewSkill _tempSkill in SplitDataFromServe._heroSkill)
                         {
                             if (this.dataSkill.data["idhk"].AsInt == _tempSkill.data["idhk"].AsInt)
                             {
                                 _tempSkill.addField("typewear", 1);
                                 break;
                             }
                         }
                         Destroy(itemBeingDragged);
                         itemBeingDragged = null;
                     }
                 }));
             }
             else if (!eventData.pointerEnter.tag.Equals("Skill") && !eventData.pointerEnter.tag.Equals("SkillSlot") && !this.gameObject.tag.Equals("SkillInList"))
             {
                 //Debug.Log("unwear skill");
                 StartCoroutine(ServerAdapter.UnEquipSkill(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, this.dataSkill.data["idhk"].AsInt, result =>
                 {
                     if (result.StartsWith("Error"))
                     {
                         //Debug.Log("Do nothing");
                         Destroy(itemBeingDragged);
                     }
                     else
                     {
                         //Debug.Log(result);
                         PlayerPrefs.DeleteKey(tempIdhk);
                         foreach (NewSkill _tempSkill in SplitDataFromServe._heroSkill)
                         {
                             if (this.dataSkill.data["idhk"].AsInt == _tempSkill.data["idhk"].AsInt)
                             {
                                 _tempSkill.addField("typewear", 0);
                                 break;
                             }
                         }
                         Destroy(itemBeingDragged);
                         itemBeingDragged = null;
                         Destroy(this.gameObject);
                     }
                 }));
             }
             else
             {
                 Destroy(itemBeingDragged);
                 itemBeingDragged = null;
             }
         }
     }
 }
Example #27
0
        public TimecodeCompareResult RippleTime(string server, Int32 list, Guid position, out TimeCode holdtime)
        {
            var result = TimecodeCompareResult.Equal;

            var allFromPosition = GetListHelper(server, list).GetList().SkipWhile(pair => pair.ADCEventId != position).Select(eventEventIdPair => new EventEventIdPair
            {
                ADCEvent   = (Event)eventEventIdPair.ADCEvent.Clone(),
                ADCEventId = eventEventIdPair.ADCEventId
            }).ToList();

            holdtime = TimeCode.Default;
            if (allFromPosition.Count > 1)
            {
                for (int i = 0; i < allFromPosition.Count; i++)
                {
                    var currEvent = allFromPosition[i];
                    if (currEvent.ADCEvent.EventType != ADCEventType.Break)
                    {
                        ServerAdapter serverAdapter = _servers.FirstOrDefault(adapter => adapter.ServerName == server);
                        var           currOnAir     = new TimeCode(serverAdapter.FrameRate, serverAdapter.DropFrame, currEvent.ADCEvent.OnAirTime);
                        if (currOnAir != TimeCode.Default && currEvent.ADCEvent.EventControl.Contains(EventControlType.AutoTimed))
                        {
                            TimeCode currTimecode = TimeCode.Empty;
                            if (serverAdapter != null)
                            {
                                currTimecode = serverAdapter.CurrentTimecode;
                            }
                            TimeCode hardTimecode = currOnAir;
                            if (hardTimecode < currTimecode)
                            {
                                TimeCode hours24 = TimeCode.Empty;
                                hours24.InitTime(TimeCode.ToBCD(24), 0, 0, 0);
                                hardTimecode += hours24;
                            }
                            if (i > 0)
                            {
                                if (holdtime == TimeCode.Default)
                                {
                                    holdtime = TimeCode.Empty;
                                }

                                if (holdtime != hardTimecode)
                                {
                                    if (holdtime > hardTimecode)
                                    {
                                        result = TimecodeCompareResult.Greater;
                                        TimeCode tempTC = hardTimecode - holdtime;
                                        if (tempTC.Hour < TimeCode.ToBCD(12))
                                        {
                                            result = TimecodeCompareResult.Less;
                                        }
                                    }
                                    else
                                    {
                                        result = TimecodeCompareResult.Less;
                                        if (hardTimecode < holdtime && hardTimecode.Hour > TimeCode.ToBCD(12) && holdtime.Hour < TimeCode.ToBCD(12))
                                        {
                                            result    = TimecodeCompareResult.Greater;
                                            holdtime -= hardTimecode;
                                        }
                                        else
                                        {
                                            holdtime = hardTimecode - holdtime;
                                        }
                                    }
                                }
                            }
                        }
                        if (RippleEvent(ref currEvent, ref holdtime))
                        {
                            ModifyEvent(server, list, currEvent, currEvent.ADCEventId);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(result);
        }
Example #28
0
        protected override void Execute()
        {
            try
            {
                while (!this._bStop)
                {
                    _statusUpdateHandle.WaitOne();

                    while (!_serversToInitialize.IsEmpty)
                    {
                        String serverName;
                        if (_serversToInitialize.TryTake(out serverName))
                        {
                            var           server    = _servers.FirstOrDefault(adapter => adapter.ServerName == serverName);
                            ServerAdapter tmpServer = server;
                            if (tmpServer != null && !this._lists.Keys.Any(listServer => listServer == tmpServer.ServerName))
                            {
                                Logger.ServiceLogger.Informational(String.Format("Initialization for server {0} started.", server.ServerName));
                                List <String>        listNames = server.GetListNames();
                                List <ADCListHelper> tmpList   = new List <ADCListHelper>();
                                for (Int32 i = 0; i < server.NumberOfLists; i++)
                                {
                                    ADCListHelper newListHelper = new ADCListHelper(server, i + 1, true);
                                    try
                                    {
                                        newListHelper.ListName = listNames.ElementAt(i);
                                    }
                                    catch (ArgumentNullException)
                                    {
                                    }
                                    catch (ArgumentOutOfRangeException)
                                    {
                                    }
                                    newListHelper.OnListChange    += this.OnListChange;
                                    newListHelper.OnDisplayChange += this.OnListChange;
                                    newListHelper.OnSystemChange  += this.OnListChange;
                                    newListHelper.OnEventsAdded   += this.OnEventsAdded;
                                    newListHelper.OnEventsUpdated += this.OnEventsUpdated;
                                    newListHelper.OnEventsDeleted += this.OnEventsDeleted;
                                    newListHelper.OnEventsMoved   += this.OnEventsMoved;
                                    tmpList.Add(newListHelper);
                                }
                                while (!this._lists.TryAdd(server.ServerName, tmpList))
                                {
                                }
                                this.OnServerInitialized(tmpServer);
                                Logger.ServiceLogger.Informational(String.Format("Initialization for server {0} has been completed successfully.", server.ServerName));
                            }
                        }
                    }

                    while (!_serversToRemove.IsEmpty)
                    {
                        String serverName;
                        if (_serversToRemove.TryTake(out serverName))
                        {
                            RemoveAllListHelpersForServer(serverName);
                        }
                    }

                    var    serversToUpdate = new List <String>();
                    String srv;
                    while (_updates.TryDequeue(out srv))
                    {
                        if (!serversToUpdate.Contains(srv))
                        {
                            serversToUpdate.Add(srv);
                        }
                    }

                    foreach (var serverName in serversToUpdate)
                    {
                        if (_servers.Any(server => server.ServerName == serverName &&
                                         server.ServerStatus == ServerStatus.Connected))
                        {
                            // Execute NetworkBackground for each listHelper
                            try
                            {
                                if (this._lists.Keys.Any(key => key == serverName))
                                {
                                    List <ADCListHelper> listHelpers = this._lists[serverName];
                                    if (listHelpers != null)
                                    {
                                        listHelpers.ForEach(lc => lc.NetworkBackground());
                                    }
                                    this.IsReady = true;
                                }

                                LowPriorityTasks(_lowPriorityCounter);
                            }
                            catch (ObjectDisposedException)
                            {
                            }
                        }
                        _lowPriorityCounter++;
                    }
                    _statusUpdateHandle.Reset();
                }
            }
            catch (ThreadInterruptedException)
            {
            }
        }
Example #29
0
 void LearnNewSkill()
 {
     if (!isLearningSkill)
     {
         isLearningSkill = true;
         bool skillLeard = false;
         foreach (NewSkill _tempSkill in SplitDataFromServe._heroSkill)
         {
             if (_tempSkill.data["idk"].AsInt == _skillDataInfo.data["idInit"].AsInt)
             {
                 skillLeard = true;
                 break;
             }
         }
         if (skillLeard == false)
         {
             int SPRequire = getSPRequiredToLearn(_skillDataInfo);
             if (CharacterInfo._instance._baseProperties.SkillPoint >= SPRequire)
             {
                 StartCoroutine(ServerAdapter.LearnSkill(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, _skillDataInfo.data["idInit"].AsInt, _skillDataInfo.data["type"].Value, SPRequire, result =>
                 {
                     if (result.StartsWith("Error"))
                     {
                         isLearningSkill = false;
                         Debug.Log("Do nothing");
                         if (ScrollviewDontDestroy.Instance != null)
                         {
                             ScrollviewDontDestroy.Instance.SetLog("Learn skill fail, result return is " + result);
                         }
                     }
                     else
                     {
                         CharacterInfo._instance._baseProperties.SkillPoint -= SPRequire;
                         var N = SimpleJSON.JSON.Parse(result.ToString());
                         _skillDataInfo.addField("idhk", N["idhk"].AsInt);
                         _skillDataInfo.addField("idk", N["idk"].AsInt);
                         _skillDataInfo.addField("typewear", N["typewear"].AsInt);
                         _skillDataInfo.addField("level", 1);
                         SplitDataFromServe._heroSkill.Add(_skillDataInfo);
                         ShowInfoSkill(_skillDataInfo);
                         //_skillInfoObj.SetActive(false);
                         ListSkillEachClass(ConverClassCharacterEnumToId(CharacterInfo._instance._baseProperties._classCharacter));
                         isLearningSkill = false;
                         if (ScrollviewDontDestroy.Instance != null)
                         {
                             ScrollviewDontDestroy.Instance.SetLog("Learn skill successfully");
                         }
                     }
                 }));
             }
             else
             {
                 PopupErrorController.Instance.ShowErrorWithContent("Don't have enought skillpoint to learn!!");
                 isLearningSkill = false;
             }
         }
         else if (skillLeard == true)
         {
             Debug.Log("Upgrade Skill");
             int SPRequire = getSPRequiredToUpgrade(_skillDataInfo);
             Debug.Log("sp learn skill" + SPRequire);
             if (CharacterInfo._instance._baseProperties.SkillPoint >= SPRequire)
             {
                 StartCoroutine(ServerAdapter.UpLevelSkill(CharacterInfo._instance._baseProperties.idHero, CharacterInfo._instance._baseProperties.idCodeHero, _skillDataInfo.data["idhk"].AsInt, _skillDataInfo.data["level"].AsInt, SPRequire, result =>
                 {
                     if (result.StartsWith("Error"))
                     {
                         Debug.Log("Do nothing");
                         isLearningSkill = false;
                         if (ScrollviewDontDestroy.Instance != null)
                         {
                             ScrollviewDontDestroy.Instance.SetLog("Upgrade skill fail, result return is " + result);
                         }
                     }
                     else
                     {
                         CharacterInfo._instance._baseProperties.SkillPoint -= SPRequire;
                         var N = SimpleJSON.JSON.Parse(result.ToString());
                         _skillDataInfo.addField("level", _skillDataInfo.data["level"].AsInt + 1);
                         ShowInfoSkill(_skillDataInfo);
                         ListSkillEachClass(ConverClassCharacterEnumToId(CharacterInfo._instance._baseProperties._classCharacter));
                         isLearningSkill = false;
                         if (ScrollviewDontDestroy.Instance != null)
                         {
                             ScrollviewDontDestroy.Instance.SetLog("Upgrade skill successfully");
                         }
                     }
                 }));
             }
             else
             {
                 PopupErrorController.Instance.ShowErrorWithContent("Don't have enought skillpoint to learn!!");
                 isLearningSkill = false;
             }
         }
     }
 }