Esempio 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();
        }
Esempio n. 2
0
 public void Separated(bool up)
 {
     if (up)
     {
         LowerJoint.connectedBody = null;
         LowerJoint.enabled       = false;
         Lower = null;
     }
     else
     {
         UpperJoint.connectedBody = null;
         UpperJoint.enabled       = false;
         Upper = null;
     }
     UpdateMovement();
 }
Esempio n. 3
0
 public void StartSelecting(CombineAction comb, int player, string tag, float range)
 {
     combining = true;
     part      = comb.part;
     if (part == CombineAction.Part.Upper)
     {
         CalculateUpDown(comb);
     }
     base.StartSelecting(player, tag, range);
     if (comb.Upper != null)
     {
         Targets.Add(comb.Upper.gameObject);
         comb.Upper.GetComponent <SelectableTarget>().SetGlow(player, true);
     }
     if (comb.Lower != null)
     {
         Targets.Add(comb.Lower.gameObject);
         comb.Lower.GetComponent <SelectableTarget>().SetGlow(player, true);
     }
 }
Esempio n. 4
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;
             }
         }
     }
 }
Esempio n. 5
0
 private void Start()
 {
     _faceAction       = GetComponent <ChangeFacingDirectionAction>();
     _combineAction    = GetComponent <CombineAction>();
     grabJoint.enabled = false;
 }
Esempio n. 6
0
 public void CalculateUpDown(CombineAction comb)
 {
     up   = comb.Upper == null;
     down = comb.Lower == null;
 }