private void SpawnSoldier(uint SoldierID) { ResMonsterCfgInfo dataCfgInfoByCurLevelDiff = MonsterDataHelper.GetDataCfgInfoByCurLevelDiff((int)SoldierID); if (dataCfgInfoByCurLevelDiff != null) { if (CActorInfo.GetActorInfo(StringHelper.UTF8BytesToString(ref dataCfgInfoByCurLevelDiff.szCharacterInfo), enResourceType.BattleScene) != null) { Transform transform = this.Region.transform; COM_PLAYERCAMP campType = this.Region.CampType; ActorMeta actorMeta = new ActorMeta { ConfigId = (int)SoldierID, ActorType = ActorTypeDef.Actor_Type_Monster, ActorCamp = campType }; VInt3 position = (VInt3)transform.position; VInt3 forward = (VInt3)transform.forward; PoolObjHandle <ActorRoot> actor = new PoolObjHandle <ActorRoot>(); if (!Singleton <GameObjMgr> .GetInstance().TryGetFromCache(ref actor, ref actorMeta)) { actor = Singleton <GameObjMgr> .GetInstance().SpawnActorEx(null, ref actorMeta, position, forward, false, true); if (actor != 0) { actor.handle.InitActor(); actor.handle.PrepareFight(); Singleton <GameObjMgr> .instance.AddActor(actor); actor.handle.StartFight(); } } else { ActorRoot handle = actor.handle; handle.TheActorMeta.ActorCamp = actorMeta.ActorCamp; handle.ReactiveActor(position, forward); } if (actor != 0) { if (this.Region.AttackRoute != null) { actor.handle.ActorControl.AttackAlongRoute(this.Region.AttackRoute.GetComponent <WaypointsHolder>()); } else if (this.Region.finalTarget != null) { FrameCommand <AttackPositionCommand> cmd = FrameCommandFactory.CreateFrameCommand <AttackPositionCommand>(); cmd.cmdId = 1; cmd.cmdData.WorldPos = new VInt3(this.Region.finalTarget.transform.position); actor.handle.ActorControl.CmdAttackMoveToDest(cmd, cmd.cmdData.WorldPos); } if (!this.isCannonNotified && (this.WaveInfo.bType == 1)) { KillNotify killNotifation = Singleton <CBattleSystem> .GetInstance().GetKillNotifation(); Player hostPlayer = Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer(); if ((killNotifation != null) && (hostPlayer != null)) { bool bSrcAllies = hostPlayer.PlayerCamp == actor.handle.TheActorMeta.ActorCamp; if (bSrcAllies) { KillInfo killInfo = new KillInfo((hostPlayer.PlayerCamp != COM_PLAYERCAMP.COM_PLAYERCAMP_1) ? KillNotify.red_cannon_icon : KillNotify.blue_cannon_icon, null, KillDetailInfoType.Info_Type_Cannon_Spawned, bSrcAllies, false, ActorTypeDef.Invalid); killNotifation.AddKillInfo(killInfo); this.isCannonNotified = true; } } } } } if (this.Region.bTriggerEvent) { SoldierWaveParam prm = new SoldierWaveParam(this.Index, this.repeatCount, this.Region.GetNextRepeatTime(false)); Singleton <GameEventSys> .instance.SendEvent <SoldierWaveParam>(GameEventDef.Event_SoldierWaveNextRepeat, ref prm); } } }
private void SpawnSoldier(uint SoldierID) { ResMonsterCfgInfo dataCfgInfoByCurLevelDiff = MonsterDataHelper.GetDataCfgInfoByCurLevelDiff((int)SoldierID); if (dataCfgInfoByCurLevelDiff == null) { return; } string path = StringHelper.UTF8BytesToString(ref dataCfgInfoByCurLevelDiff.szCharacterInfo); CActorInfo actorInfo = CActorInfo.GetActorInfo(path, enResourceType.BattleScene); if (actorInfo) { Transform transform = this.Region.transform; COM_PLAYERCAMP campType = this.Region.CampType; ActorMeta actorMeta = default(ActorMeta); ActorMeta actorMeta2 = actorMeta; actorMeta2.ConfigId = (int)SoldierID; actorMeta2.ActorType = ActorTypeDef.Actor_Type_Monster; actorMeta2.ActorCamp = campType; actorMeta = actorMeta2; VInt3 vInt = (VInt3)transform.position; VInt3 vInt2 = (VInt3)transform.forward; PoolObjHandle <ActorRoot> poolObjHandle = default(PoolObjHandle <ActorRoot>); if (!Singleton <GameObjMgr> .GetInstance().TryGetFromCache(ref poolObjHandle, ref actorMeta)) { poolObjHandle = Singleton <GameObjMgr> .GetInstance().SpawnActorEx(null, ref actorMeta, vInt, vInt2, false, true); if (poolObjHandle) { poolObjHandle.handle.InitActor(); poolObjHandle.handle.PrepareFight(); Singleton <GameObjMgr> .instance.AddActor(poolObjHandle); poolObjHandle.handle.StartFight(); } } else { ActorRoot handle = poolObjHandle.handle; handle.TheActorMeta.ActorCamp = actorMeta.ActorCamp; handle.ReactiveActor(vInt, vInt2); } if (poolObjHandle) { if (this.Region.AttackRoute != null) { poolObjHandle.handle.ActorControl.AttackAlongRoute(this.Region.AttackRoute.GetComponent <WaypointsHolder>()); } else if (this.Region.finalTarget != null) { FrameCommand <AttackPositionCommand> frameCommand = FrameCommandFactory.CreateFrameCommand <AttackPositionCommand>(); frameCommand.cmdId = 1u; frameCommand.cmdData.WorldPos = new VInt3(this.Region.finalTarget.transform.position); poolObjHandle.handle.ActorControl.CmdAttackMoveToDest(frameCommand, frameCommand.cmdData.WorldPos); } if (!this.isCannonNotified && this.WaveInfo.bType == 1 && this.Region != null && (this.Region.RouteType == RES_SOLDIER_ROUTE_TYPE.RES_SOLDIER_ROUTE_MID || this.Region.RouteType == RES_SOLDIER_ROUTE_TYPE.RES_SOLDIER_ROUTE_NONE)) { KillNotify theKillNotify = Singleton <CBattleSystem> .GetInstance().TheKillNotify; Player hostPlayer = Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer(); if (theKillNotify != null && hostPlayer != null) { bool flag = hostPlayer.PlayerCamp == poolObjHandle.handle.TheActorMeta.ActorCamp; if (flag) { KillInfo killInfo = new KillInfo((hostPlayer.PlayerCamp == COM_PLAYERCAMP.COM_PLAYERCAMP_1) ? KillNotify.blue_cannon_icon : KillNotify.red_cannon_icon, null, KillDetailInfoType.Info_Type_Cannon_Spawned, flag, false, ActorTypeDef.Invalid, false); theKillNotify.AddKillInfo(ref killInfo); this.isCannonNotified = true; } } } if (this.WaveInfo.bType == 2) { if (!this.isNotifiedBigDragonSoldier && this.Region != null && (this.Region.RouteType == RES_SOLDIER_ROUTE_TYPE.RES_SOLDIER_ROUTE_MID || this.Region.RouteType == RES_SOLDIER_ROUTE_TYPE.RES_SOLDIER_ROUTE_NONE)) { KillNotify theKillNotify2 = Singleton <CBattleSystem> .GetInstance().TheKillNotify; Player hostPlayer2 = Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer(); if (theKillNotify2 != null && hostPlayer2 != null) { bool bSrcAllies = hostPlayer2.PlayerCamp == poolObjHandle.handle.TheActorMeta.ActorCamp; KillInfo killInfo2 = new KillInfo(KillNotify.soldier_bigdragon_icon, null, KillDetailInfoType.Info_Type_Soldier_BigDragon, bSrcAllies, false, ActorTypeDef.Invalid, false); theKillNotify2.AddKillInfo(ref killInfo2); this.isNotifiedBigDragonSoldier = true; } } } else if (this.isNotifiedBigDragonSoldier) { this.isNotifiedBigDragonSoldier = false; } } } SoldierWaveParam soldierWaveParam = new SoldierWaveParam(this.Index, this.repeatCount, this.Region.GetNextRepeatTime(false), this); Singleton <GameEventSys> .instance.SendEvent <SoldierWaveParam>(GameEventDef.Event_SoldierWaveNextRepeat, ref soldierWaveParam); }
public PoolObjHandle <ActorRoot> SpawnActorEx(GameObject rootObj, ref ActorMeta actorMeta, VInt3 pos, VInt3 dir, bool useLobbyModel, bool addComponent) { if (actorMeta.Difficuty == 0) { actorMeta.Difficuty = (byte)Singleton <BattleLogic> .get_instance().GetCurLvelContext().m_levelDifficulty; } ActorStaticData theStaticData = default(ActorStaticData); IGameActorDataProvider actorDataProvider = Singleton <ActorDataCenter> .get_instance().GetActorDataProvider(GameActorDataProviderType.StaticBattleDataProvider); actorDataProvider.GetActorStaticData(ref actorMeta, ref theStaticData); ActorServerData actorServerData = default(ActorServerData); IGameActorDataProvider actorDataProvider2 = Singleton <ActorDataCenter> .get_instance().GetActorDataProvider(GameActorDataProviderType.ServerDataProvider); actorDataProvider2.GetActorServerData(ref actorMeta, ref actorServerData); if (actorMeta.SkinID == 0u) { actorMeta.SkinID = actorServerData.SkinId; } GameObject gameObject = null; ActorConfig component; if (rootObj == null) { rootObj = MonoSingleton <SceneMgr> .GetInstance().Spawn(typeof(ActorRoot).get_Name(), (SceneObjType)theStaticData.TheActorMeta.ActorType, pos, dir); component = rootObj.GetComponent <ActorConfig>(); } else { component = rootObj.GetComponent <ActorConfig>(); Animation componentInChildren = rootObj.GetComponentInChildren <Animation>(); if (componentInChildren != null) { gameObject = componentInChildren.gameObject; } rootObj.transform.parent = MonoSingleton <SceneMgr> .GetInstance().GetRoot((SceneObjType)theStaticData.TheActorMeta.ActorType).transform; } component.ConfigID = actorMeta.ConfigId; CActorInfo cActorInfo = null; if (!string.IsNullOrEmpty(theStaticData.TheResInfo.ResPath)) { CActorInfo actorInfo = CActorInfo.GetActorInfo(theStaticData.TheResInfo.ResPath, 0); if (actorInfo != null) { cActorInfo = (CActorInfo)Object.Instantiate(actorInfo); string text = (!useLobbyModel) ? cActorInfo.GetArtPrefabName((int)actorMeta.SkinID, -1) : cActorInfo.GetArtPrefabNameLobby((int)actorMeta.SkinID); if (gameObject == null && !string.IsNullOrEmpty(text)) { bool flag = false; gameObject = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(text, false, SceneObjType.ActionRes, Vector3.zero, Quaternion.identity, out flag); if (gameObject != null) { Transform component2 = gameObject.GetComponent <Transform>(); component2.SetParent(rootObj.transform); component2.localPosition = Vector3.zero; component2.localRotation = Quaternion.identity; TransformConfig transformConfigIfHaveOne = cActorInfo.GetTransformConfigIfHaveOne(ETransformConfigUsage.CharacterInGame); if (transformConfigIfHaveOne != null) { component2.localPosition += transformConfigIfHaveOne.Offset; component2.localScale *= transformConfigIfHaveOne.Scale; } } } } } PoolObjHandle <ActorRoot> result = component.AttachActorRoot(rootObj, ref actorMeta, cActorInfo); result.get_handle().TheStaticData = theStaticData; if (addComponent) { result.get_handle().Spawned(); } return(result); }