diff --git a/Assets/Prefabs/UI/Base UI Button.prefab b/Assets/Prefabs/UI/Base UI Button.prefab index bfe5e15..a946f7c 100755 --- a/Assets/Prefabs/UI/Base UI Button.prefab +++ b/Assets/Prefabs/UI/Base UI Button.prefab @@ -109,8 +109,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: -1.5} + m_SizeDelta: {x: -10, y: -7} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &6470588784042037404 CanvasRenderer: diff --git a/Assets/Scenes/Workspace.unity b/Assets/Scenes/Workspace.unity index ab1efcd..928abcf 100755 --- a/Assets/Scenes/Workspace.unity +++ b/Assets/Scenes/Workspace.unity @@ -539,6 +539,7 @@ MonoBehaviour: - {fileID: 21300000, guid: b77c21ad464eb5c45a4a1f8f0f276965, type: 3} - {fileID: 21300000, guid: 3aa2b0925144bb54193b25bf37dddf91, type: 3} - {fileID: 21300000, guid: 9ade58a4f17ab5a49bebda61d08ee88e, type: 3} + - {fileID: 21300000, guid: b5f750949f494f64b8baf51ddce0cddc, type: 3} --- !u!4 &535412053 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Workspace/ClockGate.cs b/Assets/Scripts/Workspace/ClockGate.cs new file mode 100755 index 0000000..da9f7d0 --- /dev/null +++ b/Assets/Scripts/Workspace/ClockGate.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace CompuLogic.Workspace +{ + public class ClockGate : Gate + { + #region Unity Properties + + #endregion + + #region Public Properties + + public bool State { get; set; } = true; + + #endregion + + #region Private Properties + + private Anchor OutputAnchor { + get + { + if (_outputAnchor == null) + _outputAnchor = Anchors.FirstOrDefault(g => g.Name == "Q"); + return _outputAnchor; + } + } + private Anchor _outputAnchor; + + #endregion + + #region Unity Methods + + private void Start() + { + Utils.RandomName("Input", gameObject); + } + + private void Update() + { + UpdateState(); + } + + #endregion + + #region Public Methods + + #endregion + + #region Private Methods + + private void UpdateState() + { + if ((Sprite.Hovering || OutputAnchor.Hovering) && PointerManager.Instance.DoubleClick()) + { + State = !State; + } + + if (State) + { + OutputAnchor.Activated = Mathf.Repeat(Time.time, CustomProperties[0]) >= CustomProperties[0] * 0.5f; + } + } + + #endregion + } + +} diff --git a/Assets/Scripts/Workspace/ClockGate.cs.meta b/Assets/Scripts/Workspace/ClockGate.cs.meta new file mode 100755 index 0000000..2cf4438 --- /dev/null +++ b/Assets/Scripts/Workspace/ClockGate.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e96ac3a8b8e052746ab27ed052bf1f13 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Workspace/Gate.cs b/Assets/Scripts/Workspace/Gate.cs index 1bbcab7..d1407af 100755 --- a/Assets/Scripts/Workspace/Gate.cs +++ b/Assets/Scripts/Workspace/Gate.cs @@ -20,9 +20,9 @@ namespace CompuLogic.Workspace { get { - if(_anchors == null) - _anchors = GetComponentsInChildren().ToList(); - return _anchors; + if(_anchors == null) + _anchors = GetComponentsInChildren().ToList(); + return _anchors; } } public IEnumerable InputAnchors => Anchors.Where(a => a.IsInput); @@ -30,30 +30,31 @@ namespace CompuLogic.Workspace public BoxCollider2D Box { get { - if (_box == null) - _box = GetComponentInChildren(); - return _box; + if (_box == null) + _box = GetComponentInChildren(); + return _box; } } public GateSprite Sprite { get { - if(_sprite == null) - _sprite = GetComponentInChildren(); - return _sprite; + if(_sprite == null) + _sprite = GetComponentInChildren(); + return _sprite; } } public GateDefinition Definition { get { - if(_definition == null) - _definition = GateDefinition.Get(GateType, this); - return _definition; + if(_definition == null) + _definition = GateDefinition.Get(GateType, this); + return _definition; } } public string UIName { get; set; } + public List CustomProperties; #endregion @@ -89,7 +90,7 @@ namespace CompuLogic.Workspace return !Definition.HasState && ( InputAnchors.Contains(target) || InputAnchors.Any(a => a.HasInputAnchor(target)) - ); + ); } #endregion @@ -101,8 +102,8 @@ namespace CompuLogic.Workspace var state = Definition.GetState(this).ToInt(); if (state != _lastState) { - Definition.Compute(this); - _lastState = state; + Definition.Compute(this); + _lastState = state; } } diff --git a/Assets/Scripts/Workspace/GatePrefabFactory.cs b/Assets/Scripts/Workspace/GatePrefabFactory.cs index bee74bf..576e474 100755 --- a/Assets/Scripts/Workspace/GatePrefabFactory.cs +++ b/Assets/Scripts/Workspace/GatePrefabFactory.cs @@ -64,6 +64,7 @@ namespace CompuLogic.Workspace } gate.GateType = (GateType)key; + gate.CustomProperties = item.Properties; gate.UIName = string.IsNullOrEmpty(item.Name) ? gate.GateType.ToString() : item.Name; @@ -146,6 +147,7 @@ namespace CompuLogic.Workspace public List Output { get; set; } public List InputAnchors => Input.Select(i => i.Split(new char[0])).Select(GateBookItemAnchor.Get).ToList(); public List OutputAnchors => Output.Select(i => i.Split(new char[0])).Select(GateBookItemAnchor.Get).ToList(); + public List Properties; } public class GateBookItemAnchor diff --git a/Assets/Scripts/Workspace/Gates/GateDefinitionList.cs b/Assets/Scripts/Workspace/Gates/GateDefinitionList.cs index af2f273..32d35f2 100755 --- a/Assets/Scripts/Workspace/Gates/GateDefinitionList.cs +++ b/Assets/Scripts/Workspace/Gates/GateDefinitionList.cs @@ -15,12 +15,20 @@ namespace CompuLogic.Workspace.Gates #endregion - #region 100 - Special + #region 100 - I/O internal class INGate : NoneGate { } internal class OUTGate : NoneGate { } + internal class CLK1Gate : NoneGate { } + + internal class CLK2Gate : NoneGate { } + + internal class CLK3Gate : NoneGate { } + + internal class CLK4Gate : NoneGate { } + #endregion #region 200 - Basic diff --git a/Assets/Scripts/Workspace/Gates/GateType.cs b/Assets/Scripts/Workspace/Gates/GateType.cs index f64ff2c..a8044df 100755 --- a/Assets/Scripts/Workspace/Gates/GateType.cs +++ b/Assets/Scripts/Workspace/Gates/GateType.cs @@ -7,6 +7,10 @@ // 100 - I/O IN = 100, OUT = 110, + CLK1 = 120, + CLK2 = 130, + CLK3 = 140, + CLK4 = 150, // 200 - Basic BUF = 200, AND = 210, diff --git a/Assets/Texts/gates.yaml b/Assets/Texts/gates.yaml index b61fdae..102c527 100755 --- a/Assets/Texts/gates.yaml +++ b/Assets/Texts/gates.yaml @@ -13,6 +13,42 @@ list: class: OutputGate input: - A 1.5 1.5 W big + 120: + skin: clk + name: CLK 1Hz + width: 3 + height: 3 + class: ClockGate + output: + - Q 2.5 1.5 E + properties: [ 1 ] + 130: + skin: clk + name: CLK 5Hz + width: 3 + height: 3 + class: ClockGate + output: + - Q 2.5 1.5 E + properties: [ 0.2 ] + 140: + skin: clk + name: CLK 10Hz + width: 3 + height: 3 + class: ClockGate + output: + - Q 2.5 1.5 E + properties: [ 0.1 ] + 150: + skin: clk + name: CLK 50Hz + width: 3 + height: 3 + class: ClockGate + output: + - Q 2.5 1.5 E + properties: [ 0.02 ] 200: skin: buffer width: 3 diff --git a/Assets/Textures/Gates/clk.png b/Assets/Textures/Gates/clk.png new file mode 100644 index 0000000..acab177 Binary files /dev/null and b/Assets/Textures/Gates/clk.png differ diff --git a/Assets/Textures/Gates/clk.png.meta b/Assets/Textures/Gates/clk.png.meta new file mode 100755 index 0000000..7cb2d9e --- /dev/null +++ b/Assets/Textures/Gates/clk.png.meta @@ -0,0 +1,130 @@ +fileFormatVersion: 2 +guid: b5f750949f494f64b8baf51ddce0cddc +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 1 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/SVG/Gates/clk.svg b/SVG/Gates/clk.svg new file mode 100755 index 0000000..6d7e10d --- /dev/null +++ b/SVG/Gates/clk.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TODO.txt b/TODO.txt index a78be6a..e36f5ca 100755 --- a/TODO.txt +++ b/TODO.txt @@ -2,7 +2,6 @@ TODO -(1) finish gate book -(1) mux/demux svg -(1) change fonts --(3) clocks (1Hz, 5Hz, 10Hz, etc.) -(3) cable overlap (same/diff circuit) -(5) cable management -(5) buses