IEnumerator DelayBossReborn(SceneEntityPosAgent agent) { SceneMan.RemoveSceneObj(agent); yield return(new WaitForSeconds(240)); // wait 4 min SceneMan.AddSceneObj(agent); }
public override bool OnPutDown() { if (GameConfig.IsMultiClient) { if (!Pathea.PeGameMgr.IsMultiCoop && VArtifactUtil.IsInTownBallArea(transform.position)) { new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning); return(true); } if (null != PlayerNetwork.mainPlayer) { PlayerNetwork.mainPlayer.RequestDragTower(itemDragging.itemObj.instanceId, transform.position, transform.rotation); } } else { DragTowerAgent towerAget = new DragTowerAgent(itemDragging, transform.position, transform.rotation); towerAget.Create(); SceneMan.AddSceneObj(towerAget); PeMap.TowerMark towerMask = new PeMap.TowerMark(); towerMask.position = transform.position; towerMask.ID = itemObjectId; towerMask.text = itemDragging.itemObj.protoData.GetName(); towerMask.campId = Mathf.RoundToInt(Pathea.MainPlayer.Instance.entity.GetAttribute(Pathea.AttribType.CampID)); PeMap.LabelMgr.Instance.Add(towerMask); PeMap.TowerMark.Mgr.Instance.Add(towerMask); RemoveFromBag(); } return(base.OnPutDown()); }
public static void CreateStoryDoodads(bool bNew) { if (PeGameMgr.IsMulti) { return; } foreach (KeyValuePair <int, SceneDoodadDesc> iter in StoryDoodadMap.s_dicDoodadData) { bool bSerializable = iter.Value._type > 0; if (!bNew && bSerializable) { // serializable doodad would be created from savedata loading continue; } AgentInfo spInfo = new AgentInfo(iter.Value._id, iter.Value._isShown, iter.Value._campId, iter.Value._damageId); if (!bSerializable) // Add to scene { SceneEntityPosAgent agent = CreateAgent(iter.Value._pos, iter.Value._protoId, iter.Value._scl, iter.Value._rot); agent.spInfo = spInfo; SceneMan.AddSceneObj(agent); continue; } // bNew and serializable CreateDoodad(true, spInfo, iter.Value._protoId, iter.Value._pos, iter.Value._scl, iter.Value._rot); } }
private void ReqReborn(SceneEntityPosAgent agent) { if (agent.IsIdle) { if (agent.entity == null || agent.entity.IsDead()) { agent.entity = null; agent.canRide = false; SceneMan.RemoveSceneObj(agent); SceneMan.AddSceneObj(agent); } else if (agent.entity != null && agent.entity.monstermountCtrl != null && agent.entity.monstermountCtrl.ctrlType == ECtrlType.Mount) //Lw2017.2.14:怪物已经被驯服,重新生成 { agent.entity = null; agent.canRide = false; //SceneMan.RemoveSceneObj(agent); SceneMan.AddSceneObj(agent); } else { agent.canRide = false; MonsterCmpt mc = agent.Go.GetComponent <MonsterCmpt>(); if (mc != null) { mc.Req_MoveToPosition(agent.Pos, 1, true, SpeedState.Run); } } } }
void AliveEntityDeathEvent(SkEntity arg1, SkEntity arg2) { FixedSpawnPointInfo info = null; if (SceneEntityCreatorArchiver.Instance._fixedSpawnPointInfos.TryGetValue(_fixedId, out info)) { SceneMan.RemoveSceneObj(info._agent); if (info._needCD > 0.0f) { MissionManager.Instance.PeTimeToDo(delegate(){ if (info._bActive) { SceneMan.RemoveSceneObj(info._agent); SceneMan.AddSceneObj(info._agent); } }, info._needCD, _fixedId); } else { SceneEntityCreatorArchiver.Instance.SetFixedSpawnPointActive(_fixedId, false); } SceneEntityCreatorArchiver.Instance.GetEntityByFixedSpId(_fixedId).aliveEntity.deathEvent -= AliveEntityDeathEvent; } }
public void CreateDoodadAgents(Dictionary <int, DoodadSpawnPoint> points) { foreach (KeyValuePair <int, DoodadSpawnPoint> kvp in points) { SceneStaticAgent agent = new SceneStaticAgent(kvp.Value, true); agent.ScenarioId = kvp.Value.ID; kvp.Value.agent = agent; SceneMan.AddSceneObj(agent); } }
public void CreateNpcAgents(Dictionary <int, NPCSpawnPoint> points) { foreach (KeyValuePair <int, NPCSpawnPoint> kvp in points) { SceneEntityAgent agent = new SceneEntityAgent(kvp.Value); agent.ScenarioId = kvp.Value.ID; kvp.Value.agent = agent; SceneMan.AddSceneObj(agent); } }
public void TryGenObject() { if (PeGameMgr.IsMulti) { } else { RandomItemMgr.Instance.AddItemToManager(this); SceneMan.AddSceneObj(this); } }
public void TryGenFeces() { //if (PeGameMgr.IsMulti) //{ //} //else //{ RandomItemMgr.Instance.AddFeces(this); SceneMan.AddSceneObj(this); //} }
//multi processing result public RandomItemObj(Vector3 pos, int[] itemIdNum, Quaternion rot, string path = "Prefab/RandomItems/random_box01", int id = 0) { genPos = pos; position = pos; rotation = rot; this.id = id; items = itemIdNum; this.path = path; isNew = true; SceneMan.AddSceneObj(this); }
SceneEntityAgent _createMstAgent(MonsterSpawnPoint _point, bool is_saved, MonsterSpawnArea _area = null, MonsterSpawnPoint[] _groupPoints = null, bool save_to_scene = true) { SceneEntityAgent agent = new SceneEntityAgent(_point, is_saved, _area, _groupPoints); if (save_to_scene) { SceneMan.AddSceneObj(agent); } return(agent); }
public new void TryGenObject() { // if (PeGameMgr.IsMulti) // { // } // else // { RandomItemMgr.Instance.AddItemToManager(this); SceneMan.AddSceneObj(this); // } }
public void Respawn() { if (!mIsProcessing) { if (entity == null || (entity.GetCmpt <SkAliveEntity>() != null && entity.GetCmpt <SkAliveEntity>().isDead)) { entity = null; SceneMan.RemoveSceneObj(this); SceneMan.AddSceneObj(this); } } }
IEnumerator AddMemberAgents() { yield return(new WaitForSeconds(0.1f)); int n = _lstAgents.Count; for (int i = 0; i < n; i++) { SceneMan.AddSceneObj(_lstAgents[i]); yield return(new WaitForSeconds(0.1f)); } }
public RandomItemObj(int boxId, Vector3 pos, Quaternion rot, int[] itemIdNum, string path, int id = 0) { genPos = pos; this.boxId = boxId; position = pos; rotation = Quaternion.Euler(0, (new System.Random()).Next(360), 0); this.id = id; items = itemIdNum; this.path = path; isNew = true; SceneMan.AddSceneObj(this); }
public void GenEnemyNpc(List <BuildingNpc> bNpcs, int townId, int allyId) { foreach (BuildingNpc bnpc in bNpcs) { int enemyNpcId = GetEnemyNpcId(bnpc.templateId); int allyColor = VATownGenerator.Instance.GetAllyColor(allyId); int playerId = VATownGenerator.Instance.GetPlayerId(allyId); SceneEntityPosAgent agent = MonsterEntityCreator.CreateAdAgent(bnpc.pos, enemyNpcId, allyColor, playerId); SceneMan.AddSceneObj(agent); VArtifactTownManager.Instance.AddMonsterPointAgent(townId, agent); } }
public static void AddProcedualBossSpawnPointToScene(IntVector2 idxPosRect) { #if false // (256*2)*(256*2) one int idxX = idxPosRect.x >> 1; int idxY = idxPosRect.y >> 1; int idx = ((idxPosRect.y - (idxY << 1)) << 1) + (idxPosRect.y - (idxY << 1)); int idxMax = 4; int seed = RandomMapConfig.RandSeed + idxX * 722 + idxY; // Magic code System.Random rnd4BossGen = new System.Random(seed); int idx0 = rnd4BossGen.Next(idxMax); if (idx != idx0) { return; } #else // (256*4)*(256*4) one int idxX = idxPosRect.x >> 2; int idxY = idxPosRect.y >> 2; int idx = ((idxPosRect.y - (idxY << 2)) << 2) + (idxPosRect.x - (idxX << 2)); int idxMax = 16; int seed = RandomMapConfig.RandSeed + idxY * 722 + idxX; // Magic code System.Random rnd4BossGen = new System.Random(seed); int idx0 = rnd4BossGen.Next(idxMax); int idx1 = rnd4BossGen.Next(idxMax); while (idx1 == idx0) { idx1 = rnd4BossGen.Next(idxMax); } if (idx != idx0 && idx != idx1) { return; } #endif rnd4BossGen = new System.Random(seed + idx); float dx = (float)rnd4BossGen.NextDouble(); float dy = (float)rnd4BossGen.NextDouble(); Vector3 pos = new Vector3((dx + idxPosRect.x) * 2 * SceneEntityPosRect.EntityCreationRadius, SceneEntityPosAgent.PosYTBD, (dy + idxPosRect.y) * 2 * SceneEntityPosRect.EntityCreationRadius); if (null == AIErodeMap.IsInScaledErodeArea2D(pos, 1.2f)) { SceneEntityPosAgent agent = MonsterEntityCreator.CreateAgent(pos); agent.spInfo = new MonsterEntityCreator.AgentInfo((float)rnd4BossGen.NextDouble()); SceneMan.AddSceneObj(agent); Debug.Log("<color=red>Boss Spawn Point</color>" + pos); } }
public static DragArticleAgent Create(ItemAsset.Drag drag, Vector3 pos, Vector3 scl, Quaternion rot, int id = SceneMan.InvalidID, NetworkInterface net = null, bool isCreation = false) { DragArticleAgent agent; if (isCreation) { agent = new DragCreationAgent(drag, pos, scl, rot, id, net); } else { agent = new DragArticleAgent(drag, pos, scl, rot, id, net); } agent.Create(); SceneMan.AddSceneObj(agent); return(agent); }
public RandomItemObj(int boxId, Vector3 pos, Dictionary <int, int> itemIdNum, string path = "Prefab/Item/Scene/randomitem_test", int id = 0) { genPos = pos; this.boxId = boxId; position = pos; this.id = id; items = new int[itemIdNum.Keys.Count * 2]; int index = 0; foreach (KeyValuePair <int, int> item in itemIdNum) { items[index++] = item.Key; items[index++] = item.Value; } this.path = path; SceneMan.AddSceneObj(this); }
void RPC_Tower_InitData(uLink.BitStream stream, uLink.NetworkMessageInfo info) { _pos = transform.position = stream.Read <Vector3>(); rot = transform.rotation = stream.Read <Quaternion>(); ItemObject itemObj = stream.Read <ItemObject>(); if (null == itemObj) { LogManager.Error("Invalid tower item"); return; } //[zhujiangbo] // int itemProtoId = itemObj.protoId; ItemAsset.Drag drag = itemObj.GetCmpt <ItemAsset.Drag>(); if (null == drag) { return; } DragTowerAgent item = new DragTowerAgent(drag, transform.position, Vector3.one, transform.rotation, Id, this); item.Create(); SceneMan.AddSceneObj(item); _entity = EntityMgr.Instance.Get(Id); if (null == _entity) { return; } Pathea.TowerProtoDb.Item tower = Pathea.TowerProtoDb.Get(itemObj.protoData.towerEntityId); if (null != tower) { gameObject.name = tower.name + "_" + Id; } OnSpawned(_entity.GetGameObject()); //OnSkAttrInitEvent += InitForceData; InitMapInfo(); }
EntityGrp CreateMonsterGroup(SpawnPoint grp_sp, MonsterSpawnPoint[] points, MonsterSpawnArea area) { int noid = Pathea.WorldInfoMgr.Instance.FetchNonRecordAutoId(); EntityGrp grp = EntityMgr.Instance.Create(noid, sMonsterGroupPath, Vector3.zero, Quaternion.identity, Vector3.one) as EntityGrp; if (grp == null) { Debug.LogError("Load Prefab Error"); return(null); } grp._protoId = grp_sp.Prototype; grp._cntMin = area.AmountPerSocial; grp._cntMax = area.AmountPerSocial; for (int i = 0; i < points.Length; i++) { MonsterSpawnPoint sp = points[i]; Pathea.WorldInfoMgr.Instance.FetchNonRecordAutoId(); SceneEntityAgent agent = new SceneEntityAgent(sp, false, area, null); agent.ScenarioId = area.ID; grp.scenarioId = area.ID; agent.entityGp = grp; sp.agent = agent; AddMstDeadAgent(agent); if (!sp.isDead) { SceneMan.AddSceneObj(agent); } } return(grp); }
public void SetFixedSpawnPointActive(int pointID, bool active) { FixedSpawnPointInfo info = null; if (_fixedSpawnPointInfos.TryGetValue(pointID, out info)) { if (PeGameMgr.IsMultiStory) { if (PlayerNetwork.mainPlayer != null) { PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_AI_SetFixActive, pointID, active); } } else { info._bActive = active; if (null != SceneEntityCreatorArchiver.Instance.GetEntityByFixedSpId(pointID)) { if (!active) { SceneMan.RemoveSceneObj(info._agent); } else { ReqReborn(info._agent); } } else { if (active) { info._agent.canRide = false; SceneMan.AddSceneObj(info._agent); } } } } }
public void GenDunEntrance(Vector3 genPos, DungeonBaseData basedata) { if (!allEntrance.ContainsKey(genPos)) { UnityEngine.Object entranceObj = GetEntrancePrefabPath(basedata.Type); DunEntranceObj entrance = new DunEntranceObj(entranceObj, genPos); entrance.Level = basedata.level; entrance.DungeonId = basedata.id; allEntrance[genPos] = entrance; if (basedata.level >= 100) { } else { IntVector2 indexArea = new IntVector2(Mathf.RoundToInt(genPos.x) >> AREA_RADIUS, Mathf.RoundToInt(genPos.z) >> AREA_RADIUS); entranceArea[indexArea] = entrance; } SceneMan.AddSceneObj(entrance); return; } }
public void RenderNative(NativePointInfo nativePointInfo) { int id = nativePointInfo.ID; Vector3 pos = nativePointInfo.position; // int townId = nativePointInfo.townId; //if (Pathea.PeGameMgr.IsSingleAdventure) //{ // Debug.Log("SPPoint.InstantiateSPPoint<SPPoint>: " + pos); // SPPoint point = SPPoint.InstantiateSPPoint<SPPoint>(pos, // Quaternion.identity, // IntVector4.Zero, // SPTerrainEvent.instance.transform, // 0, // id, // true, // true, // false, // false); // SPTerrainEvent.instance.RegisterSPPoint(point, true); //} //else if (GameConfig.IsMultiMode) //{ // SPTerrainEvent.instance.CreateMultiNativeStatic(pos, id, townId); //} // if(Pathea.PeGameMgr.IsSingleAdventure) // { int allyId = VArtifactTownManager.Instance.GetTownByID(nativePointInfo.townId).AllyId; int playerId = VATownGenerator.Instance.GetPlayerId(allyId); int allyColor = VATownGenerator.Instance.GetAllyColor(allyId); SceneEntityPosAgent agent = MonsterEntityCreator.CreateAdAgent(pos, id, allyColor, playerId); SceneMan.AddSceneObj(agent); VArtifactTownManager.Instance.AddMonsterPointAgent(nativePointInfo.townId, agent); // } }
//public void CreateNpcReady(IntVector4 nodePosLod) //{ // //return; // IntVector3 chunkCenter = new Vector3(nodePosLod.x, nodePosLod.y, nodePosLod.z); // //LogManager.Error("createNpcReady", chunkCenter); // for (int i = chunkCenter.x; i < chunkCenter.x + VoxelTerrainConstants._numVoxelsPerAxis; i++) // { // for (int j = chunkCenter.z; j < chunkCenter.z + VoxelTerrainConstants._numVoxelsPerAxis; j++) // { // IntVector2 posXZ = new IntVector2(i, j); // if (!npcInfoMap.ContainsKey(posXZ)) // { // continue; // } // VATownNpcInfo townNpcInfo = npcInfoMap[posXZ]; // if (!nodePosLod.ContainInTerrainNode(townNpcInfo.getPos())) // { // LogManager.Error("!nodePosLod.ContainInTerrainNode"); // continue; // } // if (townNpcInfo.PosY == -1) // { // continue; // } // int Id = townNpcInfo.getId(); // if (!NpcMissionDataRepository.m_AdRandMisNpcData.ContainsKey(Id)) // { // continue; // } // //LogManager.Error("TownNPC: ID="+townNpcInfo.getId()+" pos="+townNpcInfo.getPos()); // if (Pathea.PeGameMgr.IsSingleAdventure) // { // AdNpcData adNpcData = NpcMissionDataRepository.m_AdRandMisNpcData[Id]; // int RNpcId = adNpcData.mRnpc_ID; // int Qid = adNpcData.mQC_ID; // //int npcid = NpcManager.Instance.RequestRandomNpc(RNpcId, townNpcInfo.getPos(), StroyManager.Instance.OnRandomNpcCreated1, adNpcData); // //createdNpcIdList.Add(npcid); // //NpcRandom nr = NpcManager.Instance.CreateRandomNpc(RNpcId, townNpcInfo.getPos()); // //StroyManager.Instance.NpcTakeMission(RNpcId, Qid, townNpcInfo.getPos(), nr, adNpcData.m_CSRecruitMissionList); // //LogManager.Error("npc Created!Pos: " + townNpcInfo.getPos() + " id: " + RNpcId); // //createdNpcIdList.Add(nr.mNpcId); // createdPosList.Add(posXZ); // npcInfoMap.Remove(posXZ); // } // else if (GameConfig.IsMultiMode) // { // SPTerrainEvent.instance.CreateAdNpcByIndex(townNpcInfo.getPos(), Id); // npcInfoMap.Remove(posXZ); // } // } // } //} //public void RenderTownNPC(IntVector2 posXZ) //{ // if (!npcInfoMap.ContainsKey(posXZ)) // { // return; // } // VATownNpcInfo townNpcInfo = npcInfoMap[posXZ]; // if (townNpcInfo.PosY == -1) // { // return; // } // RenderTownNPC(townNpcInfo); //} public void RenderTownNPC(VATownNpcInfo townNpcInfo) { IntVector2 posXZ = townNpcInfo.Index; if (!npcInfoMap.ContainsKey(posXZ)) { return; } int Id = townNpcInfo.getId(); //if (!NpcMissionDataRepository.m_AdRandMisNpcData.ContainsKey(Id)) //{ // return; //} if (Pathea.PeGameMgr.IsSingleAdventure) { //AdNpcData adNpcData = NpcMissionDataRepository.m_AdRandMisNpcData[Id]; //int RNpcId = adNpcData.mRnpc_ID; //int Qid = adNpcData.mQC_ID; int enemyNpcId = GetEnemyNpcId(Id); int allyId = VArtifactTownManager.Instance.GetTownByID(townNpcInfo.townId).AllyId; int allyColor = VATownGenerator.Instance.GetAllyColor(allyId); int playerId = VATownGenerator.Instance.GetPlayerId(allyId); if (allyId != TownGenData.PlayerAlly) { SceneEntityPosAgent agent = MonsterEntityCreator.CreateAdAgent(townNpcInfo.getPos(), enemyNpcId, allyColor, playerId); SceneMan.AddSceneObj(agent); VArtifactTownManager.Instance.AddMonsterPointAgent(townNpcInfo.townId, agent); } else { PeEntity npc = NpcEntityCreator.CreateNpc(Id, townNpcInfo.getPos(), Vector3.one, Quaternion.Euler(0, 180, 0)); if (npc == null) { Debug.LogError("npc id error: templateId = " + Id); return; } //Debug.Log("created town npc:"+ npc.name+"_"+npc.position); VArtifactUtil.SetNpcStandRot(npc, 180, false); //test if (Id == VArtifactTownManager.Instance.missionStartNpcID) { VArtifactTownManager.Instance.missionStartNpcEntityId = npc.Id; } createdPosList.Add(posXZ); } //Debug.Log("Id: " + Id + " npcPos:" + townNpcInfo.getPos()); //int npcid = NpcManager.Instance.RequestRandomNpc(RNpcId, townNpcInfo.getPos(), StroyManager.Instance.OnRandomNpcCreated1, adNpcData); //createdNpcIdList.Add(Id); //NpcRandom nr = NpcManager.Instance.CreateRandomNpc(RNpcId, townNpcInfo.getPos()); //StroyManager.Instance.NpcTakeMission(RNpcId, Qid, townNpcInfo.getPos(), nr, adNpcData.m_CSRecruitMissionList); //LogManager.Error("npc Created!Pos: " + townNpcInfo.getPos() + " id: " + RNpcId); //createdNpcIdList.Add(nr.mNpcId); npcInfoMap.Remove(posXZ); } else if (GameConfig.IsMultiMode) { int enemyNpcId = GetEnemyNpcId(Id); int allyId = VArtifactTownManager.Instance.GetTownByID(townNpcInfo.townId).AllyId; int allyColor = VATownGenerator.Instance.GetAllyColor(allyId); int playerId = VATownGenerator.Instance.GetPlayerId(allyId); if (allyId != TownGenData.PlayerAlly) { SceneEntityPosAgent agent = MonsterEntityCreator.CreateAdAgent(townNpcInfo.getPos(), enemyNpcId, allyColor, playerId); SceneMan.AddSceneObj(agent); VArtifactTownManager.Instance.AddMonsterPointAgent(townNpcInfo.townId, agent); } else { StartCoroutine(RenderOneNpc(townNpcInfo.getPos(), Id)); } npcInfoMap.Remove(posXZ); } }
IEnumerator RefreshTowerMission() { _idxWave = 0; _uiData.CurWavesRemaining = _spData._waveDatas.Count; _uiData.TotalWaves = _spData._waveDatas.Count; while (_idxWave < _spData._waveDatas.Count) { while (PreTime > 0) { yield return(new WaitForSeconds(TimeStep)); PreTime -= TimeStep; } PreTime = 0; Vector3 dir = _forward; Vector3 center = _position; int m = _idxWave; AISpawnTDWavesData.TDWaveData wd = _spData._waveDatas[m]; if (Pathea.PeGameMgr.IsStory) { StroyManager.Instance.PushStoryList(wd._plotID); } int nMonsterTypes = wd._monsterTypes.Count; for (int n = 0; n < nMonsterTypes; n++) { int spType = wd._monsterTypes[n]; int minAngle = wd._minDegs[n]; int maxAngle = wd._maxDegs[n]; int spCount = UnityEngine.Random.Range(wd._minNums[n], wd._maxNums[n]); for (int i = 0; i < spCount; i++) { Vector3 pos; if (spType == 520 || spType == 521) //Special code for airborne monsters { pos = center; } else { if (isSweep) { pos = AiUtil.GetRandomPosition(center, 80, 100, dir, minAngle, maxAngle); transform.position = center + ((center - pos) * 1000); } else { pos = AiUtil.GetRandomPosition(center, 20, 80, dir, minAngle, maxAngle); } pos.y = SceneEntityPosAgent.PosYTBD; // let posagent to set y } SceneEntityPosAgent agent = MonsterEntityCreator.CreateAgent(pos, EncodeBcnMonsterProtoId(spType, _spData._dif, _spData._spawnType)); agent.spInfo = new MonsterEntityCreator.AgentInfo(this); agent.canRide = false; if (handerNewEntity != null) { handerNewEntity(agent); } _agents.Add(agent); SceneMan.AddSceneObj(agent); } } if (handlerNewWave != null) { handlerNewWave(_spData, _idxWave); } _uiData.CurWavesRemaining--; _idxWave++; if (_idxWave < _spData._waveDatas.Count) { int cdTime = _spData._timeToCool; while (cdTime > 0) { yield return(new WaitForSeconds(1)); cdTime--; } PreTime = (float)_spData._waveDatas[_idxWave]._delayTime; } } ; }
/// <summary> /// Creates all the agents from data source /// </summary> void CreateAgents(SpawnDataSource ds) { foreach (KeyValuePair <int, MonsterSpawnPoint> kvp in ds.monsters) { SceneEntityAgent agent = _createMstAgent(kvp.Value, true, null, null, !kvp.Value.isDead); agent.ScenarioId = kvp.Value.ID; kvp.Value.agent = agent; AddMstDeadAgent(agent); } foreach (KeyValuePair <int, MonsterSpawnArea> kvp in ds.areas) { for (int i = 0; i < kvp.Value.Spawns.Count; i++) { MonsterSpawnArea.SocialSpawns mss = kvp.Value.Spawns[i]; if (!mss.isSocial) { for (int j = 0; j < mss.spawnPoints.Count; j++) { MonsterSpawnPoint sp = mss.spawnPoints[j]; SceneEntityAgent agent = _createMstAgent(sp, true, kvp.Value, null, !sp.isDead); agent.ScenarioId = kvp.Value.ID; sp.agent = agent; AddMstDeadAgent(agent); } } else { _createMstAgent(mss.centerSP, false, kvp.Value, mss.spawnPoints.ToArray()); } } } CreateNpcAgents(ds.npcs); CreateDoodadAgents(ds.doodads); foreach (KeyValuePair <int, EffectSpwanPoint> kvp in ds.effects) { SceneStaticEffectAgent agent = SceneStaticEffectAgent.Create(kvp.Value.Prototype, kvp.Value.spawnPos, kvp.Value.Rotation, kvp.Value.Scale); agent.ScenarioId = kvp.Value.ID; SceneMan.AddSceneObj(agent); } foreach (KeyValuePair <int, ItemSpwanPoint> kvp in ds.items) { if (kvp.Value.isNew) { DragArticleAgent agent = DragArticleAgent.PutItemByProroId(kvp.Value.Prototype , kvp.Value.spawnPos , kvp.Value.Scale , kvp.Value.Rotation , kvp.Value.CanPickup , kvp.Value.IsTarget); if (agent != null) { agent.ScenarioId = kvp.Value.ID; kvp.Value.isNew = false; kvp.Value.ItemObjId = agent.itemDrag.itemObj.instanceId; } } } }
/// <summary> /// Create a agent for a spawn point and add sp to the spawn data source /// </summary> void CreateAgent(SpawnDataSource ds, SpawnPoint sp) { // Create Monster Agent if (sp as MonsterSpawnPoint != null) { MonsterSpawnPoint msp = sp as MonsterSpawnPoint; if (ds.AddMonster(msp)) { SceneEntityAgent agent = _createMstAgent(msp, true, null, null, !msp.isDead); msp.agent = agent; agent.ScenarioId = sp.ID; AddMstDeadAgent(agent); } else { Debug.LogError("Add Monster spawn point error"); } } // Create Npc Agent else if (sp as NPCSpawnPoint != null) { NPCSpawnPoint nsp = sp as NPCSpawnPoint; if (ds.AddNpc(nsp)) { SceneEntityAgent agent = new SceneEntityAgent(nsp); nsp.agent = agent; agent.ScenarioId = sp.ID; SceneMan.AddSceneObj(agent); } else { Debug.LogError("Add npc spawn point error"); } } // Create Doodad Agent else if (sp as DoodadSpawnPoint != null) { DoodadSpawnPoint dsp = sp as DoodadSpawnPoint; if (ds.AddDoodad(dsp)) { SceneStaticAgent agent = new SceneStaticAgent(dsp, true); dsp.agent = agent; agent.ScenarioId = sp.ID; SceneMan.AddSceneObj(agent); } else { Debug.LogError("Add doodad spawn point error"); } } // Create Item else if (sp as ItemSpwanPoint != null) { ItemSpwanPoint isp = sp as ItemSpwanPoint; if (ds.AddItem(isp)) { DragArticleAgent agent = DragArticleAgent.PutItemByProroId(isp.Prototype , isp.spawnPos , isp.Scale , isp.Rotation , isp.CanPickup , isp.IsTarget); if (agent != null) { isp.isNew = false; isp.ItemObjId = agent.itemDrag.itemObj.instanceId; agent.ScenarioId = sp.ID; } } else { Debug.LogError("Add item spawn point error"); } } // Create Effect else if (sp as EffectSpwanPoint != null) { } }
public override void Start() { base.Start(); SceneMan.AddSceneObj(this); }
public bool Start() { MissionCommonData data = MissionManager.GetMissionCommonData(MissionId); for (int i = 0; i < data.m_TargetIDList.Count; i++) { if (data.m_TargetIDList[i] == TargetId) { _idxTarId = i; break; } } if (_idxTarId == -1) { return(false); } _data = MissionManager.GetTypeMonsterData(TargetId); if (_data == null) { return(false); } Vector3 referToPos; switch (_data.m_mr.refertoType) { case ReferToType.None: referToPos = PeCreature.Instance.mainPlayer.position; break; case ReferToType.Player: referToPos = PeCreature.Instance.mainPlayer.position; break; case ReferToType.Town: VArtifactUtil.GetTownPos(_data.m_mr.referToID, out referToPos); break; case ReferToType.Npc: referToPos = EntityMgr.Instance.Get(MissionManager.Instance.m_PlayerMission.adId_entityId[_data.m_mr.referToID]).position; break; default: referToPos = PeCreature.Instance.mainPlayer.position; break; } if (referToPos == Vector3.zero) { return(false); } if (PeGameMgr.IsSingle || PeGameMgr.IsTutorial) { if (_data.type == 2) { DoodadEntityCreator.commonDeathEvent += OnMonsterDeath; } else { MonsterEntityCreator.commonDeathEvent += OnMonsterDeath; } } GenMonsterInMission = !PeGameMgr.IsStory; if (GenMonsterInMission) { #if DbgNearGen Vector2 v2 = Vector2.zero; #else Vector2 v2 = UnityEngine.Random.insideUnitCircle.normalized * _data.m_mr.radius1; #endif Vector3 center = referToPos + new Vector3(v2.x, 0.0f, v2.y); //for (int i = 0; i < _data.m_MonsterList.Count; i++) { // int num = _data.m_MonsterList[i].type; // int protoId = _data.m_MonsterList[i].npcs[UnityEngine.Random.Range(0, _data.m_MonsterList[i].npcs.Count)]; // for (int j = 0; j < num; j++) { // Vector3 pos = AiUtil.GetRandomPosition (center, 0, _data.m_mr.radius2); // pos.y = SceneEntityPosAgent.PosYTBD; // let posagent to set y // SceneEntityPosAgent agent = MonsterEntityCreator.CreateAgent(pos, protoId); // agent.spInfo = new MonsterEntityCreator.AgentInfo(EntityMonsterBeacon.GetSpBeacon4MonsterKillTask()); // _agents.Add (agent); // SceneMan.AddSceneObj (agent); // } //} for (int i = 0; i < _data.m_CreMonList.Count; i++) { for (int j = 0; j < _data.m_CreMonList[i].monNum; j++) { Vector3 pos = AiUtil.GetRandomPosition(center, 0, _data.m_mr.radius2); pos.y = SceneEntityPosAgent.PosYTBD; // let posagent to set y int protoId = _data.m_CreMonList[i].monID; if (_data.m_CreMonList[i].type == 1) { protoId |= EntityProto.IdGrpMask; } SceneEntityPosAgent agent = MonsterEntityCreator.CreateAgent(pos, protoId); agent.spInfo = new MonsterEntityCreator.AgentInfo(EntityMonsterBeacon.GetSpBeacon4MonsterKillTask()); agent.canRide = false; _agents.Add(agent); SceneMan.AddSceneObj(agent); } } } return(true); }