Beispiel #1
0
    void InitBuldingsOver()
    {
        int timer_kill = 0;

        // int h_ = 1
        for (int i = 0; i < BildingCount; i++)
        {
            // for (int j = 0; j < h_; j++)
            //  {

            Vector3 temp_position = new Vector3((float)(-6 + (i * (BildingPart.GetComponent <Renderer>().bounds.size.x + 1))), -4);
            // while (IsIntersect(_jjj, new Vector3(b.position.x + b.GetComponent<Renderer>().bounds.size.x / 2, b.position.y + b.GetComponent<Renderer>().bounds.size.y / 2)))
            while (IsIntersect(new Vector3(temp_position.x, temp_position.y)))
            {
                temp_position = new Vector3((float)(-6 + (i * (BildingPart.GetComponent <Renderer>().bounds.size.x + 1))), temp_position.y + BildingPart.GetComponent <Renderer>().bounds.size.y);
                timer_kill++;

                if (timer_kill > 500)
                {
                    break;
                }
            }

            var b = Instantiate(BildingPart) as Transform;

            // b.GetComponent<Renderer>().material.color = Color.clear;
            BiltdingPart p_ = b.GetComponent <BiltdingPart>();
            p_.Destroyed += P__BildingPartDestroyed;
            p_.Damaged   += P__BildingPartDamaged;
            // b.position = new Vector3((float)(-6 + (i * (b.GetComponent<Renderer>().bounds.size.x + 1))), -3);
            b.position = temp_position;
        }
    }
Beispiel #2
0
    void Start()
    {
        int h_ = UnityEngine.Random.Range(1, floors_max);



        for (int j = 0; j < ((!RandoomFloors)?floors_max:h_); j++)
        {
            var          b  = Instantiate(bp1) as Transform;
            BiltdingPart p_ = b.GetComponent <BiltdingPart>();
            p_.Destroyed += P__PartDestroyed;
            p_.Damaged   += P__Damaged;
            b.position    = new Vector3(transform.position.x, (-3 + j * b.GetComponent <Renderer>().bounds.size.y));
            // buldings.Add(b);
        }
        h_ = UnityEngine.Random.Range(1, floors_max);
    }
Beispiel #3
0
    void InitBuldings()
    {
        int h_ = UnityEngine.Random.Range(1, floors_max);

        for (int i = 0; i < BildingCount; i++)
        {
            for (int j = 0; j < ((!RandoomFloors) ? floors_max : h_); j++)
            {
                /* var b = Instantiate(BildingPart) as Transform;
                 * BildingScript p_ = b.GetComponent<BildingScript>();
                 * p_.BildingPartDestroyed += P__BildingPartDestroyed;
                 * p_.BildingPartDamaged += P__BildingPartDamaged;
                 * b.position = new Vector3((float)(-6 + (i * (b.GetComponent<Renderer>().bounds.size.x + 1))), b.GetComponent<Renderer>().bounds.size.y);
                 * // buldings.Add(b);*/
                var          b  = Instantiate(BildingPart) as Transform;
                BiltdingPart p_ = b.GetComponent <BiltdingPart>();
                p_.Destroyed += P__BildingPartDestroyed;
                ;
                p_.Damaged += P__BildingPartDamaged;
                b.position  = new Vector3((float)(-6 + (i * (b.GetComponent <Renderer>().bounds.size.x + 1))), (-4 + j * b.GetComponent <Renderer>().bounds.size.y));
            }
            h_ = UnityEngine.Random.Range(1, floors_max);
        }
    }