Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            if (isSelected)
            {
                isSelected = false;
                m_InspectorPannel.ChangeInspectorImage(Selected.GetComponent <SpriteRenderer>().sprite);
                m_InformationPannel.display(Selected);
                m_RightClickCanvas.setActive(false);
            }
            else
            {
                Selected = null;
                m_InspectorPannel.ChangeInspectorImage(null);
                m_InformationPannel.display(null);
                m_RightClickCanvas.setActive(false);
            }
        }

        if (Input.GetMouseButtonUp(1))
        {
            if (Selected != null)
            {
                m_RightClickCanvas.setActive(true);
                m_RightClickCanvas.setPosition(Selected.getPosition());
            }
            else
            {
                m_RightClickCanvas.setActive(false);
            }
        }
    }
 void Revolution()
 {
     if (isRevolution)
     {
         Vector2 gravityDirection = -(getPosition() - RevolutionObject.getPosition()).normalized;
         gameObject.transform.position = RevolutionObject.getPosition() + (-gravityDirection) * RevolutionDistance;
         if (phyC)
         {
             m_Riggebody2D.velocity = velocity;
             m_Riggebody2D.AddForce(gravityDirection);
             velocity = m_Riggebody2D.velocity;
         }
         else
         {
             Vector2 moveDirection = new Vector2(gravityDirection.y, -gravityDirection.x);
             velocity = RevolutionObject.getVelocity() + moveDirection * RevolutionVelocity;
             m_Riggebody2D.velocity = velocity;
         }
     }
 }