Ejemplo n.º 1
0
 void ZapTowers(AllData allData)
 {
     if (allData.zap != null)
     {
         float[] x = allData.zap.x;
         float[] y = allData.zap.y;
         float[] z = allData.zap.z;
         for (int i = 0; i < allData.zap.x.Length; i++)
         {
             ZapTower tower = Instantiate(ZapPrefab, Vector3.zero, Quaternion.identity);
             tower.GetComponent <Price>().byPass = true;
             tower.transform.position            = new Vector3(x[i], y[i], z[i]);
         }
     }
 }
Ejemplo n.º 2
0
    //zaptowers should automatically connect to all local towers
    public ZapTowerData(SaveMaster mast)
    {
        int num = mast.zapTowers.Length;

        x = new float[num];
        y = new float[num];
        z = new float[num];

        for (int i = 0; i < num; i++)
        {
            ZapTower zap = mast.zapTowers[i];
            x[i] = zap.transform.position.x;
            y[i] = zap.transform.position.y;
            z[i] = zap.transform.position.z;
        }
    }
Ejemplo n.º 3
0
    void DrawBeam(ZapTower otherTower, ZapTower thisTower)
    {
        IncinerationBeam beam = Instantiate(laser, transform.position, Quaternion.identity).GetComponent <IncinerationBeam>();

        thisTower.childLasers.Add(beam);
        otherTower.childLasers.Add(beam);
        //now move beam to proper angle
        Vector2 avgPos = (otherTower.transform.position + this.transform.position) / 2;

        beam.transform.position = avgPos;
        //since the scale of the beam is 1, multiplying it by dist should be fine
        float dist = Vector2.Distance(otherTower.transform.position, this.transform.position);

        beam.transform.localScale = new Vector2(beam.transform.localScale.x, dist * 100);
        //rotate the beam too!
        Vector3 aimDir = (otherTower.transform.position - thisTower.transform.position);
        float   angle  = (Mathf.Atan2(aimDir.y, aimDir.x) * Mathf.Rad2Deg) + 90;

        beam.transform.rotation = Quaternion.Euler(0, 0, angle);
    }