Exemplo n.º 1
0
        //---------------------------------------------------------------------
        public LoaderTicket getTexture(string name, string path, Action <LoaderTicket, Texture> call_back)
        {
            Texture texture = null;

            MapTexture.TryGetValue(name, out texture);

            LoaderTicket tick = null;

            if (texture == null)
            {
                tick = CasinosContext.Instance.AsyncAssetLoadGroup.asyncLoadAsset(
                    path, name, _eAsyncAssetLoadType.LocalBundleAsset,
                    (LoaderTicket ticket, string path_ex, UnityEngine.Object obj) =>
                {
                    texture          = (Texture)obj;
                    MapTexture[name] = texture;
                    call_back(ticket, texture);
                });
            }
            else
            {
                call_back(tick, texture);
            }

            return(tick);
        }
Exemplo n.º 2
0
        private MapOverlay OverlayTitlebarMenuTutorial()
        {
            if (API.State.WindowMode != WindowMode.Overlay)
            {
                return(this.NormalOverlayModeTutorial());
            }
            var items = new GuiOverlay();

            items.MapItems.Add(this.GetTutorialStamp(500, 200));
            int center = API.UiElements.TileDisplay.Width / 2;

            var tex = new MapTexture
            {
                Texture           = API.Content.Textures.ArrowUp,
                PositionAlignment = MapItemAlignment.Top | MapItemAlignment.Center,
                Size     = new Vector2(128, 128),
                Position = new PositionDefinition {
                    Type = DrawMode.ViewPort, X = center, Y = 0
                },
            };

            items.MapItems.Add(tex);

            var txts = new MapTextBuilder(FontType.GuiNormal, Color.White, Color.Black, true, MapItemAlignment.Top | MapItemAlignment.Left);

            txts.Text("Tutorial: Overlay Menu", textColor: Color.Red, font: FontType.GuiXLarge).Break();
            txts.Text("The Overlay Menu provides quick access to many useful controls. You may access it by right-clicking the title bar.", 400).Break();
            txts.Break();
            txts.Text("Please open the Overlay Menu now.", textColor: Color.Green).Break();
            items.MapItems.AddRange(txts.ToMapItem(DrawMode.ViewPort, (int)(this.TutorialFramePosition.X - items.MapItems.First().Size.X / 2.5), this.TutorialFramePosition.Y));

            return(items);
        }
Exemplo n.º 3
0
 //---------------------------------------------------------------------
 public void DestroyTexture(string name, bool destory_asset)
 {
     MapTexture.TryGetValue(name, out Texture texture);
     if (texture != null)
     {
         GameObject.DestroyImmediate(texture, destory_asset);
     }
 }
Exemplo n.º 4
0
    public bool LoadMapTextures()
    {
        foreach (Lump l in WadLoader.lumps)
        {
            if (l.lumpName == "TEXTURE1")
            {
                int p   = 0;
                int num = ByteReader.ReadInt32(l.data, ref p);

                int[] offsets = new int[num];
                for (int i = 0; i < num; i++)
                {
                    offsets[i] = ByteReader.ReadInt32(l.data, ref p);
                }

                MapTextures.Clear();
                for (int i = 0; i < num; i++)
                {
                    p = offsets[i];

                    MapTexture t = new MapTexture
                    {
                        textureName = ByteReader.ReadName8(l.data, ref p),

                        masked          = ByteReader.ReadInt32(l.data, ref p),
                        width           = ByteReader.ReadInt16(l.data, ref p),
                        height          = ByteReader.ReadInt16(l.data, ref p),
                        columnDirectory = ByteReader.ReadInt32(l.data, ref p),
                        patches         = new MapPatch[ByteReader.ReadInt16(l.data, ref p)]
                    };

                    for (int j = 0; j < t.patches.Length; j++)
                    {
                        t.patches[j] = new MapPatch
                        {
                            originx  = ByteReader.ReadShort(l.data, ref p),
                            originy  = ByteReader.ReadShort(l.data, ref p),
                            number   = ByteReader.ReadInt16(l.data, ref p),
                            stepdir  = ByteReader.ReadInt16(l.data, ref p),
                            colormap = ByteReader.ReadInt16(l.data, ref p)
                        }
                    }
                    ;

                    MapTextures.Add(t);
                }

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 5
0
        public MapTexture GetTutorialStamp(int width, int height)
        {
            int posX = API.UiElements.TileDisplay.Width / 2;
            int posY = API.UiElements.TileDisplay.Height / 3;


            var tex = new MapTexture
            {
                Texture  = API.Content.Textures.TutorialFrame,
                Position = new PositionDefinition {
                    Type = DrawMode.ViewPort, X = posX, Y = posY - 15
                },
                Size = new Vector2(width, height),
                PositionAlignment = MapItemAlignment.Top
            };

            return(tex);
        }
Exemplo n.º 6
0
        //---------------------------------------------------------------------
        public void LoadTextureAsync(string name, string path, Action <Texture> call_back)
        {
            MapTexture.TryGetValue(name, out Texture texture);

            if (texture == null)
            {
                if (MbAsyncLoadAssets == null)
                {
                    var go = GameObject.Find("Launch");
                    MbAsyncLoadAssets = go.GetComponent <MbAsyncLoadAssets>();
                }

                MbAsyncLoadAssets.LocalLoadTextureFromAbAsync(path, name, call_back);
            }
            else
            {
                call_back(texture);
            }
        }
Exemplo n.º 7
0
        public IEnumerable <MapOverlay> GetCustomOverlay()
        {
            MapOverlay overlay = new MapOverlay();

            foreach (PmvNetCharacterInfo character in this.characters.Values.ToArray())
            {
                var texture = new MapTexture()
                {
                    Texture           = API.Content.Textures.CharacterLocator,
                    KeyColor          = this.locatorColor,
                    Position          = new PositionDefinition(character.Zone, character.X, character.Z),
                    PositionAlignment = MapItemAlignment.Center,
                };

                var txt = new MapText
                {
                    Position          = new PositionDefinition(),
                    PositionAlignment = MapItemAlignment.Center,
                    Text         = character.Name,
                    TextColor    = texture.KeyColor,
                    OutlineColor = Color.Black,
                    Outline      = true,
                    Font         = API.Content.Fonts.GetFont(this.CharacterLocatorFont)
                };

                var mpt = new MapTextureText(texture, txt, 1)
                {
                    PositionAlignment = MapItemAlignment.Bottom | MapItemAlignment.Center,
                };

                overlay.MapItems.Add(mpt);
            }
            yield return(overlay);

            yield break;
        }
Exemplo n.º 8
0
 //---------------------------------------------------------------------
 public bool haveTexture(string name)
 {
     return(MapTexture.ContainsKey(name));
 }
Exemplo n.º 9
0
        private IMapItem[] GetCharacterLocators()
        {
            var mapTextureTexts = new List <IMapItem>();

            if (API.State.PlayerInfo.Count == 0)
            {
                return(new MapTexture[0]);
            }

            var characters = API.State.PlayerInfo.Values.ToArray();

            IMapItem activeTex = null;

            foreach (var character in characters)
            {
                var  activeCharacter = API.AoHook.GetActiveCharacter();
                bool isActive        = character.Identity == activeCharacter;
                if (character == null || character.Zone == null || character.Position == null || character.Name == null)
                {
                    continue;
                }
                if (!character.IsHooked && !this.DrawOfflineCharacters)
                {
                    // We ain't tracking offline characters.
                    continue;
                }

                var charColor = Color.Yellow;
                if (this.HighlightActiveCharacter && !isActive)
                {
                    charColor = new Color(255, 255, 156);
                }

                var texture = new MapTexture()
                {
                    Texture           = API.Content.Textures.CharacterLocator,
                    KeyColor          = charColor,
                    Position          = new PositionDefinition(character.Zone.ID, character.Position.X, character.Position.Z),
                    PositionAlignment = MapItemAlignment.Center,
                };

                if (!character.IsHooked)
                {
                    texture.KeyColor = Color.Gray;
                }

                var charRealPos = texture.Position.GetPosition();

                var txt = new MapText
                {
                    Position          = new PositionDefinition(),
                    PositionAlignment = MapItemAlignment.Center,
                    Text         = character.Name,
                    TextColor    = charColor,
                    OutlineColor = Color.Black,
                    Outline      = true,
                    Font         = API.Content.Fonts.GetFont(this.CharacterLocatorFont)
                };

                if (this.DrawCharacterDimension)
                {
                    txt.Text += " (" + character.Dimension.ToString().Substring(0, 1) + ")";
                }

                if (!character.IsHooked)
                {
                    txt.TextColor    = Color.LightGray;
                    txt.OutlineColor = Color.Gray;
                }
                var mpt = new MapTextureText(texture, txt, 1)
                {
                    PositionAlignment = MapItemAlignment.Bottom | MapItemAlignment.Center,
                };

                if (!isActive)
                {
                    mapTextureTexts.Add(mpt);
                }
                else
                {
                    activeTex = mpt;
                }
            }

            if (activeTex != null)
            {
                mapTextureTexts.Add(activeTex);
            }
            return(mapTextureTexts.ToArray());
        }
Exemplo n.º 10
0
    void ReadWADTextures()
    {
        List <DrctEntry> texLumps = new List <DrctEntry>();


        foreach (DrctEntry entry in newWad.directory)//Find texture's lumps
        {
            if (entry.name.StartsWith("TEXTURE"))
            {
                texLumps.Add(entry);
            }
        }

        foreach (DrctEntry texEntry in texLumps)
        {
            TEXTUREx newTexture = new TEXTUREx();
            int      texOfs     = 0;

            byte[] tbytes = new byte[texEntry.size];


            wadOpener.Position = texEntry.filepos;
            wadOpener.Read(tbytes, 0, tbytes.Length);



            //Header////
            newTexture.numTextures = BitConverter.ToInt32(tbytes, 0);

            for (int i = 4; i <= (4 * newTexture.numTextures); i += 4)
            {
                newTexture.offset.Add(BitConverter.ToInt32(tbytes, i));
            }

            texOfs = (newTexture.numTextures * 4) + 4; //start of maptexture_t?????


            int lastPatchCount = 0;

            //for every texture
            foreach (int ofs in newTexture.offset)
            {
                MapTexture mtex = new MapTexture();

                //read the info
                mtex.name   = new String(System.Text.Encoding.ASCII.GetChars(tbytes, ofs, 8));
                mtex.masked = BitConverter.ToBoolean(tbytes, ofs + 8);
                mtex.width  = BitConverter.ToInt16(tbytes, ofs + 12);
                mtex.height = BitConverter.ToInt16(tbytes, ofs + 14);
                //mtex.columndirectory = BitConverter.ToInt32(tbytes, ofs + 16);
                mtex.patchCount = BitConverter.ToInt16(tbytes, ofs + 20);
                lastPatchCount  = mtex.patchCount;

                mtex.name = mtex.name.Replace("\0", "");

                UsedImages.Add(mtex.name);

                for (int a = ofs + 22; a < ofs + 22 + (10 * mtex.patchCount); a += 10)
                {
                    MapPatch mPatch = new MapPatch();

                    mPatch.originx = (int)BitConverter.ToInt16(tbytes, a);
                    mPatch.originy = (int)BitConverter.ToInt16(tbytes, a + 2);
                    mPatch.patch   = (int)BitConverter.ToInt16(tbytes, a + 4);
                    mtex.mPatch.Add(mPatch);
                }

                newTexture.mtex.Add(mtex);                                   //store the info in newTexture.mtex

                Color32[,] texPixels = new Color32[mtex.width, mtex.height]; //store the pixels for the texture (L->R, U->D)
                bool trans = false;

                foreach (MapPatch mpatch in mtex.mPatch) //for each patch in the texture
                {
                    int width  = newWad.patches[mpatch.patch].GetLength(0);
                    int height = newWad.patches[mpatch.patch].GetLength(1);

                    for (int x = 0; x < width; x++)      //for each width pixel
                    {
                        for (int y = 0; y < height; y++) //for each height pixel
                        {
                            Color pixel = newWad.patches[mpatch.patch][x, (height - 1) - y];
                            int   xofs  = x + mpatch.originx;
                            int   yofs  = y + mpatch.originy;

                            if (pixel == Color.clear)
                            {
                                trans = true;
                            }

                            if (pixel.a > 0 && xofs >= 0 && yofs >= 0 && xofs < mtex.width && yofs < mtex.height)
                            {
                                texPixels[xofs, yofs] = pixel;
                            }
                        }
                    }
                }

                Color[]  texPix = new Color[mtex.width * mtex.height];
                Material newMat;

                if (!trans)
                {
                    newMat = new Material(DoomShader);
                }
                else
                {
                    newMat = new Material(DoomShaderTransparent);
                }

                for (int i = 0; i < mtex.height; i++)
                {
                    for (int j = 0; j < mtex.width; j++)
                    {
                        // Debug.Log(i * mtex.height + j);
                        texPix[i * mtex.width + j] = texPixels[j, i]; //collapse the 2Darry "texPixels" to a 1D array "texPix"
                    }
                }
                Texture2D newTex = new Texture2D(mtex.width, mtex.height, TextureFormat.RGBA32, false);
                newTex.filterMode = FilterMode.Point;
                newTex.SetPixels(texPix);
                newTex.Apply();
                newTex.name        = mtex.name;
                newMat.mainTexture = newTex;
                newWad.textures.Add(newTex.name, newMat);
            }
        }
    }
Exemplo n.º 11
0
    public bool LoadMapTextures()
    {
        foreach (Lump l in WadLoader.lumps)
        {
            if (l.lumpName == "TEXTURE1")
            {
                int p   = 0;
                int num = (int)(l.data[p++] | (int)l.data[p++] << 8 | (int)l.data[p++] << 16 | (int)l.data[p++] << 24);

                int[] offsets = new int[num];
                for (int i = 0; i < num; i++)
                {
                    offsets[i] = (int)(l.data[p++] | (int)l.data[p++] << 8 | (int)l.data[p++] << 16 | (int)l.data[p++] << 24);
                }

                MapTextures.Clear();
                for (int i = 0; i < num; i++)
                {
                    p = offsets[i];
                    MapTexture t = new MapTexture();

                    t.textureName = Encoding.ASCII.GetString(new byte[]
                    {
                        l.data[p++],
                        l.data[p++],
                        l.data[p++],
                        l.data[p++],
                        l.data[p++],
                        l.data[p++],
                        l.data[p++],
                        l.data[p++]
                    }).TrimEnd('\0').ToUpper();

                    t.masked          = (int)(l.data[p++] | (int)l.data[p++] << 8 | (int)l.data[p++] << 16 | (int)l.data[p++] << 24);
                    t.width           = (int)(l.data[p++] | (int)l.data[p++] << 8);
                    t.height          = (int)(l.data[p++] | (int)l.data[p++] << 8);
                    t.columnDirectory = (int)(l.data[p++] | (int)l.data[p++] << 8 | (int)l.data[p++] << 16 | (int)l.data[p++] << 24);
                    int patchCount = (int)(l.data[p++] | (int)l.data[p++] << 8);
                    t.patches = new MapPatch[patchCount];

                    for (int j = 0; j < patchCount; j++)
                    {
                        MapPatch patch = new MapPatch();

                        patch.originx  = (short)(l.data[p++] | (short)l.data[p++] << 8);
                        patch.originy  = (short)(l.data[p++] | (short)l.data[p++] << 8);
                        patch.number   = (int)(l.data[p++] | (int)l.data[p++] << 8);
                        patch.stepdir  = (int)(l.data[p++] | (int)l.data[p++] << 8);
                        patch.colormap = (int)(l.data[p++] | (int)l.data[p++] << 8);

                        t.patches[j] = patch;
                    }

                    MapTextures.Add(t);
                }

                return(true);
            }
        }

        return(false);
    }
        private MapOverlay GenerateTowerFieldInfo(Dimension dimension)
        {
            var overlay = new MapOverlay
            {
                Name = "LcaInfo",
            };

            // Get tower data.
            var qb = new UriQueryBuilder();
            {
                dynamic q = qb;
                q.d        = (int)dimension;
                q.output   = "xml";
                q.limit    = 300;
                q.minlevel = this.LcaMinLevel;
                q.maxlevel = this.LcaMaxLevel;
            }

            var towerData = API.XmlCache.Get <TowerSites>().Request(
                Demoder.Common.CacheFlags.Default,
                qb.ToUri(new Uri(twTowerDistribution)),
                dimension.ToString(),
                this.LcaMinLevel.ToString(),
                this.LcaMaxLevel.ToString());

            if (towerData == null)
            {
                return(null);
            }
            foreach (var site in towerData.Sites)
            {
                var tex = new MapTexture
                {
                    Position          = new PositionDefinition(site.ZoneID, site.CenterX, site.CenterY),
                    Texture           = new TextureDefinition(TextureType.Content, "TowerTexture"),
                    Size              = new Vector2(8, 8),
                    PositionAlignment = MapItemAlignment.Center | MapItemAlignment.Bottom,
                };

                // Set texture color
                switch (site.Faction)
                {
                case Common.AO.Faction.Neutral:
                    //tex.KeyColor = Color.White;
                    tex.KeyColor = Color.LightGray;
                    break;

                case Common.AO.Faction.Clan:
                    tex.KeyColor = Color.Orange;
                    break;

                case Common.AO.Faction.Omni:
                    tex.KeyColor = Color.SkyBlue;
                    break;

                default:
                    tex.KeyColor = Color.Purple;
                    break;
                }

                MapText text = null;
                if (this.ShowNames)
                {
                    text = new MapText
                    {
                        Font    = API.Content.Fonts.GetFont(this.LcaOwnerFont),
                        Outline = true,
                        Text    = site.Guild
                    };

                    // Set text color
                    switch (site.Faction)
                    {
                    case Common.AO.Faction.Neutral:
                        text.TextColor    = Color.LightGray;
                        text.OutlineColor = Color.Black;
                        break;

                    case Common.AO.Faction.Clan:
                        text.TextColor    = Color.Orange;
                        text.OutlineColor = Color.Black;
                        break;

                    case Common.AO.Faction.Omni:
                        text.TextColor    = Color.SkyBlue;
                        text.OutlineColor = Color.Black;
                        break;

                    default:
                        tex.KeyColor = Color.Purple;
                        break;
                    }
                }



                overlay.MapItems.Add(new MapTextureText(tex, text)
                {
                    PositionAlignment = MapItemAlignment.Bottom
                });
            }
            return(overlay);
        }
Exemplo n.º 13
0
 private void Awake()
 {
     Instance = this;
 }
Exemplo n.º 14
0
 public void MapTextureThread()
 {
     MapTexture.Load(currentMapTexture.mapName, new Vector2(currentMapTexture.x, currentMapTexture.y));
 }
Exemplo n.º 15
0
    // Use this for initialization
    IEnumerator Start()
    {
        Loom.Current.GetComponent<Loom>();
        layerMask = 1 << 8;
        wayList = new List<long>();
        //StartCoroutine(LoadChunk(-8.6f,41.1767f,-8.55f,41.1923f));
        MapChunkLoader.precision = GeoUTMConverter.Precision;
        GeoUTMConverter latlon2Utm = new GeoUTMConverter();
        latlon2Utm.ToUTM((minimumLat+maximumLat)/2f,(minimumLon+maximumLon)/2f);

        transform.position = new Vector3(((float)latlon2Utm.X - offsetPositionX), -0.1f, ((float)latlon2Utm.Y - offsetPositionZ));

        GameObject floor = new GameObject();
        floor.name = "Ground";
        floor.isStatic = true;

        CreateGround cg = new CreateGround();
        cg.maxLat = maximumLat + 0.01f * (maximumLat - minimumLat); //0.0001f;
        cg.maxLon = maximumLon + 0.01f * (maximumLat - minimumLat);
        cg.minLat = minimumLat - 0.01f * (maximumLat - minimumLat);
        cg.minLon = minimumLon - 0.01f * (maximumLat - minimumLat);
        cg.numberOfDivisions = numberOfDivisions;

        MeshFilter mf = floor.AddComponent<MeshFilter>();

        MeshRenderer mr = floor.AddComponent<MeshRenderer>();
        mr.material = groundMaterial;
        floor.transform.position = transform.position;
        floor.transform.parent = transform;
        floor.layer = LayerMask.NameToLayer("RayCast");

        string floorPath = Application.persistentDataPath + "Assets/Resources/Objs/" + cg.maxLat + "I" + cg.maxLon + ".obj";

        if (!File.Exists(floorPath)) // If the file isn't cached we calculate everything and then we cache it
        {
            mf.sharedMesh = cg.GetGroundMesh();
            if (exportObjs)
            {
                ObjExporter oe = new ObjExporter();
                oe.MeshToFile(mf, floorPath);
            }
        }
        else
        {
            ObjImporter oi = new ObjImporter();
            StartCoroutine(oi.FileToMesh("file://" + floorPath));

            while (oi._myMesh == null)
            {
                yield return null;
            }

            mf.sharedMesh = oi._myMesh;
            Debug.LogWarning("Loaded Ground Chunk from cache");
        }

        //Texture2D t = new Texture2D(1024, 1024);

        MapTexture mt = new MapTexture();
        mt.getTexture(cg.minLon.ToString(), cg.minLat.ToString(), cg.maxLon.ToString(), cg.maxLat.ToString(),Application.persistentDataPath,mr.material);
        while (mt.texture == null)
        {
            yield return null;
        }

        //t.LoadImage(mt.ReadFully(mt.mq_dataStream));
        //mr.material.SetTexture("_MainTex", t);

        MeshCollider m = floor.AddComponent<MeshCollider>();
        Loom l = Loom.Current;
        LoadChunk(minimumLon, minimumLat, maximumLon, maximumLat);

        //StartCoroutine();
    }