예제 #1
0
    void SetupAudioController(IntVector4 node)
    {
        Vector3 position = node.ToVector3();

        position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w),
                                0.0f,
                                Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w));

        int        height = VoxelTerrainConstants._numVoxelsPerAxis << node.w;
        RaycastHit hitInfo;

        if (Physics.Raycast(position + Vector3.up * height, Vector3.down, out hitInfo, height, GameConfig.GroundLayer))
        {
            float waterHeight;
            if (PETools.PEUtil.GetWaterSurfaceHeight(hitInfo.point, out waterHeight))
            {
                position = hitInfo.point + Vector3.up * Random.Range(0.0f, waterHeight - hitInfo.point.y);
            }
            else
            {
                position = hitInfo.point + Vector3.up * Random.Range(0.5f, 5.0f);
            }

            int             sid    = AISpawnDataStory.GetEnvMusicID(GetMapID(position));
            Transform       parent = mAudioPoint != null ? mAudioPoint.transform : null;
            AudioController ctrl   = AudioManager.instance.Create(position, sid, parent, false, false);
            envSounds.Add(ctrl);
        }
    }
예제 #2
0
    public void OnDataLoaded(byte[] data, bool bFromPool = false)
    {
        SetDataVT(data, bFromPool);
        BuildStep = BuildStep_FinDataLoading;
        AddToBuildList();

        if (GameConfig.IsMultiMode && SigOfType == VFVoxelTerrain.self.ChunkSig)
        {
            ChunkManager.Instance.AddCacheReq(_chunkPosLod.ToVector3());
        }
    }
예제 #3
0
    public static SPTerrainRect InstantiateSPTerrainRect(IntVector4 pos, int minCount, int maxCount, Transform parent, SimplexNoise noise)
    {
        GameObject obj = new GameObject(pos.x + " , " + pos.z);

        obj.transform.parent   = parent;
        obj.transform.position = pos.ToVector3();

        SPTerrainRect rect = obj.AddComponent <SPTerrainRect>();

        rect.Init(pos, minCount, maxCount, noise);

        return(rect);
    }
예제 #4
0
    void LoadDynamicPoints(IntVector4 node, int min, int max)
    {
        int count = Random.Range(min, max);

        for (int i = 0; i < count; i++)
        {
            Vector3 position = node.ToVector3();
            position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w),
                                    0.0f,
                                    Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w));

            Quaternion rot   = Quaternion.Euler(0.0f, Random.Range(0, 360), 0.0f);
            SPPoint    point = SPPoint.InstantiateSPPoint <SPPoint>(position, rot, nextIndex, transform);
            point.name = "Dynamic : " + point.name;
            RegisterSPPoint(point);
        }
    }
예제 #5
0
    public void MakeCube()
    {
        Vector3 cubePos;
        int     size      = ScaledSize;
        int     centerOfs = size >> 1;

        cubePos    = _pos.ToVector3();
        cubePos.x += centerOfs;
        cubePos.y += centerOfs;
        cubePos.z += centerOfs;

        if (cubeGO == null)
        {
        }
        //cubeGO = GameObject.Instantiate(Block45Man.self.VizCube, cubePos, Quaternion.identity) as GameObject;

        cubeGO.transform.localScale = new Vector3(size, size, size);
    }
예제 #6
0
    void SetupEffect(IntVector4 node)
    {
        Vector3 position = node.ToVector3();

        position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w),
                                0.0f,
                                Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w));

        int height = VoxelTerrainConstants._numVoxelsPerAxis << node.w;

        RaycastHit hitInfo;

        if (Physics.Raycast(position + Vector3.up * height, Vector3.down, out hitInfo, height, GameConfig.GroundLayer))
        {
            float waterHeight;
            int   type1 = -1;
            int   type2 = -1;
            if (PETools.PEUtil.GetWaterSurfaceHeight(hitInfo.point, out waterHeight))
            {
                if (Random.value < 0.3f)
                {
                    type1    = 0;
                    position = new Vector3(hitInfo.point.x, waterHeight, hitInfo.point.z);
                }
                else
                {
                    type1    = 1;
                    position = hitInfo.point + Vector3.up * Random.Range(0.0f, waterHeight - hitInfo.point.y);
                }
            }
            else
            {
                type1    = 2;
                position = hitInfo.point + Vector3.up * Random.Range(0.5f, 5.0f);
            }

            type2 = CalculateType(position);

            int       effectID = AISpawnDataStory.GetEnvEffectID(GetMapID(position), type1, type2);
            Transform parent   = mEffectPoint != null ? mEffectPoint.transform : null;
            EffectBuilder.EffectRequest req = EffectBuilder.Instance.Register(effectID, null, position, Quaternion.identity, parent);
            req.SpawnEvent += OnEffectSpawned;
        }
    }
예제 #7
0
    void LoadUpperAirPoints(IntVector4 node, int min, int max)
    {
        GameObject carrier = null;// PlayerFactory.mMainPlayer.Carrier;

        if (carrier == null)
        {
            return;
        }

        HelicopterController hel = carrier.GetComponent <HelicopterController>();

        if (hel == null)
        {
            return;
        }

        /*
         * VCPVtolCockpitFunc vtol = hel.m_Cockpit as VCPVtolCockpitFunc;
         * if (vtol == null)
         * return;
         *
         * if (vtol.FlyingHeight < 50.0f)
         * return;
         * */

        //if (Random.value > AiManager.Manager.upperPoint)
        //    return;

        Vector3 position = node.ToVector3();

        position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w),
                                0.0f,
                                Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w));

        Quaternion rot   = Quaternion.Euler(0.0f, Random.Range(0, 360), 0.0f);
        SPPoint    point = SPPoint.InstantiateSPPoint <SPPoint>(position, rot, nextIndex, transform, 0, 63);

        point.name = "Upper Air : " + point.name;
        RegisterSPPoint(point);
    }
예제 #8
0
 // Utils
 public bool IsPosVisible(IntVector4 pos)
 {
     return(_viewBoundsLod[pos.w].Contains(pos.ToVector3()));
 }
예제 #9
0
    void OnTerrainMeshCreated(IntVector4 node)
    {
        if (node.w == 0)
        {
            IntVector2 mark = AiUtil.ConvertToIntVector2FormLodLevel(node, VoxelTerrainMaxLod);
            if (pointTable.ContainsKey(mark))
            {
                SPTerrainRect tRect = pointTable[mark];
                if (tRect != null)
                {
                    List <SPPoint> points = tRect.points;
                    points = points.FindAll(ret => Match(ret, node.x, node.z));

                    foreach (SPPoint point in points)
                    {
                        point.AttachEvent(node);
                        //point.position = new Vector3(point.position.x, node.y, point.position.z);
                    }
                }
            }

            RegisterMeshNode(node);

            LODOctreeMan.self.AttachNodeEvents(null, null, null, null, OnTerrainColliderCreated, node.ToVector3(), 0);
        }
    }
예제 #10
0
    void OnTerrainColliderDestroy(IntVector4 node)
    {
        if (mNodes.Contains(node))
        {
            LODOctreeMan.self.DetachNodeEvents(null, null, null, OnTerrainColliderDestroy, OnTerrainColliderCreated, node.ToVector3(), 0);

            mNodes.Remove(node);
        }
    }
예제 #11
0
 public void AttachEvent(IntVector4 node)
 {
     if (!mNodes.Contains(node))
     {
         mNodes.Add(node);
         LODOctreeMan.self.AttachNodeEvents(null, null, null, OnTerrainColliderDestroy, OnTerrainColliderCreated, node.ToVector3(), 0);
     }
 }