private bool initToy(Toy pToy, int nTypeID, int nQuality, CAMP_TYPE eCampType, stHeroData pHeroData) { if (null == pToy) { return false; } // 这边是AI类型和英雄类型ID之间的转化关系 HERO_TYPE eHeroType = (HERO_TYPE)(nTypeID % 10000); pToy.TOY_CAMP = eCampType; pToy.init(nTypeID, pHeroData); pToy.setToyManager(ToyManager.Instance()); pToy.setMapManager(MapManage.Instance()); // 建议toy信息都完整了再绑定AI pToy.bindMyAI(eHeroType, eCampType); return true; }
// 只有ID和品质可以影响toy的外观--只创建英雄所以其实可以不用工程方法 public Toy createToy(int nTypeID, int nQuality, CAMP_TYPE eCampType, stHeroData pHeroData) { Toy pToy = null; stHeroCfg pConfig = HeroConfig.Instance().getHeroInfoById(nTypeID); if (null != pConfig) { HeroToy pHeroToy = new HeroToy(); // 这样将model放开可以使模型易于扩展 HeroModel pHeroModel = new HeroModel(); pHeroModel.init(nTypeID, nQuality); pHeroToy.bindModel(pHeroModel); pHeroToy.setHeroConfig(pConfig); pHeroToy.setHeroData(pHeroData); initToy(pHeroToy, nTypeID, nQuality, eCampType, pHeroData); pToy = pHeroToy; } return pToy; }
// 设置英雄数据 public void setHeroData(stHeroData stData) { m_pHeroData = stData; }
public override void init(int nHeroType, stHeroData pHeroData) { setHeroData(pHeroData); stHeroCfg pHeroCfg = HeroConfig.Instance().getHeroInfoById(nHeroType); if (null != pHeroCfg) { setHeroConfig(pHeroCfg); // 设置血量 TOY_CUR_HP = pHeroCfg.nBlood + pHeroData.nLevel * pHeroCfg.nAddBlood; } }