/// <summary> /// 创建主将; /// </summary> /// <returns></returns> public void CreateHero(int warriorId, Vector3 pos, float orient) { WarriorData warriorData = DataManager.s_WarriorDataManager.GetData(warriorId); if (warriorData == null) { return; } Warrior warrior = new Warrior(warriorId); Quaternion rotate = Quaternion.Euler(new Vector3(0, orient * Mathf.Rad2Deg, 0)); GameObject prefab = ResourcesManager.Instance.LoadUnitObject(warriorData.Model, UNIT_TYPE.HERO); GameObject hero = GameObject.Instantiate(prefab) as GameObject; hero.transform.position = pos; hero.transform.rotation = rotate; UnityEngine.AI.NavMeshAgent agent = hero.AddComponent <UnityEngine.AI.NavMeshAgent>(); agent.speed = 0; agent.acceleration = 0; agent.angularSpeed = 0; agent.avoidancePriority = (int)NavmeshPriority.HERO; agent.height = warriorData.Height; agent.radius = warriorData.Radius; agent.stoppingDistance = agent.radius; hero.SetLayerRecursively(LayerMask.NameToLayer("Warrior")); m_HeroController = hero.AddComponent <HeroController>(); m_HeroController.m_Warrior = warrior; }
public Warrior(int dataId) { m_WarriorBaseData = DataManager.s_WarriorDataManager.GetData(dataId); if (m_WarriorBaseData == null) { Debug.LogError("WarriorData is null: " + dataId); return; } m_SkillList = new List <Skill>(); for (int i = 0; i < m_WarriorBaseData.SkillArray.Length; i++) { Skill skill = new Skill(m_WarriorBaseData.SkillArray[i]); m_SkillList.Add(skill); if (skill.SkillType == SkillTypes.NormalSkill) { NormalSkillList.Add(skill.SkillId); } if (skill.SkillType == SkillTypes.AttackSkill) { AttackSkillList.Add(skill.SkillId); } if (skill.SkillType == SkillTypes.SuperSkill) { SuperSkillList.Add(skill.SkillId); } } Hp = MaxHp; }
/// <summary> /// 加载NPC数据; /// </summary> public void LoadWarriorData() { m_WarriorDataDic = new Dictionary <int, WarriorData>(); string textAsset = ResourcesManager.Instance.LoadConfigXML("WarriorData").text; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(textAsset); XmlNode equipXN = xmlDoc.SelectSingleNode("WarriorDatas"); XmlNodeList list = equipXN.ChildNodes; if (list != null && list.Count > 0) { foreach (XmlNode node in list) { XmlElement element = node as XmlElement; if (element.Name.Equals("WarriorData")) { WarriorData info = new WarriorData(); info.ID = CommonHelper.Str2Int(element.GetAttribute("ID")); info.Name = element.GetAttribute("Name"); info.Desc = element.GetAttribute("Desc"); info.Image = element.GetAttribute("Image"); info.Photo = element.GetAttribute("Photo"); info.Height = CommonHelper.Str2Float(element.GetAttribute("Height")); info.Radius = CommonHelper.Str2Float(element.GetAttribute("Radius")); info.Spring = CommonHelper.Str2Float(element.GetAttribute("Spring")); info.Model = element.GetAttribute("Model"); info.HP._base = CommonHelper.Str2Int(element.GetAttribute("HP")); info.Atk._base = CommonHelper.Str2Int(element.GetAttribute("Atk")); info.Def._base = CommonHelper.Str2Int(element.GetAttribute("Def")); info.BPSpeed = CommonHelper.Str2Int(element.GetAttribute("BPSpeed")); info.Speed = CommonHelper.Str2Float(element.GetAttribute("Speed")); info.NormalAttackCDTime = CommonHelper.Str2Float(element.GetAttribute("NormalAttackCDTime")); info.SkillArray = CommonHelper.Str2IntArray(element.GetAttribute("SkillArray")); info.Tactics = CommonHelper.Str2Int(element.GetAttribute("Tactics")); info.LeaderSkill = CommonHelper.Str2Int(element.GetAttribute("LeaderSkill")); info.Level = CommonHelper.Str2Int(element.GetAttribute("Level")); info.Star = CommonHelper.Str2Int(element.GetAttribute("Star")); info.Camp = CommonHelper.Str2Int(element.GetAttribute("Camp")); if (!m_WarriorDataDic.ContainsKey(info.ID)) { m_WarriorDataDic.Add(info.ID, info); } } } } }
public void OpendDungeon() { //TODO int warriorId = DungeonLogic.GetMainWarriorId(); WarriorData warriorData = DataManager.s_WarriorDataManager.GetData(warriorId); if (warriorData == null) { Debug.LogError("no hero"); } else { DungeonLogic.LoadDungeon(m_DungeonId); } }
void InitWarrior(int id) { WarriorData warriorData = DataManager.s_WarriorDataManager.GetData(id); if (warriorData == null) { return; } Warrior warrior = new Warrior(id); if (warrior != null) { m_WarriorList.Add(warrior); } }
public static void InitData() { mageData = (MageData)ScriptableObject.CreateInstance(typeof(MageData)); rogueData = (RogueData)ScriptableObject.CreateInstance(typeof(RogueData)); warriorData = (WarriorData)ScriptableObject.CreateInstance(typeof(WarriorData)); }
public void InitData() { mageData = (MageData)CreateInstance(typeof(MageData)); warriorData = (WarriorData)CreateInstance(typeof(WarriorData)); rogueData = (RougeData)CreateInstance(typeof(RougeData)); }
public static void InitData() { CreatureData = (CreatureData)ScriptableObject.CreateInstance(typeof(CreatureData)); MageData = (MageData)ScriptableObject.CreateInstance(typeof(MageData)); WarriorData = (WarriorData)ScriptableObject.CreateInstance(typeof(WarriorData)); }
public static void InitData() { warriorData = (WarriorData)ScriptableObject.CreateInstance(typeof(WarriorData)); }