public static TextureIndex[] RandomizeStrings(TextureIndex[] TI) { List<KeyValuePair<int, TextureIndex>> list = new List<KeyValuePair<int, TextureIndex>>(); // Add all strings from array // Add new random int each time foreach (TextureIndex s in TI) { list.Add(new KeyValuePair<int, TextureIndex>(_random.Next(), s)); } // Sort the list by the random number var sorted = from item in list orderby item.Key select item; // Allocate new string array TextureIndex[] result = new TextureIndex[TI.Length]; // Copy values to array int index = 0; foreach (KeyValuePair<int, TextureIndex> pair in sorted) { result[index] = pair.Value; index++; } // Return copied array return result; }
public TextureMenu(Tile TileSelected, TextureIndex Index ,List<GuiItem> Garbage) : base("TileMenu") { this.Index = Index; this.Garbage = Garbage; this.TileSelected = TileSelected; foreach (TextureEntry Entry in Index.TextureList) { if (TileSelected.Type == TileType.Normal) { if (Entry.Name.StartsWith("Normal")) { MenuItems.Add(new MenuItem(Entry.Name, Entry.Name)); } } else if(TileSelected.Type == TileType.Obstacle) { if (Entry.Name.StartsWith("Obstacle")) { MenuItems.Add(new MenuItem(Entry.Name, Entry.Name)); } } else if (TileSelected.Type == TileType.CreepEnd || TileSelected.Type == TileType.CreepStart || TileSelected.Type == TileType.CreepPath) { if (Entry.Name.StartsWith("Creep")) { MenuItems.Add(new MenuItem(Entry.Name, Entry.Name)); } } } FixAttribute(); }
public BakedEntry( TextureIndex textureIndex, string name, string hashName) { Name = name; //WearableHashId = Guid.Parse(hashName); TextureIndex = textureIndex; }
public void GetMissingDefinitions() { textureIndex = new TextureIndex(); BlockDefinition[] definitions = World.instance.gameObject.GetComponentsInChildren<BlockDefinition>(); foreach (var def in definitions) { if(def.enabled) def.AddToBlocks(); } }
public void GetMissingDefinitions(BlockCollection blockCollection) { TextureIndex = new TextureIndex(); TextureIndex.Initialize(blockCollection); TextureIndex.Load(); foreach (var def in blockCollection.Blocks) { def.AddToBlocks(); } }
public void GetMissingDefinitions() { textureIndex = new TextureIndex(); BlockDefinition[] definitions = World.instance.gameObject.GetComponentsInChildren <BlockDefinition>(); foreach (var def in definitions) { if (def.enabled) { def.AddToBlocks(); } } }
public void AddPolygon(List <VertexPositionNormalTexture> vertices, Polygon polygon, uint textureID) { if (!TextureIndex.TryGetValue(textureID, out var textureIdx)) { textureIdx = (byte)TextureIndex.Count; TextureIndex.Add(textureID, textureIdx); } foreach (var idx in polygon.Indices) { var v = vertices[idx]; Vertices.Add(new VertexPositionNormalTextures(v.Position, v.Normal, v.TextureCoordinate, textureIdx)); } }
public void ToXml(XmlWriter writer) { writer.WriteStartElement("slope"); writer.WriteStartElement("float"); writer.WriteAttributeString("name", "angleDegrees"); writer.WriteAttributeString("value", AngleDegrees.ToString()); writer.WriteEndElement(); writer.WriteStartElement("int"); writer.WriteAttributeString("name", "textureIndex"); writer.WriteAttributeString("value", TextureIndex.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); }
/// <summary> /// Returns the starting index into Instances /// </summary> public int AddParticleSlot(uint textureID, Vector2 dims) { // since we are looping over this, change so dict lookup only happens once if (!TextureIndex.TryGetValue(textureID, out var textureIdx)) { textureIdx = (byte)TextureIndex.Count; TextureIndex.Add(textureID, textureIdx); } var startIdx = Instances.Count; var instance = new ParticleDeclaration(textureIdx, dims); Instances.Add(instance); return(startIdx); }
public static Guid LocalTextureIndexToMagicId(TextureIndex index) { return(Instance.GuidByTextureIndex.ContainsKey(index) ? Instance.GuidByTextureIndex[index] : Guid.Empty); }
public void SetAlpha(int vertIndex, TextureIndex textureIndex, byte opacity) { int index = vertIndex * 16 + (int)textureIndex; alphas[index] = opacity; }
/// <summary> /// Given a texture entry, determine which wearable type owns it. /// </summary> /// <param name="index"></param> /// <returns></returns> public static WearableType GetWearableType(TextureIndex index) { return(Instance.Textures[index].WearableType); }
public void SetIndex(TextureIndex index) { _index = index; }
// Edit Terrain Paint public void Paint(TerrainIndexMapping i, TextureIndex ti, byte opacity) { terrainChunks[i.x, i.y].SetAlpha(i.index, ti, opacity); chunkStatuses[i.x, i.y].needsPaintUpdate = true; }
private void RebakeLayer(TextureIndex index) { RebakeLayer(Baker.BakeTypeFor(index)); }
private int AddImageDownload(TextureIndex index) { UUID image = AgentTextures[(int)index]; if (image != UUID.Zero) { if (!ImageDownloads.ContainsKey(image)) { Log.DebugLog("Downloading layer " + index.ToString()); ImageDownloads.Add(image, index); } return 1; } return 0; }
public void RandomizeTiles() { TextureIndex[] tex = new TextureIndex[grid.Count]; int ind = 0; TextureIndex[] excluded = { TextureIndex.Black, TextureIndex.Empty, TextureIndex.White }; foreach (TextureIndex item in tiles.texture.Keys.Except(excluded)) { tex[ind] = item; tex[ind+6] = item; ind++; } ind = 0; tex = RandomTextureIndexTool.RandomizeStrings(tex); for (int i = 0; i < nRows; i++) { for (int j = 0; j < nCols; j++) { grid[Tuple.Create(j, i)].tile = tex[ind]; ind++; } } }
public EditorWindow(Surface Screen) : base("Map Editor", 640, 800, Screen) { AppsDirectory = Directory.GetCurrentDirectory(); TexIndex = TextureIndex.LoadTextureIndex("../../../../assets/Textures/MapTiles.xml"); Textures = TexIndex.LoadTextures(); map = new Map(); ButtonBg = new BackgroundItem(Color.LightGray); ButtonBg.Width = Width; ButtonBg.Height = 100; ButtonBg.X = 0; ButtonBg.Y = 0; Background = new BackgroundItem(Color.WhiteSmoke); Background.Width = Width; Background.Height = Height; //WinBar = new WindowBar("Map Editor", Width); //WinBar.CloseButton = true; LoadMapButton = new ButtonItem("LoadMap", 120, 22, "Load Map"); LoadMapButton.X = 20; LoadMapButton.Y = 30; SaveMap = new ButtonItem("SaveMap", 120, 22, "Save Map"); SaveMap.X = 146; SaveMap.Y = 30; NewMap = new ButtonItem("NewMap", 120, 22, "New Map"); NewMap.X = 272; NewMap.Y = 30; ChangeMapName = new ButtonItem("ChangeMapName", 140, 22, "Change Map Name"); ChangeMapName.X = 398; ChangeMapName.Y = 30; SetDefaultTexture = new ButtonItem("SetDefaultTexture", 140, 22, "Set Default Texture"); SetDefaultTexture.X = 20; SetDefaultTexture.Y = 4; QuitButton = new ButtonItem("Quit", 100, 22, "Quit"); QuitButton.X = 166; QuitButton.Y = 4; mapRenderer = new MapEditRenderer(map,Textures); mapRenderer.X = 20; mapRenderer.Y = 120; MapGrid = new Grid(40, 40); MapGrid.Width = 40 * map.Columns; MapGrid.Height = 40 * map.Rows; MapGrid.X = 20; MapGrid.Y = 120; MapNameLabel = new LabelItem("Map Name : " + map.MapName); MapNameLabel.X = 16; MapNameLabel.Y = 65; RowLabel = new LabelItem("Row : -"); RowLabel.X = 20; RowLabel.Y = 610; ColumnLabel = new LabelItem("Column : -"); ColumnLabel.X = 20; ColumnLabel.Y = 630; MapNameDialog = new TextInputDialogBox("Map Name", "Map Name"); MapNameDialog.X = (Width - MapNameDialog.Width) / 2; MapNameDialog.Y = (Height - MapNameDialog.Height) / 2; MessageBox = new DialogBox("Message", "Not set"); MessageBox.X = (Width - MessageBox.Width) / 2; MessageBox.Y = (Height - MessageBox.Height) / 2; openFile = new OpenFileDialog(); openFile.InitialDirectory = @"..\..\..\..\Assets\Maps\"; openFile.Multiselect = false; openFile.Title = "Load a Map"; openFile.Filter = "XML T.D. Map (*.xml) | *.xml"; Container.Add(Background); Container.Add(ButtonBg); //Container.Add(WinBar); Container.Add(LoadMapButton); Container.Add(SaveMap); Container.Add(NewMap); Container.Add(ChangeMapName); Container.Add(SetDefaultTexture); Container.Add(QuitButton); Container.Add(MapNameLabel); Container.Add(RowLabel); Container.Add(ColumnLabel); Container.Add(mapRenderer); Container.Add(MapGrid); //Container.Add(MapNameDialog); MapNameDialog.SetEvents(); }
private void RebakeLayer(TextureIndex index) { BakeType bakeType = Baker.BakeTypeFor(index); Dictionary<int, float> paramValues; // Build a dictionary of appearance parameter indices and values from the wearables paramValues=MakeParamValues(); Baker bake = new Baker(Client, bakeType, 0, paramValues); for (int ii = 0; ii < AVATAR_TEXTURE_COUNT; ii++) { if(bakeType==Baker.BakeTypeFor((TextureIndex)ii) && AgentAssets[ii]!=null) { Logger.Log("Adding asset "+AgentAssets[ii].AssetID.ToString()+" to baker",Helpers.LogLevel.Debug); bake.AddTexture((TextureIndex)ii,(AssetTexture)AgentAssets[ii],true); } } UploadBake(bake); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Creates a new SpriteBatch, which is used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); TextureIndex.LoadContent(Content); }
private int AddImageDownload(TextureIndex index) { Guid image = AgentTextures[(int)index]; if (image != Guid.Empty) { if (!ImageDownloads.ContainsKey(image)) { Logger.DebugLog("Downloading layer " + index.ToString(), Client); ImageDownloads.Add(image, index); } return 1; } return 0; }