Esempio n. 1
0
        private GameObject InitMonsterSelf(MonsterInfo info)
        {
            MonsterBasicData monsterdata = DataManagerM.Instance.getManager(GameObjectTypes.MONSTER).getData(info.monsterId, DataTypes.Basic) as MonsterBasicData;
            string           resPath     = monsterdata.respath;

            if (resPath == null)
            {
                throw new Exception("当前playertype有误或者没有配置对应资源");
            }
            GameObject prefab;

            _resObjMap.TryGetValue(info.monsterId, out prefab);
            if (prefab == null)
            {
                prefab = Resources.Load(resPath) as GameObject;
                _resObjMap.Add(info.monsterId, prefab);
            }

            GameObject monster = GameObject.Instantiate(prefab);

            monster.transform.position = info.position;
            if (monster.GetComponent <AutoMoveController>() == null)
            {
                monster.AddComponent <AutoMoveController>();
            }
            if (monster.GetComponent <AIContainer>() == null)
            {
                monster.AddComponent <AIContainer>();
            }
            addObj(monster, info);
            return(monster);
        }
Esempio n. 2
0
        public static void SaveBasicData(XmlDocument xdoc)
        {
            XmlNodeList nodeList = xdoc.GetElementsByTagName("MonsterBatch")[0].ChildNodes;

            foreach (XmlElement xe in nodeList)
            {
                MonsterBasicData data = new MonsterBasicData();
                data.decode(xe);
                BASICDATA.Add(Convert.ToInt32(xe.GetAttribute("id")), data);
            }
        }
Esempio n. 3
0
        protected override void InitOtherInfo()
        {
            MonsterBasicData monsterdata = DataManagerM.Instance.getManager(GameObjectTypes.MONSTER).getData(monsterAttribute.monsterId, DataTypes.Basic) as MonsterBasicData;

            gameObject.GetComponent <AIContainer>().AIComponent = MonsterAIFactory.getAIComponent(monsterdata.aiComponent);
            //如果不是网络对象,开启ai
            if (!baseAttribute.isNetObj)
            {
                gameObject.GetComponent <AIContainer>().AIComponent.run();
            }
        }
Esempio n. 4
0
        public IData getData(GameObject obj, DataTypes type)
        {
            int id = obj.GetComponent <BaseAttributes>().objectId;
            MonsterBasicData basicData = getData(id, DataTypes.Basic) as MonsterBasicData;

            if (type == DataTypes.Basic)
            {
                return(basicData as IData);
            }
            if (type == DataTypes.AI)
            {
                id = basicData.aiId;
            }
            else if (type == DataTypes.Action)
            {
                id = basicData.actionId;
            }
            else if (type == DataTypes.Breeding)
            {
                id = basicData.breedId;
            }
            return(getData(id, type));
        }