Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        var worker = DrawInstance.getWorker(DrawInstance.KEY_bike);

        worker.draw(mesh, materials);
        count = worker.getCount();
    }
Exemplo n.º 2
0
    private void LateUpdate()
    {
        if (doWorldReScale)
        {
            worldReSacle(scaleValue);
            doWorldReScale = false;
        }

        var worker = DrawInstance.getWorker(DrawInstance.KEY_bike);

        worker.draw(mesh, materials);
        count = worker.getCount();
    }
Exemplo n.º 3
0
 public static DrawInstance getWorker(string key)
 {
     if (!dic.ContainsKey(key))
     {
         var worker = new DrawInstance();
         dic.Add(key, worker);
         return(worker);
     }
     else
     {
         return(dic[key]);
     }
 }
Exemplo n.º 4
0
    void Awake()
    {
        DrawInstance.getWorker(DrawInstance.KEY_bike).initMatrix(10000, false);
        for (int x = 0; x < W; x++)
        {
            for (int z = 0; z < H; z++)
            {
                var     bike   = GameObject.Instantiate <Bike>(bitePrefab, this.transform);
                Vector3 newPos = new Vector3(x, 50, z);

                bike.transform.localPosition = newPos;
                bike.name = "bike[" + x + "," + z + "]";
            }
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        // todo: 之後可以改到shader做
        for (int x = 0; x < showW; x++)
        {
            for (int z = 0; z < showH; z++)
            {
                float h = diffuse(x, z);
                waterHeightSetter[x, z].updateWater(h);
            }
        }

        swapBuffer();

        nowWater[flow_index_x, flow_index_z] += waterFollowPerSecond * Time.deltaTime;

        DrawInstance.getWorker(DrawInstance.KEY_water_park_block).draw(mesh, materials);
    }
Exemplo n.º 6
0
    void Awake()
    {
        DrawInstance.getWorker(DrawInstance.KEY_water_park_block).initMatrix(showW * showH, true);
        waterHeightSetter  = new WaterHeightSetter[showW, showH];
        terrainHeightField = new int[showW, showH];
        waterHeightField   = new float[showW, showH];
        waterHeightField2  = new float[showW, showH];

        nowWater = waterHeightField;
        newWater = waterHeightField2;

        L = Mathf.Sqrt(W * W + H * H);
        for (int x = 0; x < showW; x++)
        {
            for (int z = 0; z < showH; z++)
            {
                WaterHeightSetter newGround = GameObject.Instantiate <WaterHeightSetter>(groundPrefab, this.transform);
                waterHeightSetter[x, z] = newGround;

                float h = 0;
                h += getWave1(x, z);
                h += getWave2(x, z);

                h += -getHill(x, z, 25, 25, 5);
                h += -getHill(x, z, 20, 25, 5);
                h += -getHill(x, z, 15, 22, 7);
                h += -getHill(x, z, 10, 17, 10);

                h += getHill(x, z, 35, 20, 10);
                h += getHill(x, z, 35, 25, 10);
                h += getHill(x, z, 35, 35, 10);
                terrainHeightField[x, z] = (int)h;
                Vector3 newPos = new Vector3(x, (int)h, z);

                newGround.transform.localPosition = newPos;
                newGround.name = "obj[" + x + "," + z + "]";

                DrawInstance.getWorker(DrawInstance.KEY_water_park_block).pushTrasform(newGround.transform);
            }
        }
    }
Exemplo n.º 7
0
 // Start is called before the first frame update
 void Start()
 {
     meshRenderer.enabled = false;
     DrawInstance.getWorker(DrawInstance.KEY_bike).pushTrasform(transform);
 }
Exemplo n.º 8
0
 void OnDestroy()
 {
     DrawInstance.getWorker(DrawInstance.KEY_bike).removeTrasform(transform);
 }
Exemplo n.º 9
0
 void Awake()
 {
     DrawInstance.getWorker(DrawInstance.KEY_bike).initMatrix(10000, false);
 }