Inheritance: MonoBehaviour
Exemplo n.º 1
0
    private static string GetEditedSkillsText()
    {
        string     ret    = string.Empty;
        GameObject actor  = GameObject.Find("Editor_ActorRecord");
        GameObject skills = GameObject.Find("Editor_SkillRecords");

        if (null != actor && null != skills)
        {
            ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
            SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
            if (null != actorRecord && null != skillRecords)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("//========actor========");
                sb.AppendLine(actorRecord.GetClipboardText());
                sb.AppendLine("//========skills========");
                foreach (SkillRecords.SkillRecord record in skillRecords.records)
                {
                    sb.AppendLine(record.GetSkillClipboardText());
                }
                sb.AppendLine("//========skillResources========");
                foreach (SkillRecords.SkillRecord record in skillRecords.records)
                {
                    sb.AppendLine(record.GetSkillResourcesClipboardText());
                }
                ret = sb.ToString();
            }
        }
        return(ret);
    }
Exemplo n.º 2
0
 public void ClearRecords()
 {
     AssetFilterRecords.Clear();
     PartRecords.Clear();
     PhaseRecords.Clear();
     UserRecords.Clear();
     ScoreRecords.Clear();
     TroopRecords.Clear();
     BarrackRecords.Clear();
     TowerRecords.Clear();
     HeroRecords.Clear();
     SkillRecords.Clear();
     CutsceneRecords.Clear();
     SceneRecords.Clear();
     SpeakRecords.Clear();
 }
Exemplo n.º 3
0
    private void LoadEditedSkills(int targetId)
    {
        PlayerPrefs.SetInt("TargetId", targetId);
        PlayerPrefs.Save();

        SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt"));
        CopyTableAndDslFiles();

        PluginFramework.LoadTableConfig();
        PredefinedSkill.Instance.ReBuild();
        GfxSkillSystem.Instance.Reset();
        GfxSkillSystem.Instance.ClearSkillInstancePool();
        SkillSystem.SkillConfigManager.Instance.Clear();

        GameObject actor  = GameObject.Find("Editor_ActorRecord");
        GameObject skills = GameObject.Find("Editor_SkillRecords");

        if (null != actor && null != skills)
        {
            ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
            SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
            if (null != actorRecord && null != skillRecords)
            {
                List <int> args    = new List <int>();
                int        actorId = actorRecord.id;
                if (actorRecord.skill0 > 0)
                {
                    args.Add(actorRecord.skill0);
                }
                if (actorRecord.skill1 > 0)
                {
                    args.Add(actorRecord.skill1);
                }
                if (actorRecord.skill2 > 0)
                {
                    args.Add(actorRecord.skill2);
                }
                if (actorRecord.skill3 > 0)
                {
                    args.Add(actorRecord.skill3);
                }
                if (actorRecord.skill4 > 0)
                {
                    args.Add(actorRecord.skill4);
                }
                if (actorRecord.skill5 > 0)
                {
                    args.Add(actorRecord.skill5);
                }
                if (actorRecord.skill6 > 0)
                {
                    args.Add(actorRecord.skill6);
                }
                if (actorRecord.skill7 > 0)
                {
                    args.Add(actorRecord.skill7);
                }
                if (actorRecord.skill8 > 0)
                {
                    args.Add(actorRecord.skill8);
                }

                RebuildVisualSkillInfo(actorId);

                bool isValid = true;
                if (string.IsNullOrEmpty(actorRecord.avatar))
                {
                    Debug.LogErrorFormat("actor avatar is empty !!!");
                    isValid = false;
                }
                foreach (int skillId in args)
                {
                    CheckEditedSkill(skillId, skillRecords.records, ref isValid);
                }
                if (isValid)
                {
                    TableConfig.Actor actorInfo = TableConfig.ActorProvider.Instance.GetActor(actorId);
                    if (null == actorInfo)
                    {
                        actorInfo    = new TableConfig.Actor();
                        actorInfo.id = actorId;
                        TableConfig.ActorProvider.Instance.ActorMgr.GetData().Add(actorId, actorInfo);
                    }
                    actorRecord.CopyTo(actorInfo);

                    foreach (SkillRecords.SkillRecord record in skillRecords.records)
                    {
                        TableConfig.Skill skillInfo = TableConfig.SkillProvider.Instance.GetSkill(record.id);
                        if (null == skillInfo)
                        {
                            skillInfo    = new TableConfig.Skill();
                            skillInfo.id = record.id;
                            TableConfig.SkillProvider.Instance.SkillMgr.GetData().Add(record.id, skillInfo);
                        }
                        record.CopyTo(skillInfo);
                    }

                    if (args.Count > 1)
                    {
                        GfxStorySystem.Instance.SendMessage("reload", actorId, targetId, BoxedValue.From(args));
                    }
                }
            }

            UnityEditor.EditorUtility.DisplayDialog("提示", "编辑英雄与技能加载完毕", "ok");
        }
    }
Exemplo n.º 4
0
    private void NewEditedSkills()
    {
        if (UnityEditor.EditorUtility.DisplayDialog("关键信息", "加载或创建英雄技能数据将覆盖正在编辑的数据,继续吗?(如果之前的数据没有保存到表格文件里,请利用剪贴板拷到表格文件!)", "我确定要继续", "不要继续,我还没保存呢"))
        {
            SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt"));

            PluginFramework.LoadTableConfig();
            PredefinedSkill.Instance.ReBuild();
            GfxSkillSystem.Instance.Reset();
            GfxSkillSystem.Instance.ClearSkillInstancePool();
            SkillSystem.SkillConfigManager.Instance.Clear();

            GameObject actor  = GameObject.Find("Editor_ActorRecord");
            GameObject skills = GameObject.Find("Editor_SkillRecords");
            if (null != actor && null != skills)
            {
                ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
                SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
                if (null != actorRecord && null != skillRecords)
                {
                    int        skillCount = 0;
                    List <int> skillIds   = new List <int>();
                    if (actorRecord.skill0 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill0);
                    }
                    if (actorRecord.skill1 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill1);
                    }
                    if (actorRecord.skill2 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill2);
                    }
                    if (actorRecord.skill3 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill3);
                    }
                    if (actorRecord.skill4 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill4);
                    }
                    if (actorRecord.skill5 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill5);
                    }
                    if (actorRecord.skill6 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill6);
                    }
                    if (actorRecord.skill7 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill7);
                    }
                    if (actorRecord.skill8 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill8);
                    }

                    RebuildVisualSkillInfo(actorRecord.id);

                    skillRecords.records.Clear();
                    for (int i = 0; i < skillCount; ++i)
                    {
                        AddViewedSkill(skillIds[i], skillRecords.records);
                    }
                }
            }
        }

        UnityEditor.EditorUtility.DisplayDialog("提示", "技能数据加载/创建完毕", "ok");
    }
Exemplo n.º 5
0
    private void LoadViewedSkills(object[] fargs)
    {
        if (null != fargs && fargs.Length == 2)
        {
            int actorId  = (int)fargs[0];
            int targetId = (int)fargs[1];

            PlayerPrefs.SetInt("ActorId", actorId);
            PlayerPrefs.SetInt("TargetId", targetId);
            PlayerPrefs.Save();

            if (UnityEditor.EditorUtility.DisplayDialog("关键信息", "从文件加载数据将同时覆盖正在编辑的数据,继续吗?(如果之前的数据没有保存到表格文件里,请利用剪贴板拷到表格文件!)", "我确定要继续", "不要继续,我还没保存呢"))
            {
                SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt"));
                CopyTableAndDslFiles();
                m_CameraController.OnLevelWasLoaded(null);
                PluginFramework.LoadTableConfig();
                PredefinedSkill.Instance.ReBuild();
                GfxSkillSystem.Instance.Reset();
                GfxSkillSystem.Instance.ClearSkillInstancePool();
                SkillSystem.SkillConfigManager.Instance.Clear();

                GameObject actor  = GameObject.Find("Editor_ActorRecord");
                GameObject skills = GameObject.Find("Editor_SkillRecords");
                if (null != actor && null != skills)
                {
                    ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
                    SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
                    if (null != actorRecord && null != skillRecords)
                    {
                        TableConfig.Actor actorInfo = TableConfig.ActorProvider.Instance.GetActor(actorId);
                        if (null != actorInfo)
                        {
                            List <int> args = new List <int>();
                            if (actorInfo.skill0 > 0)
                            {
                                args.Add(actorInfo.skill0);
                            }
                            if (actorInfo.skill1 > 0)
                            {
                                args.Add(actorInfo.skill1);
                            }
                            if (actorInfo.skill2 > 0)
                            {
                                args.Add(actorInfo.skill2);
                            }
                            if (actorInfo.skill3 > 0)
                            {
                                args.Add(actorInfo.skill3);
                            }
                            if (actorInfo.skill4 > 0)
                            {
                                args.Add(actorInfo.skill4);
                            }
                            if (actorInfo.skill5 > 0)
                            {
                                args.Add(actorInfo.skill5);
                            }
                            if (actorInfo.skill6 > 0)
                            {
                                args.Add(actorInfo.skill6);
                            }
                            if (actorInfo.skill7 > 0)
                            {
                                args.Add(actorInfo.skill7);
                            }
                            if (actorInfo.skill8 > 0)
                            {
                                args.Add(actorInfo.skill8);
                            }

                            RebuildVisualSkillInfo(actorId);

                            actorRecord.CopyFrom(actorInfo);

                            skillRecords.records.Clear();
                            foreach (int skillId in args)
                            {
                                AddViewedSkill(skillId, skillRecords.records);
                            }

                            GfxStorySystem.Instance.SendMessage("reload", actorId, targetId, BoxedValue.From(args));
                        }
                    }
                }

                UnityEditor.EditorUtility.DisplayDialog("提示", "从文件加载英雄与技能完毕", "ok");
            }
        }
    }
Exemplo n.º 6
0
    void Load(String jsonUnarrangedData, String userId, Action onDataLoaded)
    {
        var unarrangedData = JsonConvert
                             .DeserializeObject <Dictionary <string, Dictionary <string, List <object> > > >(jsonUnarrangedData);

        /* Quando o userId é nulo, isso indica que apenas os dados iniciais são
         * carregados, independentemente do usuário */

        ClearRecords();

        foreach (var table in unarrangedData)
        {
            string tableName = table.Key;
            IEnumerable <string> primaryKeys = table.Value["primaryKeys"].Select(i => ToString());
            List <JObject>       records     = table.Value["records"].Cast <JObject>().ToList();

            foreach (var record in records)
            {
                AssetFilter filter = AssetFilterRecords
                                     .SingleOrDefault(i => i.NamTable == tableName);

                switch (tableName)
                {
                case "assetfilter":
                    AssetFilter assetFilter = record.ToObject <AssetFilter>();
                    // assetFilter.TxtAssetPath = $"Assets/{assetFilter.TxtAssetPath}";
                    AssetFilterRecords.Add(assetFilter);
                    break;

                case "score":     // only current user scores are retrieved
                    Score score = record.ToObject <Score>();
                    ScoreRecords.Add(score);
                    break;

                case "part":
                    Part part = record.ToObject <Part>();
                    PartRecords.Add(part);
                    break;

                case "phase":
                    Phase phase = record.ToObject <Phase>();
                    phase.Part = PartRecords
                                 .SingleOrDefault(i => i.CodPart == phase.CodPart);
                    phase.UserScore = ScoreRecords
                                      .SingleOrDefault(i => i.NumPhase == phase.NumPhase);
                    PhaseRecords.Add(phase);
                    phase.TilemapsGrid = dataUtil
                                         .LoadAsset <Grid>($"Grid_{filter.TxtAssetFilter}_{phase.NumPhase}",
                                                           new[] { filter.TxtAssetPath });
                    break;

                case "gameuser":     // only current user data is retrieved
                    GameUser user = record.ToObject <GameUser>();
                    user.CurrentPhase = PhaseRecords
                                        .SingleOrDefault(i => i.NumPhase == user.NumCurrentPhase);
                    UserRecords.Add(user);
                    break;

                case "troop":
                    Troop troop = record.ToObject <Troop>();
                    troop.GameObject = dataUtil
                                       .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{troop.TxtAssetIdentifier}",
                                                               new[] { filter.TxtAssetPath });
                    TroopRecords.Add(troop);
                    break;

                case "barrack":
                    Barrack barrack = record.ToObject <Barrack>();
                    barrack.Part = PartRecords
                                   .SingleOrDefault(i => i.CodPart == barrack.CodPart);
                    barrack.Troop = TroopRecords
                                    .SingleOrDefault(i => i.CodTroop == barrack.CodTroop);
                    barrack.GameObject = dataUtil
                                         .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{barrack.Troop.TxtAssetIdentifier}",
                                                                 new[] { filter.TxtAssetPath });
                    BarrackRecords.Add(barrack);
                    break;

                case "tower":
                    Tower tower = record.ToObject <Tower>();
                    tower.GameObject = dataUtil
                                       .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{(tower.IsEnemy ? "enemy" : "player")}",
                                                               new[] { filter.TxtAssetPath });
                    TowerRecords.Add(tower);
                    break;

                case "skill":
                    Skill skill = record.ToObject <Skill>();
                    skill.Action = dataUtil
                                   .LoadAsset <SkillAction>($"{filter.TxtAssetFilter}_{skill.TxtAssetIdentifier}",
                                                            new[] { filter.TxtAssetPath });
                    SkillRecords.Add(skill);
                    break;

                case "hero":
                    Hero hero = record.ToObject <Hero>();
                    hero.Part = PartRecords
                                .SingleOrDefault(i => i.CodPart == hero.CodPart);
                    hero.Skills = SkillRecords
                                  .Where(i => i.CodHero == hero.CodHero)
                                  .ToList();
                    hero.GameObject = dataUtil
                                      .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{hero.TxtAssetIdentifier}",
                                                              new[] { filter.TxtAssetPath });
                    HeroRecords.Add(hero);
                    break;

                case "speak":
                    Speak speak = record.ToObject <Speak>();
                    SpeakRecords.Add(speak);
                    break;

                case "scene":
                    Scene scene = record.ToObject <Scene>();
                    scene.Texts = SpeakRecords
                                  .Where(i => i.CodCutscene == scene.CodCutscene && i.CodScene == scene.CodScene)
                                  .ToList();
                    scene.Sprite = dataUtil
                                   .LoadAsset <Sprite>(new[] { $"{filter.TxtAssetPath}/{scene.TxtImagePath}" });
                    SceneRecords.Add(scene);
                    break;

                case "cutscene":
                    Cutscene cutscene = record.ToObject <Cutscene>();
                    cutscene.Scenes = SceneRecords
                                      .Where(i => i.CodCutscene == cutscene.CodCutscene)
                                      .ToList();
                    CutsceneRecords.Add(cutscene);
                    break;

                default:
                    break;
                }
            }
        }

        if (userId != null && userId.Length != 0 && UserRecords.Count == 1)
        {
            loadedUser = UserRecords.SingleOrDefault();
            SaveUserData(loadedUser); // remove later
        }

        if (!(onDataLoaded is null))
        {
            onDataLoaded();
        }
    }