Пример #1
0
    /// <summary>
    /// Sets up the office by using the specified customization data.
    /// </summary>
    /// <param name="customizationData"></param>
    public void SetUpOffice(OfficeCustomizationData data)
    {
        RemoveAllOfficeObjects();

        MaterialWallsCurrent.color   = data.GetWallsColor();
        MaterialFloorCurrent.color   = data.GetFloorColor();
        MaterialCeilingCurrent.color = data.GetCeilingColor();

        if (data.OfficeItems.Count > 0)
        {
            for (int i = 0; i < data.OfficeItems.Count; i++)
            {
                OfficeItem officeItem      = data.OfficeItems[i];
                GameObject newOfficeObject = null;

                if (officeItem.ItemID > -1)
                {
                    int iObject;

                    InitializeOfficeObject(officeItem.ItemID, out iObject);

                    newOfficeObject = CurrentObjects[iObject];
                }
                else
                {
                    foreach (GameObject obj in CurrentObjects)
                    {
                        if (obj.name == officeItem.ObjectName)
                        {
                            newOfficeObject = obj;
                            break;
                        }
                    }
                }

                newOfficeObject.transform.position = officeItem.GetPosition();
                newOfficeObject.transform.rotation = officeItem.GetRotation();
            }

            int iCurrentObjectsStart = 0;

            foreach (OfficeObjectDependency dependency in data.Dependencies)
            {
                for (int iCurrentObjects = iCurrentObjectsStart; iCurrentObjects < CurrentObjects.Count; iCurrentObjects++)
                {
                    OfficeObjectScript objScript = CurrentObjects[iCurrentObjects].GetComponent <OfficeObjectScript>();

                    if (objScript.ObjectIndex == dependency.ObjectIndexChild)
                    {
                        objScript.SetParent(dependency.ObjectIndexParent);

                        iCurrentObjectsStart++;
                        iCurrentObjects = CurrentObjects.Count; //break;
                    }
                }
            }
        }
    }
Пример #2
0
    public void ResetAllObjectParents()
    {
        foreach (GameObject obj in CurrentObjects)
        {
            OfficeObjectScript objScript = obj.GetComponent <OfficeObjectScript>();

            if (objScript.ParentIndex != -1)
            {
                objScript.SetParent(objScript.ParentIndex);
            }
            else
            {
                obj.transform.parent = officeObjectTransform;
            }
        }
    }