Inheritance: MonoBehaviour
Exemple #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);
    }
    public GameObject GetActor <T> (ActorRecord actorRecord) where T : IActor
    {
        int index = (int)LoadType.Actor * Multiply_Index;
        int type  = (int)actorRecord.type * Multiply_Type;
        int key   = index + type;

        if (!hashtable.ContainsKey(key))
        {
            return(null);
        }
        List <Object> actorList = hashtable[key];

        foreach (GameObject actor in actorList)
        {
            T com = actor.GetComponent <T> ( );
            if (com == null)
            {
                continue;
            }

            if (com.Index == actorRecord.index)
            {
                return(actor);
            }
        }

        return(null);
    }
Exemple #3
0
        public void TestActorRecords()
        {
            var baldwinActor1 = new ActorRecord {
                FirstName = "Alec", LastName = "Baldwin"
            };
            var baldwinActor2 = new ActorRecord {
                FirstName = "Alec", LastName = "Baldwin"
            };
            // Class semantic - two objects, three references.
            var baldwinActorClone = baldwinActor1;

            // Struct sementic - compiler generates value comparison code for records.
            Assert.Equal(baldwinActor1, baldwinActor2);

            // Methods that use GetHashCode() and Equals() methods behave like with structs or value types.
            List <ActorRecord> actors = new List <ActorRecord> {
                baldwinActor1, baldwinActor2
            };

            Assert.Single(actors.Distinct());

            baldwinActor1.FirstName = "William";
            Assert.Equal("William", baldwinActorClone.FirstName);
            // Still value comparison is performed for records.
            Assert.NotEqual(baldwinActor1, baldwinActor2);
            Assert.Equal(baldwinActor1, baldwinActorClone);
        }
    public void Load()
    {
        var record   = new ActorRecord(ActorType.Building, (int)buildingType);
        var building = GameManager.Create <Building> (record, transform.position, GameManager.Instance.LocalPlayer);

        building.GetComponent <Building> ( ).Owner = GameManager.Instance.LocalPlayer;
        Destroy(gameObject);
    }
Exemple #5
0
 public ActorRecord(ActorRecord other)
 {
     _actor      = other._actor;
     _id         = other._id;
     _transform  = other._transform;
     _parent     = other._parent;
     _components = other._components;
     _prefabKey  = other._prefabKey;
     _actorType  = other._actorType;
 }
Exemple #6
0
    private IEnumerator InitScene(ActorRecord playerRec, CardSet playerDeck, ActorRecord enemyRec, CardSet enemyDeck)
    {
        yield return(null);

        Player = new Actor();
        Enemy  = new Actor();

        Player.Data = playerRec;
        Player.Play.Init(playerDeck);

        Enemy.Data = enemyRec;
        Enemy.Play.Init(enemyDeck);

        EventManager.Instance.QueueEvent(new Evt_InitBattle()
        {
            Player = Player,
            Enemy  = Enemy
        });

        NextRound();
    }
Exemple #7
0
    IList GenActors()
    {
        var list = new List <ActorRecord>();

        var a0 = new ActorRecord()
        {
            Id     = 1,
            Name   = "循",
            Lv     = 999,
            MaxHp  = 999,
            MaxAp  = 999,
            Hp     = 999,
            Ap     = 999,
            View   = "view/actor/axun",
            Sounds = new Dictionary <string, string>()
            {
            }
        };

        list.Add(a0);

        var a1 = new ActorRecord()
        {
            Id     = 2,
            Name   = "草人",
            Lv     = 1,
            MaxHp  = 10,
            MaxAp  = 10,
            Hp     = 10,
            Ap     = 10,
            View   = "view/actor/straw",
            Sounds = new Dictionary <string, string>()
            {
            }
        };

        list.Add(a1);

        return(list);
    }
Exemple #8
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");
        }
    }
Exemple #9
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");
    }
Exemple #10
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");
            }
        }
    }
    public override void OnInspectorGUI()
    {
        const string c_Resources = "Resources/";
        const string c_Ext       = ".prefab";
        ActorRecord  record      = (ActorRecord)target;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("类型");
        record.type = EditorGUILayout.IntPopup(record.type, new string[] { "0--普通", "1--塔", "2--英雄", "3--BOSS", "4--技能", "5--基地" }, new int[] { 0, 1, 2, 3, 4, 5 });
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("模型");
        Rect  rect = GUILayoutUtility.GetLastRect();
        float w    = rect.width;

        //Debug.LogFormat("rect:{0} {1} {2} {3}", rect.x, rect.y, rect.width, rect.height);

        rect.width          = 60;
        rect.x             += 40;
        record.avatarFilter = EditorGUI.TextField(rect, record.avatarFilter);

        string[] guids = AssetDatabase.FindAssets("t:Prefab," + record.avatarFilter);
        string[] paths = new string[guids.Length];
        for (int i = 0; i < guids.Length; ++i)
        {
            paths[i] = AssetDatabase.GUIDToAssetPath(guids[i]);
        }
        int index = System.Array.FindIndex(paths, s => s.EndsWith(record.avatar + c_Ext));
        int ix    = EditorGUILayout.Popup(index, paths);

        if (ix >= 0 && ix < paths.Length)
        {
            string avatar     = paths[ix];
            int    startIndex = avatar.IndexOf(c_Resources);
            if (startIndex >= 0)
            {
                record.avatar = avatar.Substring(startIndex + c_Resources.Length, avatar.Length - startIndex - c_Resources.Length - c_Ext.Length);
            }
            else
            {
                record.avatar = avatar;
            }
        }

        EditorGUILayout.LabelField(record.avatar);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("小图标:" + record.icon);
        Sprite sprite1  = SpriteManager.GetActorIcon(record.icon);
        Sprite sprite10 = EditorGUILayout.ObjectField(sprite1, typeof(Sprite), false) as Sprite;

        if (sprite10 != sprite1)
        {
            record.icon = SpriteManager.GetActorIconIndex(sprite10);
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("大图标:" + record.bigIcon);
        Sprite sprite2  = SpriteManager.GetActorBigIcon(record.bigIcon);
        Sprite sprite20 = EditorGUILayout.ObjectField(sprite2, typeof(Sprite), false) as Sprite;

        if (sprite20 != sprite2)
        {
            record.bigIcon = SpriteManager.GetActorBigIconIndex(sprite20);
        }
        EditorGUILayout.EndHorizontal();
        DrawDefaultInspector();
    }