Пример #1
0
        public void Update(XSkillHoster hoster)
        {
            string   pathwithname = hoster.SkillDataExtra.ScriptPath + hoster.ConfigData.SkillName + ".txt";
            DateTime time         = File.GetLastWriteTime(pathwithname);

            if (Time == default(DateTime))
            {
                Time = time;
            }

            if (time != Time)
            {
                Time = time;
                if (EditorUtility.DisplayDialog("WARNING!",
                                                "Skill has been Modified outside, Press 'OK' to reload file or 'Ignore' to maintain your change. (Make sure the '.config' file for skill script has been well synchronized)",
                                                "Ok", "Ignore"))
                {
                    hoster.ConfigData = XDataIO <XConfigData> .singleton.DeserializeData(XEditorLibrary.GetCfgFromSkp(pathwithname));

                    hoster.SkillData = XDataIO <XSkillData> .singleton.DeserializeData(pathwithname);

                    HotBuildEx(hoster, hoster.ConfigData);
                }
            }
        }
Пример #2
0
    public void OnEnable()
    {
        hideFlags = HideFlags.HideAndDontSave;
        if (_hoster == null)
        {
            _hoster = target as XSkillHoster;
        }

        AddPanels();
        _xOptions.Clear();
        _xOptions.Add("ResultAt");
        _xOptions.Add("Hit");
        _xOptions.Add("Manipulation");
        _xOptions.Add("Fx");
        _xOptions.Add("Warning");
        _xOptions.Add("Mobs");
        foreach (XPanel panel in _panels)
        {
            panel.Hoster = _hoster;
            panel.Init();
        }
    }
Пример #3
0
        public void ColdBuild(GameObject prefab, XConfigData conf)
        {
            if (hoster != null)
            {
                GameObject.DestroyImmediate(hoster);
            }
            hoster = UnityEngine.Object.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
            hoster.transform.localScale = Vector3.one * XTableMgr.GetTable <XEntityPresentation>().GetItemID((uint)conf.Player).Scale;
            hoster.AddComponent <XSkillHoster>();
            hoster.GetComponent <CharacterController>().enabled = false;
            UnityEngine.AI.NavMeshAgent agent = hoster.GetComponent <UnityEngine.AI.NavMeshAgent>();
            if (agent != null)
            {
                agent.enabled = false;
            }

            XSkillHoster component = hoster.GetComponent <XSkillHoster>();
            string       directory = conf.Directory[conf.Directory.Length - 1] == '/' ? conf.Directory.Substring(0, conf.Directory.Length - 1) : conf.Directory;
            string       path      = XEditorLibrary.GetPath("Skill" + "/" + directory);

            component.ConfigData = conf;
            component.SkillData  = XDataIO <XSkillData> .singleton.DeserializeData(path + conf.SkillName + ".txt");

            component.SkillDataExtra.ScriptPath = path;
            component.SkillDataExtra.ScriptFile = conf.SkillName;
            component.SkillDataExtra.SkillClip  = RestoreClip(conf.SkillClip, conf.SkillClipName);
            if (component.SkillData.TypeToken != 2)
            {
                if (component.SkillData.Time == 0)
                {
                    component.SkillData.Time = component.SkillDataExtra.SkillClip.length;
                }
            }
            HotBuildEx(component, conf);

            EditorGUIUtility.PingObject(hoster);
            Selection.activeObject = hoster;
        }
Пример #4
0
        public void HotBuildEx(XSkillHoster hoster, XConfigData conf)
        {
            XSkillDataExtra edata = hoster.SkillDataExtra;
            XSkillData      data  = hoster.SkillData;

            edata.ResultEx.Clear();
            edata.Fx.Clear();
            edata.HitEx.Clear();

            if (data.Result != null)
            {
                foreach (XResultData result in data.Result)
                {
                    XResultDataExtraEx rdee = new XResultDataExtraEx();
                    if (result.LongAttackEffect)
                    {
                        rdee.BulletPrefab      = Resources.Load(result.LongAttackData.Prefab) as GameObject;
                        rdee.BulletEndFx       = Resources.Load(result.LongAttackData.End_Fx) as GameObject;
                        rdee.BulletHitGroundFx = Resources.Load(result.LongAttackData.HitGround_Fx) as GameObject;
                    }
                    edata.ResultEx.Add(rdee);
                }
            }
            if (data.Hit != null)
            {
                foreach (XHitData hit in data.Hit)
                {
                    XHitDataExtraEx hee = new XHitDataExtraEx();
                    hee.Fx = Resources.Load(hit.Fx) as GameObject;
                    edata.HitEx.Add(hee);
                }
            }
            if (data.Fx != null)
            {
                foreach (XFxData fx in data.Fx)
                {
                    XFxDataExtra fxe = new XFxDataExtra();
                    fxe.Fx = Resources.Load(fx.Fx) as GameObject;
                    if (fx.Bone != null && fx.Bone.Length > 0)
                    {
                        Transform attachPoint = hoster.gameObject.transform.Find(fx.Bone);
                        if (attachPoint != null)
                        {
                            fxe.BindTo = attachPoint.gameObject;
                        }
                        else
                        {
                            int index = fx.Bone.LastIndexOf("/");
                            if (index >= 0)
                            {
                                string bone = fx.Bone.Substring(index + 1);
                                attachPoint = hoster.gameObject.transform.Find(bone);
                                if (attachPoint != null)
                                {
                                    fxe.BindTo = attachPoint.gameObject;
                                }
                            }
                        }
                    }
                    fxe.Ratio = fx.At / data.Time;
                    edata.Fx.Add(fxe);
                }
            }
            if (data.Manipulation != null)
            {
                foreach (XManipulationData manipulation in data.Manipulation)
                {
                    XManipulationDataExtra me = new XManipulationDataExtra();
                    edata.ManipulationEx.Add(me);
                }
            }
            if (data.Warning != null)
            {
                foreach (XWarningData warning in data.Warning)
                {
                    XWarningDataExtra we = new XWarningDataExtra();
                    we.Fx    = Resources.Load(warning.Fx) as GameObject;
                    we.Ratio = warning.At / data.Time;
                    edata.WarningEx.Add(we);
                }
            }
            if (data.Mob != null)
            {
                foreach (XMobUnitData mob in data.Mob)
                {
                    XMobUnitDataExtra me = new XMobUnitDataExtra();
                    me.Ratio = mob.At / data.Time;
                    edata.MobEx.Add(me);
                }
            }
        }