Example #1
0
    void RefreshProjection()
    {
        ParticleEmitter emitter = GetComponent <ParticleEmitter>();

        emitter.ClearParticles();

        CGalaxy galaxy = CGalaxy.instance;

        if (galaxy && samplesPerAxis > 0)
        {
            Vector3 centreSample = new Vector3((samplesPerAxis - 1) * 0.5f, (samplesPerAxis - 1) * 0.5f, (samplesPerAxis - 1) * 0.5f);

            for (int x = 0; x < samplesPerAxis; ++x)
            {
                for (int y = 0; y < samplesPerAxis; ++y)
                {
                    for (int z = 0; z < samplesPerAxis; ++z)
                    {
                        Vector3          unitPos     = new Vector3(x - centreSample.x, y - centreSample.y, z - centreSample.z) / (0.5f * samplesPerAxis); // -1 to +1 on each axis.
                        CGalaxy.SCellPos sampleCell  = galaxy.AbsolutePointToAbsoluteCell(unitPos * galaxy.galaxyRadius);
                        float            noiseScalar = galaxy.SampleNoise_FogDensity(sampleCell);

                        if (noiseScalar > 0.0f)
                        {
                            emitter.Emit(unitPos * radius, Vector3.zero, particleScale * (radius * 2) / samplesPerAxis, float.PositiveInfinity, new Color(0.5f, 0.5f, 0.75f, noiseScalar * Mathf.Clamp01(1.0f - unitPos.magnitude * unitPos.magnitude * unitPos.magnitude)));
                        }
                    }
                }
            }

            mUpToDate = true;
        }
    }
Example #2
0
    public static void Behaviour()
    {
        CGalaxy.SCellPos parentAbsoluteCell          = CGalaxy.instance.RelativePointToAbsoluteCell(CGameShips.GalaxyShip.transform.position);
        uint             uiTriesToPlaceRogueAsteroid = 5;
        bool             created;

        do
        {
            Vector3 asteroidPosition = (CGameShips.GalaxyShip.transform.position - CGalaxy.instance.RelativeCellToRelativePoint(parentAbsoluteCell - CGalaxy.instance.centreCell)) + Random.onUnitSphere * CGalaxy.instance.cellRadius /*Fog end*/;
            created = CGalaxy.instance.LoadGubbin(new CGalaxy.SGubbinMeta(
                                                      (CGameRegistrator.ENetworkPrefab)Random.Range((ushort)CGameRegistrator.ENetworkPrefab.Asteroid_FIRST, (ushort)CGameRegistrator.ENetworkPrefab.Asteroid_LAST + 1), // PrefabID
                                                      parentAbsoluteCell,                                                                                                                                               // Parent cell.
                                                      asteroidPosition,                                                                                                                                                 // Position relative to parent.
                                                      Random.rotationUniform,                                                                                                                                           // Rotation.
                                                      (CGameShips.GalaxyShip.transform.position - asteroidPosition).normalized * 100.0f,                                                                                // Linear velocity.
                                                      Random.onUnitSphere * 50.0f,                                                                                                                                      // Angular velocity.
                                                      true,                                                                                                                                                             // Has networked entity script.
                                                      true));                                                                                                                                                           // Has rigid body.
        } while (created != true && --uiTriesToPlaceRogueAsteroid > 0);
    }
Example #3
0
    void OnGUI()
    {
        return;

        float   shipSpeed  = CGameShips.GalaxyShip.rigidbody.velocity.magnitude;
        Vector3 absShipPos = CGalaxy.instance.RelativePointToAbsolutePoint(CGameShips.GalaxyShip.transform.position);

        CGalaxy.SCellPos shipCellPos = CGalaxy.instance.RelativePointToAbsoluteCell(CGameShips.GalaxyShip.transform.position);

        string shipOutput = "";

        shipOutput += string.Format("\tShipSpeed: [{0}] CurrentCell [{1},{2},{3}] ShipAbsPos [{4}] ",
                                    shipSpeed.ToString("F2"),
                                    shipCellPos.x, shipCellPos.y, shipCellPos.z,
                                    absShipPos.ToString("F2"));

        float boxWidth  = 700;
        float boxHeight = 40;

        GUI.Label(new Rect(Screen.width / 2 - boxWidth, Screen.height - boxHeight, boxWidth, boxHeight),
                  "ShipMiscInfo\n" + shipOutput);
    }