Ejemplo n.º 1
0
    bool RevisePosition()
    {
        if (!mRevisePosition)
        {
            return(true);
        }

        Vector3 position = transform.position;

        RaycastHit hitInfo;

        if (AiUtil.CheckPositionOnGround(position,
                                         out hitInfo,
                                         256.0f,
                                         256.0f,
                                         AiUtil.groundedLayer))
        {
            transform.position = hitInfo.point;
            if (!mErode || AIErodeMap.IsInErodeArea(transform.position) == null)
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 2
0
    void LoadNoiseBossPoints(IntVector4 node)
    {
        int nx = node.x >> VoxelTerrainConstants._shift >> node.w;
        int nz = node.z >> VoxelTerrainConstants._shift >> node.w;

        float value = (float)mNoise.Noise(nx, nz);

        if (value < -0.5f)
        {
            int length = VoxelTerrainConstants._numVoxelsPerAxis << node.w;

            float ox = (float)mNoise.Noise(nx, nz, nx + nz) * 0.5f + 0.5f;
            float oz = (float)mNoise.Noise(nz, nx, nx - nz) * 0.5f + 0.5f;

            Vector3 pos = new Vector3(node.x + ox * length, node.y, node.z + oz * length);

            if (AIErodeMap.IsInErodeArea(pos) == null)
            {
                Quaternion rot   = Quaternion.Euler(0.0f, Random.Range(0, 360), 0.0f);
                SPPoint    point = SPPoint.InstantiateSPPoint <SPPointBoss>(pos, rot, nextIndex, transform, 0, 0, true, true, true, true, true, mNoise);
                point.name = "Noise boss : " + point.name;
                RegisterSPPoint(point);
            }

            //Debug.LogError("Noise boss ai point : " + pos);
        }
    }
Ejemplo n.º 3
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);
        }
    }
Ejemplo n.º 4
0
            void PeLauncher.ILaunchable.Launch()
            {
                AIErodeMap.ResetErodeData();
                PeGameSummary.Mgr.Instance.Init();
                DigTerrainManager.ClearBlockInfo();

                //lz-2016.09.01 重置技能树可使用状态
                if (!Pathea.PeGameMgr.IsAdventure)
                {
                    RandomMapConfig.useSkillTree   = false;
                    RandomMapConfig.openAllScripts = false;
                }
            }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
    protected virtual bool RevisePosition(IntVector4 node)
    {
        if (!mRevisePosition)
        {
            return(true);
        }

        Vector3 position = new Vector3(transform.position.x, node.y, transform.position.z);

        RaycastHit hitInfo;

        if (AiUtil.CheckPositionOnGround(position, out hitInfo, 0.0f,
                                         VoxelTerrainConstants._numVoxelsPerAxis << node.w,
                                         AiUtil.groundedLayer))
        {
            transform.position = hitInfo.point;
            if (!mErode || AIErodeMap.IsInErodeArea(transform.position) == null)
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 8
0
 public void RefreshErodeMap()
 {
     AIErodeMap.UpdateErode(m_ErodeMapId, Position, Radius);
 }
Ejemplo n.º 9
0
 public void RemoveErodeMap()
 {
     AIErodeMap.RemoveErode(m_ErodeMapId);
 }
Ejemplo n.º 10
0
 // Ai Erode
 public void InitErodeMap(Vector3 pos, float radius)
 {
     m_ErodeMapId = AIErodeMap.AddErode(pos, radius);
 }