Example #1
0
    public bool sonMovement(Vector2 pos, int id, int best)
    {
        bool    res = false;
        Vector2 v2  = (Vector2)pos - (Vector2)transform.position;

        float angle = (Mathf.Atan2(v2.y, v2.x) * Mathf.Rad2Deg) + 90;

        foreach (Transform child in transform)
        {
            BlobSon blobSon = child.GetComponent <BlobSon>();
            blobSon.parentCurrentSize = blobCurrentSize;
            if (blobSon != null && blobSon.touchID == id)
            {
                child.rotation   = Quaternion.Euler(new Vector3(0, 0, angle));
                blobSon.sonIndex = best;
            }
            else
            {
                //Debug.Log("Child not found!!!: " + blobSon.touchID + " "+id );
            }
        }
        if (blobCurrentSize == 0)
        {
            res = true;
        }
        return(res);
    }
Example #2
0
 public void deleteAllSons()
 {
     foreach (Transform child in transform)
     {
         BlobSon blobSon = child.GetComponent <BlobSon>();
         blobSon.autodestruction();
     }
 }
Example #3
0
 public BlobSon getSon(int id)
 {
     foreach (Transform child in transform)
     {
         BlobSon blobSon = child.GetComponent <BlobSon>();
         if (blobSon != null && blobSon.touchID == id)
         {
             return(blobSon);
         }
     }
     return(null);
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        setColor(rend);
        anim.SetInteger("size", blobCurrentSize);

        foreach (Transform child in transform)
        {
            BlobSon blobSon = child.GetComponent <BlobSon>();
            blobSon.parentCurrentSize = blobCurrentSize;
            setColor(blobSon.rend);
        }
    }
Example #5
0
 public void deleteSon(int id)
 {
     foreach (Transform child in transform)
     {
         BlobSon blobSon = child.GetComponent <BlobSon>();
         if (blobSon != null && blobSon.touchID == id)
         {
             blobSon.autodestruction();
             blobCurrentSize++;
         }
     }
 }
Example #6
0
    public bool notAlredyChild(int best)
    {
        bool res = true;

        foreach (Transform child in transform)
        {
            BlobSon blobSon = child.GetComponent <BlobSon>();
            blobSon.parentCurrentSize = blobCurrentSize;
            if (blobSon.sonIndex == best)
            {
                res = false;
            }
        }
        return(res);
    }
Example #7
0
 public void createSon(int id)
 {
     Debug.Log("createSon");
     Debug.Log("blobCurrentSize1: " + blobCurrentSize);
     if (blobCurrentSize >= 1)
     {
         Debug.Log("blobCurrentSize >= 1");
         GameObject blobSon = Instantiate(Resources.Load("blobSon"), transform.position, Quaternion.identity) as GameObject;
         blobSon.transform.parent = transform;
         BlobSon bs = blobSon.GetComponent <BlobSon>();
         lastSon = bs;
         blobCurrentSize--;
         bs.Initialize(blobCurrentSize, id);
     }
     Debug.Log("blobCurrentSize2: " + blobCurrentSize);
 }
Example #8
0
    public int [] partition()
    {
        int [] part = new int[5] {
            -1, -1, -1, -1, -1
        };
        int i = 0;

        foreach (Transform child in transform)
        {
            BlobSon blobSon = child.GetComponent <BlobSon>();
            if (i < 5)
            {
                part[i] = blobSon.sonIndex;
                i++;
            }
        }
        return(part);
    }