Exemplo n.º 1
0
    protected virtual void UpdateComponent(VCPart part)
    {
        part.hiddenModel = !m_Visible;

        if (part is VCPWeapon)
        {
            (part as VCPWeapon).groupIndex = m_ExtendData;
        }
    }
Exemplo n.º 2
0
    protected override void UpdateComponent(VCPart part)
    {
        base.UpdateComponent(part);

        if (part is VCPVehicleWheel)
        {
            (part as VCPVehicleWheel).isSteerWheel = (Phase & 2) == 2;
            (part as VCPVehicleWheel).isMotorWheel = (Phase & 4) != 4;
        }
    }
Exemplo n.º 3
0
 public bool Exists(VCPart part_prop)
 {
     foreach (VCEUIPartDescItem pdi in m_Items)
     {
         if (pdi.m_PartProp == part_prop)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
    public void Add(VCPart part_prop)
    {
        if (Exists(part_prop))
        {
            return;
        }
        VCEUIPartDescItem pdi = VCEUIPartDescItem.Instantiate(m_Res) as VCEUIPartDescItem;

        pdi.transform.parent     = this.transform;
        pdi.transform.localScale = Vector3.one;
        pdi.gameObject.name      = part_prop.gameObject.name;
        pdi.Set(part_prop);
        m_Items.Add(pdi);
        SetDirty();
    }
Exemplo n.º 5
0
    public bool Remove(VCPart part_prop)
    {
        VCEUIPartDescItem remove_tar = null;

        foreach (VCEUIPartDescItem pdi in m_Items)
        {
            if (pdi.m_PartProp == part_prop)
            {
                remove_tar = pdi;
                pdi.gameObject.SetActive(false);
                pdi.transform.parent = null;
                GameObject.Destroy(pdi.gameObject);
            }
        }
        if (remove_tar != null)
        {
            m_Items.Remove(remove_tar);
            SetDirty();
            return(true);
        }
        return(false);
    }
Exemplo n.º 6
0
 public void Set(VCPart part_prop)
 {
     m_PartProp       = part_prop;
     m_NameLabel.text = part_prop.gameObject.name;
     m_DescLabel.text = part_prop.description;
 }
Exemplo n.º 7
0
    void Update()
    {
        if (!VCEditor.DocumentOpen())
        {
            return;
        }

        // Check 's_LastCreate'
        if (s_LastCreate != null)
        {
            ClearSelection();
            SelectInfo si = new SelectInfo();
            si.m_Component = s_LastCreate;
            m_Selection.Add(si);
            OnSelectionChange();
        }

        VCEditor.s_ProtectLock0 = UsingGizmo;
        NormalizeSelection();

        // Update Pick Order
        Vector3 mousePos = Input.mousePosition;

        if ((mousePos - lastMousePos).magnitude > 3.1f)
        {
            pick_order   = 0;
            lastMousePos = mousePos;
        }

        #region PART_DESC
        // Part Description Board
        if (m_DescBoard != null)
        {
            m_DescBoard.m_Position = Vector3.Lerp(m_DescBoard.m_Position, VCEInput.s_PickRay.GetPoint(1.5f), 0.5f);
            List <VCEComponentTool> pickall = new List <VCEComponentTool> ();
            if (!UsingGizmo && !VCEInput.s_MouseOnUI)
            {
                pickall = VCEMath.RayPickComponents(VCEInput.s_PickRay);
            }
            List <VCPart> pps = new List <VCPart> ();
            Vector3       v   = Vector3.zero;
            if (pickall.Count > 0)
            {
                v = pickall[0].transform.localPosition;
            }
            foreach (VCEComponentTool ct in pickall)
            {
                if (Vector3.Distance(ct.transform.localPosition, v) > VCEditor.s_Scene.m_Setting.m_VoxelSize * 2)
                {
                    continue;
                }
                VCPart pp = ct.GetComponent <VCPart>();
                if (pp != null)
                {
                    pps.Add(pp);
                }
            }
            if (pickall.Count > 0)
            {
                m_DescBoard.FadeIn();
                VCEditor.Instance.m_UI.m_HoloBoardCamera.enabled = true;
            }
            else
            {
                VCEditor.Instance.m_UI.m_HoloBoardCamera.enabled = false;
                m_DescBoard.FadeOut();
            }
            pickall.Clear();
            VCEditor.Instance.m_UI.m_PartDescList.SyncList(pps);
            pps.Clear();
            pickall = null;
            pps     = null;
        }
        #endregion

        // Pick Component
        VCEComponentTool picked = null;
        if (!VCEInput.s_MouseOnUI && !m_MouseOnGizmo)
        {
            picked = VCEMath.RayPickComponent(VCEInput.s_PickRay, pick_order);
        }
        if (Input.GetMouseButtonDown(0) && !VCEInput.s_MouseOnUI && !m_MouseOnGizmo)
        {
            if (!VCEInput.s_Shift && !VCEInput.s_Control && !VCEInput.s_Alt)
            {
                m_Selection.Clear();
            }
            if (picked != null)
            {
                SelectInfo si = FindSelected(picked);
                if (si != null)
                {
                    m_Selection.Remove(si);
                }
                else
                {
                    si             = new SelectInfo();
                    si.m_Component = picked;
                    List <SelectInfo> del_list = new List <SelectInfo> ();
                    foreach (SelectInfo sel in m_Selection)
                    {
                        VCEComponentTool        ct     = sel.m_Component;
                        List <VCEComponentTool> images = MirrorImage(ct);
                        if (images.Contains(si.m_Component))
                        {
                            del_list.Add(sel);
                        }
                    }
                    m_Selection.Add(si);
                    foreach (SelectInfo del in del_list)
                    {
                        m_Selection.Remove(del);
                    }
                }
                pick_order++;
            }
            OnSelectionChange();
        }

        // Update bound color & highlight
        foreach (VCComponentData cd in VCEditor.s_Scene.m_IsoData.m_Components)
        {
            VCEComponentTool c = cd.m_Entity.GetComponent <VCEComponentTool>();
            c.m_SelBound.enabled = true;
            c.m_SelBound.GetComponent <Collider>().enabled = true;
            c.m_SelBound.m_Highlight  = (c == picked);
            c.m_SelBound.m_BoundColor = GLComponentBound.s_Blue;
        }

        // Update selection and mirror's bound color
        if (m_Selection.Count > 0)
        {
            VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
            foreach (SelectInfo si in m_Selection)
            {
                VCEComponentTool        c       = si.m_Component;
                List <VCEComponentTool> mirrors = MirrorImage(c);
                foreach (VCEComponentTool m in mirrors)
                {
                    m.m_SelBound.m_BoundColor = GLComponentBound.s_Orange;
                }
            }
            foreach (SelectInfo si in m_Selection)
            {
                VCEComponentTool c = si.m_Component;
                c.m_SelBound.m_BoundColor = GLComponentBound.s_Yellow;
            }
        }

        // Update Inspectors
        if (m_Selection.Count < 1)
        {
            HideInspectors();
        }
        else if (m_Selection.Count == 1)
        {
            ShowMainInspector();

            VCEUISelectComponentInspector sci = m_MainInspector.GetComponent <VCEUISelectComponentInspector>();
            if (m_Selection[0].m_Component != null)
            {
                sci.m_SelectInfo.text = m_Selection[0].m_Component.gameObject.name;
            }
            else
            {
                sci.m_SelectInfo.text = "< Deleted >";
            }
        }
        else
        {
            ShowMainInspector();
            HideDataInspector();
            VCEUISelectComponentInspector sci = m_MainInspector.GetComponent <VCEUISelectComponentInspector>();
            sci.m_SelectInfo.text = m_Selection.Count.ToString() + " " + "objects".ToLocalizationString() + " " + "selected".ToLocalizationString();
        }

        // Transform Gizmos
        if (m_Selection.Count > 0)
        {
            Vector3 avePos  = Vector3.zero;
            int     rotmask = 7;
            foreach (SelectInfo si in m_Selection)
            {
                avePos += si.m_Component.transform.position;
                VCPartData part_data = si.m_Component.m_Data as VCPartData;
                if (part_data != null)
                {
                    rotmask &= VCConfig.s_PartTypes[si.m_Component.m_Data.m_Type].m_RotateMask;
                }
            }
            avePos /= ((float)m_Selection.Count);
            m_MovingGizmo.transform.position   = avePos;
            m_RotatingGizmo.transform.position = avePos;
            m_MovingGizmo.gameObject.SetActive(VCEditor.TransformType == EVCETransformType.Move);
            m_RotatingGizmo.gameObject.SetActive(VCEditor.TransformType == EVCETransformType.Rotate);
            m_RotatingGizmo.m_AxisMask = rotmask;
        }
        else
        {
            m_MovingGizmo.gameObject.SetActive(false);
            m_RotatingGizmo.gameObject.SetActive(false);
        }
    }