|  |  | 
 |  |  | using System.Collections.Generic; | 
 |  |  | using System; | 
 |  |  | using UnityEngine; | 
 |  |  | using Spine.Unity; | 
 |  |  |  | 
 |  |  | public class BattleObjectFactory | 
 |  |  | { | 
 |  |  |     public static BattleObject CreateBattleObject(TeamCard teamCard) | 
 |  |  |     { | 
 |  |  |         BattleObject battleObject = null; | 
 |  |  |         // switch (teamCard.cardInfo.cardConfig.) | 
 |  |  |         // { | 
 |  |  |     //  本意是要在这里做池的内容的 但是想了一下 利用效率有点差 最多做一下红色方的缓存 蓝色方的即时用 即时删除 或者缓存上一次战斗的就行 | 
 |  |  |     // private static int AutoIncrementID = 100000; | 
 |  |  |  | 
 |  |  |         // } | 
 |  |  |     private static float m_modelScaleRate = 0f; | 
 |  |  |  | 
 |  |  |     private static float modelScaleRate | 
 |  |  |     { | 
 |  |  |         get | 
 |  |  |         { | 
 |  |  |             if (m_modelScaleRate <= 0f) | 
 |  |  |             { | 
 |  |  |                 m_modelScaleRate = float.Parse(FuncConfigConfig.Get("BattleModelScale").Numerical1); | 
 |  |  |             } | 
 |  |  |             return m_modelScaleRate; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     //  这里报错了检查一下 | 
 |  |  |     public static BattleObject CreateBattleObject(BattleField _battleField, List<GameObject> posNodeList, TeamHero teamHero, BattleCamp _Camp) | 
 |  |  |     { | 
 |  |  |         HeroSkinConfig skinCfg = teamHero.skinConfig; | 
 |  |  |         if (skinCfg == null) | 
 |  |  |         { | 
 |  |  |             Debug.LogError(teamHero.heroId + "BattleObjectFactory.CreateBattleObject: skinCfg is null for " + teamHero.SkinID); | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", "Hero_001"/*skinCfg.SpineRes*/); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         GameObject goParent = posNodeList[teamHero.positionNum]; | 
 |  |  |         BattleObject battleObject = new BattleObject(_battleField); | 
 |  |  |         battleObject.ObjID = teamHero.ObjID; | 
 |  |  |  | 
 |  |  |         GameObject realGO = GameObject.Instantiate(battleGO, goParent.transform); | 
 |  |  |         SkeletonAnimation skeletonAnimation = realGO.GetComponentInChildren<SkeletonAnimation>(true); | 
 |  |  |  | 
 |  |  |         var skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinCfg.SpineRes); | 
 |  |  |         if (skeletonDataAsset == null) | 
 |  |  |         { | 
 |  |  |             Debug.LogError("BattleObjectFactory.CreateBattleObject: skeletonDataAsset is null for " + skinCfg.SpineRes); | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         float finalScaleRate = modelScaleRate * teamHero.modelScale; | 
 |  |  |  | 
 |  |  |         skeletonAnimation.skeletonDataAsset = skeletonDataAsset; | 
 |  |  |         skeletonAnimation.Initialize(true); | 
 |  |  |         realGO.name = battleObject.ObjID.ToString(); | 
 |  |  |         realGO.transform.localScale = new Vector3(finalScaleRate, finalScaleRate, finalScaleRate); | 
 |  |  |         RectTransform rectTrans = realGO.GetComponent<RectTransform>(); | 
 |  |  |         rectTrans.anchoredPosition = Vector2.zero; | 
 |  |  |         battleObject.Init(realGO, teamHero, _Camp); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         return battleObject; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static void DestroyBattleObject(BattleObject battleObj) | 
 |  |  |     public static void DestroyBattleObject(int key, BattleObject battleObj) | 
 |  |  |     { | 
 |  |  |          | 
 |  |  |         battleObj.Destroy(); | 
 |  |  |         battleObj = null; | 
 |  |  |     } | 
 |  |  | } |