示例#1
0
    void updateWorld()
    {
        while (db == null)
        {
            ;
        }


        string        dds = world + "_map_big_revealed.dds";
        AssetDatabase adb = AssetDatabaseInst.DB;

        byte[] data = adb.extractUsingFilename(dds, AssetDatabase.RequestCategory.TEXTURE);
        image.texture = DDSLoader.DatabaseLoaderTexture_DDS.LoadDDS(data);

        int sizeX = 0;
        int sizeY = 0;

        CDRParse.getMinMax(world, ref sizeX, ref sizeY);
        int tileX = sizeX / 256;
        int tileY = sizeY / 256;

        RectTransform rt = image.GetComponent <RectTransform>();

        rt.sizeDelta = new Vector2(tileX * pixelsPerMeter, tileY * pixelsPerMeter);

        List <WorldSpawn> spawns = CDRParse.getSpawns(adb, db, world);

        foreach (WorldSpawn spawn in spawns)
        {
            if (spawn.imagePath != null && spawn.imagePath.Length > 0)
            {
                GameObject  go = GameObject.Instantiate <GameObject>(teleportTemplate, teleportRoot.transform);
                MapTeleport mt = go.AddComponent <MapTeleport>();
                mt.spawn = spawn;
                RawImage      ri  = go.GetComponent <RawImage>();
                RectTransform rrt = go.GetComponent <RectTransform>();
                rrt.anchoredPosition = new Vector3((spawn.pos.x / 256.0f) * pixelsPerMeter, ((spawn.pos.z / 256.0f) * pixelsPerMeter), 0);
                go.SetActive(true);

                makeTrigger(go, EventTriggerType.PointerEnter, (x) => OnPointerEnter((PointerEventData)x));
                makeTrigger(go, EventTriggerType.PointerExit, (x) => OnPointerExit((PointerEventData)x));
                //makeTrigger(go, EventTriggerType.PointerDown, (x) => OnPointerClick((PointerEventData)x));
                makeTrigger(go, EventTriggerType.PointerClick, (x) => OnPointerClick((PointerEventData)x));
            }
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (doMapChange)
        {
            SceneManager.LoadScene("scene1");
            return;
        }
        if (db != null && !first)
        {
            Debug.Log("TestDecomp update called");

            first = true;
            Debug.Log("get keys");
            worlds.Clear();

            worlds.AddRange(CDRParse.getSpawns(adb, db, null));
            worlds.Add(new WorldSpawn("warfront_13", "unknown", Vector3.zero, 0));
            favs.Add("tm_Meridian_EpochPlaza");


            worlds = worlds.OrderBy(w => !favs.Contains(w.spawnName)).ThenBy(w => w.worldName).ThenBy(w => w.spawnName).ToList();

            updateWorldDropdown();

            dropdownbox.SetActive(true);
            loadbutton.SetActive(true);
            loadModelViewerbutton.SetActive(true);
            loadWardrobebutton.SetActive(true);
            thirdPersonToggle.SetActive(true);
            tex.enabled = false;
        }
        else
        {
        }
        if (tex != null && img != null)
        {
            tex.text  = error;
            img.color = color;
        }
    }
示例#3
0
        void processCDRQueue()
        {
            int tileX = Mathf.FloorToInt(telaraWorldCamPos.x / 256.0f);
            int tileY = Mathf.FloorToInt(telaraWorldCamPos.z / 256.0f);

            cdrJobQueue = cdrJobQueue.OrderBy(x => Vector2.Distance(new Vector2(tileX, tileY), new Vector2(x.Key, x.Value))).ToList();
            while (runningTerrainThreads < MAX_TERRAIN_THREADS && cdrJobQueue.Count() > 0)
            {
                KeyValuePair <int, int> job = cdrJobQueue[0];
                cdrJobQueue.RemoveAt(0);
                int tx = job.Key;
                int ty = job.Value;
                runningTerrainThreads++;
                //Debug.Log("Starting thread for CDR job[" + tx + "," + ty + "]");

                System.Threading.Thread m_Thread = new System.Threading.Thread(() =>
                {
                    try
                    {
                        SCG.List <ObjectPosition> objs = new SCG.List <ObjectPosition>();
                        CDRParse.doWorldTile(AssetDatabaseInst.DB, DBInst.inst, GameWorld.worldName, tx * 256, ty * 256, (p) =>
                        {
                            objs.Add(p);
                        });
                        lock (objectPositions)
                        {
                            objectPositions.AddRange(objs);
                        }
                    }
                    finally
                    {
                        runningTerrainThreads--;
                    }
                });
                m_Thread.Priority = (System.Threading.ThreadPriority)ProgramSettings.get("MAP_LOAD_THREAD_PRIORITY", (int)System.Threading.ThreadPriority.Normal);
                m_Thread.Start();
            }
        }
示例#4
0
    // Use this for initialization
    void Start()
    {
        // prime the GUID random number generator
        Guid.NewGuid();

        GameObject lodSliderObj = GameObject.Find("LODSlider");

        if (lodSliderObj != null)
        {
            Slider lodslider = lodSliderObj.GetComponent <Slider>();
            this.LODCutoff  = PlayerPrefs.GetFloat("worldLodSlider", 0.033f);
            lodslider.value = this.LODCutoff;
            Debug.Log("Read lodcutoff:" + LODCutoff);
        }


        charC = GameObject.Find("ThirdPersonController");
        if (charC != null)
        {
            tpuc   = charC.GetComponent <ThirdPersonUserControl>();
            tpucRB = charC.GetComponent <Rigidbody>();
            charC.SetActive(false);
        }
        GameObject dropdownObj = GameObject.Find("SpawnDropdown");

        MAX_NODE_PER_FRAME = ProgramSettings.get("MAX_NODE_PER_FRAME", 15000);
        setCameraLoc(GameWorld.initialSpawn);
        map = CDRParse.getMap(GameWorld.worldName);

        if (dropdownObj != null)
        {
            dropdown = dropdownObj.GetComponent <Dropdown>();

            zoneMeshes = GameObject.Find("ZoneMeshes");
            zoneMeshes.SetActive(false);
            Material zoneBlockMaterial = Material.Instantiate(Resources.Load <Material>("borderzone"));

            zoneText = GameObject.Find("ZoneText").GetComponent <Text>();
            foreach (Zone z in map.zones)
            {
                //Debug.Log("creating zone:" + z._113Key);
                SCG.List <Vector3> points = z.points;
                GameObject         zone   = new GameObject("zone:" + z._113Key);

                PolygonCollider2D p = zone.AddComponent <PolygonCollider2D>();
                p.points   = points.Select(x => new Vector2(x.x, x.z)).ToArray();
                z.collider = p;

                GameObject zoneMesh = new GameObject("zone:" + z._113Key);
                if (z._113Key == 1802934646)
                {
                    MeshFilter   mf   = zoneMesh.AddComponent <MeshFilter>();
                    MeshRenderer mr   = zoneMesh.AddComponent <MeshRenderer>();
                    Mesh         mesh = ExtrudeSprite.CreateMesh(p.points, -10000.2f, 10000.2f);

                    mf.sharedMesh     = mesh;
                    mr.sharedMaterial = zoneBlockMaterial;


                    zoneMesh.transform.SetParent(zoneMeshes.transform);
                    zoneMesh.transform.localRotation = Quaternion.identity;
                    zoneMesh.transform.localPosition = Vector3.zero;
                }
            }
            foreach (Scene z in map.scenes)
            {
                SCG.List <Vector3> points = z.points;
                GameObject         zone   = new GameObject("scene:" + z._114Key);

                PolygonCollider2D p = zone.AddComponent <PolygonCollider2D>();
                p.points   = points.Select(x => new Vector2(x.x, x.z)).ToArray();
                z.collider = p;
            }

            dropdown.gameObject.SetActive(false);
            dropdown.options.Clear();
            int startIndex = 0;
            int i          = 0;
            foreach (WorldSpawn spawn in GameWorld.getSpawns())
            {
                if (spawn.spawnName.Equals(GameWorld.initialSpawn.spawnName))
                {
                    startIndex = i;
                }
                DOption option = new DOption(spawn.worldName + " - " + spawn.spawnName + " - " + spawn.pos, false);
                dropdown.options.Add(option);
                i++;
            }
            dropdown.value = startIndex;
            dropdown.gameObject.SetActive(true);
            dropdown.GetComponent <FavDropDown>().doOptions();
            dropdown.RefreshShownValue();
        }
        if (bigMap != null)
        {
            bigMap.setWorld(GameWorld.worldName);

            bigMap.OnSpawnClick += (s) =>
            {
                setCameraLoc(s);
            };
        }
    }