Ejemplo n.º 1
0
    void SnapPipe()
    {
        foreach (GameObject point in endSnapPoint)
        {
            if (point != null)
            {
                float dist = Vector2.Distance(localSnapPoint.transform.position, point.transform.position);
                if (dist < i)
                {
                    i           = dist;
                    CurrEndSnap = point;
                }
            }
        }

        if (Compare() == true)
        {
            myParent = CurrEndSnap.transform.parent.GetComponent <SmartPipes>();
            if (!myParent.isOccupied)
            {
                myParent.SetChild(gameObject);
                myParent.Occupy(true);

                rigidbody2D.isKinematic = true;
                gameObject.layer        = 11;

                myT.position += AdjustPosition();

                Vector3 vec = transform.eulerAngles;
                vec.z = Mathf.Round(vec.z / 90) * 90;
                transform.eulerAngles = vec;

                myT.position += AdjustPosition();

                myParent.SteamSwitch();
                SteamSwitch();
                inSitute = true;
            }
            else
            {
                myParent = null;
            }
        }
    }
Ejemplo n.º 2
0
 public void Drop(bool occupied)
 {
     inSitute = false;
     if (myParent != null)
     {
         myParent.Occupy(false);
     }
     if (myChild != null)
     {
         myChild.gameObject.layer        = 11;
         myChild.rigidbody2D.isKinematic = false;
         SmartPipes myChildPipes = myChild.GetComponent <SmartPipes>();
         if (myChildPipes != null)
         {
             myChildPipes.Drop(true);
         }
     }
     SwitchColliders();
 }