/* Awake(): de esta clase crea las esferas que sirven para determinar la posición del coche en relación al circuito * También se encarga de inicializar variables y establecer las referencias de los scripts necesarios */ private void Awake() { if (networkManager == null) { networkManager = FindObjectOfType <NetworkManager>(); } if (m_CircuitController == null) { m_CircuitController = FindObjectOfType <CircuitController>(); } m_DebuggingSpheres = new GameObject[networkManager.maxConnections]; for (int i = 0; i < networkManager.maxConnections; ++i) { m_DebuggingSpheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere); m_DebuggingSpheres[i].GetComponent <SphereCollider>().enabled = false; m_DebuggingSpheres[i].GetComponent <MeshRenderer>().enabled = false; } m_UIManager = FindObjectOfType <UIManager>(); m_UIManager.m_polePositionManager = this; //de esta forma sabemos la relacion de cada poleposition con ui manager de cada player if (isServer) { started = false; full = false; } m_MyNetworkManager = FindObjectOfType <MyNetworkManager>(); numVueltas = 3; m_UIManager.InitLaps(); }
public SelectCircuit(CircuitController controller) { InitializeComponent(); // Initialize circuit uids circuitUIDs.DataSource = controller.circuits; }
// Initialize protected override void Initialize() { if (!IsDesignerHosted) { _spriteBatch = new SpriteBatch(GraphicsDevice); _contentManager = new ContentManager(Services, "Content"); System.Diagnostics.Debug.Assert(Parent.Parent.Parent is CircuitsView); _view = Parent.Parent.Parent as CircuitsView; _controller = _view.controller; // Resources _pixel = new Texture2D(GraphicsDevice, 1, 1); _pixel.SetData <Color>(new[] { Color.White }); _and = _contentManager.Load <Texture2D>("logic_gate_icons\\and"); _or = _contentManager.Load <Texture2D>("logic_gate_icons\\or"); _not = _contentManager.Load <Texture2D>("logic_gate_icons\\not"); _input = _contentManager.Load <Texture2D>("logic_gate_icons\\input"); _output = _contentManager.Load <Texture2D>("logic_gate_icons\\output"); _circle = _contentManager.Load <Texture2D>("circle"); _font = _contentManager.Load <SpriteFont>("gate_font"); // Events Application.Idle += delegate { Invalidate(); }; MouseMove += new System.Windows.Forms.MouseEventHandler(CircuitsView_MouseMove); MouseDown += new MouseEventHandler(CircuitDisplay_MouseDown); FindForm().KeyDown += new KeyEventHandler(Parent_KeyDown); FindForm().KeyUp += new KeyEventHandler(Parent_KeyUp); } }
/// <summary> /// <para> Builds a <see cref="Policy"/> that will function like a Circuit Breaker.</para> /// <para>The circuit will break after <paramref name="exceptionsAllowedBeforeBreaking"/> /// exceptions that are handled by this policy are raised. The circuit will stay /// broken for the <paramref name="durationOfBreak"/>. Any attempt to execute this policy /// while the circuit is broken, will immediately throw a <see cref="BrokenCircuitException"/> containing the exception /// that broke the cicuit. /// </para> /// <para>If the first action after the break duration period results in an exception, the circuit will break /// again for another <paramref name="durationOfBreak"/>, otherwise it will reset. /// </para> /// </summary> /// <param name="policyBuilder">The policy builder.</param> /// <param name="exceptionsAllowedBeforeBreaking">The number of exceptions that are allowed before opening the circuit.</param> /// <param name="durationOfBreak">The duration the circuit will stay open before resetting.</param> /// <param name="onBreak">The action to call when the circuit transitions to an <see cref="CircuitState.Open"/> state.</param> /// <param name="onReset">The action to call when the circuit resets to a <see cref="CircuitState.Closed"/> state.</param> /// <param name="onHalfOpen">The action to call when the circuit transitions to <see cref="CircuitState.HalfOpen"/> state, ready to try action executions again. </param> /// <returns>The policy instance.</returns> /// <remarks>(see "Release It!" by Michael T. Nygard fi)</remarks> /// <exception cref="System.ArgumentOutOfRangeException">exceptionsAllowedBeforeBreaking;Value must be greater than zero.</exception> /// <exception cref="ArgumentNullException">onBreak</exception> /// <exception cref="ArgumentNullException">onReset</exception> /// <exception cref="ArgumentNullException">onHalfOpen</exception> public static CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action <Exception, TimeSpan, Context> onBreak, Action <Context> onReset, Action onHalfOpen) { if (exceptionsAllowedBeforeBreaking <= 0) { throw new ArgumentOutOfRangeException("exceptionsAllowedBeforeBreaking", "Value must be greater than zero."); } if (onBreak == null) { throw new ArgumentNullException("onBreak"); } if (onReset == null) { throw new ArgumentNullException("onReset"); } if (onHalfOpen == null) { throw new ArgumentNullException("onHalfOpen"); } var breakerController = new CircuitController(exceptionsAllowedBeforeBreaking, durationOfBreak, onBreak, onReset, onHalfOpen); return(new CircuitBreakerPolicy( (action, context) => CircuitBreakerEngine.Implementation(action, context, policyBuilder.ExceptionPredicates, breakerController), policyBuilder.ExceptionPredicates, breakerController )); }
// Use this for initialization void Start() { controller = new CircuitController(); bulbFirst = new NodePosition[2] { new NodePosition(3, 1), new NodePosition(7, 2) }; // Input ourselve bulbSecond = new NodePosition[2] { new NodePosition(4, 1), new NodePosition(7, 3) }; // Input ourselve resistorFirst = new NodePosition[4] { new NodePosition(2, 0), new NodePosition(2, 1), new NodePosition(2, 2), new NodePosition(3, 2) }; // Input ourselve resistorSecond = new NodePosition[4] { new NodePosition(2, 1), new NodePosition(2, 2), new NodePosition(3, 2), new NodePosition(4, 2) }; // Input ourselve BatteryFirst = new NodePosition(0, 1); BatterySecond = new NodePosition(0, 2); saveConnection = new GameObject[xSize * 2 + 1, ySize + 1]; dragging = false; node = new GameObject[xSize, ySize]; for (int j = 0; j < ySize; j++) { for (int i = 0; i < xSize; i++) { node [i, j] = GameObject.Find("Node(" + i + "," + j + ")"); } } connections = new Type [xSize * 2 + 1, ySize + 1]; for (int i = 0; i <= xSize * 2; i += 2) { for (int j = 0; j <= ySize - 1; j++) { saveConnection [i, j] = null; connections [i, j] = Type.None; } } for (int i = 1; i <= xSize * 2; i += 2) { for (int j = 0; j <= ySize; j++) { saveConnection [i, j] = null; connections [i, j] = Type.None; } } for (int i = 0; i < 2; i++) { InstanceBulb(bulbFirst [i], bulbSecond [i]); } for (int i = 0; i < 4; i++) { InstanceResistor(resistorFirst [i], resistorSecond [i]); } InstanceBattery(BatteryFirst, BatterySecond); button.onClick.AddListener(runAlgorithm); }
void Awake() { rg = GetComponent <Rigidbody>(); inventory.SetActive(false); placeholder = selection.transform.GetChild(0).GetChild(0); placeholderCollider = placeholder.GetComponent <ColliderState>(); selectionController = selection.GetComponent <SelectionController>(); circuitController = circuit.GetComponent <CircuitController>(); defaultOriginLocalPosition = selectionController.placeholderOrigin.transform.localPosition; }
public void CircuitControllerTest_WillNeverWork() { CircuitController circuitController = new CircuitController(); // var test = new Mock<RenderingContext>(); // test.Setup(x => x.PageContext = new PageContext()); // var test2 = Mock.Of<Item>(); var result = circuitController.Featured(); }
public Simulator() { InitializeComponent(); NodeMediator nMediator = new NodeMediator(); NodeFactory nFactory = NodeFactory.Instance; nFactory.setMediator(nMediator); CircuitBuilder nCircuitBuilder = new CircuitBuilder(nFactory); CircuitManager nManager = new CircuitManager(nCircuitBuilder); controller = new CircuitController(nMediator, nManager); }
void GetRefs() { if (!mainCamera) { mainCamera = Camera.main.GetComponent <CameraController>(); } if (networkManager == null) { networkManager = FindObjectOfType <CustomNetworkManager>(); } if (m_CircuitController == null) { m_CircuitController = FindObjectOfType <CircuitController>(); } }
void GetRefs() { if (m_Rigidbody == null) { m_Rigidbody = GetComponent <Rigidbody>(); } if (m_PlayerInfo == null) { m_PlayerInfo = GetComponent <PlayerInfo>(); } if (!circuitController) { circuitController = FindObjectOfType <CircuitController>(); } }
private void Awake() { if (networkManager == null) { networkManager = FindObjectOfType <NetworkManager>(); } if (m_CircuitController == null) { m_CircuitController = FindObjectOfType <CircuitController>(); } m_DebuggingSpheres = new GameObject[networkManager.maxConnections]; for (int i = 0; i < networkManager.maxConnections; ++i) { m_DebuggingSpheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere); m_DebuggingSpheres[i].GetComponent <SphereCollider>().enabled = false; } }
//Obtención de referencias y asignación de callbacks a los botones de las vueltas private void Awake() { if (networkManager == null) { networkManager = FindObjectOfType <NetworkManagerPolePosition>(); } if (m_CircuitController == null) { m_CircuitController = FindObjectOfType <CircuitController>(); } uiManager = FindObjectOfType <UIManager>(); raceEndedLayer = LayerMask.NameToLayer("PlayerRaceEnded"); Button minusButton = uiManager.GetMinusButton(); minusButton.onClick.AddListener(() => DecrementLaps()); Button addButton = uiManager.GetAddButton(); addButton.onClick.AddListener(() => AddLaps()); }
public void Awake() { m_Rigidbody = GetComponent <Rigidbody>(); m_PlayerInfo = GetComponent <PlayerInfo>(); //m_PolePositionManager = FindObjectOfType<PolePositionManager>(); m_UIManager = FindObjectOfType <UIManager>(); if (m_CircuitController == null) { m_CircuitController = FindObjectOfType <CircuitController>(); } greyMaterial = (Material)Resources.Load("grey", typeof(Material)); blueglassMaterial = (Material)Resources.Load("blueglass", typeof(Material)); greenMaterial = (Material)Resources.Load("green", typeof(Material)); blueMaterial = (Material)Resources.Load("blue", typeof(Material)); redMaterial = (Material)Resources.Load("red", typeof(Material)); orangeMaterial = (Material)Resources.Load("orange", typeof(Material)); blackMaterial = (Material)Resources.Load("black", typeof(Material)); purpleMaterial = (Material)Resources.Load("purple", typeof(Material)); pinkMaterial = (Material)Resources.Load("pink", typeof(Material)); ChangeColor(); }
private void Awake() { if (networkManager == null) { networkManager = FindObjectOfType <PolePositionNetworkManager>(); } if (uiManager == null) { uiManager = FindObjectOfType <UIManager>(); } if (m_CircuitController == null) { m_CircuitController = FindObjectOfType <CircuitController>(); } //Delegados UI OnOrderChangeDelegate += uiManager.ChangeOrder; OnOrderChangeDelegate += uiManager.ChangeOrderServer; OnCountDownDelegate += uiManager.CountDown; OnUpdateLapDelegate += uiManager.UpdateLap; OnWrongDirectionDelegate += uiManager.WrongDirection; OnLapTimeDelegate += uiManager.UpdateTimeLap; m_DebuggingSpheres = new GameObject[networkManager.maxConnections]; for (int i = 0; i < networkManager.maxConnections; ++i) { m_DebuggingSpheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere); m_DebuggingSpheres[i].GetComponent <SphereCollider>().enabled = false; m_DebuggingSpheres[i].GetComponent <MeshRenderer>().enabled = false; } for (int i = 0; i < playersConnected.Length; i++) { playersConnected[i] = false; } gameStarted = false; }
private void Awake() { m_NetworkManager = FindObjectOfType <NetworkManager>(); m_CircuitController = FindObjectOfType <CircuitController>(); m_polePositionManager = FindObjectOfType <PolePositionManager>(); }
// setController public void setController(CircuitController controller) { _controller = controller; circuitsList.DataSource = _controller.circuits; }
void Awake() { instance = this; }