Inheritance: MonoBehaviour
コード例 #1
0
ファイル: Soldier.cs プロジェクト: vietanh1441/Town
 public void Parenting()
 {
     //  parent_scr;
     if (transform.parent != null)
     {
         parent_list = transform.parent.gameObject;
         parent_scr = parent_list.GetComponent<Drag>();
         parent_scr.theList.Add(gameObject);
         transform.localPosition = new Vector3(0, 0 - 0.03f * parent_scr.theList.IndexOf(gameObject), -1);
     }
 }
コード例 #2
0
ファイル: Gestures.cs プロジェクト: Costo/Xamarin.Forms
		public static bool ScrollForElement (this IApp app, string query, Drag drag, int maxSteps = 25)
		{
			int count = 0;

			int centerTolerance = 50;

			Func<AppQuery, AppQuery> elementQuery = q => q.Raw (query);

			// Visible elements
			if (app.Query (elementQuery).Length > 1) {
				throw new UITestQueryMultipleResultsException (query);
			}

			// check to see if the element is visible already
			if (app.Query (elementQuery).Length == 1) {
				// centering an element whos CenterX is close to the bounding rectangle's center X can sometime register the swipe as a tap
				float elementDistanceToDragCenter = Math.Abs (app.Query (elementQuery).First ().Rect.CenterY - drag.DragBounds.CenterY);
 				if (elementDistanceToDragCenter > centerTolerance)
					app.CenterElementInView (elementQuery, drag.DragBounds, drag.DragDirection);
				return true;
			}

			// loop until element is seen
			while (app.Query (elementQuery).Length == 0 && count < maxSteps) {
				app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
				count++;
			}

			if (count != maxSteps) {
				// centering an element whos CenterX is close to the bounding rectangle's center X can sometime register the swipe as a tap
				float elementDistanceToDragCenter = Math.Abs (app.Query (elementQuery).First ().Rect.CenterY - drag.DragBounds.CenterY);
				if (elementDistanceToDragCenter > centerTolerance)
					app.CenterElementInView (elementQuery, drag.DragBounds, drag.DragDirection);
				return true;
			}

			count = 0;
			drag.DragDirection = drag.OppositeDirection;

			while (app.Query (elementQuery).Length == 0 && count < maxSteps) {
				app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
				count++;
			}

			if (count != maxSteps) {
				app.CenterElementInView (elementQuery, drag.DragBounds, drag.DragDirection);
				return true;
			}

			return false;
		}
コード例 #3
0
 public override bool CanReceiveDrop(Drag dragObject)
 {
     var newCard = dragObject.GetComponent<Card>();
     if (stack.Count == 0)
     {
         return newCard.Value == 13;
     }
     else
     {
         var lastCard = GetLastCard();
         return lastCard.ColorType != newCard.ColorType
             && lastCard.Value == newCard.Value + 1;
     }
 }
コード例 #4
0
ファイル: Cell.cs プロジェクト: sagivo/Unity2d-Game
 public void HandleSelect(Drag.DragType dragType, Building building)
 {
     unselectSelected();
     switch (dragType) {
     case Drag.DragType.Build:
         if (!liveObj && building.canBuild()) select();
         break;
     case Drag.DragType.Upgrade:
         if (liveObj && liveObj.status == StatusType.Live && Game.canUpgrade(liveObj as Building)) select();
         break;
     case Drag.DragType.Refund:
         if (liveObj) select();
         break;
     case Drag.DragType.Expand:
         if (!liveObj && canExpend()) select();
         break;
         default: break;
     }
 }
コード例 #5
0
ファイル: Gestures.cs プロジェクト: Costo/Xamarin.Forms
		static void CenterElementInView (this IApp app, Func<AppQuery, AppQuery> element, AppRect containingView, Drag.Direction direction)
		{
			// TODO Implement horizontal centering

			if (direction == Drag.Direction.BottomToTop || direction == Drag.Direction.TopToBottom) {

				var elementBounds = app.Query (element).First ().Rect;

				bool elementCenterBelowContainerCenter = elementBounds.CenterY > containingView.CenterY;
				bool elementCenterAboveContainerCenter = elementBounds.CenterY < containingView.CenterY;

				var displacementToCenter = Math.Abs (elementBounds.CenterY - containingView.CenterY) / 2;

				// avoid drag as touch
				if (displacementToCenter < 50)
					return;

				if (elementCenterBelowContainerCenter) {
			
					var drag = new Drag (
						containingView,
						containingView.CenterX, containingView.CenterY + displacementToCenter,
						containingView.CenterX, containingView.CenterY - displacementToCenter,
						Drag.Direction.BottomToTop
						);

					app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);

				} else if (elementCenterAboveContainerCenter) {

					var drag = new Drag (
						containingView,
						containingView.CenterX, containingView.CenterY - displacementToCenter,
						containingView.CenterX, containingView.CenterY + displacementToCenter,
						Drag.Direction.TopToBottom
						);

					app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
				}
			} 
		}
コード例 #6
0
ファイル: SummoningCircle.cs プロジェクト: grudin/team-purin
	void Start () {
		
		glowCircles = GetComponentsInChildren<SpriteRenderer> ();
		numZones = glowCircles.Length - 3;
		zones = new float[numZones, 4];
		zoneItems = new int[numZones];

		for (int i = 0; i < numZones; i++) {
			zones [i, 0] = glowCircles[i+1].gameObject.transform.position.x;
			zones [i, 1] = glowCircles[i+1].gameObject.transform.position.y;
			zones [i, 2] = size;
			zones [i, 3] = size;
		}

		runeZone [0] = glowCircles [numZones + 1].gameObject.transform.position.x;
		runeZone [1] = glowCircles [numZones + 1].gameObject.transform.position.y;
		runeZone [2] = size;
		runeZone [3] = size;

		dragManager = GameObject.FindGameObjectWithTag ("dragManager").GetComponent<Drag>();
		for (int i = 1; i < glowCircles.Length - 2; i++) {
			glowCircles [i].color = new Color (1f, 1f, 1f, 0f);
		}
	}
コード例 #7
0
 private void Start()
 {
     canvas = GetComponent <CanvasGroup>();
     game   = GameObject.FindObjectOfType <GameManager>();
     drag   = GetComponent <Drag>();
 }
コード例 #8
0
ファイル: Slot.cs プロジェクト: AlexandrMochalov/GameDev2015
 public void RemoveCard(Drag dragObject)
 {
     stack.Remove(dragObject);
 }
コード例 #9
0
ファイル: Slot.cs プロジェクト: AlexandrMochalov/GameDev2015
 public virtual bool CanReceiveDrop(Drag dragObject)
 {
     return(false);
 }
コード例 #10
0
    public void OnDrop(PointerEventData eventData)
    {
        GameObject dragedObject = Drag.isDragingObject;

        if (dragedObject == null)
        {
            return;
        }

        Drag drag = Drag.isDragingObject.GetComponent <Drag>();

        CurrentFavouriteItem dragedFavouriteItem = dragedObject.GetComponent <CurrentFavouriteItem>();
        CurrentItem          dragedCurrentItem   = dragedObject.GetComponent <CurrentItem>();


        if (dragedObject.GetComponent <CurrentFavouriteItem>())
        {
            if (dragedFavouriteItem.currentFavouriteItem.id == GetComponent <CurrentFavouriteItem>().currentFavouriteItem.id)
            {
                if (dragedFavouriteItem.currentFavouriteItem.isStackable)
                {
                    int count = dragedFavouriteItem.currentFavouriteItem.countItem;
                    GetComponent <CurrentFavouriteItem>().currentFavouriteItem.countItem += count;
                    dragedFavouriteItem.currentFavouriteItem = Inventory.instanceInventory.EmptySlot();
                }
            }
            else
            {
                Item currentItem = GetComponent <CurrentFavouriteItem>().currentFavouriteItem;
                GetComponent <CurrentFavouriteItem>().currentFavouriteItem = dragedFavouriteItem.currentFavouriteItem;
                dragedFavouriteItem.currentFavouriteItem = currentItem;
            }
        }

        if (dragedObject.GetComponent <CurrentItem>())
        {
            if (dragedCurrentItem.currentInventoryItem.id == GetComponent <CurrentFavouriteItem>().currentFavouriteItem.id)
            {
                if (dragedCurrentItem.currentInventoryItem.isStackable)
                {
                    int count = dragedCurrentItem.currentInventoryItem.countItem;
                    GetComponent <CurrentFavouriteItem>().currentFavouriteItem.countItem += count;
                    dragedCurrentItem.currentInventoryItem = Inventory.instanceInventory.EmptySlot();
                }
            }
            else
            {
                Item currentFavouriteItem = GetComponent <CurrentFavouriteItem>().currentFavouriteItem;
                GetComponent <CurrentFavouriteItem>().currentFavouriteItem = dragedCurrentItem.currentInventoryItem;
                dragedCurrentItem.currentInventoryItem = currentFavouriteItem;
            }
        }


        //if (dragedObject.GetComponent<CyrrentWeapon>())
        //{
        //    if (draggedWeapopn.currentWeapon.id == GetComponent<CyrrentWeapon>().currentWeapon.id)
        //    {
        //        if (draggedWeapopn.currentWeapon.isStackable)
        //        {
        //            int count = draggedWeapopn.currentWeapon.countItem;
        //            GetComponent<CyrrentWeapon>().currentWeapon.countItem += count;
        //            draggedWeapopn.currentWeapon = Inventory.instanceInventory.EmptySlot();
        //        }
        //    }
        //    else
        //    {
        //        Item currentWeapon = GetComponent<CyrrentWeapon>().currentWeapon;
        //        GetComponent<CyrrentWeapon>().currentWeapon = draggedWeapopn.currentWeapon;
        //        draggedWeapopn.currentWeapon = currentWeapon;
        //    }

        //}
        Inventory.instanceInventory.DisplayItems();

        Inventory.instanceInventory.favourite.DisplayItems();



        if (GetComponent <CurrentFavouriteItem>().currentFavouriteItem.id == Inventory.instanceInventory.EmptySlotID())
        {
            if (dragedCurrentItem)
            {
                Item dragItem = dragedCurrentItem.currentInventoryItem.getCopy();
                dragItem.countItem = 1;
                GetComponent <CurrentFavouriteItem>().currentFavouriteItem = dragItem;
                Inventory.instanceInventory.RemoveItem(dragedCurrentItem.ItemNum);
                Inventory.instanceInventory.favourite.DisplayItems();
                Inventory.instanceInventory.weaponSlot.DisplayItem();
                return;
            }
            if (dragedFavouriteItem)
            {
                Item dragItem = dragedFavouriteItem.currentFavouriteItem.getCopy();
                dragItem.countItem = 1;
                GetComponent <CurrentFavouriteItem>().currentFavouriteItem = dragItem;
                Inventory.instanceInventory.favourite.RemoveItem(dragedFavouriteItem.ItemNum);
                Inventory.instanceInventory.weaponSlot.DisplayItem();
                return;
            }


            Inventory.instanceInventory.favourite.DisplayItems();
        }

        if (dragedCurrentItem)
        {
            if (GetComponent <CurrentFavouriteItem>().currentFavouriteItem.id == dragedCurrentItem.currentInventoryItem.id)
            {
                if (dragedCurrentItem.currentInventoryItem.isStackable)
                {
                    drag.AddItem(GetComponent <CurrentFavouriteItem>().currentFavouriteItem);
                    Inventory.instanceInventory.RemoveItem(dragedCurrentItem.ItemNum);
                    Inventory.instanceInventory.favourite.DisplayItems();
                    Inventory.instanceInventory.weaponSlot.DisplayItem();
                    return;
                }
            }
        }



        if (dragedFavouriteItem)
        {
            if (GetComponent <CurrentFavouriteItem>().currentFavouriteItem.id == dragedFavouriteItem.currentFavouriteItem.id)
            {
                if (dragedFavouriteItem.currentFavouriteItem.isStackable)
                {
                    drag.AddItem(GetComponent <CurrentFavouriteItem>().currentFavouriteItem);
                    Inventory.instanceInventory.favourite.RemoveItem(dragedFavouriteItem.ItemNum);
                    Inventory.instanceInventory.weaponSlot.DisplayItem();
                    return;
                }
            }
        }
    }
コード例 #11
0
 protected override void OnDragSourceSet()
 {
     base.OnDragSourceSet();
     Drag.SourceSetIconName(this, "audio-x-generic");
 }
コード例 #12
0
    public void PiezaTokianJarri(Drag pieza)
    {
        AudioManager.instantzia.Play("PiezaJarri");

        pieza.SetPiezaGurasoa(transform);
    }
コード例 #13
0
ファイル: Slot.cs プロジェクト: AlexandrMochalov/GameDev2015
    public void OnDrop(Drag dragObject)
    {
        var pos = dragObject.transform.position;

        dragObject.GetComponent<SpriteRenderer>().sortingOrder = stack.Count;
    }
コード例 #14
0
ファイル: PieceTop.cs プロジェクト: yukiiris/The-Greenest
 // Use this for initialization
 void Start()
 {
     top    = GetComponent <PieceTop> ();
     drag   = GetComponent <Drag> ();
     bottom = gameObject.GetComponentInParent <PieceBottom> ();
 }
コード例 #15
0
    public void InitAfterAdd(bool setColor, Color ropeColor)
    {
        //Debug.Log("InitAfterAdd");
        connectedSocketList = new List<GameObject> ();
        availableSocketList = ropeManager.SocketList;

        //cable.GetComponent<UltimateRope> ().Regenerate (true);

        // Init Drag script
        //Add link to Drag script
        draggedA = pointA.GetComponent<Drag>();
		draggedB = pointB.GetComponent<Drag>();
		//breakCtrl = cable.GetComponent<BreakCotroller>();

        draggedA.ropeClass = GetComponent<RopeClass>();
        draggedA.attracted = pointA.GetComponent<Attracted>();
        draggedB.ropeClass = GetComponent<RopeClass>();
        draggedB.attracted = pointA.GetComponent<Attracted>();
        draggedA.plug = draggedA.gameObject;
        draggedB.plug = draggedB.gameObject;

		//Add drag plane to A and B points
        draggedA.DragPlane = DragPlane.gameObject;
		draggedB.DragPlane = DragPlane.gameObject;

		//Add (pointB link to pointA) and (pointA link to pointB) 
        draggedA.OtherPoint = pointB.gameObject;
		draggedB.OtherPoint = pointA.gameObject;

		//Add RopeClass object link to PointA and PointB 
        draggedA.ropeManager = ropeManager;
        draggedB.ropeManager = ropeManager;

        // Init Attracted script
        pointA.GetComponent<Attracted>().ropeManager = ropeManager;// = FindObjectOfType<RopeManager>(); //Testing
        //ссылка на родительский скрипт
        pointA.GetComponent<Attracted>().ropeClass = GetComponent<RopeClass>();
        //ссылка на перетаскивание
        pointA.GetComponent<Attracted>().drag = draggedA;
        //скачиваем объекты, доступные для прилипания
        pointA.GetComponent<Attracted>().availableAttractors = availableSocketList;
        
        pointB.GetComponent<Attracted>().ropeManager = ropeManager;// = FindObjectOfType<RopeManager>(); //Testing
        //ссылка на родительский скрипт
        pointB.GetComponent<Attracted>().ropeClass = GetComponent<RopeClass>();
        //ссылка на перетаскивание
        pointB.GetComponent<Attracted>().drag = draggedB;
        //скачиваем объекты, доступные для прилипания
        pointB.GetComponent<Attracted>().availableAttractors = availableSocketList;

		//breakCtrl.Ropes = Ropes.gameObject;
		//breakCtrl.thisRope = this.gameObject;

		//cable.GetComponent<UltimateRope>().DeleteRope();
		//cable.GetComponent<UltimateRope>().Regenerate(false);
		//pointA.GetComponent<AutoRotate>().setOrient();
		//pointB.GetComponent<AutoRotate>().setOrient();

        //Set random position for spline
        if (cable != null)
        {
            if (!setColor)
            {
                RopeColor = new Color(Random.value, Random.value, Random.value);
            }
            else
            {
                RopeColor = ropeColor;
            }

            cable.GetComponent<MeshRenderer>().materials[0].color = RopeColor;
        }

        //Set random color for cable
        pointA2.transform.localPosition = new Vector3(0, Random.Range(RandomMin, RandomMax), 0);
        pointB2.transform.localPosition = new Vector3(Random.Range(-RandomMin, -RandomMax), 0, 0);
        //print(pointA2.transform.localPosition);
        //print(pointB2.transform.localPosition);
        //pointA2.transform.localPosition = new Vector3(0.0f, 1.0f, 0.0f);
        //pointB2.transform.localPosition = new Vector3(-1.0f, 0.0f, 0.0f);

	}
コード例 #16
0
        public MainConfigView()
        {
            InitializeComponent();
            this.WhenActivated((disposable) =>
            {
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.GroupsDisplay)
                .BindTo(this, x => x.GroupsList.ItemsSource)
                .DisposeWith(disposable);

                this.Bind(this.ViewModel, vm => vm.SelectedProfile !.DisplayController.SelectedObject, view => view.GroupsList.SelectedValue)
                .DisposeWith(disposable);

                // Wire up patcher config data context and visibility
                this.WhenAnyValue(x => x.ViewModel !.DisplayedObject)
                .BindTo(this, x => x.DetailControl.Content)
                .DisposeWith(disposable);

                // Only show help if zero groups
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.GroupsDisplay.Count)
                .Select(c => c == 0 ? Visibility.Visible : Visibility.Collapsed)
                .BindTo(this, x => x.AddSomePatchersHelpGrid.Visibility)
                .DisposeWith(disposable);

                // Show dimmer if in initial configuration
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.Init.NewPatcher)
                .Select(newPatcher => newPatcher != null ? Visibility.Visible : Visibility.Collapsed)
                .BindTo(this, x => x.InitialConfigurationDimmer.Visibility)
                .DisposeWith(disposable);


                // Set up large overall error button
                var overallErr = this.WhenAnyFallback(x => x.ViewModel !.SelectedProfile !.BlockingError, fallback: GetResponse <ViewModel> .Succeed(null !))
                                 .Replay(1)
                                 .RefCount();
                Observable.CombineLatest(
                    this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.GroupsDisplay.Count)
                    .Select(c => c > 0),
                    overallErr.Select(x => x.Succeeded),
                    (hasGroups, succeeded) => hasGroups && !succeeded)
                .Select(x => x ? Visibility.Visible : Visibility.Collapsed)
                .BindTo(this, x => x.OverallErrorButton.Visibility)
                .DisposeWith(disposable);
                overallErr.Select(x => x.Reason)
                .BindTo(this, x => x.OverallErrorButton.ToolTip)
                .DisposeWith(disposable);
                this.WhenAnyFallback(x => x.ViewModel !.SelectedProfile !.GoToErrorCommand)
                .BindTo(this, x => x.OverallErrorButton.Command)
                .DisposeWith(disposable);

                // Set up go button
                this.WhenAnyValue(x => x.ViewModel !.RunPatchers)
                .BindTo(this, x => x.GoButton.Command)
                .DisposeWith(disposable);
                overallErr
                .Select(err => err.Succeeded ? Visibility.Visible : Visibility.Collapsed)
                .BindTo(this, x => x.GoButton.Visibility)
                .DisposeWith(disposable);

                this.WhenAnyValue(x => x.ViewModel !.RunPatchers.CanExecute)
                .Switch()
                .CombineLatest(this.WhenAnyFallback(x => x.ViewModel !.SelectedProfile !.BlockingError, GetResponse <ViewModel> .Succeed(null !)),
                               (can, overall) => !can && overall.Succeeded)
                .Select(show => show ? Visibility.Visible : Visibility.Collapsed)
                .BindTo(this, x => x.ProcessingCircle.Visibility)
                .DisposeWith(disposable);

                Drag.ListBoxDrops <ViewModel>(
                    this.GroupsList,
                    onlyWithinSameBox: false)
                .Subscribe(e =>
                {
                    if (e.Vm == null)
                    {
                        return;
                    }
                    if (e.RawArgs.OriginalSource is not DependencyObject dep)
                    {
                        return;
                    }
                    if (!dep.TryGetAncestor <ListBoxItem>(out var targetItem))
                    {
                        return;
                    }
                    if (targetItem.DataContext is not GroupVm targetGroup)
                    {
                        return;
                    }
                    if (!targetItem.TryGetAncestor <ListBox>(out var targetListBox))
                    {
                        return;
                    }

                    if (e.SourceListBox == null)
                    {
                        return;
                    }

                    if (targetListBox.ItemsSource is not ISourceListUiFunnel <GroupVm> targetGroupList)
                    {
                        return;
                    }

                    if (e.SourceListBox.ItemsSource is ISourceListUiFunnel <GroupVm> groupList)
                    {
                        if (e.Vm is not GroupVm groupVm)
                        {
                            return;
                        }
                        var index = targetGroupList.IndexOf(targetGroup);
                        if (index >= targetGroupList.SourceList.Count)
                        {
                            return;
                        }

                        groupList.SourceList.Remove(groupVm);

                        if (index >= 0)
                        {
                            targetGroupList.SourceList.Insert(index, groupVm);
                        }
                        else
                        {
                            targetGroupList.SourceList.Add(groupVm);
                        }
                    }
                    else if (e.SourceListBox.ItemsSource is ISourceListUiFunnel <PatcherVm> patcherList)
                    {
                        if (!targetItem.TryGetChildOfType <ListBox>(out var patcherListBox))
                        {
                            return;
                        }
                        if (patcherListBox.ItemsSource is not ISourceListUiFunnel <PatcherVm> targetPatcherList)
                        {
                            return;
                        }
                        if (e.Vm is not PatcherVm patcherVm)
                        {
                            return;
                        }

                        patcherList.SourceList.Remove(patcherVm);

                        targetPatcherList.SourceList.Add(patcherVm);
                    }
                })
                .DisposeWith(disposable);

                // Bind top patcher list buttons
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.GroupsDisplay.Count)
                .Select(c => c == 0 ? Visibility.Hidden : Visibility.Visible)
                .BindTo(this, x => x.TopAllPatchersControls.Visibility)
                .DisposeWith(disposable);
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.EnableAllGroupsCommand)
                .BindTo(this, x => x.EnableAllGroupsButton.Command)
                .DisposeWith(disposable);
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.DisableAllGroupsCommand)
                .BindTo(this, x => x.DisableAllGroupsButton.Command)
                .DisposeWith(disposable);
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.ExpandAllGroupsCommand)
                .BindTo(this, x => x.ExpandAllGroupsButton.Command)
                .DisposeWith(disposable);
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.CollapseAllGroupsCommand)
                .BindTo(this, x => x.CollapseAllGroupsButton.Command)
                .DisposeWith(disposable);
                this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.UpdateAllPatchersCommand)
                .BindTo(this, x => x.UpdateAllPatchersButton.Command)
                .DisposeWith(disposable);
                Observable.CombineLatest(
                    this.WhenAnyValue(x => x.ViewModel !.SelectedProfile !.UpdateAllPatchersCommand)
                    .Select(x => x.CanExecute)
                    .Switch(),
                    this.WhenAnyFallback(x => x.ViewModel !.SelectedProfile !.LockSetting.Lock),
                    (hasUpdate, locked) => hasUpdate && !locked)
                .Select(x => x ? Visibility.Visible : Visibility.Collapsed)
                .BindTo(this, x => x.UpdateAllPatchersButton.Visibility)
                .DisposeWith(disposable);
            });
        }
コード例 #17
0
 void Awake()
 {
     instance = this;
 }
コード例 #18
0
        static void Main(string[] args)
        {
            #region Spänning and stuffs

            #region Uppgift 1
            {
                var area  = Area.FromMilliMeters(200);
                var force = Force.FromNewtons(30000);
                var drag  = Drag.FromForceOverArea(force, area);

                Console.WriteLine("Uppgift 1 | Drag: " + drag);
            }
            #endregion

            #region Uppgift 1*
            {
                var area  = Area.FromMilliMeters(100);
                var force = Force.FromNewtons(20000);
                var drag  = Drag.FromForceOverArea(force, area);

                Console.WriteLine("Uppgift 1* | Drag: " + drag);
            }
            #endregion

            #region Uppgift 2
            {
                var square = Square.FromSideLength(Length.FromMilli(20));
                var force  = Force.FromNewtons(50000);
                var drag   = Drag.FromForceOverArea(force, square.Area);

                Console.WriteLine("Uppgift 2 | Drag: " + drag);
            }
            #endregion

            #region Uppgift 2*
            {
                var circle = Circle.FromDiameter(Length.FromMilli(1000));
                var force  = Force.FromNewtons(5 * Math.Pow(10, 6));
                var drag   = Drag.FromForceOverArea(force, circle.Area);

                Console.WriteLine("Uppgift 2* | Drag: " + Math.Round(drag.Value, 1) + " " + Drag.Unit);
            }
            #endregion

            #region Uppgift 3
            {
                var rect = Rectangle.FromSides(
                    Length.FromMilli(50), Length.FromMilli(100));

                var drag = Drag.FromDragArea(9, rect.Area);

                Console.WriteLine("Uppgift 3 | Force: " + drag.Force);
            }
            #endregion

            #region Uppgift 3*
            {
                var circle = Circle.FromDiameter(Length.FromMilli(100));
                var drag   = Drag.FromDragArea(100, circle.Area);

                Console.WriteLine("Uppgift 3 | Force: " +
                                  Math.Round(drag.Force * 2 / 1000, 1) + " " + SIPrefix.Kilo.Symbol + "N");
            }
            #endregion

            #region Uppgift 4
            {
                var force  = Force.FromNewtons(40000);
                var drag   = Drag.FromForceOverDrag(force, drag: 120);
                var circle = Circle.FromArea(drag.Area);
                Console.WriteLine("Uppgift 4 | Diameter: " + Math.Round(circle.Diameter * 1000, 1) + " mm");
            }
            #endregion

            // hoppa över 5

            #region Uppgift 5*
            {
                var originalLength = Length.FromMilli(5000);
                var strechedLength = Length.FromMilli(5100);
                var tension        = Tension.FromLengths(originalLength, strechedLength);
                Console.WriteLine("Uppgift 5* | Tension: " + tension);
            }
            #endregion

            // hoppa över 7, 8

            Console.WriteLine();

            #region Uppgift 8*
            {
                double sträckgräns       = 380;
                double brottgräns        = 480;
                double elasticitetsModul = 300 / 0.0032;

                Console.WriteLine("Uppgift 8*");
                Console.WriteLine("a) " + nameof(sträckgräns) + ": " + sträckgräns + " " + Drag.Unit);
                Console.WriteLine("b) " + nameof(brottgräns) + ": " + brottgräns + " " + Drag.Unit);
                Console.WriteLine("c) " + nameof(elasticitetsModul) + ": " + elasticitetsModul + " " + Drag.Unit);
                Console.WriteLine();
            }
            #endregion

            #region Uppgift 9
            {
                double kpUnit = 9.80665;

                Console.WriteLine("Uppgift 9");
                Console.WriteLine("a) aluminum: " + 75_000 * 0.05 / 100 + " " + Drag.Unit);
                Console.WriteLine("b) stål: " + 210_000 * 0.0013 + " " + Drag.Unit);
                Console.WriteLine("c) " + Math.Round(21 * kpUnit / 0.001) + " " + Drag.Unit);
                Console.WriteLine("d) " + Math.Round(150 / (0.073 / 100)) + " " + Drag.Unit);
                Console.WriteLine("e) " + Math.Round(100 / 120_000d * 100, 3) + "% " + Drag.Unit);
                Console.WriteLine();
            }
            #endregion

            const double stålElasticitetsModul = 210_000;

            #region Uppgift 10
            {
                // sökt: spänning
                // givet: töjning, elasticitetsmodul

                var tension = Tension.FromLengthExtension(Length.FromMeters(2), Length.FromMilli(2));
                Console.WriteLine("Uppgift 10: " + tension.Value * stålElasticitetsModul + " " + Drag.Unit);
            }
            #endregion

            #region Uppgift 11
            {
                // sökt: elasticitetsmodul
                // givet:
                //  diameter=10mm,
                //  längd=100mm,
                //  längdökning=0.1mm,
                //  kraft = 9500N

                var area    = Circle.FromDiameter(Length.FromMilli(10)).Area;
                var tension = Tension.FromLengthExtension(Length.FromMilli(100), Length.FromMilli(0.1));
                var drag    = Drag.FromForceOverArea(Force.FromNewtons(9500), area);

                Console.WriteLine("Uppgift 11: E = " + Math.Round(drag.Value / tension.Value));
            }
            #endregion

            const double kopparElasticitetsModul = 120_000;

            #region Uppgift 12
            {
                Console.WriteLine("Uppgift 12");
                // sökt: förlängning
                // givet:
                //  kraft = 10_000N
                //  stor  diameter = 30mm
                //  liten diameter = 10mm
                //  stor  längd = 40mm
                //  liten längd = 20mm

                var force = Force.FromNewtons(10_000);

                var    storArea      = Circle.FromDiameter(Length.FromMilli(30)).Area;
                var    storDrag      = Drag.FromForceOverArea(force, storArea);
                double storTension   = storDrag.Value / kopparElasticitetsModul;
                var    storLength    = Length.FromMilli(40);
                var    storExtension = Length.FromMilli(storLength * storTension);
                Console.WriteLine(
                    "Stor-förlängning = " + Math.Round(storExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m");

                var    litenArea      = Circle.FromDiameter(Length.FromMilli(10)).Area;
                var    litenDrag      = Drag.FromForceOverArea(force, litenArea);
                double litenTension   = litenDrag.Value / kopparElasticitetsModul;
                var    litenLength    = Length.FromMilli(20);
                var    litenExtension = Length.FromMilli(litenLength * litenTension);
                Console.WriteLine(
                    "Liten-förlängning = " + Math.Round(litenExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m");

                var totalExtensionDeci = Math.Round((storExtension + litenExtension).Micro);
                Console.WriteLine("Total förlängning = " + totalExtensionDeci + " " + SIPrefix.Micro.Symbol + "m");

                Console.WriteLine();
            }
            #endregion

            const double aluminiumElasticitetsModul = 70_000;

            #region Uppgift 12*
            {
                Console.WriteLine("Uppgift 12");
                // sökt: förlängning
                // givet:
                //  kraft = 10_000N
                //  dellängd = 300mm
                //  alum diameter = 80mm
                //  stål diameter = 40mm

                var force      = Force.FromNewtons(10_000);
                var partLength = Length.FromMilli(300);

                var    alumArea      = Circle.FromDiameter(Length.FromMilli(80)).Area;
                var    alumDrag      = Drag.FromForceOverArea(force, alumArea);
                double alumTension   = alumDrag.Value / aluminiumElasticitetsModul;
                var    alumExtension = Length.FromMilli(partLength * alumTension);
                Console.WriteLine(
                    "Alum-förlängning = " + Math.Round(alumExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m");

                var    stålArea      = Circle.FromDiameter(Length.FromMilli(40)).Area;
                var    stålDrag      = Drag.FromForceOverArea(force, stålArea);
                double stålTension   = stålDrag.Value / stålElasticitetsModul;
                var    stålExtension = Length.FromMilli(partLength * stålTension);
                Console.WriteLine(
                    "Stål-förlängning = " + Math.Round(stålExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m");

                var totalExtensionDeci = Math.Round((alumExtension + stålExtension).Micro);
                Console.WriteLine("Total förlängning = " + totalExtensionDeci + " " + SIPrefix.Micro.Symbol + "m");

                Console.WriteLine();
            }
            #endregion

            const double konstantanElasticitetsModul = 110_000;

            #region Uppgift 13
            {
                Console.WriteLine("Uppgift 13");
                // sökt: diameter (mm)
                // givet:
                //  kraft = 100N
                //  längd = 8mm
                //  förlängning = 0.06mm

                var    length    = Length.FromMilli(8);
                var    extension = Length.FromMilli(0.06);
                double tension   = Tension.FromLengthExtension(length, extension).Value;
                double drag      = tension * konstantanElasticitetsModul;

                var force = Force.FromNewtons(100);
                var area  = Drag.FromForceOverDrag(force, drag).Area;

                Console.WriteLine(Circle.FromArea(area).Diameter.ToString());
            }
            #endregion

            #endregion

            Console.WriteLine();

            #region Skjuvning

            const double härdplastLimDragMax = 15; //  N/mm^2

            #region Uppgift 36
            {
                var area  = Rectangle.FromSides(Length.FromMilli(50), Length.FromMilli(90)).Area;
                var skjuv = Drag.FromDragArea(härdplastLimDragMax, area);

                Console.WriteLine("Uppgift 36 | " + skjuv.Force + " innan limmet släpper");
            }
            #endregion

            #region Uppgift 36*
            {
                double maxLimDrag = 10; // N/mm^2
                var    force      = Force.FromKiloNewtons(50);
                var    area       = Drag.FromForceOverDrag(force, maxLimDrag).Area;
                var    length     = area / Length.FromMilli(60);

                Console.WriteLine("Uppgift 36* | " + Length.FromMilli(Math.Ceiling(length.Milli)));
            }
            #endregion

            #region Uppgift 37
            {
                var bredd = Length.FromMilli(30);
                var längd = Length.FromMilli(100);

                var skärArea       = Rectangle.FromSides(bredd, längd).Area;
                var limMaxSpänning = Drag.FromDragArea(härdplastLimDragMax, skärArea);

                var vänsterHöjd = Length.FromMilli(2);
                var vänsterArea = Rectangle.FromSides(bredd, vänsterHöjd).Area;
                var vänsterMaxAluminiumSpänning = Drag.FromDragArea(150, vänsterArea);

                var högerHöjd = Length.FromMilli(3);
                var högerArea = Rectangle.FromSides(bredd, högerHöjd).Area;
                var högerMaxAluminiumSpänning = Drag.FromDragArea(150, högerArea);

                var lowestForce = Drag.GetLowestForce(
                    limMaxSpänning, vänsterMaxAluminiumSpänning, högerMaxAluminiumSpänning);

                Console.WriteLine("Uppgift 37 | " + lowestForce);
            }
            #endregion

            #region Uppgift 38
            {
                var a      = Length.FromMilli(3);
                var length = Length.FromMilli(20);

                var area     = Rectangle.FromSides(a, length * 2).Area;
                var spänning = Drag.FromDragArea(200, area);

                Console.WriteLine("Uppgift 38 | " + spänning.Force);
            }
            #endregion

            #region Uppgift 38*
            {
                var    force        = Force.FromNewtonsPow(10, 5);
                double skärSpänning = 150;
                var    area         = Drag.FromForceOverDrag(force, skärSpänning).Area;
                var    svetsLängd   = Length.FromMilli(150);
                var    längd        = area / svetsLängd;

                Console.WriteLine("Uppgift 38* | " + längd);
            }
            #endregion

            #region Uppgift 39
            {
                var omkrets               = Circle.FromDiameter(Length.FromMilli(30)).Circumference;
                var svetsArea             = Rectangle.FromSides(omkrets, Length.FromMilli(5)).Area;
                var sänktTillåtenSpänning = 100 / 2d;
                var spänning              = Drag.FromDragArea(sänktTillåtenSpänning, svetsArea);

                Console.WriteLine("Uppgift 39 | " + spänning.Force);
            }
            #endregion

            #region Uppgift 40
            {
                var    kraft        = Force.FromKiloNewtons(20);
                double skärSpänning = 100;
                var    skärArea     = Drag.FromForceOverDrag(kraft, skärSpänning).Area;

                //Console.WriteLine(Math.Sqrt(skärArea.MilliMeters / 5 / 2));
                Console.WriteLine("Uppgift 40 | " + "TODO");

                // a * L
            }
            #endregion

            #region Uppgift 41
            {
                var    nitArea          = Circle.FromDiameter(Length.FromMilli(10)).Area;
                double tillåtenSpänning = 80;
                var    kraft            = Force.FromNewtons(nitArea.MilliMeters * tillåtenSpänning);

                Console.WriteLine("Uppgift 41 | " + kraft);
            }
            #endregion

            #region Uppgift 42
            {
                var    kraft            = Force.FromKiloNewtons(10);
                double tillåtenSpänning = 90;
                var    area             = Drag.FromForceOverDrag(kraft, tillåtenSpänning).Area;

                var areaFörNit  = area / 4;
                var nitDiameter = Circle.FromArea(areaFörNit).Diameter;

                Console.WriteLine("Uppgift 42 | " + nitDiameter);
            }
            #endregion

            #region Uppgift 43
            {
                var    kraft = Force.FromKiloNewtons(50);
                double tillåtenSkärSpänning = 100;
                var    totalNitArea         = Drag.FromForceOverDrag(kraft, tillåtenSkärSpänning).Area;
                var    areaFörNit           = totalNitArea / 4;
                var    nitDiameter          = Circle.FromArea(areaFörNit).Diameter;

                double ssStål_1312_00__tillåtenSpänning = 220;
                double säkerhetsFaktor       = 1.0 / 3;
                double säkerTillåtenSpänning = ssStål_1312_00__tillåtenSpänning * säkerhetsFaktor;

                var plåtSpänningsArea = Drag.FromForceOverDrag(kraft, säkerTillåtenSpänning).Area;
                var totalSkärLängd    = plåtSpänningsArea / Length.FromMilli(10);
                var skärLängd         = totalSkärLängd + nitDiameter * 2;

                Console.WriteLine("Uppgift 43 | d = " + nitDiameter + ", b = " + skärLängd);
            }
            #endregion

            #region Uppgift på tavlan :|
            {
                var    tjocklek   = Length.FromMilli(7);
                var    circle     = Circle.FromDiameter(12);
                var    area       = (Area)(circle.Circumference * tjocklek);
                double brottGräns = 360;
                var    kraft      = Drag.FromDragArea(brottGräns, area).Force;

                //Console.WriteLine("Uppgift 44 | " + kraft);
            }
            #endregion

            #region Uppgift 44
            {
            }
            #endregion

            #endregion
        }
コード例 #19
0
ファイル: Slot.cs プロジェクト: AlexandrMochalov/GameDev2015
 public void RemoveCard(Drag dragObject)
 {
     stack.Remove(dragObject);
 }
コード例 #20
0
 private void imageButton1_Click(object sender, EventArgs e)
 {
     Drag.SetPane(new PointF(0, 0));
     Drag.SetAngleY(-180);
     InvalidateAll();
 }
コード例 #21
0
 public virtual void OnDrag(PointerEventData eventData)
 {
     Drag.SafeInvoke(eventData);
 }
コード例 #22
0
ファイル: Slot.cs プロジェクト: AlexandrMochalov/GameDev2015
 public virtual bool CanReceiveDrop(Drag dragObject)
 {
     return false;
 }
コード例 #23
0
 //public bool Enable { get; set; }
 public ActionDrag(FrameworkElement dragControl, Image dataIcon, Drag dragAction)
 {
     DragControl = dragControl;
     OnDrag      = dragAction;
 }
コード例 #24
0
 internal void SendDrag(AnnotationDragState state)
 {
     Drag?.Invoke(this, new AnnotationDragEventArgs(state));
 }
コード例 #25
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     Drag.Init();
     InvalidateAll();
 }
コード例 #26
0
ファイル: DragEventTrigger.cs プロジェクト: yu821157174/Lcc
 public override void OnDrag(PointerEventData eventData)
 {
     Drag?.Invoke(eventData.delta);
 }
コード例 #27
0
    public void OnDrop(PointerEventData eventData)
    {
        bool piezaJarriDaiteke = true;
        Drag pieza             = eventData.pointerDrag.GetComponent <Drag>();

        if (pieza != null)
        {
            if (pieza.piezaMota == Drag.mota.Izenburua)
            {
                return;
            }
            if (piezaMota == pieza.piezaMota || piezaMota == Drag.mota.Denak) // pieza hemen jarri daiteke
            {
                if (piezaBakarra)
                {
                    if (transform.childCount == 1) // badago pieza bat jarrita, aldatu
                    {
                        Transform piezaPos = transform.GetChild(0);
                        if (piezaPos.GetComponent <Drag>() != null)
                        {
                            if (piezaPos.GetComponent <Drag>().isActiveAndEnabled)
                            {
                                // jarrita dagoen pieza tokiz mugitu daiteke
                                piezaPos.SetParent(piezaTokia);
                                piezaPos.SetSiblingIndex(piezaTokia.childCount);
                                piezaJarriDaiteke = true;
                            }
                            else
                            {
                                // jarrita dagoen pieza ezin da mugitu
                                piezaJarriDaiteke = false;
                            }
                        }
                        else
                        {
                            //pieza guk sortutako hutsunea da, pieza tokian jarri
                            piezaJarriDaiteke = true;
                        }
                    }
                }
                if (goikoPieza != null && goikoPieza.parent == piezaTokia) // eskumaldean piezak ez muntatzeko // !!! pieza bakarra ez exekutatu
                {
                    pieza.transform.SetParent(pieza.GetPiezaGurasoa());
                    pieza.transform.SetSiblingIndex(pieza.GetHasierkoIndizea());
                }
                else
                {
                    //pieza.SetPiezaGurasoa(transform); // pieza hutsunean jarri
                    if (piezaJarriDaiteke)
                    {
                        PiezaTokianJarri(pieza);
                    }
                }
            }
            else // pieza toki okerren jarri da, datorren tokira itzuli
            {
                AudioManager.instantzia.Play("PiezaTxartoJarri");

                pieza.transform.SetParent(pieza.GetPiezaGurasoa());
                pieza.transform.SetSiblingIndex(pieza.GetHasierkoIndizea());
            }
        }
    }
コード例 #28
0
ファイル: Throwable.cs プロジェクト: Steedalion/Planet-golf
 protected void Awake()
 {
     drag   = GetComponent <Drag>();
     planet = GetComponent <Rigidbody>();
 }
コード例 #29
0
 public void dellCell(Drag drag)
 {
     Destroy(drag.gameObject);
     _set.dellItemInventar(drag.item.name, 1);
 }
コード例 #30
0
 void _disposeDrag()
 {
     this._drag = null;
 }
コード例 #31
0
ファイル: Room.cs プロジェクト: julmaxi/opdtab
        void UpdateGuiSection(string section, int i, object data)
        {
            Container c = (Container)GetField("c" + section);

            if (data == null)
            {
                SetDummyLabel(c, section);
            }
            else if (data is List <RoundDebater> )
            {
                // Judges or FreeSpeakers (variable number...)
                MiscHelpers.ClearContainer(c);
                List <RoundDebater> list = (List <RoundDebater>)data;
                if (list.Count == 0)
                {
                    SetDummyLabel(c, section);
                }
                else
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        UpdateGuiSection(section, j, list[j]);
                    }
                    // append label for adding by D&D
                    if (small)
                    {
                        if (section == "Judges")
                        {
                            SetDummyLabel(c, section, roomData.Judges.Count.ToString());
                        }
                        else if (section == "FreeSpeakers" && list.Count < 3)
                        {
                            SetDummyLabel(c, section, "F");
                        }
                    }
                    else if (section == "Judges" || list.Count < 3)
                    {
                        SetDummyLabel(c, section, "Drag here to add");
                    }
                }
            }
            else
            {
                IDragDropWidget w = null;

                if (data is TeamData)
                {
                    if (small)
                    {
                        w = Team.Small((TeamData)data);
                    }
                    else
                    {
                        w = new Team((TeamData)data, null);
                    }
                }
                else if (data is RoundDebater)
                {
                    if (small)
                    {
                        w = DebaterWidget.Small((RoundDebater)data, false);
                    }
                    else
                    {
                        w = new DebaterWidget((RoundDebater)data);
                    }
                }
                else
                {
                    throw new NotImplementedException("Don't know how to create widget for data");
                }

                // tell Debater the room for visitedRooms list..
                w.SetRoom(roomData.RoundName, roomData);

                w.SetupDragDropSource(section, data);
                w.SetDataTrigger += delegate(Widget sender, object data_) {
                    SetItem(section, i, data_);
                };

                // Add to container after source, but before Dest
                Widget wi = (Widget)w;
                MiscHelpers.AddToContainer(c, wi, small);

                // Drag drop DestSet, needs Container for scrolling support...
                DragDropHelpers.DestSet(wi,
                                        DestDefaults.All,
                                        DragDropHelpers.TgtFromString(section),
                                        Gdk.DragAction.Move);

                wi.DragDataReceived += delegate(object o, DragDataReceivedArgs args) {
                    object data_ =
                        DragDropHelpers.Deserialize(args.SelectionData);
                    // save data here
                    SetItem(section, i, data_);
                    // delete data there
                    MyButton b = (MyButton)Drag.GetSourceWidget(args.Context);
                    b.Owner.SetData(data);
                };
            }
            // show judge quality by icons
            if (section == "Judges" && !small)
            {
                int    nStars     = 0;
                double sumAvgSpkr = 0.0;
                double sumAvgTeam = 0.0;
                int    nAvgSpkr   = 0;
                int    nAvgTeam   = 0;

                foreach (RoundDebater rd in roomData.Judges)
                {
                    Debater d = Tournament.I.FindDebater(rd);
                    if (d == null)
                    {
                        continue;
                    }
                    nStars += d.Role.JudgeQuality;
                    if (!double.IsNaN(d.StatsAvg[0]))
                    {
                        sumAvgSpkr += d.StatsAvg[0];
                        nAvgSpkr++;
                    }
                    if (!double.IsNaN(d.StatsAvg[2]))
                    {
                        sumAvgTeam += d.StatsAvg[2];
                        nAvgTeam++;
                    }
                }

                lblJudgeStats.Markup = "JudgeStats: " +
                                       JudgeStatsToMarkup(sumAvgSpkr, nAvgSpkr, 2) + " " +
                                       JudgeStatsToMarkup(sumAvgTeam, nAvgTeam, 5);


                MiscHelpers.ClearTable(tableJudgeStars);
                tableJudgeStars.NRows = (uint)nStars / 5 + 1;

                for (int j = 0; j < nStars; j++)
                {
                    uint col = (uint)j % 5;
                    uint row = (uint)j / 5;

                    tableJudgeStars.Attach(new Image(MiscHelpers.LoadIcon("face-smile")),
                                           col, col + 1,
                                           row, row + 1,
                                           AttachOptions.Shrink, AttachOptions.Shrink,
                                           0, 0);
                }
                if (nStars == 0)
                {
                    tableJudgeStars.HideAll();
                }
                else
                {
                    tableJudgeStars.ShowAll();
                }
            }
        }
コード例 #32
0
    public void InsertAt(int Order, GameObject GameObj)
    {
        GameObj.GetComponent <Drag>().order = Order;
        //Debug.Log("Inserting " + GameObj + " at " + Order);
        //TODO: When inserting/removing a block inside a resizable block, the block after the resizable block won't change pos most of the time
        int SkipsPoint = 0;

        temporary = obj;
        int  StartPoint = 0;
        int  V          = 0;
        Drag res        = null;
        bool Skip       = false;
        bool Reset      = false;

        int AdvencementPoints = 0;

        if (temporary.Count == 0)
        {
            Skip = true;
        }
        for (int i = 0; !Skip; i++)
        {
            //Debug.Log("I is " + i);
            if (Reset && 0 < temporary.Count)
            {
                //Debug.Log("I is 0");
                i     = 0;
                Reset = false;
            }
            else if (Reset && 0 >= temporary.Count)
            {
                //Debug.Log("Out of sequence");
                V = 0;
                break;
            }
            //First, check to see if the block is inside a resizable block (Or inside a resizable that is inside a resizable block...)
            //Debug.Log("Is " + temporary.ToArray()[i].name + " a resizable block? " + temporary.ToArray()[i].GetComponent<Resize>());
            if (temporary.ToArray()[i].GetComponent <Resize>())             //order was order-startpoint
            //Debug.Log("Checking if " + (Order-StartPoint) + " is > than " + (AdvencementPoints-1) + " and < than " + (AdvencementPoints+temporary.ToArray()[i].GetComponent<Resize>().Steps));
            {
                if (Order > AdvencementPoints - 1 /* + i*/ && Order < AdvencementPoints + temporary.ToArray()[i].GetComponent <Resize>().Steps)
                {
                    AdvencementPoints++;
                    //Debug.Log("What is temporairy?");
                    //Debug.Log("res: " + temporary.ToArray()[i].GetComponent<Drag>().strsources[0] + ", temporary: " + temporary.ToArray()[i].GetComponent<Drag>().childs.Count);
                    res       = temporary.ToArray()[i].GetComponent <Drag>();
                    temporary = temporary.ToArray()[i].GetComponent <Drag>().childs;
                    V         = i;
                    //Debug.Log("Adding " + (i+1) + " to the StartPoint");
                    StartPoint += i /*+1*/;
                    Reset       = true;
                    //Debug.Log("Iteration: " + i);
                }
                else
                {
                    AdvencementPoints += temporary.ToArray()[i].GetComponent <Resize>().Steps + 1;
                }
            }
            else
            {
                AdvencementPoints++;
            }
            //StartPoint += i+1;
            if ((i + 1 >= temporary.Count) && !Reset)
            {
                //Debug.Log("Breaking");
                break;
            }
        }
        if (res != null)
        {
            res.AddChild(GameObj, Mathf.Clamp((Order - (StartPoint)), 0, res.GetComponent <Resize>().Steps - 2));

            //res is GOOD!

            //res.Replace();
            return;
        }

        obj.Insert(Mathf.Clamp(Order, 0, obj.Count), GameObj);
        for (int i = 0; i < obj.Count; i++)
        {
            obj.ToArray()[i].GetComponent <RectTransform>().localPosition = new Vector3(GetComponent <RectTransform>().sizeDelta.x / 2 + 6 + (24 * obj.ToArray()[i].GetComponent <Drag>().Aligment), -20 - ((i + SkipsPoint) * 27), 0);
            if (obj.ToArray()[i].GetComponent <Resize>())
            {
                SkipsPoint += obj.ToArray()[i].GetComponent <Resize>().Steps;
            }
        }
        RedistributeReplaceAction();
    }
コード例 #33
0
ファイル: DragDropHelpers.cs プロジェクト: JLimperg/opdtab
 public static void DestSet(Widget w, DestDefaults d, TargetEntry[] t, Gdk.DragAction a)
 {
     Drag.DestSet(w, d, t, a);
     HandleDragScrolling(w);
 }
コード例 #34
0
 public void Start()
 {
     drag = new Drag();
 }
コード例 #35
0
ファイル: Slot.cs プロジェクト: AlexandrMochalov/GameDev2015
    public void OnDrop(Drag dragObject)
    {
        var pos = dragObject.transform.position;

        dragObject.GetComponent <SpriteRenderer>().sortingOrder = stack.Count;
    }
コード例 #36
0
 protected override void Awake()
 {
     base.Awake();
     drag = GetComponent <Drag>();
 }
 private void lstStyles_DragDataReceived_Drop(object sender, DragDataReceivedArgs e)
 {
     if (e.SelectionData.Length > 0 && e.SelectionData.Format == 8)
     {
         byte[] data    = e.SelectionData.Data;
         string encoded = System.Text.Encoding.UTF8.GetString(data);
         System.Collections.Generic.List <string> paths = new System.Collections.Generic.List <string>(encoded.Split('\r', '\n'));
         paths.RemoveAll(string.IsNullOrEmpty);
         foreach (string sTP in paths)
         {
             if (sTP.StartsWith("file://"))
             {
                 string StylePath = sTP.Substring(7);
                 string sTitle    = System.IO.Path.GetFileNameWithoutExtension(StylePath);
                 string sExt      = System.IO.Path.GetExtension(StylePath).ToLower();
                 while (!string.IsNullOrEmpty(System.IO.Path.GetExtension(sTitle)))
                 {
                     sExt   = System.IO.Path.GetExtension(sTitle).ToLower() + sExt;
                     sTitle = System.IO.Path.GetFileNameWithoutExtension(sTitle);
                 }
                 if (sExt == ".tgz" | sExt == ".tar.gz" | sExt == ".tar")
                 {
                     File.Copy(StylePath, System.IO.Path.Combine(modFunctions.AppData, sTitle + sExt), true);
                     TreeIter iter;
                     lstStyles.Model.GetIterFirst(out iter);
                     bool Add = true;
                     do
                     {
                         GLib.Value val = new GLib.Value();
                         lstStyles.Model.GetValue(iter, 0, ref val);
                         if ((string)val.Val == sTitle)
                         {
                             Add = false;
                             break;
                         }
                     } while (lstStyles.Model.IterNext(ref iter));
                     if (Add)
                     {
                         lstStyles.AddItem(sTitle);
                     }
                     if (paths.Count == 1)
                     {
                         TreeIter iterSel;
                         lstStyles.Model.GetIterFirst(out iterSel);
                         do
                         {
                             GLib.Value val = new GLib.Value();
                             lstStyles.Model.GetValue(iterSel, 0, ref val);
                             if ((string)val.Val == sTitle)
                             {
                                 lstStyles.Selection.SelectIter(iterSel);
                                 break;
                             }
                         } while (lstStyles.Model.IterNext(ref iterSel));
                     }
                 }
             }
         }
         Drag.Finish(e.Context, true, false, e.Time);
     }
     lstStyles.DragDataReceived -= lstStyles_DragDataReceived_Drop;
 }
コード例 #38
0
        public static bool Choose(List <Car> original, ConsoleLogger logger, DataManager data)
        {
            Console.WriteLine($"\nPlease enter a command to choose a function:");
            string option = Console.ReadLine();

            if (option == ":exit")
            {
                if (!data.EqualInstances(original))
                {
                    Console.Clear();
                    logger.Warning("You didn't saved your database yet!\nYou really want to quit? (yes/no)");
                    if (Console.ReadLine().ToLower() == "yes")
                    {
                        Environment.Exit(-1);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    Environment.Exit(-1);
                }

                return(false);
            }
            else if (option == ":fill")
            {
                Console.Clear();
                Console.WriteLine("How many cars you want to create?");
                string num = Console.ReadLine();

                if (!int.TryParse(num, out int x))
                {
                    throw new InvalidInputException($"The entered value is not a number! ('{num}')");
                }

                if (num == "0")
                {
                    throw new SWWException("The value cannot be 0!");
                }

                List <Car> cars = new List <Car>();
                for (int i = 0; i < int.Parse(num); i++)
                {
                    cars.Add(data.AddNewRandomCar());
                }

                Console.Clear();
                logger.Info($"You have created {num} pieces of cars.\n");
                bool check = original.Count == 0;

                foreach (Car car in cars)
                {
                    data.AddCar(car);

                    /*
                     * if (check)
                     *  original.Add(car);
                     */
                    Console.WriteLine(PrintCarProperties(car, false));
                }
                return(true);
            }
            else if (option == ":create")
            {
                Console.Clear();
                string[] properties = { "license plate. (e.g.: XXX-000):",
                                        "brand.:",
                                        "color.:",
                                        "max speed.:",
                                        "Can the car take part in the traffic? (Yes/No)" };
                string[] car_data = new string[properties.Length];

                for (int i = 0; i < properties.Length; i++)
                {
                    if (i == properties.Length - 1)
                    {
                        Console.WriteLine($"\n{properties[i]}");
                    }
                    else
                    {
                        Console.WriteLine($"\nEnter your car {properties[i]}");
                    }

                    if (i == 0)
                    {
                        while (true)
                        {
                            string temp = Console.ReadLine().ToUpper();

                            if (Common.CheckPlateFormat(temp))
                            {
                                if (!Common.CheckValidPlate(data.GetCars(), temp))
                                {
                                    car_data[i] = temp;
                                    break;
                                }
                                else
                                {
                                    Console.Clear();
                                    logger.Error($"Your license plate is already exist! ('{temp}')");
                                    Console.WriteLine("Please enter another license plate:");
                                }
                            }
                            else
                            {
                                throw new InvalidInputException($"Invalid license plate format! ('{temp}')");
                            }
                        }
                    }
                    else if (i == 3)
                    {
                        while (true)
                        {
                            string temp  = Console.ReadLine();
                            bool   check = true;
                            for (int n = 0; n < temp.Length; n++)
                            {
                                if (!char.IsNumber(temp[n]))
                                {
                                    Console.Clear();
                                    logger.Error($"The entered value is not a number! ('{temp}')");
                                    Console.WriteLine("Please enter another value:");
                                    check = false;
                                    break;
                                }
                            }
                            if (check)
                            {
                                car_data[i] = temp;
                                break;
                            }
                        }
                    }
                    else
                    {
                        car_data[i] = Common.Capitalize(Console.ReadLine());
                    }
                }

                Car car = new Car(car_data);

                data.AddCar(car);
                if (original.Count == 0)
                {
                    original.Add(car);
                }

                Console.Clear();
                logger.Info("You have created a car.\n");
                Console.WriteLine(PrintCarProperties(car, true));

                return(true);
            }
            else if (option == ":list")
            {
                if (data.GetCars().Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }

                Console.Clear();
                logger.Info($"There are {data.GetCars().Count} cars in the database.\n");
                foreach (Car car in data.GetCars())
                {
                    Console.WriteLine(PrintCarProperties(car, false));
                }

                return(true);
            }
            else if (option == ":find")
            {
                if (data.GetCars().Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }

                Console.Clear();
                Console.WriteLine("What do you want to look for?\n");
                string[] properties =
                {
                    "License plate",
                    "Brand",
                    "Color",
                    "Max speed",
                    "Validity"
                };
                for (int i = 0; i < properties.Length; i++)
                {
                    Console.WriteLine($"({i + 1}). - {properties[i]}");
                }
                Console.WriteLine("\nPlease type a property index to choose it.");
                int    index;
                string input = Console.ReadLine();
                if (int.TryParse(input, out index))
                {
                    index = int.Parse(input) - 1;
                }
                else
                {
                    throw new InvalidInputException($"Invalid type - string != int! ('{input}')");
                }

                Console.Clear();
                Console.WriteLine($"Please enter the {properties[index].ToLower()} what are you looking for.");
                string search;

                switch (index)
                {
                case 0:
                    search = Console.ReadLine().ToUpper();
                    if (!Common.CheckPlateFormat(search))
                    {
                        throw new InvalidInputException($"Invalid license plate format! ('{search}')");
                    }
                    break;

                case 1:
                    search = Common.Capitalize(Console.ReadLine());
                    if (!data.GetRP().GetBrands().Contains(search))
                    {
                        throw new SWWException($"Unknown brand! ('{search}')");
                    }
                    break;

                case 2:
                    search = Common.Capitalize(Console.ReadLine());
                    if (!data.GetRP().GetColors().Contains(search))
                    {
                        throw new SWWException($"Unknown color! ('{search}')");
                    }
                    break;

                case 3:
                    search = Console.ReadLine();
                    if (!int.TryParse(search, out int x))
                    {
                        throw new InvalidInputException($"The entered value is not a number! ('{search}')");
                    }
                    break;

                case 4:
                    search = Console.ReadLine().ToLower();
                    if (search != "valid" && search != "invalid")
                    {
                        throw new InvalidInputException($"Invalid validity! ('{search}')");
                    }
                    break;

                default:
                    search = Console.ReadLine();
                    break;
                }

                Console.Clear();
                int count = 0;
                foreach (Car car in data.GetCars())
                {
                    if (index == 0 && car.LicensePlate.Equals(search) ||
                        index == 1 && car.Brand.Equals(search) ||
                        index == 2 && car.Color.Equals(search) ||
                        index == 3 && car.MaxSpeed.ToString().Equals(search) ||
                        index == 4 && car.Validity.ToString().Equals(search.Equals("valid").ToString()))
                    {
                        count++;
                        Console.WriteLine(PrintCarProperties(car, false));
                    }
                }
                logger.Info($"Totally matches: {count}pc");

                return(true);
            }
            else if (option == ":update")
            {
                if (data.GetCars().Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }

                Console.Clear();
                Console.WriteLine("Enter the car's license plate:");
                string plate = Console.ReadLine().ToUpper();

                if (!Common.CheckPlateFormat(plate))
                {
                    throw new InvalidInputException($"Invalid license plate format! ('{plate}')");
                }
                if (!Common.CheckValidPlate(data.GetCars(), plate))
                {
                    throw new InvalidInputException($"Invalid license plate! ('{plate}')");
                }

                Console.Clear();
                string[] properties = new string[] {
                    "License plate",
                    "Brand",
                    "Color",
                    "Max speed",
                    "Validity"
                };

                Console.WriteLine("Please type a property name to choose it.\n");
                for (int i = 0; i < properties.Length; i++)
                {
                    Console.WriteLine($"- {properties[i]}");
                }
                Console.WriteLine("\nWhich property you want to change?");
                string choose = Console.ReadLine().ToLower();

                if (!Array.Exists(properties, item => item == Common.Capitalize(choose)))
                {
                    throw new UnknownKeyException($"There is no such option! ('{choose}')");
                }

                Console.Clear();
                Console.WriteLine($"What will be the new {choose}?");

                foreach (Car car in data.GetCars())
                {
                    if (car.LicensePlate.Equals(plate))
                    {
                        if (choose == "license plate")
                        {
                            car.LicensePlate = Console.ReadLine();
                        }
                        else if (choose == "brand")
                        {
                            car.Brand = Common.Capitalize(Console.ReadLine());
                        }
                        else if (choose == "color")
                        {
                            car.Color = Common.Capitalize(Console.ReadLine());
                        }
                        else if (choose == "max speed")
                        {
                            car.MaxSpeed = int.Parse(Console.ReadLine());
                        }
                        else if (choose == "validity")
                        {
                            car.Validity = Console.ReadLine().ToLower().Equals("valid");
                        }

                        Console.Clear();
                        logger.Info($"You have succesfully updated the car's {choose}.\n");
                        Console.WriteLine(PrintCarProperties(car, true));
                        break;
                    }
                }

                return(true);
            }
            else if (option == ":remove")
            {
                if (data.GetCars().Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }

                Console.Clear();
                Console.WriteLine("Enter the car's license plate:");
                string plate = Console.ReadLine().ToUpper();

                if (!Common.CheckPlateFormat(plate))
                {
                    throw new InvalidInputException($"Invalid license plate format! ('{plate}')");
                }
                if (!Common.CheckValidPlate(data.GetCars(), plate))
                {
                    throw new InvalidInputException($"Invalid license plate! ('{plate}')");
                }
                Console.Clear();
                //
                int index = -1;
                foreach (Car car in data.GetCars())
                {
                    index++;
                    if (plate.Equals(car.LicensePlate))
                    {
                        logger.Info("You have removed a car from a database.\n");
                        Console.WriteLine(PrintCarProperties(car, true));
                        break;
                    }
                }

                data.DeleteCar(index);
                return(true);
            }
            else if (option == ":clear")
            {
                if (data.GetCars().Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }

                Console.Clear();
                logger.Info($"You have successfully delete '{data.GetCars().Count}' cars from the database.");
                data.GetCars().Clear();

                return(true);
            }
            else if (option == ":save")
            {
                if (data.GetCars().Count == 0 && original.Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }
                else if ((data.GetCars().Count - original.Count) == 0)
                {
                    throw new SWWException("There are no new cars created!");
                }

                Console.Clear();
                data.Save();
                logger.Info($"You have successfully saved {data.GetCars().Count - original.Count} cars to your simulation.");

                original.Clear();
                foreach (Car car in data.GetCars())
                {
                    original.Add(car);
                }

                return(true);
            }
            else if (option == ":reload")
            {
                if (data.EqualInstances(original))
                {
                    throw new SWWException("You can't reload your database!");
                }

                Console.Clear();
                data.GetCars().Clear();

                foreach (Car car in original)
                {
                    data.AddCar(car);
                }

                logger.Info("You have successfully reload your database.");

                return(true);
            }
            else if (option == ":race")
            {
                if (data.GetCars().Count == 0)
                {
                    throw new EmptyDatabaseException("There are no cars in the database!");
                }

                Console.Clear();
                string index = SelectRace();

                Race race;
                if (index == "1")
                {
                    race = new IllegalRace();
                }
                else if (index == "2")
                {
                    race = new Derby();
                }
                else if (index == "3")
                {
                    race = new Drag();
                }
                else
                {
                    throw new UnknownKeyException($"There is no such option! ('{index}')");
                }

                while (true)
                {
                    logger.Info($"You have started {GetRaceName(index)}.");

                    Console.WriteLine(
                        $"\n[DESCRIPTION]:\n" +
                        $" - Validity = {(race.Validity == null ? "N/A" : race.Validity)}\n" +
                        $" - Max participants = {(race.MaxParticipant == 0 ? "N/A" : race.MaxParticipant.ToString())}\n" +
                        $" - Minimum speed = {(race.MinimumSpeed == 0 ? "N/A" : race.MinimumSpeed.ToString() + "Km/h\n")}"
                        );

                    logger.Info($"You are already selected '{race.GetRaceCars().Count}'pcs of cars to the race.\n");

                    foreach (Car car in data.GetCars())
                    {
                        if (!car.Choosed)
                        {
                            Console.WriteLine(PrintCarProperties(car, false));
                        }
                    }

                    Console.WriteLine("\nPlease type a car's license plate to choose it or write '0' to start the race.");
                    string plate = Console.ReadLine().ToUpper();

                    if (plate == "0")
                    {
                        if (race.GetRaceCars().Count <= 1)
                        {
                            Console.Clear();
                            logger.Error($"You haven't selected enough cars for the race yet! Choosen cars: {race.GetRaceCars().Count}");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (!Common.CheckPlateFormat(plate))
                    {
                        Console.Clear();
                        logger.Error($"Invalid license plate format! ('{plate}')");
                        continue;
                    }

                    if (!Common.CheckValidPlate(data.GetCars(), plate))
                    {
                        Console.Clear();
                        logger.Error($"Invalid license plate! ('{plate}')");
                        continue;
                    }

                    foreach (Car car in data.GetCars())
                    {
                        if (plate.Equals(car.LicensePlate))
                        {
                            if (!race.Contains(car))
                            {
                                race.AddCar(car);
                                car.Choosed = true;
                                Console.Clear();
                                break;
                            }
                            else
                            {
                                Console.Clear();
                                logger.Error("This car is already participate in the race!");
                            }
                        }
                    }
                }
                Console.Clear();
                logger.Info($"{GetRaceName(index)} result:");
                race.DoRace();
                data.ChooseDefault();

                Console.WriteLine($"\nParticipants: {race.GetRaceCars().Count}/{race.MaxParticipant}");
                foreach (Car car in race.GetRaceCars())
                {
                    Console.WriteLine(PrintCarProperties(car, false));
                }
                Console.WriteLine($"\nThe winner is {race.GetWinner().ToString()}!");

                return(true);
            }
            else
            {
                throw new UnknownKeyException($"There is no such option! ('{option}')");
            }
        }
コード例 #39
0
    public override void Awake()
    {
        Input.simulateMouseWithTouches = false;
        this.Ink = 40;

        Drag.MouseDownStream()
        .Subscribe(position =>
        {
            SubscribeDragStream(position, Drag.MouseDragStream(threshold));
        })
        .AddTo(this.eventResources);

        Drag.TouchStartStream()
        .Subscribe(touch =>
        {
            SubscribeDragStream(Camera.main.ScreenToWorldPoint(touch.Item1.position), Drag.TouchDragStream(touch.Item1.fingerId, threshold));
        })
        .AddTo(this.eventResources);

        base.Awake();
    }
コード例 #40
0
ファイル: AOEAtTower.cs プロジェクト: Daniel95/TowerDefense2D
 protected override void Awake()
 {
     base.Awake();
     drag = GetComponent<Drag>();
 }
コード例 #41
0
ファイル: Gestures.cs プロジェクト: Costo/Xamarin.Forms
		public static void Pan (this IApp app, Drag drag)
		{
			app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
		}
コード例 #42
0
    private void Update()
    {
        //Change id according to sprite
        if (Array.IndexOf(spriteLoopBlockEnd, sr.sprite) > -1)
        {
            blockId = 2;
        }
        if (Array.IndexOf(spriteLoopBlock, sr.sprite) > -1)
        {
            blockId = 1;
        }
        if (sr.sprite != spriteOrig && !GameManager.instance.running)
        {
            Vector2 clickpo       = (Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position);
            Vector2 clickpoGlobal = (Camera.main.ScreenToWorldPoint(Input.mousePosition));
            //Check if mouse on top
            if ((clickpo.x > -0.16f) && (clickpo.x < 0.16f) && (clickpo.y > -0.16f) && (clickpo.y < 0.16f) && clickpoGlobal.x > 0.32f && clickpoGlobal.x < 6.08f)
            {
                //Give codeblock when clicked
                if (Input.GetMouseButtonDown(0))
                {
                    Vector2 middle = new Vector2(transform.position.x, transform.position.y);
                    Drag    block  = Instantiate(codeBlock, middle, Quaternion.identity);
                    block.GetComponent <SpriteRenderer>().sprite = sr.sprite;
                    block.startPos = _startPos;
                    sr.sprite      = spriteOrig;
                    blockId        = 0;
                }
                //Change with mouse wheel if id = 0 (loop)
                if (blockId == 1 || blockId == 2)
                {
                    //Up
                    if (Input.GetAxis("Mouse ScrollWheel") > 0)
                    {
                        if (currentSprite < 8)
                        {
                            currentSprite++;
                        }
                        if (blockId == 1)
                        {
                            sr.sprite = spriteLoopBlock[currentSprite];
                        }
                        else
                        {
                            sr.sprite = spriteLoopBlockEnd[currentSprite];
                        }
                    }
                    //Down
                    if (Input.GetAxis("Mouse ScrollWheel") < 0)
                    {
                        if (currentSprite > 0)
                        {
                            currentSprite--;
                        }
                        if (blockId == 1)
                        {
                            sr.sprite = spriteLoopBlock[currentSprite];
                        }
                        else
                        {
                            sr.sprite = spriteLoopBlockEnd[currentSprite];
                        }
                    }
                }

                //Destroy with left click
                if (Input.GetMouseButtonDown(1))
                {
                    ReturnToStart();
                }
            }
        }
    }
コード例 #43
0
ファイル: ItemButton.cs プロジェクト: grudin/team-purin
    // Use this for initialization
    void Start () {
		drag = GameObject.FindGameObjectWithTag ("dragManager").GetComponent<Drag>();
	}
コード例 #44
0
ファイル: AnimalItem.cs プロジェクト: vietanh1441/AnimalFarm
    // Use this for initialization
    void Start()
    {
        own = 0;
        drag = transform.parent.gameObject;
        drag_script = drag.GetComponent<Drag>();
        drag_script.AddList(gameObject);
        central = GameObject.Find("Central");
        central_scr = central.GetComponent<Central>();
        if (type == 0)
        {
            own = central_scr.dog;
        }
        else if(type == 1)
        {
            own = central_scr.chicken;
        }
        guiStyleFore = new GUIStyle();
        guiStyleFore.normal.textColor = Color.white;
        guiStyleFore.alignment = TextAnchor.UpperCenter;
        guiStyleFore.wordWrap = true;
        guiStyleBack = new GUIStyle();
        guiStyleBack.normal.textColor = Color.black;
        guiStyleBack.alignment = TextAnchor.UpperCenter;
        guiStyleBack.wordWrap = true;

           // toolTipText = name + "\n In Storage: " + own + "\n " + toolTipText;
    }