//public bool AddNpc(IntVector2 posXZ, int id) //{ // if (npcInfoMap.ContainsKey(posXZ)) // { // return false; // } // VATownNpcInfo townNpcInfo = new VATownNpcInfo(posXZ, id); // npcInfoMap.Add(posXZ, townNpcInfo); // return true; //} public bool AddNpc(VATownNpcInfo npcInfo) { IntVector2 posXZ = new IntVector2(Mathf.RoundToInt(npcInfo.getPos().x), Mathf.RoundToInt(npcInfo.getPos().z)); if (npcInfoMap.ContainsKey(posXZ)) { return(false); } npcInfoMap.Add(posXZ, npcInfo); return(true); }
//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); } }