/// <summary> /// Ajoute une porte custom de la librairie QCS /// Celle-ci est transformée pour devenir Serialisable /// </summary> /// <param name="gate"></param> /// <returns></returns> public Builder AddCustomGate(QCS.Gate gate) { Gate gateSerialisable = SerializableClass.Helper.ToGateSerialisable(gate); _customGates.Add(gateSerialisable); return(this); }
/// <summary> /// Construit un Objet unity englobé dans la classe "GateObject" représentant une porte du jeu. /// </summary> /// <param name="parent">Parent de l'objet qui doit être créé</param> public static GateObject Build(QCS.Gate gate, Transform parent) { if (gate.Equals(QCS.Gate.IDENTITY)) { return(IDENTITY_GATE(parent)); } return(DYNAMIC_GATE(gate, parent)); }
public void AddCustomGateToMenu(QCS.Gate gate) { if (!_customGates.ContainsKey(gate.Name)) { _customGates.Add(gate.Name, gate); MakeCustomGateButton(gate); } else { _customGates.Remove(gate.Name); _customGates.Add(gate.Name, gate); } }
/// <summary> /// Construit un Objet unity représentant une porte. /// </summary> /// <param name="parent">Parent de l'objet qui doit être créé</param> private static GameObject GATE(QCS.Gate gate, Transform parent) { GameObject root = new GameObject(); root.tag = "gate"; root.name = "gate"; /* root BoxCollider */ BoxCollider boxCollider = root.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(GridBoard.localColWidth * gate.NbEntries, GridBoard.localRowHeight * GridBoard.gateHeightRatio, 2); boxCollider.transform.localPosition = new Vector3(0, (GridBoard.localRowHeight / 2) - (GridBoard.localRowHeight * GridBoard.gateHeightRatio / 2), 0); /* gate TextMesh */ TextMesh textMesh = root.AddComponent <TextMesh>(); textMesh.text = gate.Name; textMesh.alignment = TextAlignment.Center; textMesh.anchor = TextAnchor.MiddleCenter; textMesh.offsetZ = -(GridBoard.gateThikness / 2); textMesh.tabSize = 4f; textMesh.fontSize = 50; textMesh.lineSpacing = 1f; textMesh.richText = true; textMesh.color = Color.white; textMesh.characterSize = 0.1f; textMesh.fontStyle = FontStyle.Bold; /* gate Transform */ root.transform.parent = parent; root.transform.localScale = new Vector3(1, 1, 1); root.transform.localPosition = new Vector3(0, (GridBoard.localRowHeight / 2) - (GridBoard.localRowHeight * GridBoard.gateHeightRatio / 2), 0); /* cube */ GameObject cube = new GameObject(); SpriteRenderer sp = cube.AddComponent(typeof(SpriteRenderer)) as SpriteRenderer; Sprite pipeSprite = Sprite.Create(_boxGateMaterial2D, new Rect(0.0f, 0.0f, _boxGateMaterial2D.width, _boxGateMaterial2D.height), new Vector2(0.5f, 0.5f)); sp.sprite = pipeSprite; /* cube Transform */ cube.transform.parent = root.transform; cube.transform.localScale = new Vector3(GridBoard.localColWidth * gate.NbEntries - GridBoard.gateSideSpace, GridBoard.localRowHeight * GridBoard.gateHeightRatio, 1); float offset = -(GridBoard.gateThikness / 2) + 0.1f; cube.transform.localPosition = new Vector3(0, 0, offset); return(root); }
/// <summary> /// Construit un Objet unity représentant une porte. /// </summary> /// <param name="parent">Parent de l'objet qui doit être créé</param> private static GameObject GATE(QCS.Gate gate, Transform parent) { GameObject root = new GameObject(); root.tag = "gate"; root.name = "gate"; /* root BoxCollider */ BoxCollider boxCollider = root.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(GridBoard.localColWidth * gate.NbEntries, GridBoard.localRowHeight * GridBoard.gateHeightRatio, 2); boxCollider.transform.localPosition = new Vector3(0, (GridBoard.localRowHeight / 2) - (GridBoard.localRowHeight * GridBoard.gateHeightRatio / 2), 0); /* gate TextMesh */ TextMesh textMesh = root.AddComponent <TextMesh>(); textMesh.text = gate.Name; textMesh.alignment = TextAlignment.Center; textMesh.anchor = TextAnchor.MiddleCenter; textMesh.offsetZ = -(GridBoard.gateThikness / 2); textMesh.tabSize = 4f; textMesh.fontSize = 50; textMesh.lineSpacing = 1f; textMesh.richText = true; textMesh.color = Color.white; textMesh.characterSize = 0.1f; textMesh.fontStyle = FontStyle.Bold; /* gate Transform */ root.transform.parent = parent; root.transform.localScale = new Vector3(1, 1, 1); root.transform.localPosition = new Vector3(0, (GridBoard.localRowHeight / 2) - (GridBoard.localRowHeight * GridBoard.gateHeightRatio / 2), 0); /* cube */ GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); /* cube Material */ cube.GetComponent <Renderer>().material = _boxGateMaterial; /* cube Transform */ cube.transform.parent = root.transform; cube.transform.localScale = new Vector3(GridBoard.localColWidth * gate.NbEntries - GridBoard.gateSideSpace, GridBoard.localRowHeight * GridBoard.gateHeightRatio, GridBoard.gateThikness); cube.transform.localPosition = new Vector3(0, 0, 0); return(root); }
/// <summary> /// Construit dynamiquement une porte de la scène unity. /// </summary> /// <param name="parent">Parent de l'objet qui doit être créé</param> public static GateObject DYNAMIC_GATE(QCS.Gate gate, Transform parent) { GameObject gateGameObject = GATE(gate, parent); /* bind gateObject */ GateObject gateObject = gateGameObject.AddComponent <GateObject>(); gateObject.body = gateGameObject; gateObject.pipes = new List <GameObject>(); /* gate pipes */ for (int i = 0; i < gate.NbEntries; i++) { GameObject pipe = PIPE(parent); gateObject.pipes.Add(pipe); } return(gateObject); }
public void MakeCustomGateButton(QCS.Gate gate) { GameObject gateButton = Instantiate( Resources.Load("02_prefabs/BtnGate", typeof(GameObject)), customGateMenu.transform) as GameObject; gateButton.name = gate.Name; Button buttonComponent = gateButton.GetComponent <Button>(); buttonComponent.onClick.AddListener(delegate { CurrentState.OnSelectGate(_customGates[gate.Name]); }); gateButton.GetComponent <Text>().text = gate.Name; RectTransform rectTransform = gateButton.GetComponent <RectTransform>(); rectTransform.localPosition = new Vector3( 71.5f, (_customGates.Count) * -60, 0); }
// Gate subactions. public virtual void OnSelectGate(QCS.Gate gate) { }
public GateStruct(int row, int col, Gate gate) { this.row = row; this.col = col; this.gate = gate; }
/// <summary> /// Evalue partiellement le circuit jusquà la ligne de numéro spécifié /// </summary> /// <param name="till_row"></param> /// <returns>State</returns> public State Evaluate(int till_row) { State entry = GetEntryState(); return(new State(LinearAlgebra.Mult(entry.Vector, Gate.Add(FuncTools.Map(GetRowGate, FuncTools.Take(till_row + 1, rows))).Matrix))); }
/// <summary> /// Convertit le circuit en porte (produit matriciel des portes représenttant les lignes) /// </summary> /// <param name="name"></param> /// <returns>Gate</returns> public Gate GetCircuitGate(string name) { return(new Gate(name, Gate.Add(FuncTools.Map(GetRowGate, rows)))); }
/// <summary> /// Convertit le circuit en porte (produit matriciel des portes représenttant les lignes). /// </summary> /// <returns>Gate</returns> public Gate GetCircuitGate() { return(Gate.Add(FuncTools.Map(GetRowGate, rows))); }
/// <summary> /// Convertit une ligne en une porte (produit tensoriel des toutes les portes de la ligne). /// </summary> /// <param name="row"></param> /// <returns>Gate</returns> public Gate GetRowGate(List <GateStruct> row) { return(Gate.Kron(FuncTools.Map((GateStruct a) => a.gate, FilterRow(row)))); }
public void AddDefaultGate(QCS.Gate gate) { _defaultGates.Add(gate.Name, gate); MakeGateButton(gate); }