public virtual void Init(CharacterConfigInfo cInfos, Action createComplete = null) { IsCreate = false; onCreateComplete = createComplete; characterConfigInfo = cInfos; if (Model != null) { Model.Destroy(); Model = null; } Model = new CommonModel(); modelName = characterConfigInfo.ModelName; Model.Init(GameConst.CharacterModelABDirectory + modelName, modelName, OnCreateCompleteHandler); }
private void OnModelSelectedHandler(string abn) { //to do CharacterConfigInfo characterConfigInfo = DataManager.GetCharacterConfigInfo(abn); if (tCreature == null) { tCreature = new TCreature(); EntityManager.AddEntity(tCreature); } tCreature.Init(characterConfigInfo); if (beAttacker == null) { beAttacker = new TCreature(); EntityManager.AddEntity(beAttacker); beAttacker.Init(tCreature.GetCharacterConfigInfo()); } beAttacker.Hide(); AttributeSetting.Instance.StartSetting(characterConfigInfo); EditorCameraController.Instance.Target = tCreature.Container; AttributeSetting.Instance.OnWearWeaponHandler = ShowWeapon; AttributeSetting.Instance.OnActionSelectedHandler = OnActionSelectedHandler; AttributeSetting.Instance.GetActionLength = GetActionLength; AttributeSetting.Instance.PreviewHandler = PreviewHandler; int row = 20; int col = 20; byte[,] grids = new byte[row, col]; for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) { grids[i, j] = 1;// (byte)(((i % 6 == 0) && (j % 4 == 0)) == true ? 1 : 0); } } ResourceManager.CreateAssetBundle("configs/configs"); ResourceManager.GetText("configs/configs", "test_scene"); ConfigManager.GetSceneConfigInfo("test_scene"); }
private static void SaveSingle(CharacterConfigInfo characterConfigInfo) { string content = characterConfigInfo.ToXMLString(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<?xml version='1.0' encoding='utf-8'?>\n"); stringBuilder.Append(content); string path = Application.dataPath + "/ArtAssets/prefabs/configs/characters/" + characterConfigInfo.ModelName.ToLower() + ".xml"; if (File.Exists(path)) { File.Delete(path); } StreamWriter SW; SW = File.CreateText(path); SW.WriteLine(stringBuilder.ToString()); SW.Close(); }
private static void OnDelHandler(float del) { if (tempList.Count > 0) { int index = tempList.Count - 1; CharacterConfigInfo characterConfigInfo = tempList[index]; tempList.RemoveAt(index); SaveSingle(characterConfigInfo); } else { TimerManager.RemoveHandler(timerInfo); timerInfo = null; // to do 保存完成 if (OnCompleteHandler != null) { OnCompleteHandler(); } } }
public static CharacterConfigInfo GetCharacterConfigInfo(string modelName) { CharacterConfigInfo characterConfigInfo; characterInfos.TryGetValue(modelName, out characterConfigInfo); if (characterConfigInfo == null) { characterConfigInfo = ConfigManager.GetCharacterConfigInfo(modelName); if (characterConfigInfo != null) { characterInfos.Add(modelName, characterConfigInfo); } } if (characterConfigInfo == null) { characterConfigInfo = new CharacterConfigInfo(); characterConfigInfo.ModelName = modelName; characterInfos.Add(modelName, characterConfigInfo); } return(characterConfigInfo); }
private void PreviewHandler(CharacterConfigInfo characterConfigInfo, ActionInfo actionInfo) { Debug.LogError("start preview"); Alert.Show("预览准备中,请稍等......"); currentCharacterConfigInfo = characterConfigInfo; currentActionInfo = actionInfo; if (currentCharacterConfigInfo != null && currentActionInfo != null && tCreature != null) { bool isCorrect = CheckActionInfo(currentActionInfo); if (!isCorrect) { return; } if (currentActionInfo.ActionName != AnimationType.Idle) { tTimerInfo = TimerManager.AddDelayHandler(OnDelHandler, 2f, 1); tCreature.PlayAnimation(AnimationType.Idle, true); } } }
public void StartSetting(CharacterConfigInfo characterConfigInfo) { if (container != null) { container.SetActive(true); } currentCharacterConfigInfo = characterConfigInfo; modelnText.text = currentCharacterConfigInfo.ModelName; int index = DataManager.GetWeaponIndex(characterConfigInfo.LeftWeaponName); leftweapon.ListView.Select(index); index = DataManager.GetWeaponIndex(characterConfigInfo.RightWeaponName); rightweapon.ListView.Select(index); walkSpeedSet.SetValue(currentCharacterConfigInfo.WalkSpeed, DataManager.WalkSpeedMax); walkSpeedValue.text = currentCharacterConfigInfo.WalkSpeed.ToString(); runSpeedSet.SetValue(currentCharacterConfigInfo.RunSpeed, DataManager.RunSpeedMax); runSpeedValue.text = currentCharacterConfigInfo.RunSpeed.ToString(); index = DataManager.GetActionIndex(AnimationType.Idle); actionNameSet.ListView.Select(index); }
public void Init(CharacterConfigInfo cInfos) { base.Init(cInfos, OnCreateHandler); FSM = FSMFactory.GetCharacterEditorFSM(this); }
private static void ParseSingleCharacter(XmlNodeList nodeList) { if (nodeList == null) { return; } for (int i = 0; i < nodeList.Count; ++i) { XmlElement node = nodeList[i] as XmlElement; CharacterConfigInfo characterConfigInfo = new CharacterConfigInfo(); XmlNodeList childList = node.GetElementsByTagName("p"); for (int j = 0; j < childList.Count; j++) { XmlElement child = childList[j] as XmlElement; string key = child.GetAttribute("n"); string value = child.InnerXml; switch (key) { case "ModelName": characterConfigInfo.ModelName = value; break; case "WalkSpeed": float.TryParse(value, out characterConfigInfo.WalkSpeed); break; case "RunSpeed": float.TryParse(value, out characterConfigInfo.RunSpeed); break; case "LeftWeaponName": characterConfigInfo.LeftWeaponName = value; break; case "RightWeaponName": characterConfigInfo.RightWeaponName = value; break; } } childList = node.GetElementsByTagName("as"); for (int j = 0; j < childList.Count; ++j) { XmlElement child = childList[j] as XmlElement; ActionInfo actionInfo = new ActionInfo(); XmlNodeList acts = child.GetElementsByTagName("a"); for (int t = 0; t < acts.Count; t++) { XmlElement act = acts[t] as XmlElement; string key = act.GetAttribute("n"); string value = act.InnerXml; switch (key) { case "ActionName": actionInfo.ActionName = value; break; case "Length": float.TryParse(value, out actionInfo.Length); break; case "IsLangAttack": actionInfo.IsLangAttack = (value == "1" ? true : false); break; case "PlaySpeed": float.TryParse(value, out actionInfo.PlaySpeed); break; case "IsLoop": actionInfo.IsLoop = (value == "1" ? true : false); break; case "SoundName": actionInfo.SoundName = value; break; case "SoundPlayDelayTime": float.TryParse(value, out actionInfo.SoundPlayDelayTime); break; case "AttRange": float.TryParse(value, out actionInfo.AttackRadius); break; case "AttAngle": float.TryParse(value, out actionInfo.AttackAngle); break; case "SelfMoveDelayTime": float.TryParse(value, out actionInfo.SelfMoveDelayTime); break; case "SelfMoveDistance": float.TryParse(value, out actionInfo.SelfMoveDistance); break; case "SelfMoveTime": float.TryParse(value, out actionInfo.SelfMoveTime); break; case "IsHitMove": actionInfo.IsHitMove = value == "1" ? true : false; break; case "HitMoveDistance": float.TryParse(value, out actionInfo.HitMoveDistance); break; case "HitMoveTime": float.TryParse(value, out actionInfo.HitMoveTime); break; case "IsHitFly": actionInfo.IsHitFly = value == "1" ? true : false; break; case "HitFlyDistance": float.TryParse(value, out actionInfo.HitFlyDistance); break; case "HitFlyTime": float.TryParse(value, out actionInfo.HitFlyTime); break; case "ShakeScreen": actionInfo.ShakeScreen = value; break; case "DefaultShakeScene": actionInfo.DefaultShakeScene = (value == "1" ? true : false); break; } } ParseEffectInfo(child, "acs", "ac", actionInfo.ActionEffectInfos); ParseEffectInfo(child, "his", "hi", actionInfo.HitEffectInfos); characterConfigInfo.AddActionInfo(actionInfo); } characterConfigInfos.Add(characterConfigInfo.ModelName, characterConfigInfo); } }