Beispiel #1
0
    /// <summary>
    /// Show the info of the item.
    /// </summary>
    /// <param name="orderType">The order type of item.</param>
    /// <param name="equipItem">The equip item script on the item.</param>
    /// <param name="quality">The quality of the item.</param>
    /// <param name="level">The level of the item.</param>
    /// <param name="job">The job of the item.</param>
    /// <param name="atk">The attack of the item.</param>
    /// <param name="hp">The hp value of the item.</param>
    /// <param name="recover">The recover value of the item.</param>
    public static void ShowItem(OrderType orderType, EquipItem equipItem, int quality, short level, sbyte job, int atk, int hp, int recover)
    {
        switch (orderType)
        {
            case OrderType.Time:
                equipItem.ShowByLvl(level);
                break;

            case OrderType.Job:
                equipItem.ShowByJob(atk);
                break;

            case OrderType.Rarity:
                equipItem.ShowByQuality(quality);
                break;

            case OrderType.Team:
                equipItem.ShowByLvl(level);
                break;

            case OrderType.Attack:
                equipItem.ShowByJob(atk);
                break;

            case OrderType.Health:
                equipItem.ShowByHp(hp);
                break;

            case OrderType.Recover:
                equipItem.ShowByRecover(recover);
                break;

            case OrderType.Level:
                equipItem.ShowByLvl(level);
                break;
        }
    }
Beispiel #2
0
    void UpdateProperty()
    {
        this.attack = 0;
        this.def    = 0;
        this.speed  = 0;
        EquipItem headgearItem = headgear.GetComponentInChildren <EquipItem>();

        PlusProperty(headgearItem);
        EquipItem armorItem = armor.GetComponentInChildren <EquipItem>();

        PlusProperty(armorItem);
        EquipItem leftHandItem = lefthand.GetComponentInChildren <EquipItem> ();

        PlusProperty(leftHandItem);
        EquipItem rightHandItem = righthand.GetComponentInChildren <EquipItem> ();

        PlusProperty(rightHandItem);
        EquipItem shoeItem = shoe.GetComponentInChildren <EquipItem>();

        PlusProperty(shoeItem);
        EquipItem accessoryItem = accessory.GetComponentInChildren <EquipItem>();

        PlusProperty(accessoryItem);
    }
Beispiel #3
0
        public override bool init(EquipItem item)
        {
            if (_bInit == false || ResetFlag)
            {
                if (base.init(item) == false)
                {
                    return(false);//通讯失败
                }
                try
                {
                    //获取Equip表communication_time_param中的延迟值
                    _sleepTime = Convert.ToInt32(item.communication_time_param);
                }
                catch
                {
                    //获取失败或信息不正确则默认300,这是比较好的异常处理机制:含修正代码
                    _sleepTime = 300;
                }

                Task.Run(async() => { await client.ConnectMqttServerAsync(); });
                _bInit = true;
            }
            return(true);
        }
Beispiel #4
0
    /// <summary>
    /// 被封印类道具生效后结果
    /// </summary>
    /// <param name="pos"></param>
    /// <param name="type"></param>
    /// <param name="Num"></param>
    /// <returns></returns>
    public string ReapNormalEquip(EquipPosition pos, int type)
    {
        List <EquipItem> equips = SDDataManager.Instance.AllEquipList;
        List <EquipItem> all    = equips.FindAll(x => x.EquipPos == pos);

        if (pos == EquipPosition.End)
        {
            all = equips;
        }

        if (type > 0)
        {
            all = all.FindAll(x => x.ArmorRank.Index == type);
        }

        float[] r     = new float[] { 6, 3.5f, 0.46f, 0.04f };
        int     level = RandomIntger.Choose(r);

        all = all.FindAll(x => x.LEVEL == level);
        int       randomNum = UnityEngine.Random.Range(0, all.Count);
        EquipItem result    = all[randomNum];

        return(result.ID);
    }
Beispiel #5
0
    public void setLegging(int hashcode)
    {
        GDEEquipmentData armor = SDDataManager.Instance.getHeroEquipLegging(hashcode);

        if (armor == null || string.IsNullOrEmpty(armor.id))
        {
            equipList.EquipVision(EquipPosition.Leg).initEquipVision(armor);
            _legging.initDataEmpty(); return;
        }
        EquipItem Item = SDDataManager.Instance.GetEquipItemById(armor.id);

        if (Item == null)
        {
            equipList.EquipVision(EquipPosition.Leg).initEquipVision(armor);
            _legging.initDataEmpty(); return;
        }
        //
        _legging.initData(Item.LEVEL, Item.RAL, 0, 0, 0, 0, RoleBarChart.zero
                          , Item.ID, Item.NAME, 0);
        _legging.PassiveEffectInit(Item.PassiveEffect);
        _legging.armorRank = Item.ArmorRank;
        //
        equipList.EquipVision(EquipPosition.Leg).initEquipVision(armor);
    }
Beispiel #6
0
    /// <summary>
    /// 初始化装备信息
    /// </summary>
    /// <param name="itemFielInfo">Item fiel info.</param>
    public void InitItemData(ItemFielInfo itemFielInfo)
    {
        if (itemFielInfo != null)
        {
            ItemFielInfo = itemFielInfo;
            //装备图标
            SetEquipIcon();
            //已装备提示
            if (EquipedIcon != null)
            {
                long equipId   = itemFielInfo.equipmentEntity.SMsg_Header.uidEntity;
                bool isEquipEd = ContainerInfomanager.Instance.sSyncHeroContainerGoods_SCs.Exists(item => item.uidGoods == equipId);
                EquipedIcon.gameObject.SetActive(isEquipEd);
            }
            //等级及星级
            var equipLevel = GetItemInfoDetail(this.ItemFielInfo, EquipInfoType.EquipStrenLevel);
            if (equipLevel != "+0")
            {
                LevelInfo.SetActive(true);
                EquipLevel.text = equipLevel;
            }
            else
            {
                LevelInfo.SetActive(false);
            }
            var equipStarIndex = EquipItem.GetItemInfoDetail(this.ItemFielInfo, EquipInfoType.EquipStarColorIndex);
            EquipStar.ChangeSprite(int.Parse(equipStarIndex));

            //引导
            // gameObject.RegisterBtnMappingId(itemFielInfo.LocalItemData._goodID, UIType.EquipStrengthen, BtnMapId_Sub.EquipStrengthen_Item);
        }
        else
        {
            TraceUtil.Log(SystemModel.Rocky, TraceLevel.Error, "装备为空-- EquipItem->InitItemData");
        }
    }
Beispiel #7
0
    public void Init(ItemFielInfo itemfileInfo)
    {
        IconItem.Init(itemfileInfo);
        Lable_name.SetText(NGUIColor.SetTxtColor(LanguageTextManager.GetString(itemfileInfo.LocalItemData._szGoodsName), (TextColor)itemfileInfo.LocalItemData._ColorLevel));
        Lable_position.SetText(EquipmentUpgradeDataManger.Instance.PositionDic[itemfileInfo.LocalItemData._GoodsSubClass]);
        Lable_Currentforce.SetText((int)EquipItem.GetEquipForce(itemfileInfo));
        int addforce = ((int)EquipItem.GetNextLevelEquipForce(itemfileInfo, UpgradeType.StarUp) - (int)EquipItem.GetEquipForce(itemfileInfo));

        if (addforce > 0)
        {
            Lable_addForce.gameObject.SetActive(true);
            Lable_addForce.SetText("+" + addforce);
        }
        else
        {
            Lable_addForce.gameObject.SetActive(false);
        }
        //Lable_strengthLevle.SetText(EquipmentUpgradeDataManger.Instance.GetStrengthLevel(itemfileInfo));
        int starLevel = PlayerDataManager.Instance.GetEquipmentStarLevel((EquiptSlotType)itemfileInfo.sSyncContainerGoods_SC.nPlace);

        if (starLevel < CommonDefineManager.Instance.CommonDefine.StartStrengthLimit)
        {
            Eff_go.SetActive(true);
        }
        else
        {
            Eff_go.SetActive(false);
        }
        SetStarColor(starLevel);
    }
Beispiel #8
0
        void DoDuplicateObject()
        {
            if (source == null)
            {
                Debug.LogError("A source must be assigned!");
                return;
            }

            if (string.IsNullOrEmpty(object_title.Trim()))
            {
                Debug.LogError("Title can't be blank");
                return;
            }
            ;
            copied_prefabs.Clear();

            if (source is ItemData)
            {
                ItemData nitem = CopyAsset <ItemData>((ItemData)source, object_title);

                if (nitem != null && nitem.item_prefab != null)
                {
                    GameObject nprefab = CopyPrefab(nitem.item_prefab, object_title);
                    nitem.item_prefab = nprefab;
                    Item item = nprefab.GetComponent <Item>();
                    if (item != null)
                    {
                        item.data = nitem;
                    }
                }

                if (nitem != null && nitem.equipped_prefab != null)
                {
                    GameObject nprefab = CopyPrefab(nitem.equipped_prefab, object_title + "Equip");
                    nitem.equipped_prefab = nprefab;
                    EquipItem item = nprefab.GetComponent <EquipItem>();
                    if (item != null)
                    {
                        item.data = nitem;
                    }
                }

                Selection.activeObject = nitem;
            }

            if (source is CharacterData)
            {
                CharacterData nitem = CopyAsset <CharacterData>((CharacterData)source, object_title);

                if (nitem != null && nitem.character_prefab != null)
                {
                    GameObject nprefab = CopyPrefab(nitem.character_prefab, object_title);
                    nitem.character_prefab = nprefab;
                    Character character = nprefab.GetComponent <Character>();
                    if (character != null)
                    {
                        character.data = nitem;
                    }
                }

                Selection.activeObject = nitem;
            }

            if (source is ConstructionData)
            {
                ConstructionData nitem = CopyAsset <ConstructionData>((ConstructionData)source, object_title);

                if (nitem != null && nitem.construction_prefab != null)
                {
                    GameObject nprefab = CopyPrefab(nitem.construction_prefab, object_title);
                    nitem.construction_prefab = nprefab;
                    Construction construct = nprefab.GetComponent <Construction>();
                    if (construct != null)
                    {
                        construct.data = nitem;
                    }
                }

                Selection.activeObject = nitem;
            }

            if (source is PlantData)
            {
                PlantData nitem = CopyAsset <PlantData>((PlantData)source, object_title);

                if (nitem != null)
                {
                    if (nitem.growth_stage_prefabs.Length == 0 && nitem.plant_prefab != null)
                    {
                        GameObject nprefab = CopyPrefab(nitem.plant_prefab, object_title);
                        nitem.plant_prefab = nprefab;
                        Plant plant = nprefab.GetComponent <Plant>();
                        if (plant != null)
                        {
                            plant.data = nitem;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < nitem.growth_stage_prefabs.Length; i++)
                        {
                            GameObject sprefab = CopyPrefab(nitem.growth_stage_prefabs[i], object_title + "S" + (i + 1));
                            nitem.growth_stage_prefabs[i] = sprefab;
                            nitem.plant_prefab            = sprefab;
                            Plant plant_stage = sprefab.GetComponent <Plant>();
                            if (plant_stage != null)
                            {
                                plant_stage.data = nitem;
                            }
                        }
                    }
                }

                Selection.activeObject = nitem;
            }

            AssetDatabase.SaveAssets();
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
Beispiel #9
0
    // Load equipment from PlayerInventory.xml
    void LoadEquipment()
    {
        XmlDocument xmlDocument = new XmlDocument();

        xmlDocument.LoadXml(INVENTORY_XML.text);
        XmlNodeList itemNode = xmlDocument.GetElementsByTagName("EquipedWeapon");

        // Read items from xml, copy from database, and add to inventory
        foreach (XmlNode itemInfo in itemNode)
        {
            string tempName = "";
            tempName = itemInfo.InnerText;

            Dictionary <string, string> tempDict;
            // Copy item from database and set count
            if (itemDatabase != null)
            {
                tempDict = itemDatabase.GetItem(tempName);
                if (tempDict != null)
                {
                    switch (tempDict ["ItemSubtype"])
                    {
                    case "WEAPON":
                        EquipItem tempEquip = new EquipItem(tempDict);
                        weapon = tempEquip;
                        break;

                    case "NA":
                        weapon = null;
                        break;
                    }
                }
            }
        }

        itemNode = xmlDocument.GetElementsByTagName("EquipedArmor");

        // Read items from xml, copy from database, and add to inventory
        foreach (XmlNode itemInfo in itemNode)
        {
            string tempName = "";
            tempName = itemInfo.InnerText;

            Dictionary <string, string> tempDict;
            // Copy item from database and set count
            if (itemDatabase != null)
            {
                tempDict = itemDatabase.GetItem(tempName);
                if (tempDict != null)
                {
                    switch (tempDict ["ItemSubtype"])
                    {
                    case "ARMOR":
                        EquipItem tempArmor = new EquipItem(tempDict);
                        armor = tempArmor;
                        break;

                    case "NA":
                        armor = null;
                        break;
                    }
                }
            }
        }

        itemNode = xmlDocument.GetElementsByTagName("EquipedBoots");

        // Read items from xml, copy from database, and add to inventory
        foreach (XmlNode itemInfo in itemNode)
        {
            string tempName = "";
            tempName = itemInfo.InnerText;

            Dictionary <string, string> tempDict;
            // Copy item from database and set count
            if (itemDatabase != null)
            {
                tempDict = itemDatabase.GetItem(tempName);
                if (tempDict != null)
                {
                    switch (tempDict ["ItemSubtype"])
                    {
                    case "NA":
                        boots = null;
                        break;

                    case "BOOTS":
                        EquipItem tempBoots = new EquipItem(tempDict);
                        boots = tempBoots;
                        break;
                    }
                }
            }
        }
    }
Beispiel #10
0
        /// <summary>
        /// 初始装备信息栏,添加信息prefab
        /// </summary>
        /// <param name="itemFielInfo">Item fiel info.</param>
        public override void Init(ItemFielInfo itemFielInfo, bool isLeftPos, bool Cansale)
        {
            List <JewelInfo> jewelInfos = PlayerDataManager.Instance.GetJewelInfo((EquiptSlotType)int.Parse((itemFielInfo.LocalItemData as EquipmentData)._vectEquipLoc));

            m_AutoAddDragTool.ClearAll();
            EquipItemMainProperty mainPropertyObj = (Instantiate(MainPropertyPrefab) as GameObject).GetComponent <EquipItemMainProperty>();

            mainPropertyObj.gameObject.AddComponent <BoxCollider>().size = new Vector3(300, 200, 1);
            //EquipItemMainProperty mainPropertyObj = CreatObjectToNGUI.InstantiateObj(MainPropertyPrefab,Grid).GetComponent<EquipItemMainProperty>();
            //mainPropertyObj.transform.localPosition = Vector3.zero;
            mainPropertyObj.Init(itemFielInfo);
            AddObj(mainPropertyObj.gameObject);

            SingleItemTipsEffect mainAtbObj = (Instantiate(IsShowEquiptItem?MainAttribute_NormalPrefab:MainAttribute_CompairPrefab) as GameObject).GetComponent <SingleItemTipsEffect>();

            //SingleItemTipsEffect mainAtbObj = CreatObjectToNGUI.InstantiateObj(IsShowEquiptItem?MainAttribute_CompairPrefab:MainAttribute_NormalPrefab ,Grid).GetComponent<SingleItemTipsEffect>();
            mainAtbObj.Init(itemFielInfo, IsShowEquiptItem?SingleItemTipsEffect.EffectType.MainAttribute:SingleItemTipsEffect.EffectType.MainAttributeCompair);
            AddObj(mainAtbObj.gameObject);

            if (EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1MainAdd) != "+0")
            {
                SingleItemTipsEffect normalAdd = (Instantiate(MainAttribute_NormalPrefab) as GameObject).GetComponent <SingleItemTipsEffect>();
                //SingleItemTipsEffect normalAdd = CreatObjectToNGUI.InstantiateObj(MainAttribute_NormalPrefab ,Grid).GetComponent<SingleItemTipsEffect>();
                normalAdd.Init(itemFielInfo, SingleItemTipsEffect.EffectType.MainProAdd);
                AddObj(normalAdd.gameObject);
            }

            if (EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1StarAdd) != "+0")
            {
                SingleItemTipsEffect normalAdd = (Instantiate(MainAttribute_NormalPrefab) as GameObject).GetComponent <SingleItemTipsEffect>();
                //SingleItemTipsEffect normalAdd = CreatObjectToNGUI.InstantiateObj(MainAttribute_NormalPrefab ,Grid).GetComponent<SingleItemTipsEffect>();
                normalAdd.Init(itemFielInfo, SingleItemTipsEffect.EffectType.MainProAddForStar);
                AddObj(normalAdd.gameObject);
            }
            if (Cansale)
            {
                if (jewelInfos[0].JewelID != 0) //1号孔已镶嵌
                {
                    jewel1 = ItemDataManager.Instance.GetItemData(jewelInfos[0].JewelID) as Jewel;
                    skill  = _PassiveSkillDataBase._dataTable.First(c => c.SkillID == jewel1.PassiveSkill && c.SkillLevel == jewelInfos[0].JewelLevel);
                    EquipmentAtt_Jewel att = (Instantiate(MainAttribute_jewelPrefab) as GameObject).GetComponent <EquipmentAtt_Jewel>();
                    att.init(jewel1, skill, false, jewel1._ColorLevel);
                    AddObj(att.gameObject);
                }
                if (jewelInfos[1].JewelID != 0) //2号孔已镶嵌
                {
                    jewel2 = ItemDataManager.Instance.GetItemData(jewelInfos[1].JewelID) as Jewel;
                    skill  = _PassiveSkillDataBase._dataTable.First(c => c.SkillID == jewel2.PassiveSkill && c.SkillLevel == jewelInfos[1].JewelLevel);
                    EquipmentAtt_Jewel att = (Instantiate(MainAttribute_jewelPrefab) as GameObject).GetComponent <EquipmentAtt_Jewel>();
                    att.init(jewel2, skill, false, jewel2._ColorLevel);
                    AddObj(att.gameObject);
                }
                if (jewelInfos[0].JewelID != 0 && jewelInfos[1].JewelID != 0 && jewelInfos[0].JewelID != jewelInfos[1].JewelID)
                {
                    if (jewel1.StoneGrop != 0 && jewel1.StoneGrop == jewel2.StoneGrop)
                    {
                        skill = _PassiveSkillDataBase._dataTable.First(c => c.SkillID == jewel1._activePassiveSkill.skillID && c.SkillLevel == jewel1._activePassiveSkill.skillLevel);
                        EquipmentAtt_Jewel att = (Instantiate(MainAttribute_jewelPrefab) as GameObject).GetComponent <EquipmentAtt_Jewel>();
                        att.init(jewel2, skill, true, jewel2._ColorLevel);
                        AddObj(att.gameObject);
                    }
                }
            }
            GameObject desLabel = (Instantiate(DesPanelPrefab) as GameObject);

            desLabel.GetComponent <SingleButtonCallBack>().SetButtonText(LanguageTextManager.GetString(itemFielInfo.LocalItemData._szDesc));
            AddObj(desLabel);
            if (Cansale)
            {
                GameObject PriceLabel = (Instantiate(PricePanelPrefab) as GameObject);
                PriceLabel.GetComponent <ItemPricePanel>().SetPrice(itemFielInfo.LocalItemData._SaleCost + itemFielInfo.equipmentEntity.ITEM_FIELD_VISIBLE_COMM);
                AddObj(PriceLabel);
            }
            base.Init(itemFielInfo, isLeftPos, Cansale);
        }
Beispiel #11
0
 /// <summary>
 /// Show the info of the item.
 /// </summary>
 /// <param name="orderType">The order type of item.</param>
 /// <param name="itemTran">The transform of item.</param>
 /// <param name="itemInfo">The info of item.</param>
 public static void ShowItem(OrderType orderType, EquipItem itemTran, ItemInfo itemInfo)
 {
     var quality = ItemModeLocator.Instance.GetQuality(itemInfo.TmplId);
     var level = itemInfo.Level;
     var job = ItemModeLocator.Instance.GetJob(itemInfo.TmplId);
     var atk = ItemModeLocator.Instance.GetAttack(itemInfo.TmplId, itemInfo.Level);
     var hp = ItemModeLocator.Instance.GetHp(itemInfo.TmplId, itemInfo.Level);
     var recover = ItemModeLocator.Instance.GetRecover(itemInfo.TmplId, itemInfo.Level);
     ShowItem(orderType, itemTran, quality, level, job, atk, hp, recover);
 }
Beispiel #12
0
 /// <summary>
 /// Show the info of the item.
 /// </summary>
 /// <param name="orderType">The order type of item.</param>
 /// <param name="itemTran">The transform of item.</param>
 /// <param name="tempId">The template id of the item.</param>
 /// <param name="level">The level of the item.</param>
 public static void ShowItem(OrderType orderType, EquipItem itemTran, int tempId, short level)
 {
     int quality = 0;
     sbyte job = -1;
     int atk = -1;
     int hp = -1;
     int recover = -1;
     var itemType = ItemModeLocator.Instance.GetItemType(tempId);
     if (itemType == EquipType.Equip)
     {
         var equipTemp = ItemModeLocator.Instance.ItemTemplates.EquipTmpls[tempId];
         quality = equipTemp.BaseTmpl.Quality;
         job = equipTemp.JobType;
         atk = equipTemp.Attack;
         hp = equipTemp.Hp;
         recover = equipTemp.Recover;
     }
     if (itemType == EquipType.Armor)
     {
         var armorTemp = ItemModeLocator.Instance.ItemTemplates.ArmorTmpls[tempId];
         quality = armorTemp.BaseTmpl.Quality;
         atk = armorTemp.Attack;
         hp = armorTemp.Hp;
         recover = armorTemp.Recover;
     }
     if (itemType == EquipType.Material)
     {
         var materialTemp = ItemModeLocator.Instance.ItemTemplates.MaterialTmpls[tempId];
         quality = materialTemp.BaseTmpl.Quality;
         job = materialTemp.FitJobType;
     }
     ShowItem(orderType, itemTran, quality, level, job, atk, hp, recover);
 }
Beispiel #13
0
    private static void CreateArmorConfig()
    {
        List <Dictionary <string, string> > xxListResult;


        #region BasicHeros
        xxListResult = ReadVSC("hero");
        HeroRace[]      heroRaces   = Resources.LoadAll <HeroRace>("");
        RoleCareer[]    careers     = Resources.LoadAll <RoleCareer>("");
        List <HeroInfo> AlreadyHave = Resources.LoadAll <HeroInfo>("").ToList();
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];

            if (AlreadyHave.Exists(x => x.ID == Dic["id"]))
            {
                continue;
            }
            //
            HeroInfo     mi  = ScriptableObject.CreateInstance <HeroInfo>();
            CharacterSex sex = (CharacterSex)(StringToInteger(Dic["gender"]));
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], sex, "");
            int Race = StringToInteger(Dic["race"]);
            foreach (HeroRace race in heroRaces)
            {
                if (race.Index == Race)
                {
                    mi.Race = race; break;
                }
            }
            int career = StringToInteger(Dic["career"]);
            foreach (RoleCareer c in careers)
            {
                if (c.Index == career)
                {
                    mi.Career = c; break;
                }
            }
            mi.InitRAL(RALByDictionary(Dic));
            mi.WeaponRaceList = GetWeaponTypeList(Dic["weaponClass"]);
            mi.SpecialStr     = Dic["specialStr"];
            mi.AddSkillData(
                getSkillsByString(Dic["skill0"])
                , getSkillsByString(Dic["skill1"])
                , getSkillsByString(Dic["skillOmega"])
                );
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/heroes/"
                                      + career + "_"
                                      + mi.ID.Substring(mi.ID.Length - 3) + "_" + mi.Name + ".asset");
        }
        #endregion
        return;

        #region enemy
        xxListResult = CreateConfig.ReadVSC("enemy");
        EnemyRank[] eRanks = Resources.LoadAll <EnemyRank>("");
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            EnemyInfo    mi  = ScriptableObject.CreateInstance <EnemyInfo>();
            CharacterSex sex = (CharacterSex)(StringToInteger(Dic["gender"]));
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], sex, "");
            mi.Race = EnemyRaces(Dic["race"]);

            int ranktype = StringToInteger(Dic["rank"]);
            foreach (EnemyRank rank in eRanks)
            {
                if (rank.Index == ranktype)
                {
                    mi.EnemyRank = rank; break;
                }
            }
            mi.RAL              = RALByDictionary(Dic);
            mi.weight           = StringToInteger(Dic["weight"]);
            mi.dropPercent      = StringToInteger(Dic["dropRate"]);
            mi.StartAppearLevel = StringToInteger(Dic["startLevel"]);
            mi.EndAppearLevel   = StringToInteger(Dic["endLevel"]);
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/enemies/"
                                      + mi.ID.Split('#')[1] + mi.Name + ".asset");
        }
        #endregion
        return;

        #region Equip
        xxListResult = CreateConfig.ReadVSC("equip");
        ArmorRank[]        armor_ranks  = Resources.LoadAll <ArmorRank>("");
        WeaponRace[]       waepon_races = Resources.LoadAll <WeaponRace>("");
        List <SpriteAtlas> allAtlas     = Resources.LoadAll <SpriteAtlas>("Sprites/atlas").ToList();
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            EquipItem ei = ScriptableObject.CreateInstance <EquipItem>();
            ei.initData(Dic["id"], Dic["name"], Dic["desc"], CreateConfig.StringToInteger(Dic["level"])
                        , false, true, true, true, false, Dic["specialStr"]);
            ei.ResistStr = Dic["resistStr"];
            //
            int rankType = CreateConfig.StringToInteger(Dic["type"]);
            foreach (ArmorRank rank in armor_ranks)
            {
                if (rank.Index == rankType)
                {
                    ei.ArmorRank = rank; break;
                }
            }
            if (!string.IsNullOrEmpty(Dic["suit"]))
            {
                ei.SuitBelong = true; ei.SuitId = Dic["suit"];
            }
            //
            ei.RAL           = RALBySpecialStr(RoleAttributeList.zero, Dic["specialStr"]);
            ei.RAL           = RALByResistStr(ei.RAL, Dic["resistStr"]);
            ei.PassiveEffect = Dic["passiveEffect"];
            //
            string        _class = Dic["class"];
            EquipPosition pos    = ROHelp.EQUIP_POS(_class);
            ei.EquipPos = pos;
            if (pos == EquipPosition.Hand)
            {
                string weaponClass = Dic["weaponClass"].ToLower();
                foreach (WeaponRace r in waepon_races)
                {
                    if (weaponClass == r.NAME.ToLower())
                    {
                        ei.WeaponRace = r; break;
                    }
                }
            }


            //
            AssetDatabase.CreateAsset(ei, "Assets/Resources/ScriptableObjects/items/Equips/"
                                      + (int)ei.EquipPos + "_"
                                      + ei.LEVEL + "_" + ei.NAME + ".asset");
        }
        #endregion
        return;

        xxListResult = ReadVSC("hero");
        //HeroRace[] heroRaces = Resources.LoadAll<HeroRace>("");
        //RoleCareer[] careers = Resources.LoadAll<RoleCareer>("");
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            HeroInfo     mi  = ScriptableObject.CreateInstance <HeroInfo>();
            CharacterSex sex = (CharacterSex)(StringToInteger(Dic["gender"]));
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], sex, "");
            int Race = StringToInteger(Dic["race"]);
            foreach (HeroRace race in heroRaces)
            {
                if (race.Index == Race)
                {
                    mi.Race = race; break;
                }
            }
            int career = StringToInteger(Dic["career"]);
            foreach (RoleCareer c in careers)
            {
                if (c.Index == career)
                {
                    mi.Career = c; break;
                }
            }
            mi.InitRAL(RALByDictionary(Dic));
            mi.WeaponRaceList = GetWeaponTypeList(Dic["weaponClass"]);
            mi.SpecialStr     = Dic["specialStr"];
            mi.AddSkillData(
                getSkillsByString(Dic["skill0"])
                , getSkillsByString(Dic["skill1"])
                , getSkillsByString(Dic["skillOmega"])
                );
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/heroes/"
                                      + career + "_"
                                      + mi.ID.Substring(mi.ID.Length - 3) + "_" + mi.Name + ".asset");
        }

        return;



        return;

        #region Consumable
        xxListResult = CreateConfig.ReadVSC("material");
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            SDConstants.MaterialType    MT  = CreateConfig.getMTypeByString(Dic["materialType"]);
            consumableItem mi = ScriptableObject.CreateInstance <consumableItem>();
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], CreateConfig.StringToInteger(Dic["level"])
                        , false, true, true, true, false, Dic["specialStr"], SDConstants.ItemType.Consumable);
            mi.MaterialType     = MT;
            mi.buyPrice_coin    = StringToInteger(Dic["buyPrice_coin"]);
            mi.buyPrice_diamond = StringToInteger(Dic["buyPrice_diamond"]);
            mi.minLv            = StringToInteger(Dic["minLv"]);
            mi.maxLv            = StringToInteger(Dic["maxLv"]);
            mi.exchangeType     = StringToInteger(Dic["exchangeType"]);
            mi.weight           = StringToInteger(Dic["weight"]);
            mi.ConsumableType   = (SDConstants.ConsumableType)StringToInteger(Dic["consumableType"]);
            if (Dic.ContainsKey("range"))
            {
                mi.AOE = ROHelp.AOE_TYPE(Dic["range"]);
            }
            if (Dic.ContainsKey("target"))
            {
                mi.AIM = Dic["target"].ToUpper();
            }
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/items/Consumables/"
                                      + mi.ID.Substring(mi.ID.Length - 3) + mi.NAME + ".asset");
        }
        #endregion
    }
Beispiel #14
0
    public void Init(ItemFielInfo itemFielInfo)
    {
        CurrItemFielInfo = itemFielInfo;
        if (CurrItemFielInfo == null)
        {
            EquipName.text     = string.Empty;
            EquipAllowLev.text = string.Empty;
            VactionBg.SetActive(false);
            Occupations.ApplyAllItem(P => P.ChangeSprite(0));

            Part.text     = string.Empty;
            StarLev.text  = string.Empty;
            StarName.text = string.Empty;

            StarDesc.text           = string.Empty;
            StarProcess.sliderValue = 0;
            return;
        }
        //初始化图标
        if (m_equipItem == null)
        {
            Transform attachPoint;
            transform.RecursiveFindObject("ItemAttachPoint", out attachPoint);
            m_equipItem = NGUITools.AddChild(attachPoint.gameObject, EquipItemPrefab).GetComponent <EquipItem>();
        }
        if (CurrItemFielInfo == null)
        {
            return;
        }
        m_equipItem.InitItemData(itemFielInfo);
        //初始化其他属性(名称,其他属性.....)
        EquipName.text = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.EquipName);
        var playerLev  = PlayerManager.Instance.FindHeroDataModel().UnitValues.sMsgPropCreateEntity_SC_UnitVisibleValue.UNIT_FIELD_LEVEL;
        var allowLevel = itemFielInfo.LocalItemData._AllowLevel;

        //玩家等级不足时,等级数字显示为红色
        EquipAllowLev.text = allowLevel.ToString().SetColor(allowLevel > playerLev?TextColorType.Red:TextColorType.EquipProperty);
        //玩家职业处理
        string[] ItemVocation = itemFielInfo.LocalItemData._AllowProfession.Split('+');
        VactionBg.SetActive(false);
        Occupations.ApplyAllItem(P => P.ChangeSprite(0));
        if (ItemVocation.Length > 0)
        {
            var vos = ItemVocation.ToList();
            vos.Sort((a, b) => a.CompareTo(b));
            for (int i = 0; i < vos.Count; i++)
            {
                Occupations[i].ChangeSprite(int.Parse(vos[i]));
            }
            if (ItemVocation.Length == 1)
            {
                var vo = int.Parse(ItemVocation[0]);
                if (vo != PlayerManager.Instance.FindHeroDataModel().PlayerValues.PlayerCommonValue.PLAYER_FIELD_VISIBLE_VOCATION)
                {
                    VactionBg.SetActive(true);
                }
            }
        }

        Part.text = ((GoodsSubClass)itemFielInfo.LocalItemData._GoodsSubClass).GetGoodsSubClassName();        //扩展方法计算物品类型的IDS
        string s       = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.EquipStarLevel);
        int    starLev = 0;

        if (!string.IsNullOrEmpty(s))
        {
            starLev = Convert.ToInt32(s);
        }

        StarLev.SetText(starLev);
        int Starclass = (starLev - 1) / 10;
        int spriteId  = starLev == 0?1:Starclass + 2;

        Star.ChangeSprite(spriteId);

        StarName.text = LanguageTextManager.GetString(string.Format("{0}{1}", "IDS_I36_", Starclass + 1));//1=明珠 2=夏炉 桐琴 御盾 玉麟 周鼎

        //分母固定为10,分子为:求余数(星阶等级/10)。进度条进度长度显示星阶(等级/10)百分比长度
        //int starLevel=itemFielInfo.equipmentEntity.EQUIP_FIELD_START_LEVEL;
        int currProcess = ((starLev - 1) % 10) + 1;

        //currProcess=(currProcess==0&&starLevel!=0)?10:currProcess;
        StarDesc.text = string.Format("{0}/{1}", currProcess, 10);

        m_starProcessFore.ChangeSprite(spriteId - 1);
        StarProcess.sliderValue = currProcess / 10f;
    }
Beispiel #15
0
    public void OpenEquipScreen(EquipItem selectedEquip)
    {
        InventoryScreenObject.gameObject.SetActive(false);

        EquipImage.sprite     = selectedEquip.equipImage;
        EquipName.text        = selectedEquip.equipName;
        EquipDescription.text = selectedEquip.equipDescription;

        //Requirements
        if (selectedEquip.firstRequirement == "")
        {
            firstRequirement.gameObject.SetActive(false);
        }
        else if (selectedEquip.firstRequirement != "")
        {
            firstRequirement.gameObject.SetActive(true);
            FirstRequirementText.text = selectedEquip.firstRequirement;
        }
        if (selectedEquip.secondRequirement == "")
        {
            SecondRequirement.gameObject.SetActive(false);
        }
        else if (selectedEquip.secondRequirement != "")
        {
            SecondRequirement.gameObject.SetActive(true);
            SecondRequirementText.text = selectedEquip.secondRequirement;
        }

        //Costs and Inventory
        if (selectedEquip.firstItem == null && selectedEquip.secondItem == null)
        {
            firstItemCostObject.gameObject.SetActive(false);
            secondItemCostObject.gameObject.SetActive(false);
            firstItemInventoryObject.gameObject.SetActive(false);
            secondItemInventoryObject.gameObject.SetActive(false);
        }
        else
        {
            firstItemCostObject.gameObject.SetActive(true);
            secondItemCostObject.gameObject.SetActive(true);
            firstItemInventoryObject.gameObject.SetActive(true);
            secondItemInventoryObject.gameObject.SetActive(true);


            firstItem.sprite          = selectedEquip.firstItem.resourceImage;
            firstItemCost.text        = selectedEquip.firstItemCost.ToString();
            firstItemInventory.sprite = selectedEquip.firstItem.resourceImage;
            firstItemPQnty.text       = selectedEquip.firstItem.playerQuantity.ToString();

            secondItem.sprite          = selectedEquip.secondItem.resourceImage;
            secondItemCost.text        = selectedEquip.secondItemCost.ToString();
            secondItemInventory.sprite = selectedEquip.secondItem.resourceImage;
            secondItemPQnty.text       = selectedEquip.secondItem.playerQuantity.ToString();

            if (selectedEquip.firstItemCost > selectedEquip.firstItem.playerQuantity)
            {
                firstItemInventory.color = new Color32(123, 6, 27, 255);
                firstItemPQnty.color     = new Color32(123, 6, 27, 255);
            }
            else
            {
                firstItemInventory.color = new Color32(255, 255, 255, 255);
                firstItemPQnty.color     = new Color32(255, 255, 255, 255);
            }
            if (selectedEquip.secondItemCost > selectedEquip.secondItem.playerQuantity)
            {
                secondItemInventory.color = new Color32(123, 6, 27, 255);
                secondItemPQnty.color     = new Color32(123, 6, 27, 255);
            }
            else
            {
                secondItemInventory.color = new Color32(255, 255, 255, 255);
                secondItemPQnty.color     = new Color32(255, 255, 255, 255);
            }
        }

        if (selectedEquip.thirdItem != null)
        {
            thirdItemCostObject.gameObject.SetActive(true);
            thirdItemInventoryObject.gameObject.SetActive(true);

            thirdItem.sprite          = selectedEquip.thirdItem.resourceImage;
            thirdItemCost.text        = selectedEquip.thirdItemCost.ToString();
            thirdItemInventory.sprite = selectedEquip.thirdItem.resourceImage;
            thirdItemPQnty.text       = selectedEquip.thirdItem.playerQuantity.ToString();

            if (selectedEquip.thirdItemCost > selectedEquip.thirdItem.playerQuantity)
            {
                thirdItemInventory.color = new Color32(123, 6, 27, 255);
                thirdItemPQnty.color     = new Color32(123, 6, 27, 255);
            }
            else
            {
                thirdItemInventory.color = new Color32(255, 255, 255, 255);
                thirdItemPQnty.color     = new Color32(255, 255, 255, 255);
            }
        }
        else
        {
            thirdItemCostObject.gameObject.SetActive(false);
            thirdItemInventoryObject.gameObject.SetActive(false);
        }

        //Craft Button
        if (selectedEquip.firstItem == null && selectedEquip.secondItem == null)
        {
            UpgradeButton.GetComponent <Button>().interactable             = false;
            UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 125);
        }
        else if (selectedEquip.thirdItem != null)
        {
            if (selectedEquip.firstRequirement != "")
            {
                UpgradeButton.GetComponent <Button>().interactable             = false;
                UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 125);
            }
            if (selectedEquip.firstItemCost > selectedEquip.firstItem.playerQuantity || selectedEquip.secondItemCost > selectedEquip.secondItem.playerQuantity || selectedEquip.thirdItemCost > selectedEquip.thirdItem.playerQuantity)
            {
                UpgradeButton.GetComponent <Button>().interactable             = false;
                UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 125);
            }
            else
            {
                UpgradeButton.GetComponent <Button>().interactable             = true;
                UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 255);
            }
        }
        else
        {
            if (selectedEquip.firstRequirement != "")
            {
                UpgradeButton.GetComponent <Button>().interactable             = false;
                UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 125);
            }
            if (selectedEquip.firstItemCost > selectedEquip.firstItem.playerQuantity || selectedEquip.secondItemCost > selectedEquip.secondItem.playerQuantity)
            {
                UpgradeButton.GetComponent <Button>().interactable             = false;
                UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 125);
            }
            else
            {
                UpgradeButton.GetComponent <Button>().interactable             = true;
                UpgradeButton.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 255);
            }
        }

        EquipScreenObject.gameObject.SetActive(true);
    }
Beispiel #16
0
    public bool Dress(int id)
    {
        objectInfo info = ObjectsInfo.instance.FindObjecInfoById(id);

        if (info.type != objectType.Equip)
        {
            return(false);
        }
        if (ps.hero == herotype.magician)
        {
            if (info.applicationType == ApplicationType.Swordman)
            {
                return(false);
            }
        }
        if (ps.hero == herotype.swordman)
        {
            if (info.applicationType == ApplicationType.Magician)
            {
                return(false);
            }
        }

        GameObject parent = null;

        switch (info.dressType)
        {
        case DressType.Headgear:
            parent = headgear;
            break;

        case DressType.Armor:
            parent = armor;
            break;

        case DressType.LeftHand:
            parent = lefthand;
            break;

        case DressType.RightHand:
            parent = righthand;
            break;

        case DressType.Shoe:
            parent = shoe;
            break;

        case DressType.Accessory:
            parent = accessory;
            break;
        }

        EquipItem item = parent.GetComponentInChildren <EquipItem> ();

        if (item != null)
        {
            EquipAndBag.instance.getId(item.id);//装备卸下,放回
            MinProperty(item.id);
            item.SetInfo(info);
            plusProperty(info.id);
        }
        else
        {
            GameObject itemGo = Instantiate(equip_item);
            itemGo.transform.SetParent(parent.transform);
            itemGo.transform.position = parent.transform.position;
            itemGo.GetComponent <EquipItem> ().SetInfo(info);
            plusProperty(id);
        }

        //UpdateProperty ();
        return(true);
    }
Beispiel #17
0
    public override void OnSelect()
    {
        EquipItem equipItem = (EquipItem)data;

        foreach (var itr in inventory.equip_slots)
        {
            UIEquipSlot slot = itr.Value;
            if (slot.part != equipItem.part)
            {
                slot.SetActiveGuideArrow(false);
                continue;
            }

            if (slot.equip_index == equipItem.equip_index)
            {
                slot.SetActiveGuideArrow(false);
                continue;
            }

            slot.SetActiveGuideArrow(true);
        }

        inventory.item_info.Clear();
        inventory.item_info.SetItemIcon(this);
        inventory.item_info.SetItemName(data.meta.name + "\n" + "<size=" + (inventory.item_info.name.fontSize * 0.8) + ">Lv." + equipItem.level + "</size>");

        string description = data.meta.description + "\n\n";

        foreach (Stat.Data stat in equipItem.main_stat.GetStats())
        {
            Stat.Meta meta = Stat.Manager.Instance.FindMeta(stat.type);
            description += "<color=white> " + meta.ToString(stat.value) + "</color>\n";
        }

        foreach (Stat.Data stat in equipItem.sub_stat.GetStats())
        {
            Stat.Meta meta = Stat.Manager.Instance.FindMeta(stat.type);
            description += "<color=#4eb105> " + meta.ToString(stat.value) + "</color>\n";
        }

        foreach (Skill skill in equipItem.skills)
        {
            description += "<color=red> " + skill.meta.description + "</color>\n";
        }
        inventory.item_info.SetDescription(description);

        Text text = UIUtil.FindChild <Text>(inventory.item_info.buttons[(int)UIItemInfo.Action.Equip_0].transform, "Text");

        if (EquipItem.Part.Hand == equipItem.part || EquipItem.Part.Ring == equipItem.part)
        {
            text.text = "[Equip:L]";
        }
        else
        {
            text.text = "[Equip]";
        }
        inventory.item_info.SetButtonListener(UIItemInfo.Action.Equip_0, () =>
        {
            if (0 <= equipItem.slot_index)
            {
                GameManager.Instance.player.inventory.Remove(equipItem.slot_index);
            }
            if (true == equipItem.equip)
            {
                GameManager.Instance.player.Unequip(equipItem.part, equipItem.equip_index);
            }
            EquipItem prevItem = GameManager.Instance.player.Equip(equipItem, 0);
            if (null != prevItem)
            {
                GameManager.Instance.player.inventory.Add(prevItem);
            }
            OnSelect();
            foreach (var itr in inventory.equip_slots)
            {
                itr.Value.SetActiveGuideArrow(false);
            }
        });
        inventory.item_info.SetButtonListener(UIItemInfo.Action.Equip_1, () =>
        {
            if (0 <= equipItem.slot_index)
            {
                GameManager.Instance.player.inventory.Remove(equipItem.slot_index);
            }
            if (true == equipItem.equip)
            {
                GameManager.Instance.player.Unequip(equipItem.part, equipItem.equip_index);
            }
            EquipItem prevItem = GameManager.Instance.player.Equip(equipItem, 1);
            if (null != prevItem)
            {
                GameManager.Instance.player.inventory.Add(prevItem);
            }
            OnSelect();
            foreach (var itr in inventory.equip_slots)
            {
                itr.Value.SetActiveGuideArrow(false);
            }
        });
        inventory.item_info.SetButtonListener(UIItemInfo.Action.Unequip, () =>
        {
            EquipItem item = GameManager.Instance.player.Unequip(equipItem.part, equipItem.equip_index);
            GameManager.Instance.player.inventory.Add(item);
            OnSelect();
            foreach (var itr in inventory.equip_slots)
            {
                itr.Value.SetActiveGuideArrow(false);
            }
        });
        inventory.item_info.SetButtonListener(UIItemInfo.Action.Drop, () =>
        {
            if (0 <= data.slot_index)
            {
                GameManager.Instance.player.inventory.Remove(data.slot_index);
            }
            else
            {
                GameManager.Instance.player.Unequip(equipItem.part, equipItem.equip_index);
            }
            inventory.item_info.Clear();
        });

        if (true == equipItem.equip)
        {
            if (EquipItem.Part.Hand == equipItem.part || EquipItem.Part.Ring == equipItem.part)
            {
                if (0 == equipItem.equip_index)
                {
                    inventory.item_info.buttons[(int)UIItemInfo.Action.Equip_0].gameObject.SetActive(false);
                }
                if (1 == equipItem.equip_index)
                {
                    inventory.item_info.buttons[(int)UIItemInfo.Action.Equip_1].gameObject.SetActive(false);
                }
            }
            else
            {
                inventory.item_info.buttons[(int)UIItemInfo.Action.Equip_0].gameObject.SetActive(false);
                inventory.item_info.buttons[(int)UIItemInfo.Action.Equip_1].gameObject.SetActive(false);
            }
            inventory.item_info.buttons[(int)UIItemInfo.Action.Drop].gameObject.SetActive(false);
        }
        else
        {
            if (EquipItem.Part.Hand == equipItem.part || EquipItem.Part.Ring == equipItem.part)
            {
                //
            }
            else
            {
                inventory.item_info.buttons[(int)UIItemInfo.Action.Equip_1].gameObject.SetActive(false);
            }
            inventory.item_info.buttons[(int)UIItemInfo.Action.Unequip].gameObject.SetActive(false);
        }
    }
Beispiel #18
0
    public void Init(ItemFielInfo itemfileInfo)
    {
        IconItem.Init(itemfileInfo);
        Lable_name.SetText(NGUIColor.SetTxtColor(LanguageTextManager.GetString(itemfileInfo.LocalItemData._szGoodsName), (TextColor)itemfileInfo.LocalItemData._ColorLevel));
        Lable_position.SetText(EquipmentUpgradeDataManger.Instance.PositionDic[itemfileInfo.LocalItemData._GoodsSubClass]);
        Lable_Currentforce.SetText((int)EquipItem.GetEquipForce(itemfileInfo));
        int addforce = ((int)EquipItem.GetNextLevelEquipForce(itemfileInfo, UpgradeType.Strength) - (int)EquipItem.GetEquipForce(itemfileInfo));

        if (addforce > 0)
        {
            Lable_addForce.gameObject.SetActive(true);
            Lable_addForce.SetText("+" + addforce);
        }
        else
        {
            Lable_addForce.gameObject.SetActive(false);
        }
        Lable_strengthLevle.SetText(EquipmentUpgradeDataManger.Instance.GetStrengthLevel(itemfileInfo));
        TaskGuideBtnRegister();
    }
Beispiel #19
0
        /// <summary>
        /// 普通装备属性显示
        /// </summary>
        /// <param name="itemFielInfo">Item fiel info.</param>
        /// <param name="effectType">Effect type.</param>
        public void Init(ItemFielInfo itemFielInfo, EffectType effectType)
        {
            Effect1Icon.spriteName = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1IconName);
            Effect2Icon.spriteName = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop2IconName);
            string effect1Name   = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1Name);
            string effect2Name   = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop2Name);
            string effect1AddNum = string.Empty;
            string effect2AddNum = string.Empty;

            switch (effectType)
            {
            case EffectType.MainAttribute:
            {
                TitleLabel.SetText(LanguageTextManager.GetString("IDS_I3_25"));
                Effect1NameLabel.SetText(effect1Name);
                Effect2NameLabel.SetText(effect2Name);
                string TatalValue = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1Value);
                if (string.IsNullOrEmpty(TatalValue))
                {
                    TatalValue = "0";
                }
                string AddValue = (int.Parse(TatalValue) - itemFielInfo.equipmentEntity.EQUIP_FIELD_EFFECTBASE0_VALUE).ToString();
                if (AddValue == "0")
                {
                    AddValue = "";
                }
                else
                {
                    AddValue = "(+" + AddValue + ")";
                }
                effect1AddNum = string.Format("{0} {1}", TatalValue, GetEffectYellowText(AddValue));

                string TatalValue1 = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop2Value);
                if (string.IsNullOrEmpty(TatalValue1))
                {
                    TatalValue1 = "0";
                }
                string AddValue1 = (int.Parse(TatalValue1) - itemFielInfo.equipmentEntity.EQUIP_FIELD_EFFECTBASE1_VALUE).ToString();
                if (AddValue1 == "0")
                {
                    AddValue1 = "";
                }
                else
                {
                    AddValue1 = "(+" + AddValue1 + ")";
                }
                effect2AddNum = string.Format("{0} {1}", TatalValue1, GetEffectYellowText(AddValue1));
            }
            break;

            case EffectType.MainAttributeCompair:
            {
                TitleLabel.SetText(LanguageTextManager.GetString("IDS_I3_25"));
                Effect1NameLabel.SetText(effect1Name);
                Effect2NameLabel.SetText(effect2Name);

                string TatalValue = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1Value);
                if (string.IsNullOrEmpty(TatalValue))
                {
                    TatalValue = "0";
                }
                string AddValue = (int.Parse(TatalValue) - itemFielInfo.equipmentEntity.EQUIP_FIELD_EFFECTBASE0_VALUE).ToString();
                if (AddValue == "0")
                {
                    AddValue = "";
                }
                else
                {
                    AddValue = "(+" + AddValue + ")";
                }
                effect1AddNum = string.Format("{0} {1}", TatalValue, GetEffectYellowText(AddValue));

                string TatalValue1 = EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop2Value);
                if (string.IsNullOrEmpty(TatalValue1))
                {
                    TatalValue1 = "0";
                }
                string AddValue1 = (int.Parse(TatalValue1) - itemFielInfo.equipmentEntity.EQUIP_FIELD_EFFECTBASE1_VALUE).ToString();
                if (AddValue1 == "0")
                {
                    AddValue1 = "";
                }
                else
                {
                    AddValue1 = "(+" + AddValue1 + ")";
                }
                effect2AddNum = string.Format("{0} {1}", TatalValue1, GetEffectYellowText(AddValue1));

                int effect1CompairNum = GetCompairNum(itemFielInfo, EquipInfoType.Prop1Value);
                int effect2CompairNum = GetCompairNum(itemFielInfo, EquipInfoType.Prop2Value);
                Effect1CompairNumLabel.SetText(effect1CompairNum > 0?GetEffectYellowText(effect1CompairNum.ToString()):GetEffectRedText(effect1CompairNum.ToString()));
                Effect2CompairNumLabel.SetText(effect2CompairNum > 0?GetEffectYellowText(effect2CompairNum.ToString()):GetEffectRedText(effect2CompairNum.ToString()));
                if (effect1CompairNum == 0)
                {
                    Effect1CompairNumLabel.gameObject.SetActive(false);
                }
                else
                {
                    Effect1CompairNumLabel.gameObject.SetActive(true);
                }
                if (effect2CompairNum == 0)
                {
                    Effect2CompairNumLabel.gameObject.SetActive(false);
                }
                else
                {
                    Effect2CompairNumLabel.gameObject.SetActive(true);
                }
                GenerateCompairIcon(effect1CompairNum, Effet1CompairIconPos);
                GenerateCompairIcon(effect2CompairNum, Effet2CompairIconPos);
            }
            break;

            case EffectType.MainProAdd:
                TitleLabel.SetText(LanguageTextManager.GetString("IDS_I3_59"));
                Effect1NameLabel.SetText(GetEffectBlueText(string.Format("{0} {1}", LanguageTextManager.GetString("IDS_I3_27"), effect1Name)));
                Effect2NameLabel.SetText(GetEffectBlueText(string.Format("{0} {1}", LanguageTextManager.GetString("IDS_I3_27"), effect2Name)));
                effect1AddNum = GetEffectYellowText(EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1MainAdd));
                effect2AddNum = GetEffectYellowText(EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop2MainAdd));
                break;

            case EffectType.MainProAddForStar:
                TitleLabel.SetText(LanguageTextManager.GetString("IDS_I3_60"));
                Effect1NameLabel.SetText(GetEffectGreenText(string.Format("{0} {1}", LanguageTextManager.GetString("IDS_I3_28"), effect1Name)));
                Effect2NameLabel.SetText(GetEffectGreenText(string.Format("{0} {1}", LanguageTextManager.GetString("IDS_I3_28"), effect2Name)));
                effect1AddNum = GetEffectYellowText(EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop1StarAdd));
                effect2AddNum = GetEffectYellowText(EquipItem.GetItemInfoDetail(itemFielInfo, EquipInfoType.Prop2StarAdd));
                break;
            }
            Effect1NumLabel.SetText(effect1AddNum);
            Effect2NumLabel.SetText(effect2AddNum);
        }
Beispiel #20
0
    //************************************************************
    // ITEM FUNCTIONS
    //************************************************************

    // Add to or increase inventory count
    public void AddItem(string name, int count)
    {
        // Check to see if the player already has the item
        foreach (EquipItem item in playerEquipItems)
        {
            if (name == item.Name)
            {
                item.Count += count;
                return;
            }
        }
        foreach (ConsumableItem item in playerConsumableItems)
        {
            if (name == item.Name)
            {
                item.Count += count;
                return;
            }
        }
        foreach (StoryItem item in playerStoryItems)
        {
            if (name == item.Name)
            {
                item.Count += count;
                return;
            }
        }

        // Otherwhise create new item
        Dictionary <string, string> tempDict;

        tempDict = itemDatabase.GetItem(name);
        if (tempDict != null)
        {
            Object     ITEM;
            GameObject tempItem;
            switch (tempDict ["ItemType"])
            {
            case "EQUIP":
                // Add to inventory
                EquipItem tempEquip = new EquipItem(tempDict);
                tempEquip.Count = count;
                playerEquipItems.Add(tempEquip);

                // Add to menu active Object list
                ITEM     = Resources.Load("Prefab/" + tempEquip.Prefab) as GameObject;
                tempItem = Instantiate(ITEM, Vector3.zero, Quaternion.identity) as GameObject;
                activeObjects.Add(tempItem);
                tempItem.name = tempEquip.Prefab;
                tempItem.SetActive(false);
                break;

            case "CONSUMABLE":
                // Add to inventory
                ConsumableItem tempConsumable = new ConsumableItem(tempDict);
                tempConsumable.Count = count;
                playerConsumableItems.Add(tempConsumable);

                // Add to menu active Object list
                ITEM     = Resources.Load("Prefab/" + tempConsumable.Prefab) as GameObject;
                tempItem = Instantiate(ITEM, Vector3.zero, Quaternion.identity) as GameObject;
                activeObjects.Add(tempItem);
                tempItem.name = tempConsumable.Prefab;
                tempItem.SetActive(false);
                break;

            case "STORY":
                // Add to inventory
                StoryItem tempStory = new StoryItem(tempDict);
                tempStory.Count = count;
                playerStoryItems.Add(tempStory);

                // Add to menu active Object list
                ITEM     = Resources.Load("Prefab/" + tempStory.Prefab) as GameObject;
                tempItem = Instantiate(ITEM, Vector3.zero, Quaternion.identity) as GameObject;
                activeObjects.Add(tempItem);
                tempItem.name = tempStory.Prefab;
                tempItem.SetActive(false);
                break;
            }

            UpdateDisplay();
        }
    }
Beispiel #21
0
    public void Init()
    {
        UpdateEventIcon();
        m_EnchantBtnLabel.text = (m_Creature.Grade >= 6 && m_Creature.Enchant >= 5) ? Localization.Get("OverEnchant") : Localization.Get("Enchant");
        //m_CreatureType.spriteName = string.Format("hero_info_type_{0}", m_Creature.Info.ShowAttackType);
        m_CreatureType.spriteName = string.Format("New_hero_info_type_{0}", m_Creature.Info.ShowAttackType);
        m_LabelName.text          = m_Creature.Info.Name;
        if (m_Creature.Enchant > 0)
        {
            m_LabelName.text += " " + m_Creature.GetEnchantText();
        }
        m_LeftLabelLevel.text = m_Creature.GetLevelText();
        m_LabelLevel.text     = Localization.Format("HeroLevelDesc", m_Creature.Level, m_Creature.LevelLimit);

        UpdateLock();

        m_CharacterContainer.Init(AssetManager.GetCharacterAsset(m_Creature.Info.ID, m_Creature.SkinName), UICharacterContainer.Mode.UI_Normal, "win");
        m_CharacterContainer.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
        m_CharacterContainer.SetPlay(UICharacterContainer.ePlayType.Social);

        if (m_Creature.Info.TeamSkill != null)
        {
            if (m_TeamSkill.atlas.Contains(m_Creature.TeamSkill.Info.ID) == true)
            {
                m_TeamSkill.spriteName = m_Creature.TeamSkill.Info.ID;
            }
            else
            {
                m_TeamSkill.spriteName = "skill_default";
            }
            m_TeamSkill.gameObject.transform.parent.parent.gameObject.SetActive(true);
        }
        else
        {
            m_TeamSkill.gameObject.transform.parent.parent.gameObject.SetActive(false);
        }

        for (int i = 0; i < m_Stars.Length; ++i)
        {
            m_Stars[i].SetSpriteActive(m_Creature.Grade > i);
            m_Stars[i].gameObject.SetActive(m_Creature.Grade > i);
        }
        m_GridStars.Reposition();

        // equips
        if (m_Weapon == null)
        {
            m_Weapon = NGUITools.AddChild(m_WeaponIndicator, EquipItemPrefab).GetComponent <EquipItem>();
        }
        if (m_Armor == null)
        {
            m_Armor = NGUITools.AddChild(m_ArmorIndicator, EquipItemPrefab).GetComponent <EquipItem>();
        }
        m_Weapon.Init(m_Creature.Weapon);
        //m_WeaponParts.Init(m_Creature.Weapon);

        m_Armor.Init(m_Creature.Armor);
        //m_ArmorParts.Init(m_Creature.Armor);


        // skills
        List <Skill> active_skills = m_Creature.GetSkillsByType(eSkillType.active);

        for (int i = 0; i < m_ActiveSkills.Length; ++i)
        {
            bool active = i < active_skills.Count;
            m_ActiveSkills[i].gameObject.SetActive(active);
            if (active)
            {
                m_ActiveSkills[i].Init(active_skills[i]);
            }
        }

        List <Skill> passive_skills = m_Creature.GetSkillsByType(eSkillType.passive);

        for (int i = 0; i < m_PassiveSkills.Length; ++i)
        {
            bool active = i < passive_skills.Count;
            m_PassiveSkills[i].gameObject.SetActive(active);
            if (active)
            {
                m_PassiveSkills[i].Init(passive_skills[i]);
            }
        }


        bool move = m_Creatures != null && m_Creatures.Count > 0;

        m_ButtonLeft.SetActive(move);
        m_ButtonRight.SetActive(move);
        if (move)
        {
            UpdateNextCreatureIcon();
        }

        for (int i = 0; i < 10; ++i)
        {
            if (m_RuneList.Count <= i)
            {
                RuneItem item = RuneItemPrefab.GetNewObject <RuneItem>(m_GridRune.transform, Vector3.zero);
                m_RuneList.Add(item);
            }

            if (m_Creature.Runes.Count <= i)
            {
                m_RuneList[i].Init(null, m_Creature.RuneSlotCount <= i, null, i);
            }
            else
            {
                m_RuneList[i].Init(m_Creature.Runes[i], false, null, i);
            }
        }
        m_GridRune.Reposition();

        InitHeroInfo();
        InitSkillInfo();
        InitRuneInfo();
        InitEvolveInfo();
    }
Beispiel #22
0
        private void InitializeControls()
        {
            checkScrollButton = new StandardButton(20)
            {
                Position = new Point(Width - 30, 40),
                Text     = "[C] Check Scroll"
            };
            checkScrollButton.Click += (sender, args) => CheckScroll?.Invoke(this, EventArgs.Empty);
            Add(checkScrollButton);

            useItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[U] Use"
            };
            useItemButton.Click += (sender, args) => UseItem?.Invoke(this, EventArgs.Empty);
            Add(useItemButton);

            equipItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[E] Equip"
            };
            equipItemButton.Click += (sender, args) => EquipItem?.Invoke(this, EventArgs.Empty);
            Add(equipItemButton);

            equipLeftHoldableButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[Z] Equip Left"
            };
            equipLeftHoldableButton.Click += (sender, args) => EquipHoldableItemLeft?.Invoke(this, EventArgs.Empty);
            Add(equipLeftHoldableButton);

            equipRightHoldableButton = new StandardButton(20)
            {
                Position = new Point(Width - 31, 40),
                Text     = "[X] Equip Right"
            };
            equipRightHoldableButton.Click += (sender, args) => EquipHoldableItemRight?.Invoke(this, EventArgs.Empty);
            Add(equipRightHoldableButton);

            takeOffItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[T] Take Off"
            };
            takeOffItemButton.Click += (sender, args) => TakeOffItem?.Invoke(this, EventArgs.Empty);
            Add(takeOffItemButton);

            dropItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 43),
                Text     = "[D] Drop"
            };
            dropItemButton.Click += (sender, args) => DropItem?.Invoke(this, EventArgs.Empty);
            Add(dropItemButton);

            dropAllItemsButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 46),
                Text     = "[A] Drop All"
            };
            dropAllItemsButton.Click += (sender, args) => DropStack?.Invoke(this, EventArgs.Empty);
            Add(dropAllItemsButton);
        }
 private void Awake()
 {
     _instance    = this;
     equipImage   = this.GetComponent <Image>();
     playerStatus = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <PlayerStatus>();
 }
Beispiel #24
0
    public void refreshSelectedEquipmentDetail(int hashcode)
    {
        if (hashcode > 0)
        {
            GDEEquipmentData equip = SDDataManager.Instance.getEquipmentByHashcode(hashcode);

            if (equip != null)
            {
                currentEquipHashcode = equip.hashcode;
                equipedItemName.text
                    = SDDataManager.Instance.getEquipNameByHashcode(currentEquipHashcode);
                equipedItemLevel.text = SDGameManager.T("Lv.")
                                        + equip.lv;
                equipedItemBattleForce.text
                    = "" + SDDataManager.Instance.getEquipBattleForceByHashCode(equip.hashcode);
                //
                equipIcon.sprite = SDDataManager.Instance.GetEquipIconById(equip.id);
                EquipItem item = SDDataManager.Instance.GetEquipItemById(equip.id);
                equipFrameIcon.sprite = SDDataManager.Instance.baseFrameSpriteByRarity(item.LEVEL);
                equipBgIcon.sprite    = SDDataManager.Instance.baseBgSpriteByRarity(item.LEVEL);
                //
                equipedItemBtn.gameObject.SetActive(true);
                if (equip.OwnerHashcode > 0)//判断是否已被装备
                {
                    bool flag = false;
                    if (equip.OwnerHashcode == heroDetail.Hashcode)//是当前角色装备
                    {
                        flag = true;
                        if (SDDataManager.Instance.getEquipPosById(equip.id) == 4)
                        {
                            if (!isSecondJewelryPos &&
                                SDDataManager.Instance.getHeroByHashcode(heroDetail.Hashcode)
                                .jewelry0.hashcode != equip.hashcode)
                            {
                                flag = false;
                            }
                            else if (isSecondJewelryPos &&
                                     SDDataManager.Instance.getHeroByHashcode(heroDetail.Hashcode)
                                     .jewelry1.hashcode != equip.hashcode)
                            {
                                flag = false;
                            }
                        }
                    }
                    else
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        equipItemBtnText.text = SDGameManager.T("解除装备");
                    }
                    else
                    {
                        equipedItemBtn.gameObject.SetActive(false);
                        equipItemBtnText.text = SDGameManager.T("无法装备");
                    }
                }
                else
                {
                    equipItemBtnText.text = SDGameManager.T("装备");
                }
            }
        }
    }
        void DoCreateObject()
        {
            if (settings == null)
            {
                Debug.LogError("Settings must not be null");
                return;
            }

            //Find data folder
            string folder = "";

            if (type == CreateObjectType.Item)
            {
                folder = settings.items_folder;
            }
            if (type == CreateObjectType.Construction)
            {
                folder = settings.constructions_folder;
            }
            if (type == CreateObjectType.Plant)
            {
                folder = settings.plants_folder;
            }
            if (type == CreateObjectType.Character)
            {
                folder = settings.characters_folder;
            }

            if (type == CreateObjectType.None)
            {
                Debug.LogError("Type can't be none!");
                return;
            }

            if (mesh == null)
            {
                Debug.LogError("A mesh must be assigned!");
                return;
            }

            if (string.IsNullOrEmpty(object_title.Trim()))
            {
                Debug.LogError("Title can't be blank");
                return;
            }

            //Make sure folder is valid
            string full_folder = Application.dataPath + "/" + folder;

            if (!string.IsNullOrEmpty(folder) && !Directory.Exists(full_folder))
            {
                Debug.LogError("Error, folder can't be found: " + full_folder);
                return;
            }

            //Make sure folder is valid
            string full_folder_equip = Application.dataPath + "/" + settings.prefab_equip_folder;

            if (type == CreateObjectType.Item && item_type == ItemType.Equipment && !Directory.Exists(full_folder_equip))
            {
                Debug.LogError("Error, folder can't be found: " + full_folder_equip);
                return;
            }

            //Make sure file don't already exists
            string file_title = object_title.Replace(" ", "");
            string full_file  = full_folder + "/" + file_title + ".asset";

            if (!string.IsNullOrEmpty(folder) && File.Exists(full_file))
            {
                Debug.LogError("Error, file already exists: " + full_file);
                return;
            }

            //Make sure prefab don't already exists
            string full_prefab = Application.dataPath + "/" + settings.prefab_folder + "/" + file_title + ".prefab";

            if (File.Exists(full_prefab))
            {
                Debug.LogError("Error, prefab file already exists: " + full_prefab);
                return;
            }

            //---------------

            string file_data         = "Assets/" + folder + "/" + file_title + ".asset";
            string file_prefab       = "Assets/" + settings.prefab_folder + "/" + file_title + ".prefab";
            string file_prefab_equip = "Assets/" + settings.prefab_equip_folder + "/" + file_title + "Equip.prefab";

            bool       is_plant_growth = type == CreateObjectType.Plant && stages_mesh != null && stages_mesh.Length > 1;
            string     obj_title       = is_plant_growth ? object_title + "S1" : object_title;
            GameObject obj             = CreateBasicObject(obj_title, is_plant_growth ? stages_mesh[0] : mesh);
            Selectable select          = obj.GetComponent <Selectable>();

            GameObject prefab = null;

            //Create data
            if (type == CreateObjectType.Item)
            {
                Item     item = obj.AddComponent <Item>();
                UniqueID uid  = obj.GetComponent <UniqueID>();
                ItemData data = CreateAsset <ItemData>(file_data);
                item.data        = data;
                item.take_audio  = settings.take_audio;
                item.take_fx     = settings.take_fx;
                uid.uid_prefix   = "item_";
                select.use_range = 1f;

                prefab           = CreatePrefab(obj, file_prefab);
                data.item_prefab = prefab;
                data.type        = item_type;

                List <SAction> actions = new List <SAction>();

                if (item_type == ItemType.Consumable)
                {
                    actions.Add(settings.eat_action);
                    data.eat_hp          = 1;
                    data.eat_hunger      = 5;
                    data.durability_type = DurabilityType.Spoilage;
                }

                if (item_type == ItemType.Equipment)
                {
                    GameObject obj_equip = new GameObject(object_title + "Equip");
                    obj_equip.transform.position = FindPosition();

                    GameObject mesh_equip = Instantiate(mesh, obj_equip.transform.position, mesh.transform.rotation);
                    mesh_equip.name = object_title + "Mesh";
                    mesh_equip.transform.SetParent(obj_equip.transform);
                    mesh_equip.transform.localRotation = Quaternion.Euler(90f, 0f, 0f) * mesh.transform.rotation;

                    EquipItem equip_item = obj_equip.AddComponent <EquipItem>();
                    equip_item.data      = data;
                    data.inventory_max   = 1;
                    data.equip_slot      = equip_slot;
                    data.equip_side      = equip_side;
                    data.durability_type = DurabilityType.UsageCount;

                    if (data.equip_slot == EquipSlot.Hand)
                    {
                        data.damage      = 10;
                        data.weapon_type = WeaponType.WeaponMelee;
                    }
                    else
                    {
                        data.armor = 2;
                    }

                    actions.Add(settings.equip_action);

                    GameObject equip_prefab = CreatePrefab(obj_equip, file_prefab_equip);
                    data.equipped_prefab = equip_prefab;
                    DestroyImmediate(obj_equip);
                }

                actions.AddRange(settings.item_actions);
                data.actions = actions.ToArray();
            }

            else if (type == CreateObjectType.Construction)
            {
                Buildable        buildable = obj.AddComponent <Buildable>();
                Construction     construct = obj.AddComponent <Construction>();
                UniqueID         uid       = obj.GetComponent <UniqueID>();
                ConstructionData data      = CreateAsset <ConstructionData>(file_data);
                construct.data        = data;
                buildable.build_audio = settings.build_audio;
                buildable.build_fx    = settings.build_fx;
                uid.uid_prefix        = "construction_";
                prefab = CreatePrefab(obj, file_prefab);
                data.construction_prefab = prefab;
                select.use_range         = 2f;
            }

            else if (type == CreateObjectType.Plant)
            {
                int nb_stages = stages_mesh != null && stages_mesh.Length > 0 ? stages_mesh.Length : 1;

                PlantData data = CreateAsset <PlantData>(file_data);

                List <GameObject> growth_prefabs = new List <GameObject>();

                for (int i = 0; i < nb_stages; i++)
                {
                    string stage_suffix = nb_stages > 1 ? "S" + (i + 1) : "";

                    GameObject obj_stage    = i == 0 ? obj : CreateBasicObject(object_title + stage_suffix, stages_mesh[i]);
                    Selectable select_stage = obj_stage.GetComponent <Selectable>();
                    Buildable  buildable    = obj.AddComponent <Buildable>();
                    Plant      plant        = obj_stage.AddComponent <Plant>();
                    UniqueID   auid         = obj_stage.GetComponent <UniqueID>();
                    plant.data             = data;
                    plant.gather_audio     = settings.take_audio;
                    buildable.build_audio  = settings.build_audio;
                    buildable.build_fx     = settings.build_fx;
                    auid.uid_prefix        = "plant_";
                    select_stage.use_range = 1f;
                    plant.growth_stage     = i;

                    //Soil mesh
                    if (soil_mesh != null)
                    {
                        GameObject msh = Instantiate(soil_mesh, obj_stage.transform.position, soil_mesh.transform.rotation);
                        msh.name = "SoilMesh";
                        msh.transform.SetParent(obj_stage.transform);
                        msh.transform.localPosition = new Vector3(0f, 0.02f, 0f);
                    }

                    file_prefab       = "Assets/" + settings.prefab_folder + "/" + file_title + stage_suffix + ".prefab";
                    prefab            = CreatePrefab(obj_stage, file_prefab);
                    data.plant_prefab = prefab; //Set to last created
                    growth_prefabs.Add(prefab);
                }

                if (nb_stages > 1)
                {
                    data.growth_stage_prefabs = growth_prefabs.ToArray();
                }
            }

            else if (type == CreateObjectType.Character)
            {
                Character     character = obj.AddComponent <Character>();
                UniqueID      uid       = obj.GetComponent <UniqueID>();
                CharacterData data      = CreateAsset <CharacterData>(file_data);
                character.data         = data;
                uid.uid_prefix         = "character_";
                prefab                 = CreatePrefab(obj, file_prefab);
                data.character_prefab  = prefab;
                select.use_range       = 2f;
                character.attack_audio = settings.attack_audio;
            }

            else
            {
                prefab = CreatePrefab(obj, file_prefab);
            }

            if (prefab != null)
            {
                Selection.activeObject = prefab;
            }

            AssetDatabase.SaveAssets();
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
Beispiel #26
0
    void HeroCharacterSet()
    {
        Debug.Log("Hero_Character_Set");
        string w0 = "wuqi";
        string w1 = "R_wuqi";

        weaponBaseData  = skeleton.FindSlot(w0).Bone.Data;
        weaponBaseData2 = skeleton.FindSlot(w1).Bone.Data;
        //
        Material M = GetComponent <MeshRenderer>().material;

        if (skeleton.FindSlot(w0).Attachment != null)
        {
            M.shader = skeleton.FindSlot(w0).Attachment.GetMaterial().shader;
        }

        if (CMC.notShowWeaponSlot)
        {
            skeleton.FindSlot(w0).A = 0;
            skeleton.FindSlot(w1).A = 0;
        }
        else
        {
            skeleton.FindSlot(w0).A = 1;
            skeleton.FindSlot(w1).A = 1;
            //
            EquipItem weapon = SDDataManager.Instance.GetEquipItemById(CMC.weaponId);
            if (weapon == null)
            {
                return;
            }
            List <Sprite> allSprites = Resources.LoadAll <Sprite>("Spine/WeaponVision/").ToList();
            weaponSprite = allSprites.Find(x => x.name == weapon.ID);
            if (weaponSprite == null)
            {
                return;
            }


            Spine.Slot       baseWQ             = skeleton.FindSlot(w0);
            string           an                 = baseWQ.Data.AttachmentName;
            Spine.Attachment originalAttachment = baseWQ.Attachment;
            Spine.Attachment newAttachment      = originalAttachment.GetRemappedClone(weaponSprite, M);
            if (weapon.WeaponRace.WeaponClass == SDConstants.WeaponClass.Sharp)
            {
                Spine.Slot otherWQ   = skeleton.FindSlot(w1);
                string     newWSName = weaponSprite.name + "_2";
                weaponSprite2 = allSprites.Find(x => x.name == newWSName);
                if (weaponSprite2 != null)
                {
                    Spine.Attachment oa1    = otherWQ.Attachment;
                    Spine.Attachment newoa1 = oa1.GetRemappedClone(weaponSprite2, M);
                    otherWQ.Attachment = newoa1;
                }
            }
            else if (weapon.WeaponRace.WeaponClass == SDConstants.WeaponClass.Claymore)
            {
                baseWQ.Bone.ScaleY   = -weaponBaseData.ScaleY;
                baseWQ.Bone.Rotation = weaponBaseData.Rotation - 45;
                baseWQ.Bone.SetLocalPosition(new Vector2(0, -weaponBaseData.Y * 2));
            }
            baseWQ.Attachment = newAttachment;
        }
    }