private void GetAnimState(EntityGameObject entObj, List <Vector3> state) { state.Clear(); foreach (var hb in entObj.Hitboxes) { state.Add(hb.transform.position); state.Add(hb.transform.eulerAngles); } }
private void SetAnimatorState(EntityGameObject entObj, List <Vector3> state) { var idx2 = 0; for (int i = 0; i < entObj.Hitboxes.Length; i++) { entObj.Hitboxes[i].transform.position = state[idx2]; entObj.Hitboxes[i].transform.eulerAngles = state[idx2 + 1]; idx2 += 2; } }
/// <summary> /// 根据策划资源表的restype随机生成 /// </summary> /// <param name="resType"></param> /// <param name="entityFuncType"></param> /// <returns></returns> public EntityGameObject GetRandomEntity(ResType resType, EntityFuncType entityFuncType) { EntityGameObject entity = null; List <ResourceKeyCell> cellList = GlobalDataManager.GetInstance().logicTableResource.GetResListByResType((int)resType); if (cellList == null || cellList.Count <= 0) { string e = string.Format("cellList 异常 {0}", (int)resType); throw new System.Exception(e); } int idx = UnityEngine.Random.Range(0, cellList.Count); var cell = cellList[idx]; entity = GenEntityGameObject(cell.key, entityFuncType); return(entity); }
protected void TracedCamera(EntityGameObject entity, bool isBool) { if (IsTraceBool(isBool)) { return; } if (isTracedVisitor == false) { isTracedVisitor = true; } else if (isTracedCar == false) { isTracedCar = true; ////模型到达出口 调用新手引导的内容 显示步骤13 //if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true) //{ // UIGuide[] pAllObjects = (UIGuide[])Resources.FindObjectsOfTypeAll(typeof(UIGuide)); // //延时刷新关于出口的暂停和文本 // pAllObjects[0].VerdictExit(4f); //} } LogWarp.LogError("测试: 相机跟随"); }
/// <summary> /// 根据策划资源表的主键和实体单位功能类型(与表无关) /// </summary> /// <param name="entityResType">对应策划资源表的主键</param> /// <param name="entityFuncType"></param> /// <returns></returns> public EntityGameObject GenEntityGameObject(int entityResType, EntityFuncType entityFuncType) { EntityGameObject entity = null; int ientityFuncType = (int)entityFuncType; switch (entityFuncType) { case EntityFuncType.VisitorCar_EnterZoo: case EntityFuncType.VisitorCar_LeaveZoo: entity = EntityVisitorCar.pool.New(); #if UNITY_EDITOR if ((entity as EntityVisitorCar).followPath != null && (entity as EntityVisitorCar).followPath.IsRunning()) { string ee = string.Format("{0} followPath.IsRunning", entity.entityID); throw new System.Exception(ee); } #endif break; case EntityFuncType.Visitor_From_Car: case EntityFuncType.Visitor_From_Ship: case EntityFuncType.Visitor_From_GroundParking: entity = EntityVisitor.pool.New(); break; case EntityFuncType.Animal_Wander: entity = EntityAnimalWander.pool.New(); break; case EntityFuncType.Shuttle: entity = EntityShuttle.pool.New(); break; case EntityFuncType.Ship: entity = EntityShip.pool.New(); break; case EntityFuncType.Train: entity = EntityShip.pool.New(); break; case EntityFuncType.GroundParkingCar: entity = EntityGroundParkingCar.pool.New(); break; case EntityFuncType.CrossRoadCar: entity = CrossRoadGame.EntityCrossRoadCar.pool.New(); break; case EntityFuncType.Animal_LittleGame: entity = CrossRoadGame.EntityCrossRoadAnimal.pool.New(); break; default: string e = string.Format("没有这种 EntityFuncType {0}", entityFuncType); throw new System.Exception(e); } entity.entityFuncType = ientityFuncType; int newEntityID = GetNewEntityID(); #if UNITY_EDITOR if (entity.mainGameObject != null) { DebugFile.GetInstance().WriteKeyFile(newEntityID, "{0} get from pool oldEntityID={1}, mainGameObject={2} ", newEntityID, entity.entityID, entity.mainGameObject.GetInstanceID()); DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} get from pool oldEntityID={1}, newEntityID={2} ", entity.mainGameObject.GetInstanceID(), entity.entityID, newEntityID); } #endif entity.entityID = newEntityID; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} GetNewEntityID", entity.entityID); if (entity.mainGameObject != null && entity.entityResType == entityResType) { #if UNITY_EDITOR if (entityMovables.ContainsKey(entity.entityID)) { string e = string.Format("{0} 还在移动列表", entity.entityID); throw new System.Exception(e); } #endif //什么都不用干,用原来的mainGameObject DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} old {1}", entity.entityID, entity.mainGameObject.GetInstanceID()); DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} old {1}", entity.mainGameObject.GetInstanceID(), entity.entityID); return(entity); } GameObjectPool pool = null; if (entity.mainGameObject != null && entity.entityResType != entityResType) { //回收mainGameObject pool = PoolManager.GetInstance().IsBelongGameObjectPool(entity.entityResType); if (pool == null) { string e = string.Format("异常,找不到回收的GameObjectPool {0}", entity.entityResType); throw new System.Exception(e); } DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} change {1}, pos {2}", entity.entityID, entity.mainGameObject.GetInstanceID(), entity.mainGameObject.transform.position); DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} change {1}, pos {2}", entity.mainGameObject.GetInstanceID(), entity.entityID, entity.mainGameObject.transform.position); pool.Delete(entity.mainGameObject); entity.ClearCatchTrans(); } entity.entityResType = (int)entityResType; pool = PoolManager.GetInstance().GetGameObjectPool(entity.entityResType); entity.mainGameObject = pool.New(); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} new {1}", entity.entityID, entity.mainGameObject.GetInstanceID()); DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} new {1}", entity.mainGameObject.GetInstanceID(), entity.entityID); return(entity); }