public ConcreteMediator(Widget1 concreteWidget1, Widget2 concreteWidget2) { this._concreteWidget1 = concreteWidget1; this._concreteWidget1.SetMediator(this); this._concreteWidget2 = concreteWidget2; this._concreteWidget2.SetMediator(this); }
private void SetupLargeWidgets() { Widget2 widget2 = null; { widget2 = new LargeWidgets2(); SetupWidgets2(widget2); } }
private void SetupMediumWidgets() { Widget2 widget2 = null; { widget2 = new MediumWidget2(); SetupWidgets2(widget2); } }
private void SetupSmallWidgets() { Widget2 widget2 = null; { widget2 = new SmallWidget2(); SetupWidgets2(widget2); } }
private void SetupWidgets2(Widget2 widget2) { widget2.IsWidgetOrder = true; widget2.SetupPaintedDefault(_sColorDefaultWidget1); widget2.SetupPaintedDefault(_sColorDefaultWidget2); widget2.SetupPaintedDefault(_sColorDefaultWidget3); widget2.SetupGears(); widget2.SetupSprings(); widget2.SetupLevers(); _Widgets2.Add(widget2); }
static void Main(string[] args) { Widget1 widget1 = new Widget1(); Widget2 widget2 = new Widget2(); ConcreteMediator mediator = new ConcreteMediator(widget1, widget2); Console.WriteLine("Client triggers operation A."); widget1.DoA(); Console.WriteLine("Client triggers operation D."); widget2.DoD(); }
// Update is called once per frame void Update() { //Hvis der er over 3 touch points, begynd at lede efter widgets if(Input.touchCount >= 3) { //Clear listen _touchLists.Clear(); for(int i = 0; i < Input.touchCount; i++) { //Check om der findes en liste if(_touchLists.Count == 0) { //Hvis ikke, lav ny liste og smid touch point deri List<Vector2> tempList = new List<Vector2>(); _touchLists.Add(tempList); tempList.Add(Input.touches[i].position); } else { //Find den liste der har punkter tættest på, OBS: FINDER IKKE DEN DER ER TÆTTEST PÅ for(int o = 0; o < _touchLists.Count; o++) { //Hvis punktet er tæt på, smid dette punkt i den liste også if(Vector2.Distance(Input.touches[i].position, _touchLists[o][0]) < DIST_THRESHOLD) { _touchLists[o].Add(Input.touches[i].position); if(_touchLists[o].Count == 3) { //Hvis den individuelle liste nu har 3 point, tjek om der kan findes en valid Widget deri Widget2 _tempWidget = new Widget2(_touchLists[o]); //CalculateAnglesInList(_touchLists[o]); } } else { //Hvis den er langt væk, lav ny liste til dette punkt List<Vector2> tempList = new List<Vector2>(); _touchLists.Add(tempList); tempList.Add(Input.touches[i].position); } } //Check punkt-distance til punkt i liste //Hvis for langt væk, lav ny liste og smid deri } } //Gruppér efter distance } if(Input.touchCount > 1) { for(int i = 0; i<Input.touchCount; i++){ float x = 0; float y = 0; float z = -30; Vector3 startPoint = Vector3.zero; Vector3 endPoint = Vector3.zero; if(i == Input.touchCount - 1) { startPoint = Camera.main.ScreenToWorldPoint(new Vector3(Input.touches[i].position.x, Input.touches[i].position.y, z)); endPoint = Camera.main.ScreenToWorldPoint(new Vector3(Input.touches[0].position.x, Input.touches[0].position.y, z)); Debug.DrawLine(startPoint, endPoint, Color.white); } else { startPoint = Camera.main.ScreenToWorldPoint(new Vector3(Input.touches[i].position.x, Input.touches[i].position.y, z)); endPoint = Camera.main.ScreenToWorldPoint(new Vector3(Input.touches[i + 1].position.x, Input.touches[i + 1].position.y, z)); Debug.DrawLine(startPoint, endPoint, Color.white); } //print("Start: " + startPoint.ToString() + ", End: " + endPoint.ToString()); } } #if UNITY_EDITOR if(Input.touchCount == 1) { //print(Input.touches[0].position); } if(Input.GetKeyDown(KeyCode.K)) { ShowTouchPoints(); } #endif if(Input.touchCount > 0) { } }
// Validation rule does run on this parameter, catches the failure. public void WithValidation([Test(Bad = true, Path = "%k1%-{k2}")] Widget2 x) { }