Ejemplo n.º 1
0
    private void IgnoreCollisionWithLayer(int id)
    {
        uteTagObject[] uteS = (uteTagObject[])MAP_STATIC.GetComponentsInChildren <uteTagObject>();
        uteTagObject[] uteD = (uteTagObject[])MAP_DYNAMIC.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < uteS.Length; i++)
        {
            uteTagObject m_uteS = (uteTagObject)uteS[i];

            if (m_uteS.layerName.Equals(AllLayers[id].layerName))
            {
                AllLayers[id].ignoredObjects.Add(m_uteS.gameObject);
                m_uteS.gameObject.layer = 2;
            }
        }

        for (int i = 0; i < uteD.Length; i++)
        {
            uteTagObject m_uteD = (uteTagObject)uteD[i];

            if (m_uteD.layerName.Equals(AllLayers[id].layerName))
            {
                AllLayers[id].ignoredObjects.Add(m_uteD.gameObject);
                m_uteD.gameObject.layer = 2;
            }
        }
    }
Ejemplo n.º 2
0
    private void HideObjectsWithLayer(int id)
    {
        uteTagObject[] uteS = (uteTagObject[])MAP_STATIC.GetComponentsInChildren <uteTagObject>();
        uteTagObject[] uteD = (uteTagObject[])MAP_DYNAMIC.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < uteS.Length; i++)
        {
            uteTagObject m_uteS = (uteTagObject)uteS[i];

            if (m_uteS.layerName.Equals(AllLayers[id].layerName))
            {
                AllLayers[id].hiddenObjects.Add(m_uteS.gameObject);
                m_uteS.gameObject.SetActive(false);
            }
        }

        for (int i = 0; i < uteD.Length; i++)
        {
            uteTagObject m_uteD = (uteTagObject)uteD[i];

            if (m_uteD.layerName.Equals(AllLayers[id].layerName))
            {
                AllLayers[id].hiddenObjects.Add(m_uteD.gameObject);
                m_uteD.gameObject.SetActive(false);
            }
        }
    }
Ejemplo n.º 3
0
    public void CheckIfAllTilesHasExistingLayer()
    {
        bool needsRewrite = false;

        uteTagObject[] uteS = (uteTagObject[])MAP_STATIC.GetComponentsInChildren <uteTagObject>();
        uteTagObject[] uteD = (uteTagObject[])MAP_DYNAMIC.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < uteS.Length; i++)
        {
            uteTagObject m_uteS = (uteTagObject)uteS[i];
            if (!isLayerExists(m_uteS.layerName))
            {
                needsRewrite     = true;
                m_uteS.layerName = AllLayers[0].layerName;
            }
        }

        for (int i = 0; i < uteD.Length; i++)
        {
            uteTagObject m_uteD = (uteTagObject)uteD[i];
            if (!isLayerExists(m_uteD.layerName))
            {
                needsRewrite     = true;
                m_uteD.layerName = AllLayers[0].layerName;
            }
        }

        if (needsRewrite)
        {
            Debug.Log("[LayersEngine] Some of the Tiles has non-existing layer, these tiles will be merged to DEFAULT layer.");
            AllLayers.Clear();
            ReadLayersFromMap(m_mapName, MAP_STATIC, MAP_DYNAMIC, MEE);
            StartCoroutine(ReSaveMap());
        }
    }
    public string SaveMap(string mapName)
    {
        mapName = ValidateMapName(mapName);
        AddMapToList(mapName);
        string     allInfo   = "";
        GameObject ALL_TILES = (GameObject)GameObject.Find("uteMAP_ALLTILES");

        uteTagObject[] allObjsD = (uteTagObject[])ALL_TILES.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < allObjsD.Length; i++)
        {
            uteTagObject objDTag = (uteTagObject)allObjsD[i];

            if (objDTag)
            {
                GameObject goD   = objDTag.gameObject;
                string     goDID = goD.name;

                goDID = goDID.Replace("(Clone)", "");
                goDID = goDID.Replace(" ", "");

                Vector3 goDPos      = goD.transform.position;
                Vector3 goDRot      = goD.transform.localEulerAngles;
                string  goDisStatic = GetStringFromBool(goD.isStatic);

                if (goDID.Equals(""))
                {
                    goDID = goD.name;
                    Debug.Log(goDID);
                }

                allInfo += goDID + ":" + goDPos.x + ":" + goDPos.y + ":" + goDPos.z + ":" + goDRot.x + ":" + goDRot.y + ":" + goDRot.z + ":" + goDisStatic + ":$";
            }
        }

        string fpth  = uteGLOBAL3dMapEditor.getRuntimeMapDir() + mapName + ".txt";
        string fpthC = uteGLOBAL3dMapEditor.getRuntimeMapDir();

        if (Directory.Exists(fpthC))
        {
            StreamWriter sw = new StreamWriter(fpth);
            sw.Write("");
            sw.Write(allInfo);
            sw.Flush();
            sw.Close();

            return(allInfo);
        }
        else
        {
            Debug.LogError("[Runtime Builder] Error saving map. Make sure you click on 'Prepare for Runtime' on uteRuntimeBuilder script before going runtime.");
        }

        return("");
    }
Ejemplo n.º 5
0
    private void MergeLayerTo(int idA, int idB)
    {
        if (!AllLayers[idA].isVisible || !AllLayers[idB].isVisible)
        {
            Debug.Log("[LayersEngine] In order to merge layers, both layers must be visible.");
            return;
        }

        if (idA == idB)
        {
            Debug.Log("[LayersEngine] Can't merge to same Layer.");
            return;
        }

        uteTagObject[] uteS = (uteTagObject[])MAP_STATIC.GetComponentsInChildren <uteTagObject>();
        uteTagObject[] uteD = (uteTagObject[])MAP_DYNAMIC.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < uteS.Length; i++)
        {
            uteTagObject m_uteS = (uteTagObject)uteS[i];

            if (m_uteS.layerName.Equals(AllLayers[idA].layerName))
            {
                m_uteS.layerName = AllLayers[idB].layerName;
            }
        }

        for (int i = 0; i < uteD.Length; i++)
        {
            uteTagObject m_uteD = (uteTagObject)uteD[i];

            if (m_uteD.layerName.Equals(AllLayers[idA].layerName))
            {
                m_uteD.layerName = AllLayers[idB].layerName;
            }
        }

        DeleteLayer(idA);
    }
Ejemplo n.º 6
0
    private void DeleteLayer(int id)
    {
        uteTagObject[] uteS = (uteTagObject[])MAP_STATIC.GetComponentsInChildren <uteTagObject>();
        uteTagObject[] uteD = (uteTagObject[])MAP_DYNAMIC.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < uteS.Length; i++)
        {
            uteTagObject m_uteS = (uteTagObject)uteS[i];

            if (m_uteS.layerName.Equals(AllLayers[id].layerName))
            {
                Destroy(m_uteS.gameObject);
            }
        }

        for (int i = 0; i < uteD.Length; i++)
        {
            uteTagObject m_uteD = (uteTagObject)uteD[i];

            if (m_uteD.layerName.Equals(AllLayers[id].layerName))
            {
                Destroy(m_uteD.gameObject);
            }
        }

        AllLayers.RemoveAt(id);

        if (selectedLayer == id)
        {
            if (selectedLayer > 0)
            {
                selectedLayer--;
            }
        }

        RewriteLayersFromArrayToFile();
    }
Ejemplo n.º 7
0
    private void RenameLayer(int id, string newName)
    {
        uteTagObject[] uteS = (uteTagObject[])MAP_STATIC.GetComponentsInChildren <uteTagObject>();
        uteTagObject[] uteD = (uteTagObject[])MAP_DYNAMIC.GetComponentsInChildren <uteTagObject>();

        for (int i = 0; i < uteS.Length; i++)
        {
            uteTagObject m_uteS = (uteTagObject)uteS[i];

            if (m_uteS.layerName.Equals(AllLayers[id].layerName))
            {
                m_uteS.layerName = newName;
            }
        }

        for (int i = 0; i < uteD.Length; i++)
        {
            uteTagObject m_uteD = (uteTagObject)uteD[i];

            if (m_uteD.layerName.Equals(AllLayers[id].layerName))
            {
                m_uteD.layerName = newName;
            }
        }

        for (int i = 0; i < AllLayers.Count; i++)
        {
            if (AllLayers[i].layerName.Equals(AllLayers[id].layerName))
            {
                AllLayers[i].layerName = newName;
                break;
            }
        }

        RewriteLayersFromArrayToFile();
    }
Ejemplo n.º 8
0
    public IEnumerator LoadMap(string name, GameObject map_static, GameObject map_dynamic, bool isItMap)
    {
        isMapLoaded = false;
        string path;

        if (isItMap)
        {
            path = uteGLOBAL3dMapEditor.getMapsDir() + name + ".txt";
        }
        else
        {
            path = uteGLOBAL3dMapEditor.getPatternsDir() + name + ".txt";
        }

        StreamReader sr   = new StreamReader(path);
        string       info = sr.ReadToEnd();

        sr.Close();

        string[] allparts = info.Split("$"[0]);

        for (int i = 0; i < allparts.Length; i++)
        {
            if (!allparts[i].Equals(""))
            {
                if (i % 2000 == 0)
                {
                    yield return(0);
                }

                string[] allinfo = allparts[i].Split(":"[0]);

                string guid       = allinfo[0].ToString();
                float  pX         = System.Convert.ToSingle(allinfo[1].ToString());
                float  pY         = System.Convert.ToSingle(allinfo[2].ToString());
                float  pZ         = System.Convert.ToSingle(allinfo[3].ToString());
                int    rX         = System.Convert.ToInt32(allinfo[4].ToString());
                int    rY         = System.Convert.ToInt32(allinfo[5].ToString());
                int    rZ         = System.Convert.ToInt32(allinfo[6].ToString());
                string staticInfo = allinfo[7].ToString();
                string tcInfo     = allinfo[8].ToString();
                string familyName = allinfo[9].ToString();
                string layerName  = allinfo[10].ToString();

                if (layerName.Equals(""))
                {
                    layerName = "DEFAULT";
                }

                string     opath = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
                GameObject tGO   = (GameObject)UnityEditor.AssetDatabase.LoadMainAssetAtPath(opath);

                if (tGO)
                {
                    GameObject        newGO = (GameObject)Instantiate(tGO, Vector3.zero, Quaternion.identity);
                    List <GameObject> twoGO = new List <GameObject>();
                    twoGO = uMEE.createColliderToObject(newGO, newGO);
                    GameObject behindGO = (GameObject)twoGO[0];
                    GameObject objGO    = (GameObject)twoGO[1];
                    newGO          = objGO;
                    behindGO.name  = tGO.name;
                    newGO.name     = tGO.name;
                    behindGO.layer = 0;
                    behindGO.transform.position         = new Vector3(pX, pY, pZ);
                    behindGO.transform.localEulerAngles = new Vector3(rX, rY, rZ) + tGO.transform.localEulerAngles;
                    behindGO.collider.isTrigger         = false;
                    uteTagObject uTO = behindGO.AddComponent <uteTagObject>();
                    uTO.objGUID   = guid;
                    uTO.layerName = layerName;

                    if (staticInfo.Equals("1"))
                    {
                        newGO.isStatic            = true;
                        uTO.isStatic              = true;
                        behindGO.transform.parent = map_static.transform;
                    }
                    else if (staticInfo.Equals("0"))
                    {
                        newGO.isStatic            = false;
                        uTO.isStatic              = false;
                        behindGO.transform.parent = map_dynamic.transform;
                    }

                    if (tcInfo.Equals("1"))
                    {
                        uTO.isTC = true;
                        uteTcTag uTT = (uteTcTag)behindGO.AddComponent <uteTcTag>();
                        uTT.tcFamilyName = familyName;
                    }

                    uteGLOBAL3dMapEditor.mapObjectCount++;
                }
            }
        }

        isMapLoaded = true;

        yield return(0);
    }