Beispiel #1
0
    void Start()
    {
        if (CNetwork.IsServer)   // If this is the server...
        {
            // Find the galaxy instance and register this object as an observer.
            CNetwork network = CNetwork.Instance; System.Diagnostics.Debug.Assert(network);
            CGame    game    = CGame.Instance; System.Diagnostics.Debug.Assert(game);
            CGalaxy  galaxy  = CGalaxy.instance; System.Diagnostics.Debug.Assert(galaxy);

            galaxy.RegisterObserver(this.gameObject, CGalaxy.GetBoundingRadius(gameObject));

            //textObject = new GameObject();
            //textObject.transform.parent = this.gameObject.transform;
            //textObject.transform.localPosition = Vector3.zero;
            //textObject.transform.localRotation = Quaternion.identity;
            //textObject.layer = gameObject.layer;

            //// Add the mesh renderer
            //MeshRenderer mr = textObject.AddComponent<MeshRenderer>();
            //mr.material = (Material)Resources.Load("Fonts/Couri", typeof(Material));

            //// Add the text mesh
            //tm = textObject.AddComponent<TextMesh>();
            //tm.fontSize = 72;
            //tm.characterSize = .125f;
            //tm.color = Color.white;
            //tm.font = (Font)Resources.Load("Fonts/Couri", typeof(Font));
            //tm.anchor = TextAnchor.MiddleCenter;
            //tm.offsetZ = 0.0f;
            //tm.text = "OHAI";
            //tm.fontStyle = FontStyle.Italic;
        }
    }
Beispiel #2
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;
        }
    }
Beispiel #3
0
    //GameObject textObject;
    //TextMesh tm;
    //void Update()
    //{
    //    textObject.transform.position = gameObject.transform.position;
    //    if (Camera.current)
    //        textObject.transform.rotation = Quaternion.LookRotation(gameObject.transform.position - Camera.current.transform.position);

    //    CGalaxy galaxy = CGalaxy.instance;
    //    CGalaxy.SGridCellPos transformedCellPos = galaxy.PointToRelativeCell(gameObject.transform.position);
    //    CGalaxy.SGridCellPos untransformedCellPos = galaxy.PointToAbsoluteCell(gameObject.transform.position);
    //    tm.text = string.Format("Rel({0},{1},{2})\nAbs({3},{4},{5})", transformedCellPos.x, transformedCellPos.y, transformedCellPos.z, untransformedCellPos.x, untransformedCellPos.y, untransformedCellPos.z);
    //}

    void OnDestroy()
    {
        CGalaxy galaxy = CGalaxy.instance;

        if (galaxy)
        {
            galaxy.DeregisterObserver(this.gameObject);
        }
    }
Beispiel #4
0
    void OnDestroy()
    {
        CGalaxy galaxy = CGalaxy.instance;

        if (galaxy)
        {
            galaxy.DeregisterShiftableEntity(this);
        }
    }
Beispiel #5
0
	void OnDestroy()
	{
		sGalaxy = null;
	}
Beispiel #6
0
	///////////////////////////////////////////////////////////////////////////
	// Functions:

	public CGalaxy()
	{
		sGalaxy = this;

		// Instantiate galaxy noises.
		for (uint ui = 0; ui < (uint)ENoiseLayer.MAX; ++ui)
			mNoises[ui] = new PerlinSimplexNoise();
	}