Beispiel #1
0
    void LoadStaticSpawnPoints()
    {
        if (Application.loadedLevelName.Equals(GameConfig.MainSceneName))
        {
            GameObject obj = new GameObject("StaticPoints");
            obj.transform.parent = transform;

            foreach (KeyValuePair <int, AISpawnPoint> pair in AISpawnPoint.s_spawnPointData)
            {
                AISpawnPoint point = pair.Value;
                point.spPoint = SPPoint.InstantiateSPPoint <SPPoint>(point.Position,
                                                                     Quaternion.Euler(point.euler),
                                                                     IntVector4.Zero,
                                                                     obj.transform,
                                                                     0,
                                                                     point.resId,
                                                                     point.isActive,
                                                                     false,
                                                                     false,
                                                                     false,
                                                                     false,
                                                                     null,
                                                                     point.OnSpawned);

                point.spPoint.name = ("Static id = " + point.id + " , " + "path id = " + point.resId + " : ") + point.spPoint.name;
            }
        }
    }
    protected override SPPoint Spawn(AISpawnData spData)
    {
        base.Spawn(spData);

        Vector3    pos;
        Quaternion rot;

        if (GetPositionAndRotation(out pos, out rot, spData.minAngle, spData.maxAngle))
        {
            //if (!GameConfig.IsMultiMode)
            {
                SPPointMovable movable = SPPoint.InstantiateSPPoint <SPPointMovable>(pos,
                                                                                     rot,
                                                                                     IntVector4.Zero,
                                                                                     pointParent,
                                                                                     spData.isPath ? 0 : spData.spID,
                                                                                     spData.isPath ? spData.spID : 0,
                                                                                     true,
                                                                                     true,
                                                                                     false,
                                                                                     false,
                                                                                     true,
                                                                                     null,
                                                                                     OnSpawned,
                                                                                     this) as SPPointMovable;

                movable.target = transform;
                return(movable);
            }
        }

        return(null);
    }
Beispiel #3
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);
        }
    }
Beispiel #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);
        }
    }
Beispiel #5
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);
    }
    protected override SPPoint Spawn(AISpawnData spData)
    {
        base.Spawn(spData);

        Vector3    pos;
        Quaternion rot;
        Vector3    target;

        if (GetPositionAndRotation(spData, out pos, out rot, out target))
        {
            SPPointSimulate simulate = SPPoint.InstantiateSPPoint <SPPointSimulate>(pos,
                                                                                    rot,
                                                                                    IntVector4.Zero,
                                                                                    pointParent,
                                                                                    spData.isPath ? 0 : spData.spID,
                                                                                    spData.isPath ? spData.spID : 0,
                                                                                    true,
                                                                                    true,
                                                                                    false,
                                                                                    false,
                                                                                    true,
                                                                                    null,
                                                                                    OnSpawned,
                                                                                    this) as SPPointSimulate;

            simulate.SetData(damage, minInterval, maxInterval, damageRadius);
            simulate.targetPos = target;

            if (!simulates.Contains(simulate))
            {
                simulates.Add(simulate);
            }

            return(simulate);
        }

        return(null);
    }
Beispiel #7
0
    void LoadNoisePoints(IntVector4 node, int minCount, int maxCount)
    {
        int nx = node.x >> VoxelTerrainConstants._shift >> node.w;
        int nz = node.z >> VoxelTerrainConstants._shift >> node.w;

        float noise       = (float)mNoise.Noise(nx, nz, nx + nz);
        int   randomCount = Mathf.FloorToInt((maxCount - minCount) * noise);
        int   count       = Mathf.Clamp(minCount + randomCount, minCount, maxCount);
        int   length      = VoxelTerrainConstants._numVoxelsPerAxis << node.w;

        for (int i = 0; i < count; i++)
        {
            float ox = (float)mNoise.Noise(nx, (nx + nz) * i) * 0.5f + 0.5f;
            float oz = (float)mNoise.Noise(nz, (nx - nz) * i) * 0.5f + 0.5f;

            Vector3    pos   = new Vector3(node.x + ox * length, node.y, node.z + oz * length);
            Quaternion rot   = Quaternion.Euler(0.0f, UnityEngine.Random.Range(0, 360), 0.0f);
            SPPoint    point = SPPoint.InstantiateSPPoint <SPPoint>(pos, rot, nextIndex, transform, 0, 0, true, true, false, true, true, mNoise);
            point.name = "Noise : " + point.name;
            RegisterSPPoint(point);

            //Debug.LogError("Noise normal ai point : " + pos);
        }
    }