Example #1
0
    public AcData Copy()
    {
        AcData newData = Utils.Clone(this) as AcData;

        newData.HP         = HP;
        newData.Level      = Level;
        newData.LootXp     = LootXp;
        newData.LootScore1 = LootScore1;
        newData.LootScore2 = LootScore2;
        newData.LootBonus1 = LootBonus1;
        newData.LootBonus2 = LootBonus2;
        newData.LootBonus3 = LootBonus3;

        return(newData);
    }
Example #2
0
    //protected ActionController
    public void PassiveEffect(int aiLevel, AcData acd)
    {
        if (enablePassiveSkill)
        {
            foreach (FCPassiveSkillConfig psc in passiveSkillMaps[aiLevel]._skillConfigs)
            {
                if (psc.SkillModule.beActive)
                {
                    foreach (FCPassiveSkillAttribute skill in psc.SkillModule.skillAttributes)
                    {
                        switch (skill.skillType)
                        {
                        case AIHitParams.Hp:
                            acd.AddHitParamsData(AIHitParams.Hp, skill.attributeValue);
                            break;

                        case AIHitParams.HpPercent:
                            acd.AddHitParamsData(AIHitParams.HpPercent, skill.attributeValue);
                            break;

                        case AIHitParams.Attack:
                            acd.AddHitParamsData(AIHitParams.Attack, skill.attributeValue);
                            break;

                        case AIHitParams.AttackPercent:
                            acd.AddHitParamsData(AIHitParams.AttackPercent, skill.attributeValue);
                            break;

                        case AIHitParams.Defence:
                            acd.AddHitParamsData(AIHitParams.Defence, skill.attributeValue);
                            break;

                        case AIHitParams.DefencePercent:
                            acd.AddHitParamsData(AIHitParams.DefencePercent, skill.attributeValue);
                            break;

                        case AIHitParams.RunSpeed:
                            //acd.passiveSpeed = acd.TotalMoveSpeed * skill.attributePercents + skill.attributeValue;
                            acd.AddHitParamsData(AIHitParams.RunSpeed, skill.attributeValue);
                            break;

                        case AIHitParams.RunSpeedPercent:
                            acd.AddHitParamsData(AIHitParams.RunSpeedPercent, skill.attributeValue);
                            break;

                        case AIHitParams.CriticalDamage:
                            acd.AddHitParamsData(AIHitParams.CriticalDamage, skill.attributeValue);
                            break;

                        case AIHitParams.CriticalDamagePercent:
                            acd.AddHitParamsData(AIHitParams.CriticalDamagePercent, skill.attributeValue);
                            break;

                        case AIHitParams.CriticalChance:
                            acd.AddHitParamsData(AIHitParams.CriticalChance, skill.attributeValue);
                            break;

                        case AIHitParams.CriticalChancePercent:
                            acd.AddHitParamsData(AIHitParams.CriticalChancePercent, skill.attributeValue);
                            break;

                        case AIHitParams.PassiveSkillGodDownCriticalToHp:
                            acd.AddHitParamsData(AIHitParams.PassiveSkillGodDownCriticalToHp, skill.attributeValue);
                            break;
                        }
                    }
                }
            }
        }
    }
Example #3
0
    private string GetQuestTargetString(QuestTargetProgress qtp, QuestData qd)
    {
        string resultStr = string.Empty;

        string typeName = Localization.instance.Get(QuestTarget.typeNames[(int)qtp.target_type]);

        string levelName;

        switch (qtp.target_type)
        {
        case QuestTargetType.complete_level:
            levelName = Localization.instance.Get(LevelManager.Singleton.LevelsConfig.GetLevelData(qtp.target_id).levelNameIDS);
            if (qtp.required_amount == qtp.actual_amount)                     //target achieved, use same color for level
            {
                levelName = "[-]" + levelName;
            }
            resultStr = string.Format(typeName, levelName);
            break;

        case QuestTargetType.kill_monster:
            AcData ad          = DataManager.Instance.CurAcDataList.Find(qtp.target_id);
            string monsterName = ad == null ? "Error" : Localization.instance.Get(ad.nameIds);

            levelName = Localization.instance.Get(LevelManager.Singleton.LevelsConfig.GetLevelData(qd.recommended_level_name).levelNameIDS);
            if (qtp.required_amount == qtp.actual_amount)                     //target achieved, use same color for level
            {
                levelName = "[-]" + levelName;
            }

            resultStr = string.Format(typeName, levelName, monsterName);
            break;

        case QuestTargetType.find_loot:
        case QuestTargetType.purchase_item:
            string itemName = Localization.instance.Get(DataManager.Instance.GetItemData(qtp.target_id).nameIds);
            resultStr = string.Format(typeName, itemName, qtp.required_amount);
            break;

        case QuestTargetType.level_up:
            resultStr = string.Format(typeName, qtp.required_amount);
            break;

        case QuestTargetType.fusion_up:
            int targetLevel = -1;                           //-1: up to any level,  1~3: reach level 1~5

            Int32.TryParse(qtp.target_id, out targetLevel);

            if (targetLevel < 0)
            {
                resultStr = string.Format(typeName, qtp.required_amount);
            }
            else
            {
                typeName = Localization.instance.Get("IDS_MESSAGE_QUEST_TARGET_FUSIONTIME");

                resultStr = string.Format(typeName, targetLevel, qtp.required_amount);                         //upgrade 10 items to level X
            }
            break;
        }

        resultStr += "  " + qtp.actual_amount.ToString() + "/" + qtp.required_amount;
        return(resultStr);
    }
    public static void Read()
    {
        AcDataList acDataList;

        bool newFile = false;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(AcDataList));
        if (oldFile == null)
        {
            newFile    = true;
            acDataList = ScriptableObject.CreateInstance(typeof(AcDataList)) as AcDataList;
        }
        else
        {
            acDataList = oldFile as AcDataList;
        }

        acDataList._dataList.Clear();

        string jsonStr = File.ReadAllText(fileName);

        JsonHashtable ht = FCJson.jsonDecode(jsonStr) as JsonHashtable;

        foreach (System.Object obj in ht.ValueList)
        {
            Hashtable data = obj as Hashtable;

            AcData newData = new AcData();

            newData.id = data["id"] as string;

            newData.characterId = data["characterId"] as string;
            newData.classIds    = data["class"] as string;
            newData.nameIds     = data["nameIds"] as string;
            newData.faction     = (FC_AC_FACTIOH_TYPE)Enum.Parse(typeof(FC_AC_FACTIOH_TYPE), data["faction"] as string);
            newData.eliteType   = (FC_ELITE_TYPE)Enum.Parse(typeof(FC_ELITE_TYPE), data["type"] as string);
            newData.isPlayer    = (int)data["isPlayer"] == 1;
            newData.speed       = (float)data["speed"];
            newData.angleSpeed  = (float)data["angleSpeed"];
            newData.hp          = (int)data["hp"];
            //newData._energy = (int)data["energy"];
            //newData._vitality = (int)data["vitality"];
            newData.level           = (int)data["level"];
            newData.thresholdMax    = (int)data["thresholdMax"];
            newData.physicalAttack  = (float)(int)data["physicalAttack"];
            newData.physicalDefense = (float)(int)data["physicalDefense"];
            newData.fireAttack      = (float)(int)data["fireAttack"];
            newData.fireResist      = (float)(int)data["fireResist"];
            newData.poisonAttack    = (float)(int)data["poisonAttack"];
            newData.poisonResist    = (float)(int)data["poisonResist"];
            newData.lightningAttack = (float)(int)data["lightingAttack"];
            newData.lightningResist = (float)(int)data["lightingResist"];
            newData.iceAttack       = (float)(int)data["iceAttack"];
            newData.iceResist       = (float)(int)data["iceResist"];
            newData.critRate        = (float)data["critRate"];
            newData.critDamage      = (float)data["critDamage"];

            newData.equipList.Clear();
            AddEquip(newData.equipList, data["equip1"] as string);
            AddEquip(newData.equipList, data["equip2"] as string);
            AddEquip(newData.equipList, data["equip3"] as string);
            AddEquip(newData.equipList, data["equip4"] as string);
            AddEquip(newData.equipList, data["equip5"] as string);
            AddEquip(newData.equipList, data["equip6"] as string);
            AddEquip(newData.equipList, data["equip7"] as string);
            AddEquip(newData.equipList, data["equip8"] as string);


            newData.lootXp = (int)data["lootXp"];

            acDataList._dataList.Add(newData);
        }

        if (newFile)
        {
            AssetDatabase.CreateAsset(acDataList, outFileName);
        }
        else
        {
            EditorUtility.SetDirty(acDataList);
        }
        Debug.Log(string.Format("Character data successfully imported. {0} records.", acDataList._dataList.Count));
    }
Example #5
0
    public GameObject AssembleCharacter(string label)
    {
        AcData data = DataManager.Instance.CurAcDataList.Find(label);

        if (data == null)
        {
            Debug.LogError("can't find ac data: [" + label + "]");
            return(null);
        }

        AddCharacterToLoad(data.characterId);


        CharacterInformation ci = null;

        if (_activedCharacters.TryGetValue(data.characterId, out ci))
        {
            // prepare ai module prefab.
            GameObject aiModule = InJoy.AssetBundles.AssetBundles.Load(ci.aiAgentPath) as GameObject;
            if (aiModule != null)
            {
                // instance a graphics model.
                GameObject model = CharacterFactory.Singleton.AssembleCharacter(ci.modelPath);
                if (model != null)
                {
                    GameObject ai = GameObject.Instantiate(aiModule) as GameObject;
                    // assemble ActionController
                    ActionController ac = model.GetComponent <ActionController>();
                    if (ac == null)
                    {
                        ac = model.AddComponent <ActionController>();
                    }
                    //ac._data = ci.extraData.Duplicate();
                    ac.Data                    = data;
                    ac._agent                  = ai;
                    ai.transform.parent        = model.transform;
                    ai.transform.localPosition = Vector3.zero;
                    ai.transform.localRotation = Quaternion.identity;
                    ai.transform.localScale    = Vector3.one;

                    //trace all colliders in children
                    //if I find the Damage collider, regist it
                    bool hasFindDamageCollider = false;

                    Collider[] colliders = model.GetComponentsInChildren <Collider>();
                    foreach (Collider collider in colliders)
                    {
                        if (collider.gameObject.name == "DamageCollider")
                        {
                            hasFindDamageCollider = true;
                            ActionControllerManager.Instance.RegisterACByCollider(ac, collider);
                        }
                    }

                    //no damage collider found
                    //register the collider in the root.
                    if (!hasFindDamageCollider)
                    {
                        Collider colliderInRoot = model.GetComponent <Collider>();
                        if ((colliderInRoot != null) && (ActionControllerManager.Instance != null))
                        {
                            ActionControllerManager.Instance.RegisterACByCollider(ac, colliderInRoot);
                        }
                    }

                    // navMesh component settings.
                    NavMeshAgent nma    = model.GetComponentInChildren <NavMeshAgent>();
                    MoveAgent[]  agents = model.GetComponentsInChildren <MoveAgent>();
                    foreach (MoveAgent ma in agents)
                    {
                        ma._navAgent = nma;
                    }

                    return(model);
                }
                else
                {
                    Debug.LogError(string.Format("[CharacterAssembler] Model not found: \"{0}\"", ci.modelPath));
                }
            }
            else
            {
                Debug.LogError(string.Format("[CharacterAssembler] Agent path not found: \"{0}\"", ci.aiAgentPath));
            }
        }
        else
        {
            Debug.LogError(string.Format("[CharacterAssembler] Character id not found: \"{0}\"", data.characterId));
        }

        return(null);
    }