public virtual void Start() { this.particleTextures = new Texture2D[3]; this.particleTextures[0] = (Texture2D)Resources.Load("Proton_TIF"); this.particleTextures[1] = (Texture2D)Resources.Load("Neutron_TIF"); this.particleTextures[2] = (Texture2D)Resources.Load("Electron_TIF"); if (!this.texture) { this.texture = (Texture2D)Resources.Load("Tray_TIF"); } this.style = new GUIStyle(); this.style.normal.background = this.texture; this.style.border.left = this.style.border.right = this.style.border.top = this.style.border.bottom = this.border; this.contents = new TraySlot[Mathf.RoundToInt(this.dimensions.x * this.dimensions.y)]; int i = 0; while (i < this.contents.Length) { TraySlot s = new TraySlot(); s.type = PType.Empty; s.collider = (DraggableCollider)this.gameObject.AddComponent(typeof(DraggableCollider)); s.collider.id = i; s.collider.parent = this; this.contents[i] = s; i++; } }
public void Matched() { TraySlot.Matched(); TraySlot = null; TileSlot = null; QueueFree(); }
public override void Initialize <T>(TraySlot traySlot, T color) { var meshInstance = GetNode <MeshInstance>("./MeshInstance"); var colorEnum = (Color)(int)(object)color; Color = colorEnum; var meshMaterial = meshInstance.Mesh.SurfaceGetMaterial(0); if (meshMaterial is SpatialMaterial spatialMaterial) { // the material must be duplicated for the mesh instance, otherwise the changes will affect all instances of the mesh var instanceSpatialMaterial = spatialMaterial.Duplicate() as SpatialMaterial; instanceSpatialMaterial.AlbedoColor = ColorTileMaterials.Colors[colorEnum]; meshInstance.MaterialOverride = instanceSpatialMaterial; } TraySlot = traySlot; }
public override void Initialize <T>(TraySlot traySlot, T symbol) { var meshInstance = GetNode <MeshInstance>("./MeshInstance"); var symbolEnum = (Symbol)(int)(object)symbol; Symbol = symbolEnum; var meshMaterial = meshInstance.Mesh.SurfaceGetMaterial(0); if (meshMaterial is SpatialMaterial spatialMaterial) { // the material must be duplicated for the mesh instance, otherwise the changes will affect all instances of the mesh var instanceSpatialMaterial = spatialMaterial.Duplicate() as SpatialMaterial; // set the UV1 offset so that the Tile displays the correct portion of the texture var uvOffset = SymbolTileMaterials.SymbolTextureUvOffset[symbolEnum]; instanceSpatialMaterial.Uv1Offset = new Vector3(uvOffset.x, uvOffset.y, 0); meshInstance.MaterialOverride = instanceSpatialMaterial; } TraySlot = traySlot; }
public abstract void Initialize <T>(TraySlot traySlot, T tileType) where T : System.Enum;