Ejemplo n.º 1
0
    public void LoadCharacterProperties()
    {
        _baseProperties = new CharacterProperties(int.Parse(SplitDataFromServe._heroCurrentPLay.idh),
                                                  SplitDataFromServe._heroCurrentPLay.idcode,
                                                  SplitDataFromServe._heroCurrentPLay.idclass,
                                                  SplitDataFromServe._heroCurrentPLay.name,
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.level),
                                                  double.Parse(SplitDataFromServe._heroCurrentPLay.exp),
                                                  0, 0, 0,
                                                  double.Parse(SplitDataFromServe._heroCurrentPLay.skillpoint),
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.point),
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.levelmap),
                                                  double.Parse(SplitDataFromServe._heroCurrentPLay.gold),
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.diamond),
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.slotchest),
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.type),
                                                  int.Parse(SplitDataFromServe._heroCurrentPLay.hp),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.strength),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.intelligence),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.vitality),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.focus),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.luck),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.endurance),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.blessing),
                                                  float.Parse(SplitDataFromServe._heroCurrentPLay.fighting));

        _myEquipments = SplitDataFromServe._equipmentCurrentHero;
        _currentHP    = (int)_baseProperties.hp;
        UpdatePropertiesFromEquipment(_myEquipments, _baseProperties);
        _skillPoints  = 0;
        _statPoints   = 0;
        _actionPoints = 0;
        _damaged      = 0;
        MainMenuUI._instance.UpdateTextValue();
    }
Ejemplo n.º 2
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);
        }
    }
Ejemplo n.º 3
0
 public void UpdatePropertiesFromEquipment(EquipmentsCharacter _tempEquipment, CharacterProperties _tempProperties)
 {
     if (_tempEquipment.amuletItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.amuletItem);
     }
     if (_tempEquipment.beltItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.beltItem);
     }
     if (_tempEquipment.bootsItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.bootsItem);
     }
     if (_tempEquipment.glovesItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.glovesItem);
     }
     if (_tempEquipment.headItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.headItem);
     }
     if (_tempEquipment.legItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.legItem);
     }
     if (_tempEquipment.ringItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.ringItem);
     }
     if (_tempEquipment.shieldItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.shieldItem);
     }
     if (_tempEquipment.torsoItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.torsoItem);
     }
     if (_tempEquipment.weaponItem != null)
     {
         _tempProperties.AddBonusItem(_tempEquipment.weaponItem);
     }
 }
Ejemplo n.º 4
0
    private void OnEnable()
    {
        _equipmentsCharacter = CharacterInfo._instance._myEquipments;
        _myCurrentLevel      = int.Parse(SplitDataFromServe._heroCurrentPLay.level);
        _bagHeroPanel.transform.localPosition = new Vector3(_bagHeroPanel.transform.localPosition.x, 1050);
        _bagHeroPanel.transform.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutBack);

        _equipmentButton.onClick.AddListener(OpenEquipmentTab);
        _itemButton.onClick.AddListener(OpenItemTab);
        _gemButton.onClick.AddListener(OpenGemTab);

        numberCapacity = CharacterInfo._instance._baseProperties.SlotChest;
        CreateSlotViewInEquipmentBag();

        idTabSelected        = -1;
        numberEquipmentInBag = -1;
        numberItemInBag      = -1;
        numberGemInBag       = -1;

        OpenEquipmentTab();
        isActiveStorageUI               = true;
        ItemUIScript.OnItemClicked     += ItemClick;
        ItemInforController.OnBtnClick += BtnItemInforClick;
    }
Ejemplo n.º 5
0
    public static void ReadDetailDataHeroEnemyPlay(string data)
    {
        var N = SimpleJSON.JSON.Parse(data);

        _heroEnemyPlay = JsonUtility.FromJson <HeroCurrentPlay>(N["hero"].ToString());

        int        numberItemEquip    = N["equipped"].Count;
        List <int> listIdWearEquipped = new List <int>();

        for (int i = 0; i < N["wear_equipped"].Count; i++)
        {
            if (N["wear_equipped"][i].AsInt != 0)
            {
                listIdWearEquipped.Add(N["wear_equipped"][i].AsInt);
            }
        }
        List <EquipmentItem> _listEquippedInHero = new List <EquipmentItem>();

        for (int i = 0; i < numberItemEquip; i++)
        {
            if (listIdWearEquipped.Contains(N["equipped"][i]["ide"].AsInt))
            {
                int    tempIdItem        = N["equipped"][i]["ide"].AsInt;
                int    tempIdInitItem    = N["equipped"][i]["idie"].AsInt;
                string tempnameItem      = N["equipped"][i]["name"].Value;
                int    templevelRequired = N["equipped"][i]["levelrequired"].AsInt;
                int    templevelUpgrade  = N["equipped"][i]["levelupgraded"].AsInt;
                int    tempidSet         = N["equipped"][i]["idsuit"].AsInt;

                int temTypeEquipped = N["equipped"][i]["typequipped"].AsInt;
                int temChildType    = N["equipped"][i]["childtype"].AsInt;

                //TypeEquipmentCharacter tempType = GetSlotWearEquipped(data, tempIdItem, _heroEnemyPlay.idclass);

                int priceItem = N["equipped"][i]["sellprice"].AsInt;
                int rareItem  = N["equipped"][i]["rateitem"].AsInt;

                int typeEquipped = N["equipped"][i]["typequipped"].AsInt;
                int typeChild    = N["equipped"][i]["childtype"].AsInt;
                ClassCharacterItem _classCharacterItem = ClassCharacterItem.None;
                switch (typeEquipped)
                {
                case 12: _classCharacterItem = ClassCharacterItem.HeavyArmor; break;

                case 13: _classCharacterItem = ClassCharacterItem.SoftArmor; break;

                case 14: _classCharacterItem = ClassCharacterItem.ClothArmor; break;

                default: _classCharacterItem = ClassCharacterItem.None; break;
                }

                TypeEquipmentCharacter tempType = MappingData.ConvertIdItemToType(typeEquipped, typeChild, _heroCurrentPLay.idclass, listIdWearEquipped.Contains(tempIdItem));

                if (N["wear_equipped"]["ide_weapon"].AsInt == tempIdItem)
                {
                    tempType = TypeEquipmentCharacter.Weapon;
                }
                else if (N["wear_equipped"]["ide_shield"].AsInt == tempIdItem)
                {
                    if (_heroCurrentPLay.idclass == 1 || _heroCurrentPLay.idclass == 5 || _heroCurrentPLay.idclass == 7)
                    {
                        tempType = TypeEquipmentCharacter.OffhandWeapon;
                    }
                    else
                    {
                        tempType = TypeEquipmentCharacter.Shield;
                    }
                }



                EquipmentItem item = new EquipmentItem(tempIdItem, tempIdInitItem, tempType, _classCharacterItem, typeEquipped, tempidSet, tempnameItem, templevelRequired, templevelUpgrade, priceItem, rareItem);
                item.setValue("1", N["equipped"][i]["mindamage"].AsFloat);
                item.setValue("2", N["equipped"][i]["maxdamage"].AsFloat);
                item.setValue("3", N["equipped"][i]["minmagic"].AsFloat);
                item.setValue("4", N["equipped"][i]["maxmagic"].AsFloat);
                item.setValue("5", N["equipped"][i]["critmax"].AsFloat);
                item.setValue("6", N["equipped"][i]["multicastmax"].AsFloat);
                item.setValue("7", N["equipped"][i]["min_incrdamage"].AsFloat);
                item.setValue("8", N["equipped"][i]["max_incrdamage"].AsFloat);
                item.setValue("9", N["equipped"][i]["min_incrmagic"].AsFloat);
                item.setValue("10", N["equipped"][i]["max_incrmagic"].AsFloat);
                item.setValue("11", N["equipped"][i]["min_rate"].AsFloat);
                item.setValue("12", N["equipped"][i]["max_rate"].AsFloat);
                item.setValue("13", N["equipped"][i]["minparryrate"].AsFloat);
                item.setValue("14", N["equipped"][i]["maxparryrate"].AsFloat);
                item.setValue("15", N["equipped"][i]["min_block"].AsFloat);
                item.setValue("16", N["equipped"][i]["max_block"].AsFloat);
                item.setValue("17", N["equipped"][i]["minphydef"].AsFloat);
                item.setValue("18", N["equipped"][i]["maxphydef"].AsFloat);
                item.setValue("19", N["equipped"][i]["minmagicdef"].AsFloat);
                item.setValue("20", N["equipped"][i]["maxmagicdef"].AsFloat);
                item.setValue("21", N["equipped"][i]["minphyreduction"].AsFloat);
                item.setValue("22", N["equipped"][i]["maxphyreduction"].AsFloat);
                item.setValue("23", N["equipped"][i]["minmagicreduction"].AsFloat);
                item.setValue("24", N["equipped"][i]["maxmagicreduction"].AsFloat);
                item.setValue("25", N["equipped"][i]["minphyabsorb"].AsFloat);
                item.setValue("26", N["equipped"][i]["maxphyabsorb"].AsFloat);
                item.setValue("27", N["equipped"][i]["minmagicabsorb"].AsFloat);
                item.setValue("28", N["equipped"][i]["maxmagicabsorb"].AsFloat);

                item.setValue("listidproperty", N["equipped"][i]["maxmagicabsorb"].Value.ToString());

                _listEquippedInHero.Add(item);
            }
        }

        _equipmentCurrentEnemy = new EquipmentsCharacter(_listEquippedInHero);
    }
Ejemplo n.º 6
0
    public static void ReadDetailDataHeroCurrentPlay(string data)
    {
        //Debug.Log(data);
        var N = SimpleJSON.JSON.Parse(data);

        _heroCurrentPLay = JsonUtility.FromJson <HeroCurrentPlay>(N["hero"].ToString());

        int        numberItemEquip    = N["equipped"].Count;
        List <int> listIdWearEquipped = new List <int>();

        for (int i = 0; i < N["wear_equipped"].Count; i++)
        {
            if (N["wear_equipped"][i].AsInt != 0)
            {
                listIdWearEquipped.Add(N["wear_equipped"][i].AsInt);
            }
        }
        List <EquipmentItem> _listEquippedInHero = new List <EquipmentItem>();

        for (int i = 0; i < numberItemEquip; i++)
        {
            int    tempIdItem        = N["equipped"][i]["ide"].AsInt;
            int    tempIdInitItem    = N["equipped"][i]["idie"].AsInt;
            string tempnameItem      = N["equipped"][i]["name"].Value;
            int    templevelRequired = N["equipped"][i]["levelrequired"].AsInt;
            int    templevelUpgrade  = N["equipped"][i]["levelupgraded"].AsInt;
            int    tempidSet         = N["equipped"][i]["idsuit"].AsInt;
            int    temTypeEquipped   = N["equipped"][i]["typequipped"].AsInt;
            int    temChildType      = N["equipped"][i]["childtype"].AsInt;

            int typeEquipped = N["equipped"][i]["typequipped"].AsInt;
            int typeChild    = N["equipped"][i]["childtype"].AsInt;
            ClassCharacterItem _classCharacterItem = ClassCharacterItem.None;
            switch (typeEquipped)
            {
            case 12: _classCharacterItem = ClassCharacterItem.HeavyArmor; break;

            case 13: _classCharacterItem = ClassCharacterItem.SoftArmor; break;

            case 14: _classCharacterItem = ClassCharacterItem.ClothArmor; break;

            default: _classCharacterItem = ClassCharacterItem.None; break;
            }

            TypeEquipmentCharacter tempType = MappingData.ConvertIdItemToType(typeEquipped, typeChild, _heroCurrentPLay.idclass, listIdWearEquipped.Contains(tempIdItem));

            if (N["wear_equipped"]["ide_weapon"].AsInt == tempIdItem)
            {
                tempType = TypeEquipmentCharacter.Weapon;
            }
            else if (N["wear_equipped"]["ide_shield"].AsInt == tempIdItem)
            {
                if (_heroCurrentPLay.idclass == 1 || _heroCurrentPLay.idclass == 5 || _heroCurrentPLay.idclass == 7)
                {
                    tempType = TypeEquipmentCharacter.OffhandWeapon;
                }
                else
                {
                    tempType = TypeEquipmentCharacter.Shield;
                }
            }

            int priceItem = N["equipped"][i]["sellprice"].AsInt;
            int rare      = N["equipped"][i]["rateitem"].AsInt;

            EquipmentItem item = new EquipmentItem(tempIdItem, tempIdInitItem, tempType, _classCharacterItem, typeEquipped, tempidSet, tempnameItem, templevelRequired, templevelUpgrade, priceItem, rare);
            item.setValue("1", N["equipped"][i]["mindamage"].AsFloat);
            item.setValue("2", N["equipped"][i]["maxdamage"].AsFloat);
            item.setValue("3", N["equipped"][i]["minmagic"].AsFloat);
            item.setValue("4", N["equipped"][i]["maxmagic"].AsFloat);
            item.setValue("5", N["equipped"][i]["critmax"].AsFloat);
            item.setValue("6", N["equipped"][i]["multicastmax"].AsFloat);
            item.setValue("7", N["equipped"][i]["min_incrdamage"].AsFloat);
            item.setValue("8", N["equipped"][i]["max_incrdamage"].AsFloat);
            item.setValue("9", N["equipped"][i]["min_incrmagic"].AsFloat);
            item.setValue("10", N["equipped"][i]["max_incrmagic"].AsFloat);
            item.setValue("11", N["equipped"][i]["min_rate"].AsFloat);
            item.setValue("12", N["equipped"][i]["max_rate"].AsFloat);
            item.setValue("13", N["equipped"][i]["minparryrate"].AsFloat);
            item.setValue("14", N["equipped"][i]["maxparryrate"].AsFloat);
            item.setValue("15", N["equipped"][i]["min_block"].AsFloat);
            item.setValue("16", N["equipped"][i]["max_block"].AsFloat);
            item.setValue("17", N["equipped"][i]["minphydef"].AsFloat);
            item.setValue("18", N["equipped"][i]["maxphydef"].AsFloat);
            item.setValue("19", N["equipped"][i]["minmagicdef"].AsFloat);
            item.setValue("20", N["equipped"][i]["maxmagicdef"].AsFloat);
            item.setValue("21", N["equipped"][i]["minphyreduction"].AsFloat);
            item.setValue("22", N["equipped"][i]["maxphyreduction"].AsFloat);
            item.setValue("23", N["equipped"][i]["minmagicreduction"].AsFloat);
            item.setValue("24", N["equipped"][i]["maxmagicreduction"].AsFloat);
            item.setValue("25", N["equipped"][i]["minphyabsorb"].AsFloat);
            item.setValue("26", N["equipped"][i]["maxphyabsorb"].AsFloat);
            item.setValue("27", N["equipped"][i]["minmagicabsorb"].AsFloat);
            item.setValue("28", N["equipped"][i]["maxmagicabsorb"].AsFloat);
            item.priceItem = N["equipped"][i]["sellprice"].AsInt;
            string _valueProperty = N["equipped"][i]["listidproperty"].Value;
            item.setValue("listidproperty", _valueProperty);

            if (_valueProperty.Equals("null") || _valueProperty.Equals("[]") || string.IsNullOrEmpty(_valueProperty))
            {
            }
            else
            {
                try
                {
                    var M = CoreLib.JSON.Parse(_valueProperty);
                    foreach (KeyValuePair <string, CoreLib.JSONNode> _temp in M.AsObject)
                    {
                        //Debug.Log(_temp.Key.ToString());
                        item.setValue(_temp.Key.ToString(), float.Parse(_temp.Value.AsFloat.ToString()));
                    }
                }
                catch (Exception e)
                {
                    Debug.Log(e);
                    Debug.Log(tempIdItem + " " + _valueProperty);
                }
            }

            //Debug.Log(item.typeItem);
            if (listIdWearEquipped.Contains(tempIdItem))
            {
                _listEquippedInHero.Add(item);
            }
            else
            {
                _listEquipmentInBag.Add(item);
            }
        }

        int numberAvatar = N["avatar"].Count;

        for (int i = 0; i < numberAvatar; i++)
        {
            int tempIdItem = N["avatar"][i]["idha"].AsInt;

            //int tempIdInitItem = N["avatar"][i]["idia"].AsInt;
            string        tempnameItem      = N["avatar"][i]["name"].Value.ToString();
            int           templevelRequired = 1;
            int           templevelUpgrade  = int.Parse(N["avatar"][i]["level"].Value.ToString());
            int           tempidSet         = 0;
            int           priceItem         = 0;
            int           rare = 0;
            EquipmentItem item = new EquipmentItem(tempIdItem, 1, TypeEquipmentCharacter.Avatar, ClassCharacterItem.None, 0, tempidSet, tempnameItem, templevelRequired, templevelUpgrade, priceItem, rare);

            //Thêm các dòng trắng
            item.setValue("97", float.Parse(N["avatar"][i]["hp"].Value.ToString()));
            item.setValue("98", float.Parse(N["avatar"][i]["physical_damage"].Value.ToString()));
            item.setValue("99", float.Parse(N["avatar"][i]["magical_damage"].Value.ToString()));
            item.setValue("100", float.Parse(N["avatar"][i]["physical_absorption"].Value.ToString()));
            item.setValue("101", float.Parse(N["avatar"][i]["magical_absorption"].Value.ToString()));
            item.setValue("999", N["avatar"][i]["maxlist"].AsInt);
            item.setValue("listidproperty", N["avatar"][i]["listidproperty"].Value.ToString());
            try
            {
                var M = SimpleJSON.JSON.Parse(N["avatar"][i]["listidproperty"].Value.ToString());
                foreach (KeyValuePair <string, SimpleJSON.JSONNode> _temp in M.AsObject)
                {
                    //Debug.Log(_temp.Key.ToString());
                    item.setValue(_temp.Key.ToString(), float.Parse(_temp.Value.AsFloat.ToString()));
                }
            }
            catch (Exception e)
            {
            }
            //check trong túi hay người
            if (listIdWearEquipped.Contains(tempIdItem))
            {
                _listEquippedInHero.Add(item);
            }
            else
            {
                _listEquipmentInBag.Add(item);
            }
        }

        int numberBuff = N["buff"].Count;

        for (int i = 0; i < numberBuff; i++)
        {
            int           tempIdItem        = N["buff"][i]["idbf"].AsInt;
            int           tempIdInit        = N["buff"][i]["idibf"].AsInt;
            string        tempnameItem      = N["buff"][i]["name"].Value.ToString();
            int           templevelRequired = 1;
            int           templevelUpgrade  = int.Parse(N["buff"][i]["level"].Value.ToString());
            int           tempidSet         = 0;
            int           priceItem         = N["buff"][i]["sellprice"].AsInt;
            int           rare = 0;
            EquipmentItem item = new EquipmentItem(tempIdItem, tempIdInit, TypeEquipmentCharacter.Buff, ClassCharacterItem.None, 0, tempidSet, tempnameItem, templevelRequired, templevelUpgrade, priceItem, rare);

            float _rate   = N["buff"][i]["rate"].AsFloat;
            int   _idRate = MappingData.ConvertIdBuffToAttribute(tempIdInit);
            item.setValue(_idRate.ToString(), _rate);
            //check trong túi hay người
            if (listIdWearEquipped.Contains(tempIdItem))
            {
                _listEquippedInHero.Add(item);
            }
            else
            {
                _listEquipmentInBag.Add(item);
            }
        }
        _equipmentCurrentHero = new EquipmentsCharacter(_listEquippedInHero);
    }