Exemplo n.º 1
0
    public void Fill(int cntNpc, int cntMonster)
    {
        Vector3             center     = RectIdxToCenterPos(_idx);
        bool                bAvailable = false;
        SceneEntityPosAgent agent;

        System.Random rand = new System.Random();
        for (int i = 0; i < cntNpc; i++)
        {
            Vector3 point = !PeGameMgr.randomMap ? GetEntityPoint(center, out bAvailable) : GetNpcPointInRndTer(center, out bAvailable);
            if (bAvailable)
            {
                if (VFDataRTGen.IsTownConnectionType(Mathf.RoundToInt(point.x), Mathf.RoundToInt(point.z)))
                {
                    agent        = NpcEntityCreator.CreateAgent(point);
                    agent.spInfo = _rndNpcAgentInfo;
                    _posRndNpcAgents.Add(agent);                        // npc entity would not be destroyed by scene
                }
                else
                {
                    if (rand.NextDouble() < 0.25)
                    {
                        agent        = NpcEntityCreator.CreateAgent(point);
                        agent.spInfo = _rndNpcAgentInfo;
                        _posRndNpcAgents.Add(agent);                            // npc entity would not be destroyed by scene
                    }
                }
            }
        }
        for (int i = 0; i < cntMonster; i++)
        {
            Vector3 point = GetEntityPoint(center, out bAvailable);
            if (bAvailable && null == AIErodeMap.IsInErodeArea2D(point))
            {
                _posRndMonsterAgents.Add(MonsterEntityCreator.CreateAgent(point));
            }
        }
        SceneMan.AddSceneObjs(_posRndNpcAgents);
        SceneMan.AddSceneObjs(_posRndMonsterAgents);

        if (PeGameMgr.IsStory)
        {
            _posFixedMonsterIds = AISpawnPoint.Find(center.x - EntityCreationRadius, center.z - EntityCreationRadius, center.x + EntityCreationRadius, center.z + EntityCreationRadius);
            if (_posFixedMonsterIds.Count > 0)
            {
                SceneEntityCreatorArchiver.Instance.AddFixedSpawnPointToScene(_posFixedMonsterIds);
            }
        }
        else if (PeGameMgr.IsSingleAdventure)
        {
            SceneEntityPosRect.AddProcedualBossSpawnPointToScene(_idx);
        }
    }
Exemplo n.º 2
0
 public bool IsTerrainAvailableForFeces(IntVector2 GenPos, out Vector3 pos)
 {
     pos = Vector3.zero;
     if (AIErodeMap.IsInErodeArea2D(new Vector3(GenPos.x, 0, GenPos.y)) != null)
     {
         return(false);
     }
     if (PeGameMgr.IsStory)
     {
         Vector3    checkPos = new Vector3(GenPos.x, s_maxHeight, GenPos.y);
         RaycastHit hit;
         if (Physics.Raycast(checkPos, Vector3.down, out hit, s_maxHeight, 1 << Pathea.Layer.VFVoxelTerrain))
         {
             pos = hit.point + new Vector3(0, 1, 0);
             if (!VFVoxelWater.self.IsInWater(pos))
             {
                 if (!mRandomItemsDic.ContainsKey(pos))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     else if (PeGameMgr.IsAdventure)
     {
         int height = VFDataRTGen.GetPosHeight(GenPos.x, GenPos.y, true);
         pos = new Vector3(GenPos.x, height, GenPos.y);
         bool inWater = VFDataRTGen.IsSea(height);
         if (!inWater)
         {
             RaycastHit hit;
             if (Physics.Raycast(pos + new Vector3(0, 2, 0), Vector3.down, out hit, a_maxHeight, 1 << Pathea.Layer.VFVoxelTerrain))
             {
                 pos = hit.point;
             }
             pos.y += 1;
             if (!mRandomItemsDic.ContainsKey(pos))
             {
                 return(true);
             }
         }
     }
     return(false);
 }