Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="up">this module is on top of caller</param>
        /// <param name="comb"></param>
        public void Combined(bool up, CombineAction comb)
        {
            if (up)
            {
                Lower = comb;
                LowerJoint.enabled       = true;
                LowerJoint.connectedBody = comb.GetComponent <Rigidbody2D>();
            }
            else
            {
                Upper = comb;
                UpperJoint.enabled       = true;
                UpperJoint.connectedBody = comb.GetComponent <Rigidbody2D>();
                if (comb.GetMass() > SupportableMass)
                {
                    Break();
                }
            }

            if (Selecting)
            {
                if (part == Part.Upper)
                {
                    //if(Upper!=null && Lower&&null)
                }
            }
            UpdateMovement();
        }
Ejemplo n.º 2
0
        //bool Movement

        /// <summary>
        /// Mass of the module, and the module on top if it.
        /// </summary>
        /// <returns></returns>
        public float GetMass()
        {
            if (Upper == null)
            {
                return(Mass);
            }
            else
            {
                return(Mass + Upper.GetMass());
            }
        }
Ejemplo n.º 3
0
 private void Update()
 {
     if (GameInput.GetKeyDown(player, ActionKey))
     {
         MovementAction movement = GetComponent <MovementAction>();
         Selecting = true;
         if (movement != null)
         {
             movement.enabled = false;
         }
         ((CombineSelection)selection).StartSelecting(this, player, "Combinable", Range);
     }
     if (GameInput.GetKeyUp(player, ActionKey))
     {
         Selecting = false;
         GameObject g = selection.StopSelecting();
         if (g != null)
         {
             if (Upper != null && g == Upper.gameObject)
             {
                 UpperJoint.connectedBody = null;
                 UpperJoint.enabled       = false;
                 Upper.Separated(true);
                 Upper = null;
             }
             else if (Lower != null && g == Lower.gameObject)
             {
                 LowerJoint.connectedBody = null;
                 LowerJoint.enabled       = false;
                 Lower.Separated(false);
                 Lower = null;
             }
             else
             {
                 CombineAction comb = g.GetComponent <CombineAction>();
                 if (comb.part > part)
                 {
                     comb.transform.position  = comb.transform.position + (UpperAttachPoint.position - comb.LowerAttachPoint.position);
                     UpperJoint.enabled       = true;
                     UpperJoint.connectedBody = comb.GetComponent <Rigidbody2D>();
                     Upper = comb;
                     comb.Combined(true, this);
                     if (comb.GetMass() > SupportableMass)
                     {
                         Break();
                     }
                 }
                 else
                 {
                     transform.position       = transform.position + (comb.UpperAttachPoint.position - LowerAttachPoint.position);
                     LowerJoint.enabled       = true;
                     LowerJoint.connectedBody = comb.GetComponent <Rigidbody2D>();
                     Lower = comb;
                     comb.Combined(false, this);
                 }
             }
             UpdateMovement();
         }
         if (Movement)
         {
             MovementAction movement = GetComponent <MovementAction>();
             if (movement != null)
             {
                 movement.enabled = true;
             }
         }
     }
 }