stateful gates

This commit is contained in:
klemek
2020-12-22 14:14:55 +01:00
parent 0c64c185ab
commit 51b660318e
11 changed files with 196 additions and 126 deletions
+2 -2
View File
@@ -98,7 +98,7 @@ SpriteRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 73ddb2958e9cd451c82f37c26efa5eb0, type: 2}
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
@@ -152,7 +152,7 @@ PolygonCollider2D:
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_AutoTiling: 1
m_Points:
m_Paths:
- - {x: 0, y: 1}
+2 -1
View File
@@ -530,7 +530,7 @@ MonoBehaviour:
GateSprites:
- {fileID: 21300000, guid: 7c428151c48a9e7469e49309fd0842fb, type: 3}
- {fileID: 21300000, guid: 93ae44d6ee7ae4c4bbfef39811752f3a, type: 3}
- {fileID: -620755829403384321, guid: da2a0d4ce655c0d4cbbb94bd47b72db7, type: 3}
- {fileID: 21300000, guid: da2a0d4ce655c0d4cbbb94bd47b72db7, type: 3}
- {fileID: 21300000, guid: 01327adc9a6ecc64f86ce22adff1a362, type: 3}
- {fileID: 21300000, guid: bcba8dfefa97b414f9d2e8ab38cc5e68, type: 3}
- {fileID: 21300000, guid: 6bd139aab8ffc4e46941870cf98a7b92, type: 3}
@@ -565,6 +565,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 11e573998e532eb42bdb43b80953d23f, type: 3}
m_Name:
m_EditorClassIdentifier:
MinDistanceInteracting: 0.5
DoubleClickThreshold: 0.05
DoubleClickDelay: 0.5
DefaultCursor: {fileID: 2800000, guid: 65e646daa3ca2db4f991e6231e8dce8f, type: 3}
+72 -65
View File
@@ -16,6 +16,9 @@ namespace UntitledLogicGame
#region Unity Properties
[Header("Interaction")]
public float MinDistanceInteracting;
[Header("Click")]
public float DoubleClickThreshold;
public float DoubleClickDelay;
@@ -30,8 +33,9 @@ namespace UntitledLogicGame
#region Public Properties
public static Vector3 MousePos { get; set; }
public bool Interacting => _currentCable != null || _currentGate != null;
public bool MovingObject => _currentGate != null;
public bool Interacting => DraggingCable || MovingObject;
public bool DraggingCable => _currentCable != null && (_currentCableInitialMousePos - MousePos).magnitude > MinDistanceInteracting;
public bool MovingObject => _currentGate != null && (_currentGateInitialPos == null || (_currentGateInitialPos.Value - _currentGate.transform.position).magnitude > MinDistanceInteracting);
public bool Clicking => Input.GetButton("Fire1");
public bool DeleteOnRelease { get; set; }
@@ -40,6 +44,7 @@ namespace UntitledLogicGame
#region Private Properties
private Cable _currentCable;
private Vector3 _currentCableInitialMousePos;
private Gate _currentGate;
private Vector3? _currentGateInitialPos;
private Vector3 _currentGateDelta;
@@ -57,11 +62,11 @@ namespace UntitledLogicGame
if (Clicking)
{
UpdateDrag();
UpdateDrag();
}
else
{
UpdateDrop();
UpdateDrop();
}
UpdateCursor();
@@ -78,7 +83,7 @@ namespace UntitledLogicGame
_currentGateInitialPos = created ? (Vector3?)null : _currentGate.transform.position;
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
{
renderer.sortingLayerName = "moving";
renderer.sortingLayerName = "moving";
}
}
@@ -86,8 +91,8 @@ namespace UntitledLogicGame
{
if (_currentGate != null)
{
Destroy(_currentGate.gameObject);
_currentGate = null;
Destroy(_currentGate.gameObject);
_currentGate = null;
}
}
@@ -96,24 +101,24 @@ namespace UntitledLogicGame
if (Clicking)
{
_clicked += Time.deltaTime;
_clicked += Time.deltaTime;
}
else
{
if(_clicked >= DoubleClickThreshold)
{
if(Time.time - _clicktime < DoubleClickDelay)
if(_clicked >= DoubleClickThreshold)
{
_clicked = 0f;
_clicktime = 0f;
return true;
if(Time.time - _clicktime < DoubleClickDelay)
{
_clicked = 0f;
_clicktime = 0f;
return true;
}
else
{
_clicktime = Time.time;
}
}
else
{
_clicktime = Time.time;
}
}
_clicked = 0f;
_clicked = 0f;
}
return false;
}
@@ -133,22 +138,23 @@ namespace UntitledLogicGame
{
var cursor = DefaultCursor;
var position = Vector2.zero;
var interacting = _currentCable != null || _currentGate != null;
if (!Interacting && GameManager.Instance.CurrentAnchor != null || Interacting && _currentCable != null)
if (!interacting && GameManager.Instance.CurrentAnchor != null || _currentCable != null)
{
cursor = PointerCursor;
position = new Vector2(cursor.width / 2f, 0f);
cursor = PointerCursor;
position = new Vector2(cursor.width / 2f, 0f);
}
else if (!Interacting && GameManager.Instance.CurrentGate != null || Interacting && _currentGate != null)
else if (!interacting && GameManager.Instance.CurrentGate != null || _currentGate != null)
{
cursor = MoveCursor;
position = new Vector2(cursor.width / 2f, cursor.height / 2f);
cursor = MoveCursor;
position = new Vector2(cursor.width / 2f, cursor.height / 2f);
}
if(_currentCursor != cursor)
{
Cursor.SetCursor(cursor, position, CursorMode.Auto);
_currentCursor = cursor;
Cursor.SetCursor(cursor, position, CursorMode.Auto);
_currentCursor = cursor;
}
}
@@ -156,21 +162,22 @@ namespace UntitledLogicGame
{
if (_currentCable != null) // Dragging cable
{
_currentCable.FallbackEndPos = MousePos;
_currentCable.FallbackEndPos = MousePos;
}
else if (_currentGate != null) // Dragging gate
{
_currentGate.transform.position = MousePos - _currentGateDelta;
_currentGate.transform.position = MousePos - _currentGateDelta;
}
else if (GameManager.Instance.CurrentAnchor != null) // Dragging new cable
{
_currentCable = Instantiate(GameManager.Instance.CablePrefab, GameManager.Instance.CablesGroup, true);
_currentCable.StartAnchor = GameManager.Instance.CurrentAnchor;
_currentCable.FallbackEndPos = MousePos;
_currentCable = Instantiate(GameManager.Instance.CablePrefab, GameManager.Instance.CablesGroup, true);
_currentCable.StartAnchor = GameManager.Instance.CurrentAnchor;
_currentCable.FallbackEndPos = MousePos;
_currentCableInitialMousePos = MousePos;
}
else if (GameManager.Instance.CurrentGate != null) // Dragging new gate
{
DragGate(GameManager.Instance.CurrentGate, false);
DragGate(GameManager.Instance.CurrentGate, false);
}
}
@@ -178,48 +185,48 @@ namespace UntitledLogicGame
{
if (_currentCable != null) // Dropping cable
{
if (GameManager.Instance.CurrentAnchor == null || _currentCable.StartAnchor.IsInput == GameManager.Instance.CurrentAnchor.IsInput)
{
Destroy(_currentCable.gameObject);
}
else
{
_currentCable.EndAnchor = GameManager.Instance.CurrentAnchor;
}
_currentCable = null;
if (GameManager.Instance.CurrentAnchor == null || _currentCable.StartAnchor.IsInput == GameManager.Instance.CurrentAnchor.IsInput)
{
Destroy(_currentCable.gameObject);
}
else
{
_currentCable.EndAnchor = GameManager.Instance.CurrentAnchor;
}
_currentCable = null;
}
else if (_currentGate != null) // Dropping gate
{
if (DeleteOnRelease)
{
Destroy(_currentGate.gameObject);
}
else
{
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
if (DeleteOnRelease)
{
renderer.sortingLayerName = "default";
Destroy(_currentGate.gameObject);
}
_currentGate.transform.position = _currentGate.transform.position.Round();
var currentBox = _currentGate.Box;
if (FindObjectsOfType<Gate>()
.Where(g => !g.Equals(_currentGate))
.Select(g => g.Box)
.Any(b => currentBox.IsTouching(b)))
else
{
// Collision with another gate
if (_currentGateInitialPos == null)
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
{
Destroy(_currentGate.gameObject);
renderer.sortingLayerName = "default";
}
else
_currentGate.transform.position = _currentGate.transform.position.Round();
var currentBox = _currentGate.Box;
if (FindObjectsOfType<Gate>()
.Where(g => !g.Equals(_currentGate))
.Select(g => g.Box)
.Any(b => currentBox.IsTouching(b)))
{
_currentGate.transform.position = _currentGateInitialPos.Value; // Reset pos
// Collision with another gate
if (_currentGateInitialPos == null)
{
Destroy(_currentGate.gameObject);
}
else
{
_currentGate.transform.position = _currentGateInitialPos.Value; // Reset pos
}
}
}
}
_currentGate = null;
DeleteOnRelease = false;
_currentGate = null;
DeleteOnRelease = false;
}
}
+17 -3
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -11,6 +12,19 @@ namespace UntitledLogicGame.UI
{
public class UIGate : UIToolbarButton
{
#region Static Properties
public float MaxSize {
get
{
if(_maxSize == null)
_maxSize = GameManager.Instance.GateSprites.Select(s => s.rect.width).Max();
return _maxSize.Value;
}
}
private float? _maxSize;
#endregion
#region Unity Properties
#endregion
@@ -23,9 +37,9 @@ namespace UntitledLogicGame.UI
{
var sprite = value.GetComponentInChildren<SpriteRenderer>().sprite;
Image.sprite = sprite;
Image.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 100 * sprite.rect.width / 700f); // TODO get max width from UIManager
gameObject.name = "UI_" + value.Definition.Name;
Text.text = value.Definition.Name;
Image.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 100 * sprite.rect.width / MaxSize);
gameObject.name = "UI_" + value.GateType.ToString();
Text.text = value.UIName;
}
}
+2 -1
View File
@@ -53,6 +53,7 @@ namespace UntitledLogicGame.Workspace
return _definition;
}
}
public string UIName { get; set; }
#endregion
@@ -70,7 +71,7 @@ namespace UntitledLogicGame.Workspace
private void Start()
{
Utils.RandomName(Definition.Name, gameObject);
Utils.RandomName(GateType.ToString(), gameObject);
}
// Update is called once per frame
+15 -3
View File
@@ -24,6 +24,7 @@ namespace UntitledLogicGame.Workspace
private Anchor _anchorPrefab;
private Anchor _bigAnchorPrefab;
private List<Sprite> _gateSprites;
private Sprite _defaultSprite => _gateSprites.First(s => s.name == "default");
#endregion
@@ -64,9 +65,19 @@ namespace UntitledLogicGame.Workspace
gate.GateType = (GateType)key;
gate.UIName = string.IsNullOrEmpty(item.Name) ? gate.GateType.ToString() : item.Name;
var sprite = _gateSprites.First(s => s.name == item.Skin);
gate.Sprite.Renderer.sprite = sprite;
if (string.IsNullOrEmpty(item.Skin))
{
gate.Sprite.Renderer.sprite = _defaultSprite;
gate.Sprite.Renderer.drawMode = SpriteDrawMode.Sliced;
gate.Sprite.Renderer.size = new Vector2(item.Width, item.Height);
}
else
{
var sprite = _gateSprites.First(s => s.name == item.Skin);
gate.Sprite.Renderer.sprite = sprite;
}
gate.Sprite.ResetCollider();
if(item.Input != null && item.Input.Count > 0)
@@ -101,7 +112,7 @@ namespace UntitledLogicGame.Workspace
1f
);
Debug.Log($"Loaded gate {gate.Definition.Name}");
Debug.Log($"Loaded gate {key} {gate.GateType}");
return gate;
}
@@ -122,6 +133,7 @@ namespace UntitledLogicGame.Workspace
public class GateBookItem
{
public string Skin { get; set; }
public string Name { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public string Class { get; set; }
+2 -1
View File
@@ -60,7 +60,8 @@ namespace UntitledLogicGame.Workspace
public void ResetCollider()
{
Destroy(GetComponent<PolygonCollider2D>());
gameObject.AddComponent<PolygonCollider2D>();
var collider = gameObject.AddComponent<PolygonCollider2D>();
collider.autoTiling = true;
}
#endregion
@@ -19,8 +19,7 @@ namespace UntitledLogicGame.Workspace.Gates
// Public properties
public GateType Type { get; private set; }
public GateCategory Category => (GateCategory)((int)Type / 100);
public string Name => Type.ToString();
public bool HasState => false;
public abstract bool HasState { get; }
public Dictionary<InputState, OutputState> TruthTable { get; private set; } = new Dictionary<InputState, OutputState>();
// Herited properties
@@ -121,8 +120,13 @@ namespace UntitledLogicGame.Workspace.Gates
}
}
internal abstract class StateGateDefinition : GateDefinition
internal abstract class StatelessGateDefinition : GateDefinition
{
public new bool HasState => true;
public override bool HasState { get; } = false;
}
internal abstract class StatefulGateDefinition : GateDefinition
{
public override bool HasState { get; } = true;
}
}
@@ -5,7 +5,7 @@ namespace UntitledLogicGame.Workspace.Gates
{
#region 000 - Technical
internal class NoneGate : GateDefinition
internal class NoneGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { };
public override string[] Outputs { get; } = new string[] { };
@@ -25,7 +25,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 200 - Basic
internal class BUFGate : GateDefinition
internal class BUFGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -33,7 +33,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(input[0]);
}
internal class ANDGate : GateDefinition
internal class ANDGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -41,7 +41,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(input[0] && input[1]);
}
internal class ORGate : GateDefinition
internal class ORGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -49,7 +49,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(input[0] || input[1]);
}
internal class XORGate : GateDefinition
internal class XORGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -57,7 +57,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(input[0] ^ input[1]);
}
internal class NOTGate : GateDefinition
internal class NOTGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -65,7 +65,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(!input[0]);
}
internal class NANDGate : GateDefinition
internal class NANDGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -73,7 +73,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(!(input[0] && input[1]));
}
internal class NORGate : GateDefinition
internal class NORGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -81,7 +81,7 @@ namespace UntitledLogicGame.Workspace.Gates
internal override Func<InputState, OutputState> Function => (input) => new OutputState(!(input[0] || input[1]));
}
internal class XNORGate : GateDefinition
internal class XNORGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -93,7 +93,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 300 - Latches
internal class SRLatchGate : StateGateDefinition
internal class SRLatchGate : StatefulGateDefinition
{
public new string Name => "SR Latch";
public override string[] Inputs { get; } = new string[] { "S", "R" };
@@ -113,7 +113,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class JKLatchGate : StateGateDefinition
internal class JKLatchGate : StatefulGateDefinition
{
public new string Name => "JK Latch";
public override string[] Inputs { get; } = new string[] { "J", "K" };
@@ -135,7 +135,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class DLatchGate : StateGateDefinition
internal class DLatchGate : StatefulGateDefinition
{
public new string Name => "D Latch";
public override string[] Inputs { get; } = new string[] { "D", "E" };
@@ -157,7 +157,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 400 - Flip-Flops
internal class SRFlipFlopGate : StateGateDefinition
internal class SRFlipFlopGate : StatefulGateDefinition
{
public new string Name => "SR Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "S", "R" };
@@ -181,7 +181,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class JKFlipFlopGate : StateGateDefinition
internal class JKFlipFlopGate : StatefulGateDefinition
{
public new string Name => "JK Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "J", "K" };
@@ -207,7 +207,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class DFlipFlopGate : StateGateDefinition
internal class DFlipFlopGate : StatefulGateDefinition
{
public new string Name => "D Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "D" };
@@ -227,7 +227,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class TFlipFlopGate : StateGateDefinition
internal class TFlipFlopGate : StatefulGateDefinition
{
public new string Name => "T Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "T" };
@@ -252,7 +252,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 500 - Arithmetic
internal class HalfAddGate : GateDefinition
internal class HalfAddGate : StatelessGateDefinition
{
public new string Name => "Half Add.";
public override string[] Inputs { get; } = new string[] { "A", "B" };
@@ -270,7 +270,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class FullAddGate : GateDefinition
internal class FullAddGate : StatelessGateDefinition
{
public new string Name => "Full Add.";
public override string[] Inputs { get; } = new string[] { "A", "B", "Cɪ" };
@@ -289,7 +289,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class HalfSubGate : GateDefinition
internal class HalfSubGate : StatelessGateDefinition
{
public new string Name => "Half Sub.";
public override string[] Inputs { get; } = new string[] { "A", "B" };
@@ -308,7 +308,7 @@ namespace UntitledLogicGame.Workspace.Gates
}
internal class FullSubGate : GateDefinition
internal class FullSubGate : StatelessGateDefinition
{
public new string Name => "Full Add.";
public override string[] Inputs { get; } = new string[] { "A", "B", "Cɪ" };
@@ -332,7 +332,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 600 - Data
internal class MuxGate : GateDefinition
internal class MuxGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "E", "S", "D₀", "D₁" };
public override string[] Outputs { get; } = new string[] { "Y" };
@@ -350,7 +350,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class DemuxGate : GateDefinition
internal class DemuxGate : StatelessGateDefinition
{
public override string[] Inputs { get; } = new string[] { "E", "S", "D" };
public override string[] Outputs { get; } = new string[] { "Y₀", "Y₁" };
@@ -368,7 +368,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class Mux2bGate : GateDefinition
internal class Mux2bGate : StatelessGateDefinition
{
public new string Name => "2bits Mux";
public override string[] Inputs { get; } = new string[] { "E", "S₀", "S₁", "D₀", "D₁", "D₂", "D₃" };
@@ -395,7 +395,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class Demux2bGate : GateDefinition
internal class Demux2bGate : StatelessGateDefinition
{
public new string Name => "2bits Demux";
public override string[] Inputs { get; } = new string[] { "E", "S₀", "S₁", "D" };
@@ -417,7 +417,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class Enc2b4bGate : GateDefinition
internal class Enc2b4bGate : StatelessGateDefinition
{
public new string Name => "2b/4b Enc.";
public override string[] Inputs { get; } = new string[] { "D₀", "D₁" };
@@ -437,7 +437,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class Dec4b2bGate : GateDefinition
internal class Dec4b2bGate : StatelessGateDefinition
{
public new string Name => "4b/2b Dec.";
public override string[] Inputs { get; } = new string[] { "D₀", "D₁", "D₂", "D₃"};
@@ -461,7 +461,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 700 - Registers
internal class SISO4bGate : StateGateDefinition
internal class SISO4bGate : StatefulGateDefinition
{
public new string Name => "4bits SISO";
public override string[] Inputs { get; } = new string[] { "CLK", "D" };
@@ -489,7 +489,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class SIPO4bGate : StateGateDefinition
internal class SIPO4bGate : StatefulGateDefinition
{
public new string Name => "4bits SIPO";
public override string[] Inputs { get; } = new string[] { "CLK", "D" };
@@ -517,7 +517,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class PIPO4bGate : StateGateDefinition
internal class PIPO4bGate : StatefulGateDefinition
{
public new string Name => "4bits PIPO";
public override string[] Inputs { get; } = new string[] { "CLK", "D₀", "D₁", "D₂", "D₃" };
@@ -552,7 +552,7 @@ namespace UntitledLogicGame.Workspace.Gates
#region 800 - Counters
internal class Counter2bGate : StateGateDefinition
internal class Counter2bGate : StatefulGateDefinition
{
public new string Name => "2bits Count.";
public override string[] Inputs { get; } = new string[] { "CLK", "RST" };
@@ -584,7 +584,7 @@ namespace UntitledLogicGame.Workspace.Gates
};
}
internal class Counter4bGate : StateGateDefinition
internal class Counter4bGate : StatefulGateDefinition
{
public new string Name => "4bits Count.";
public override string[] Inputs { get; } = new string[] { "CLK", "RST" };
+30
View File
@@ -92,3 +92,33 @@ list:
- B 0.5 3.5 W
output:
- Q 6.5 2.5 E
300:
name: SR Latch
width: 5
height: 6
input:
- S 0.5 1.5 W
- R 0.5 4.5 W
output:
- Q 4.5 1.5 W
- Q̅ 4.5 4.5 W
310:
name: JK Latch
width: 5
height: 6
input:
- J 0.5 1.5 W
- K 0.5 4.5 W
output:
- Q 4.5 1.5 W
- Q̅ 4.5 4.5 W
320:
name: D Latch
width: 5
height: 6
input:
- D 0.5 1.5 W
- E 0.5 4.5 W
output:
- Q 4.5 1.5 W
- Q̅ 4.5 4.5 W
+13 -13
View File
@@ -68,13 +68,13 @@ TextureImporter:
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
spriteMeshType: 0
alignment: 1
spritePivot: {x: 0.5, y: 0.5}
spritePivot: {x: 0, y: 1}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteBorder: {x: 100, y: 100, z: 100, w: 100}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
@@ -148,7 +148,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -169,7 +169,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -190,7 +190,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -211,7 +211,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -232,7 +232,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -253,7 +253,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -274,7 +274,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -295,7 +295,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
@@ -316,7 +316,7 @@ TextureImporter:
width: 100
height: 100
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []