Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Transmission transmission = GameObject.Find("Persistent").GetComponent <Transmission>();

        distribution = transmission.distribution;
        enthusaism   = transmission.enthusaism;

        if (NUM_DISTRICTS < 7)
        {
            Color[] area_pix  = area.GetPixels();
            Color[] align_pix = align_tex.GetPixels();


            // districts never extend more than 400 pixels away from their capital
            int dist = 400;
            int x    = (int)capital.texture_loc.x;
            int y    = (int)capital.texture_loc.y;
            for (int r = Math.Max(y - dist, 0); r < area.height && r < y + dist; ++r)
            {
                for (int c = Math.Max(x - dist, 0); c < area.width && c < x + dist; ++c)
                {
                    // alter the noise in the localized area to offset by how much the player agrees with local politics
                    float alpha = area_pix[r * area.width + c].a;
                    if (alpha > 0)
                    {
                        float sample = align_pix[r * area.width + c].r;                         // noise as generated in Transmission.Awake
                        sample = alignment.AgreesWithPlayerFactor() * 4 / 5 + sample / 5;

                        align_pix[r * area.width + c] = new Color(sample, sample, sample, alpha);
                    }
                }
            }
            align_tex.SetPixels(align_pix);
            align_tex.Apply();
        }

        UpdateComposite();
        NUM_DISTRICTS++;
        if (NUM_DISTRICTS % 7 == 0)
        {
            GameObject.Find("Debug").GetComponent <SpriteRenderer>().sprite = Sprite.Create(align_tex, new Rect(0, 0, area.width, area.height), new Vector2(0.5f, 0.5f), 100.0f);
        }
    }