示例#1
0
 void Start()
 {
     audioBox    = GetComponent <Rigidbody>();
     sample      = GetComponent <AudioSource>();
     m_DragBox   = gameObject.GetComponent <DragNDrop>();
     sample.mute = true;
 }
示例#2
0
    public void MoveNext()
    {
        MoveSystem.MoveNext(grid);
        KillSystem.KillBroadcaster();

        DragNDrop.Unlock();
    }
    public virtual IEnumerator ElectronToTray()
    {
        TrayGUI[] allTrays = (TrayGUI[])UnityEngine.Object.FindObjectsOfType(typeof(TrayGUI));
        TrayGUI   theTray  = null;
        int       i        = 0;

        while (i < allTrays.Length)
        {
            if (allTrays[i].acceptTypes[2] == 1)
            {
                theTray = allTrays[i];
            }
            i++;
        }
        Vector2           origin = DragNDrop.WorldToScreen(Vector3.right * this.orbitals.shells[this.orbitals.outerShell].radius);
        GameObject        obj    = new GameObject("Draggable");
        Draggable_Nucleon dr     = (Draggable_Nucleon)obj.AddComponent(typeof(Draggable_Nucleon));

        dr.type = PType.E;
        float time      = 0.8f;
        float startTime = Time.time;

        while (Time.time < (startTime + time))
        {
            float amt = (Time.time - startTime) / time;
            dr.position = (origin * (1f - amt)) + ((theTray.position - new Vector2(0, ((UnityScript.Lang.UnityBuiltins.parseFloat(theTray.dimensions.y) - 0.5f) * theTray.itemSize.y) * 0.5f)) * amt);
            yield return(null);
        }
        theTray.Drop(dr);
        dr.Die();
    }
 private void TimelineControl_MouseUp(object sender, MouseEventArgs e)
 {
     if (howToDrag == DragNDrop.MOVE_TIMELINE_BAR)
     {
         steuerung.AdvanceTo(GetTimeAtControlPosition(e.Location, false));
     }
     howToDrag = DragNDrop.NONE;
 }
示例#5
0
    void Awake()
    {
        worldNavigation = GameObject.Find("WorldNavigation");
        dragNDrop       = GameObject.Find("LevelManager").GetComponent <DragNDrop>();



        //INSTANTIATE STRUCTURE MENU

        foreach (Transform child in buildGrid.transform)
        {
            if (child.CompareTag("BuildingButton"))
            {
                buildingButtons.Add(child.gameObject);
            }
        }
        for (int i = 0; i < buildingButtons.Count; i++)
        {
            buildingButtons[i].GetComponent <StructMenuBlock>().blockNo = i;
        }



        ProducalToActive();
        //float blockWidth = buildingMenuBlockPre.GetComponent<RectTransform>().rect.width;
        //float openerWidth = gameObject.GetComponent<RectTransform>().rect.width;

        //INSTATIATE BUILDGRID
        //buildGrid = Instantiate(new GameObject(), new Vector3(0,0,0), transform.rotation);
        //buildGrid.active = false;
        //buildGrid.name = "Building Grid";
        //buildGrid.transform.parent = gameObject.transform;
        //buildGrid.AddComponent<Image>();
        //buildGrid.GetComponent<Image>().sprite = gridSprite;
        //buildGrid.GetComponent<RectTransform>().anchoredPosition = new Vector2(-256, 260);
        //buildGrid.GetComponent<RectTransform>().localScale = new Vector3(7f, 4f, 1f);

        //Building buttons spawn
        //for (int x = 0; x < gridSizeX; x++)
        //{
        //    for (int y = 0; y < gridSizeX; y++)
        //    {
        //        Vector3 pos = new Vector3(gameObject.transform.position.x - 500 + (100 * x), gameObject.transform.position.y + 200 - (100 * y), gameObject.transform.position.z);
        //        structButtons[x,y] = Instantiate(buildingMenuBlockPre, pos, transform.rotation);
        //        structButtons[x,y].transform.SetParent(buildGrid.transform);
        //        structButtons[x, y].GetComponent<StructMenuBlock>().blockNo = curBlockNo;
        //        if (buildingsPro.Length > curBlockNo)
        //        {
        //            structButtons[x, y].GetComponent<Image>().sprite = buildingsPro[curBlockNo].GetComponent<SpriteRenderer>().sprite;
        //        }
        //        structButtons[x,y].name = "StructButton " + x + ", "+ y;
        //        structButtons[x,y].GetComponent<StructMenuBlock>().structMenu = this;
        //        curBlockNo += 1;
        //    }

        //}
    }
    void Start()
    {
        Movement                     = gameObject.AddComponent <DragNDrop>();
        Movement.Enabled             = true;
        Movement.SelectionCallback   = this.CursorSelect;
        Movement.DeselectionCallback = this.CursorDeselect;

        Movement.CursorSelect();
    }
示例#7
0
 public PlaylistForm(Form1 form1, Dictionary<string, VideoFile> ParsedVideoFiles, DragNDrop.DragAndDropListView Form1PlaylistDragAndDropListView)
 {
     InitializeComponent();
     this.form1 = form1;
     this.ParsedVideoFiles = ParsedVideoFiles;
     this.Form1PlaylistDragAndDropListView = Form1PlaylistDragAndDropListView;
     foreach (KeyValuePair<string, VideoFile> entry in ParsedVideoFiles)
     {
         PlaylistDragAndDropListView.Items.Add(new ListViewItem(new string[2] { entry.Value.CasparPath, entry.Value.DurationString }));
     }
 }
示例#8
0
 public void OnReDrop()
 {
     if (drag)
     {
         //Debug.Log("drop set");
         dragNDrop.OnDrop();
         drag = false;
         if (droppedEssence == null)
         {
             dragNDrop = null;
             gridGen.OnHexGridExport();
         }
     }
 }
示例#9
0
    public void OnGetBack()
    {
        //Debug.Log("clicked" + droppedEssence);

        if (droppedEssence != null && locked == false)
        {
            GetBack();
            dragNDrop      = null;
            droppedEssence = null;
            _img.sprite    = _defaultImg;
            _img.color     = _defaultColor;
        }
        gridGen.OnHexGridExport();
    }
示例#10
0
    IEnumerator WhatIfRunConsole(int number) //TODO - this
    {
        int startIndent = number % 3;

        for (int i = number; i < slots.Count - (2 - startIndent); i += 3)
        {
            if (loopFixer > 0 && loopFixer > i && startIndent != loopFixer % 3)
            {
                i = (loopFixer - loopFixer % 3) + startIndent; loopFixer = 0;
            }

            slotValue slot = slots[i];

            if (slot.method != null)
            {
                DragNDrop blockScript = slot.method.GetComponent <DragNDrop>();
                if (slot.method.CompareTag("IfStatement"))
                {
                    if (startIndent > 1)
                    {
                        break;
                    }                               //don't allow nesting within nesting!
                    yield return(StartCoroutine("WhatIfRunConsole", (i + 3 + 1)));
                }
                else if (slot.method.CompareTag("Loop"))
                {
                    if (startIndent > 1)
                    {
                        break;
                    }                               //don't allow nesting within nesting!
                    string loopTimes = "";
                    loopTimes = blockScript.loopVar.text == "" ? "1" : blockScript.loopVar.text;
                    for (int j = 0; j < int.Parse(loopTimes); j++)
                    {
                        yield return(StartCoroutine("WhatIfRunConsole", (i + 3 + 1)));
                    }
                }
                else
                {
                    print("Doing nothing, as I am supposed to, sir! " + Time.time.ToString());
                }
            }
            else if (startIndent > 0)   /*print("Method is null! " + "Looking at: " + (i / 3) + "," + (i % 3) + " : " + Time.time.ToString());*/
            {
                loopFixer = i; break;
            }
        }
        yield break;
    }
示例#11
0
    private void AddAvailableJobs()
    {
        foreach (Job job in jobsContainer.jobsContainer)
        {
            GameObject newJob = new GameObject(job.title);
            newJob.transform.parent = availableJobsContainer.transform;

            // Store location data for repositioning on failed drop.
            // Assign the individual floats to prevent copying the reference
            job.startingPosition = new Vector2(newJob.transform.position.x, newJob.transform.position.y);

            Image jobImage = newJob.AddComponent <Image>();
            jobImage.sprite = jobSprite;

            DragNDrop dragNDrop = newJob.AddComponent <DragNDrop>();
            dragNDrop.availableJobsContainer = availableJobsContainer;
            dragNDrop.scheduleContainer      = scheduleContainer;
            dragNDrop.job = job;

            // Needs to be false otherwise Schedule can't fire events
            newJob.AddComponent <CanvasGroup>().interactable = false;
        }
    }
示例#12
0
    bool ifif(DragNDrop blockScript)
    {
        int thot = (int)playerMovement.transform.eulerAngles.z;

        switch (thot)
        {
        case 0:
            direction = new Vector2(1, 0);
            break;

        case 90:
            direction = new Vector2(0, 1);
            break;

        case 180:
            direction = new Vector2(-1, 0);
            break;

        case 270:
            direction = new Vector2(0, -1);
            break;

        default:
            direction = new Vector2(0, 0);
            break;
        }
        RaycastHit2D inFrontRay = Physics2D.Raycast(playerMovement.transform.position, direction, 1.5f);

        if (!inFrontRay)
        {
            return(false);
        }
        GameObject inFront = inFrontRay.collider.gameObject;

        return((inFront.CompareTag("Building") && blockScript.methodVar == 'b') || (inFront.CompareTag("RoadBlock") && blockScript.methodVar == 'r') || (blockScript.methodVar == 'e'));
    }
示例#13
0
        void DaGrid_MouseUp(object sender, MouseEventArgs e)
        {
            Vector2 clickedPosition = new Vector2(e.X, e.Y);
            clickedPosition *= zoomMultipliers[zoomComboBox.SelectedIndex, 1];
            clickedPosition += daGridScrollPosition;
            this.Cursor = Cursors.Default;

            switch (howToDrag)
                {
                case DragNDrop.DRAG_RUBBERBAND:
                    // nun nochLineNode markieren
                    if (Math.Abs(daGridRubberband.Width) > 2 && Math.Abs(daGridRubberband.Height) > 2)
                        {
                        // Rubberband normalisieren:
                        if (daGridRubberband.Width < 0)
                            {
                            daGridRubberband.X += daGridRubberband.Width;
                            daGridRubberband.Width *= -1;
                            }
                        if (daGridRubberband.Height < 0)
                            {
                            daGridRubberband.Y += daGridRubberband.Height;
                            daGridRubberband.Height *= -1;
                            }

                        if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                            {
                            List<LineNode> tmp = nodeSteuerung.GetLineNodesAt(daGridRubberband);
                            foreach (LineNode ln in selectedLineNodes)
                                {
                                if (!tmp.Contains(ln))
                                    tmp.Add(ln);
                                }
                            selectedLineNodes = tmp;
                            }
                        else
                            {
                            selectedLineNodes = nodeSteuerung.GetLineNodesAt(daGridRubberband);
                            }
                        }
                    else
                        {
                        selectedLineNodes = new List<LineNode>();
                        selectedNodeConnection = nodeSteuerung.GetNodeConnectionAt(clickedPosition);
                        selectedVehicle = nodeSteuerung.GetVehicleAt(clickedPosition);
                        }
                    break;
                case DragNDrop.MOVE_MAIN_GRID:
                    thumbGrid.Invalidate();
                    break;
                default:
                    break;
                }

            if ((howToDrag == DragNDrop.CREATE_NODE || howToDrag == DragNDrop.MOVE_NODES || howToDrag == DragNDrop.MOVE_IN_SLOPE || howToDrag == DragNDrop.MOVE_OUT_SLOPE) && m_selectedLineNodes != null)
                {
                nodeSteuerung.UpdateNodeConnections(m_selectedLineNodes);
                nodeSteuerung.InvalidateNodeBounds();
                UpdateDaGridClippingRect();
                thumbGrid.Invalidate();
                }

            // Drag'n'Drop Bereich wieder löschen
            howToDrag = DragNDrop.NONE;
            Invalidate(InvalidationLevel.ONLY_MAIN_CANVAS);
        }
示例#14
0
    IEnumerator RunConsole(int number) //TODO - this
    {
        int emptyCheck  = 0;
        int startIndent = number % 3;

        for (int i = number; i < slots.Count - (2 - startIndent); i += 3)
        {
            if (loopFixer > 0 && loopFixer > i && startIndent < loopFixer % 3)
            {
                i = (loopFixer - loopFixer % 3) + startIndent; loopFixer = 0;
            }
            slotValue slot = slots[i];

            if (slot.method != null)
            {
                DragNDrop blockScript = slot.method.GetComponent <DragNDrop>();
                if (slot.method.CompareTag("IfStatement"))
                {
                    if (startIndent > 1)
                    {
                        break;
                    }                               //don't allow nesting within nesting!
                    if (ifif(blockScript))
                    {
                        print("if-Block entered. Starting new console at row: " + ((i + 3) / 3) + " and " + (startIndent + 1) + " : " + Time.time.ToString());
                        yield return(StartCoroutine("RunConsole", (i + 3 + 1)));
                    }
                    else
                    {
                        yield return(StartCoroutine("WhatIfRunConsole", (i + 3 + 1)));
                    }
                }
                else if (slot.method.CompareTag("Loop"))
                {
                    if (startIndent > 1)
                    {
                        break;
                    }                               //don't allow nesting within nesting!
                    string loopTimes = "";
                    loopTimes = blockScript.loopVar.text == ""? "1" : blockScript.loopVar.text;
                    for (int j = 0; j < int.Parse(loopTimes); j++)
                    {
                        print("loop entered. Starting new console at row: " + ((i + 3) / 3) + " and " + (startIndent + 1) + " : " + Time.time.ToString());
                        yield return(StartCoroutine("RunConsole", (i + 3 + 1)));
                    }
                }
                else
                {
                    print("Executing function: " + blockScript.methodName.text + " " + Time.time.ToString());
                    yield return(playerMovement.StartCoroutine(blockScript.methodName.text));
                    //yield return new WaitWhile(() => playerMovement.driving); //<-- this is still nice code. Just not used
                }
            }
            else if (startIndent > 0)
            {
                print("Method is null! " + "Looking at: " + (i / 3) + "," + (i % 3) + " : " + Time.time.ToString()); loopFixer = i; break;
            }
            else
            {
                emptyCheck++; if (emptyCheck == 50)
                {
                    Cursor.lockState = CursorLockMode.None; print("You are a fat c**t.");
                }
            }
        }
        yield break;
    }
 public static Question CreateSubQuestion(String line)
 {
     Question temp = new OneChoice(Constants.MathCourse, 1, Constants.OneChoiceQuestionType, String.Empty, String.Empty);
     String[] properties = line.Split(Constants.SemiColon);
     char course = Convert.ToChar(properties[0]);
     int difficulty = Convert.ToInt32(properties[1]);
     char questionType = Convert.ToChar(properties[2]);
     String question = properties[3];
     switch (questionType)
     {
         case Constants.OneChoiceQuestionType:
             temp = new OneChoice(course, difficulty, questionType, question, properties[4]);
             break;
         case Constants.MultipleChoiceQuestionType:
             String[] possibleAnswers = new String[5];
             bool[] correctAnswers = new bool[5];
             for (int i = 0; i <= 4; i++)
             {
                 possibleAnswers[i] = properties[i + 4];
                 correctAnswers[i] = Convert.ToBoolean(properties[i + 9]);
             }
             temp = new MultipleChoice(course, difficulty, questionType, question, possibleAnswers, correctAnswers);
             break;
         case Constants.DragDropQuestionType:
             String[] dragAnswers = new String[5];
             String[] dropAnswers = new String[5];
             for (int i = 0; i <= 4; i++)
             {
                 dragAnswers[i] = properties[i + 4];
                 dropAnswers[i] = properties[i + 9];
             }
             temp = new DragNDrop(course, difficulty, questionType, question, dragAnswers, dropAnswers);
             break;
         case Constants.TableQuestionType:
             temp = new TableQuestion(course, difficulty, questionType, question, Convert.ToInt32(properties[4]));
             break;
     }
     return temp;
 }
    public override void Drop(Draggable d)
    {
        float             time         = 0f;
        Draggable_Nucleon nuc          = d as Draggable_Nucleon;
        Vector3           pos          = DragNDrop.ScreenToWorld(Input.mousePosition) + Vector3.forward;
        Vector3           outDir       = new Vector3(pos.x, pos.y, 0).normalized;
        GameObject        particleObj  = UnityEngine.Object.Instantiate(this.particlePrefab, pos, Quaternion.identity);
        CreatorParticle   mover        = (CreatorParticle)particleObj.GetComponent(typeof(CreatorParticle));
        string            resourceName = nuc.type == PType.E ? "Electron_TIF" : (nuc.type == PType.P ? "Proton_TIF" : "Neutron_TIF");

        particleObj.GetComponent <Renderer>().material.mainTexture = (Texture2D)Resources.Load(resourceName);
        if (this.mouseOver == 0)
        {
            if (nuc.type == PType.E)
            {
                if ((UserAtom.p >= UserAtom.e) && (AtomChart.elements[UserAtom.p - 1].grabElectron || (UserAtom.e < UserAtom.p)))
                {
                    float   speed     = 3f;
                    Vector3 targetPos = Vector3.right * this.orbitals.shells[this.orbitals.outerShell].radius;
                    speed          = Mathf.Clamp(speed * (targetPos - pos).magnitude, 3, 10);
                    time           = (pos - targetPos).magnitude / speed;
                    mover.velocity = (targetPos - pos).normalized * speed;
                    mover.lifetime = time;
                    this.StartCoroutine(this.AddToOrbitalsRoutine(time));
                }
                else
                {
                    mover.velocity = outDir * (UserAtom.p < UserAtom.e ? 4 : 1);
                    mover.lifetime = 10;
                }
            }
            else
            {
                if (nuc.type == PType.N)
                {
                    mover.velocity = outDir;
                    mover.lifetime = 10;
                }
                else
                {
                    float ratio = Mathf.Min(pos.magnitude / this.orbitals.shells[this.orbitals.outerShell].radius, 1);
                    mover.velocity = outDir * Mathf.Lerp(8, 1, ratio);
                    mover.lifetime = 10;
                }
            }
        }
        else
        {
            // mouseOver == 1
            if (nuc.type == PType.E)
            {
                mover.velocity = outDir * 8;
                mover.lifetime = 3;
            }
            else
            {
                mover.velocity = outDir * -4;
                time           = 0.2f;
                mover.lifetime = time;
                this.StartCoroutine(this.AddToNucleusRoutine(time, nuc.type));
            }
        }
    }
        /// <summary>
        /// Eventhandler beim Drücken der Maustaste
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimelineControl_MouseDown(object sender, MouseEventArgs e)
        {
            // wurde der Zeitschieber angeklickt?
            if ((e.Button == MouseButtons.Left) && (Math.Abs(e.X - GetHorizontalClientPositionAtCurrentTime()) < 2))
            {
                // Drag'n'Drop Modus setzen
                howToDrag = DragNDrop.MOVE_TIMELINE_BAR;
            }

            // wurde ein Plus-/Minussysmbol einer Gruppe angeklickt?
            else if (e.X < rowHeight && GetGroupAtClientPosition(e.Location, true) != null)
            {
                TimelineGroup tg = GetGroupAtClientPosition(e.Location, true);
                tg.collapsed = !tg.collapsed;
            }

            // wurde vielleicht was anderes wichtiges angeklickt?
            else
            {
                TimelineEntry newEntry = GetTimelineEntryAtControlPosition(e.Location);
                TimelineGroup newGroup = GetGroupAtClientPosition(e.Location, false);

                if (newEntry != m_selectedEntry || newGroup != m_selectedGroup)
                {
                    m_selectedGroup = newGroup;
                    m_selectedEntry = newEntry;
                    OnSelectionChanged();
                }

                // wurde ein TimelineEntry angeklickt?
                if (m_selectedEntry != null)
                {
                    // gucken, ob es sich bei te um ein TrafficLight handelt
                    TrafficLight tl = m_selectedEntry as TrafficLight;
                    if (tl != null)
                    {
                        switch (e.Button)
                        {
                        case MouseButtons.Left:
                            #region TimelineEvent hinzufügen
                            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                            {
                                double time = GetTimeAtControlPosition(e.Location, true);

                                // Event hinzufügen, welches die Ampel umschaltet
                                TimelineEvent eventToAdd = new TimelineEvent(time, Math.Min(1, (m_selectedEntry.GetTimeOfNextEvent(time) - time) / 2), Color.Green, tl.SwitchToGreen, tl.SwitchToRed);
                                m_selectedEntry.AddEvent(eventToAdd, true, false);

                                howToDrag   = DragNDrop.MOVE_EVENT_END;
                                eventToDrag = eventToAdd;
                                this.Cursor = Cursors.SizeWE;
                                Invalidate();
                            }
                            #endregion

                            #region TimelineEntry selektieren
                            else
                            {
                                // Drag'n'Drop für Events initialisieren
                                TimelineEvent theEvent = GetTimelineEventAtControlPosition(e.Location, true);
                                if (theEvent != null)
                                {
                                    if (Math.Abs(GetClientPositionForTimelineEvent(theEvent).X - e.Location.X) < 3)
                                    {
                                        howToDrag   = DragNDrop.MOVE_EVENT_START;
                                        eventToDrag = theEvent;
                                    }
                                    else if (Math.Abs(GetClientPositionForTimelineEvent(theEvent).X + theEvent.eventLength * zoom - e.Location.X) < 3)
                                    {
                                        howToDrag   = DragNDrop.MOVE_EVENT_END;
                                        eventToDrag = theEvent;
                                    }
                                    else
                                    {
                                        mouseDownPosition = e.Location;
                                        eventToDragOffset = GetClientPositionForTimelineEvent(theEvent).X - e.Location.X;
                                        howToDrag         = DragNDrop.MOVE_EVENT;
                                        eventToDrag       = theEvent;
                                    }
                                }
                            }
                            #endregion
                            break;

                        case MouseButtons.Right:
                            #region TimelineEvent entfernen
                            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                            {
                                double time = GetTimeAtControlPosition(e.Location, false);

                                TimelineEvent eventToRemove = tl.GetEventAtTime(time);
                                tl.RemoveEvent(eventToRemove);
                            }
                            #endregion
                            break;
                        }
                    }
                }

                Invalidate();
            }
        }
 /// <summary>
 /// Erstellt ein neues SelectionChangedEventArgs
 /// </summary>
 /// <param name="te">ausgewähltes TimelineEntry</param>
 /// <param name="ev">ausgewähltes TimelineEvent</param>
 /// <param name="dragAction">Art des Drag and Drop-Vorganges</param>
 public EventChangedEventArgs(TimelineEntry te, TimelineEvent ev, DragNDrop dragAction)
 {
     this.m_selectedEntry = te;
     this.m_handeledEvent = ev;
     this.m_dragAction    = dragAction;
 }
 /// <summary>
 /// Erstellt ein neues SelectionChangedEventArgs
 /// </summary>
 /// <param name="te">ausgewähltes TimelineEntry</param>
 /// <param name="ev">ausgewähltes TimelineEvent</param>
 /// <param name="dragAction">Art des Drag and Drop-Vorganges</param>
 public EventChangedEventArgs(TimelineEntry te, TimelineEvent ev, DragNDrop dragAction)
 {
     this.m_selectedEntry = te;
     this.m_handeledEvent = ev;
     this.m_dragAction = dragAction;
 }
        /// <summary>
        /// Eventhandler beim Drücken der Maustaste
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimelineControl_MouseDown(object sender, MouseEventArgs e)
        {
            // wurde der Zeitschieber angeklickt?
            if ((e.Button == MouseButtons.Left) && (Math.Abs(e.X - GetHorizontalClientPositionAtCurrentTime()) < 2))
                {
                // Drag'n'Drop Modus setzen
                howToDrag = DragNDrop.MOVE_TIMELINE_BAR;
                }

            // wurde ein Plus-/Minussysmbol einer Gruppe angeklickt?
            else if (e.X < rowHeight && GetGroupAtClientPosition(e.Location, true) != null)
                {
                TimelineGroup tg = GetGroupAtClientPosition(e.Location, true);
                tg.collapsed = !tg.collapsed;
                }

            // wurde vielleicht was anderes wichtiges angeklickt?
            else
                {
                TimelineEntry newEntry = GetTimelineEntryAtControlPosition(e.Location);
                TimelineGroup newGroup = GetGroupAtClientPosition(e.Location, false);

                if (newEntry != m_selectedEntry || newGroup != m_selectedGroup)
                    {
                    m_selectedGroup = newGroup;
                    m_selectedEntry = newEntry;
                    OnSelectionChanged();
                    }

                // wurde ein TimelineEntry angeklickt?
                if (m_selectedEntry != null)
                    {
                    // gucken, ob es sich bei te um ein TrafficLight handelt
                    TrafficLight tl = m_selectedEntry as TrafficLight;
                    if (tl != null)
                        {
                        switch (e.Button)
                            {
                        case MouseButtons.Left:
                            #region TimelineEvent hinzufügen
                            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                                {
                                double time = GetTimeAtControlPosition(e.Location, true);

                                // Event hinzufügen, welches die Ampel umschaltet
                                TimelineEvent eventToAdd = new TimelineEvent(time, Math.Min(1, (m_selectedEntry.GetTimeOfNextEvent(time) - time) / 2), Color.Green, tl.SwitchToGreen, tl.SwitchToRed);
                                m_selectedEntry.AddEvent(eventToAdd, true, false);

                                howToDrag = DragNDrop.MOVE_EVENT_END;
                                eventToDrag = eventToAdd;
                                this.Cursor = Cursors.SizeWE;
                                Invalidate();
                                }
                            #endregion

                            #region TimelineEntry selektieren
                            else
                                {
                                // Drag'n'Drop für Events initialisieren
                                TimelineEvent theEvent = GetTimelineEventAtControlPosition(e.Location, true);
                                if (theEvent != null)
                                    {
                                    if (Math.Abs(GetClientPositionForTimelineEvent(theEvent).X - e.Location.X) < 3)
                                        {
                                        howToDrag = DragNDrop.MOVE_EVENT_START;
                                        eventToDrag = theEvent;
                                        }
                                    else if (Math.Abs(GetClientPositionForTimelineEvent(theEvent).X + theEvent.eventLength * zoom - e.Location.X) < 3)
                                        {
                                        howToDrag = DragNDrop.MOVE_EVENT_END;
                                        eventToDrag = theEvent;
                                        }
                                    else
                                        {
                                        mouseDownPosition = e.Location;
                                        eventToDragOffset = GetClientPositionForTimelineEvent(theEvent).X - e.Location.X;
                                        howToDrag = DragNDrop.MOVE_EVENT;
                                        eventToDrag = theEvent;
                                        }
                                    }

                                }
                            #endregion
                            break;

                        case MouseButtons.Right:
                            #region TimelineEvent entfernen
                            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                                {
                                double time = GetTimeAtControlPosition(e.Location, false);

                                TimelineEvent eventToRemove = tl.GetEventAtTime(time);
                                tl.RemoveEvent(eventToRemove);
                                }
                            #endregion
                            break;
                            }
                        }
                    }

                Invalidate();
                }
        }
示例#21
0
 public virtual void OnEnable()
 {
     DragNDrop.Add(this);
 }
    // Update is called once per frame
    void Update()
    {
        // Debug.Log(_mouseState);
        if (Input.GetMouseButtonDown(0))
        {
            origin = transform.localPosition;
            RaycastHit hitInfo;
            target = GetClickedObject(out hitInfo);
            if (target != null)
            {
                DragNDrop dnd = target.GetComponent <DragNDrop>();
                if (dnd != null)
                {
                    _mouseState = true;
                    screenSpace = Camera.main.WorldToScreenPoint(target.transform.position);
                    offset      = target.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));
                    Collider col = target.GetComponent <Collider>();
                    if (col != null)
                    {
                        col.enabled = false;
                    }
                }
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            _mouseState = false;
            RaycastHit hitInfo;
            target = GetClickedObject(out hitInfo);
            if (target != null)
            {
                Collider col = GetComponent <Collider>();
                if (col != null)
                {
                    col.enabled = true;
                }
                Body body = target.GetComponent <Body>();
                if (body != null)
                {
                    if (body.TryEquipGameObject(this.gameObject))
                    {
                        isEquipped = true;
                        Rotate rotate = GetComponent <Rotate>();
                        if (rotate != null)
                        {
                            rotate.enabled          = false;
                            transform.localRotation = originRotation;
                            transform.localScale    = originScale;
                        }
                    }
                    else
                    {
                        transform.localPosition = origin;
                        isEquipped = false;
                    }
                }
                else
                {
                    body = target.GetComponentInParent <Body>();
                    if (body != null)
                    {
                        if (body.TryEquipGameObject(this.gameObject))
                        {
                            isEquipped = true;
                            Rotate rotate = GetComponent <Rotate>();
                            if (rotate != null)
                            {
                                rotate.enabled          = false;
                                transform.localRotation = originRotation;
                                transform.localScale    = originScale;
                            }
                        }
                        else
                        {
                            transform.localPosition = origin;
                            isEquipped = false;
                        }
                    }
                    else
                    {
                        // InspectPosition needs  rigidbody and collider and larger hot spot
                        // Player needs larger hotspot as well
                        if (isEquipped && target.name == "InspectPosition")
                        {
                            if (target.transform.childCount > 0)
                            {
                                for (int i = 0; i < target.transform.childCount; i++)
                                {
                                    DestroyObject(target.transform.GetChild(i).gameObject);
                                }
                            }
                            BodyPartHover bph = GetComponent <BodyPartHover>();
                            if (bph != null)
                            {
                                bph.isEnabled = false;
                            }
                            isEquipped              = false;
                            transform.parent        = target.transform;
                            transform.localRotation = originRotation;
                            transform.localScale    = originScale;
                            Rotate rotate = GetComponent <Rotate>();
                            if (rotate != null)
                            {
                                rotate.enabled = true;
                            }
                            BodyPart[]      bodyParts = GetComponents <BodyPart>();
                            InventoryObject io        = GetComponent <InventoryObject>();
                            if (io != null)
                            {
                                foreach (BodyPart bodyPart in bodyParts)
                                {
                                    if (bodyPart != null)
                                    {
                                        switch (bodyPart.bodyPartType)
                                        {
                                        case BodyPartType.Hat:
                                            if (EquipedItems.GetHat() == io.ResourceName)
                                            {
                                                EquipedItems.EquipHat(null);
                                            }
                                            break;

                                        case BodyPartType.EyeNose:
                                            if (EquipedItems.GetLeftEye() == io.ResourceName)
                                            {
                                                EquipedItems.EquipLeftEye(null);
                                            }
                                            if (EquipedItems.GetRightEye() == io.ResourceName)
                                            {
                                                EquipedItems.EquipRightEye(null);
                                            }
                                            if (EquipedItems.GetNose() == io.ResourceName)
                                            {
                                                EquipedItems.EquipNose(null);
                                            }
                                            break;

                                        case BodyPartType.Mouth:
                                            if (EquipedItems.GetMouth() == io.ResourceName)
                                            {
                                                EquipedItems.EquipMouth(null);
                                            }
                                            break;

                                        case BodyPartType.Scarf:
                                            if (EquipedItems.GetNeck() == io.ResourceName)
                                            {
                                                EquipedItems.EquipNeck(null);
                                            }
                                            break;

                                        case BodyPartType.Mitten:
                                            if (EquipedItems.GetLeftHand() == io.ResourceName)
                                            {
                                                EquipedItems.EquipLeftHand(null);
                                            }
                                            if (EquipedItems.GetRightHand() == io.ResourceName)
                                            {
                                                EquipedItems.EquipRightHand(null);
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            transform.localPosition = origin;
                            isEquipped = false;
                        }
                    }
                }
            }
            else
            {
                transform.localPosition = origin;
                isEquipped = false;
            }
        }
        if (_mouseState)
        {
            //keep track of the mouse position
            var curScreenSpace = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);

            //convert the screen mouse position to world point and adjust with offset
            var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;

            //update the position of the object in the world
            target.transform.position = curPosition;
        }
    }
示例#23
0
        private void thumbGrid_MouseDown(object sender, MouseEventArgs e)
        {
            if (!thumbGridClientRect.Contains(e.Location))
                {
                RectangleF bounds = nodeSteuerung.GetLineNodeBounds();
                float zoom = Math.Min(1.0f, Math.Min((float)thumbGrid.ClientSize.Width / bounds.Width, (float)thumbGrid.ClientSize.Height / bounds.Height));
                thumbGridClientRect.X = e.Location.X - thumbGridClientRect.Width / 2;
                thumbGridClientRect.Y = e.Location.Y - thumbGridClientRect.Height/2;

                daGridScrollPosition = new Point(
                    (int)Math.Round((thumbGridClientRect.X / zoom) + bounds.X),
                    (int)Math.Round((thumbGridClientRect.Y / zoom) + bounds.Y));

                UpdateDaGridClippingRect();
                thumbGrid.Invalidate();
                DaGrid.Invalidate(true);
                }

            mouseDownPosition = new Point(thumbGridClientRect.X - e.Location.X, thumbGridClientRect.Y - e.Location.Y);
            howToDrag = DragNDrop.MOVE_THUMB_RECT;
        }
示例#24
0
 public virtual void OnDisable()
 {
     DragNDrop.Remove(this);
 }
示例#25
0
        private void thumbGrid_MouseUp(object sender, MouseEventArgs e)
        {
            if (howToDrag == DragNDrop.MOVE_THUMB_RECT)
                {
                RectangleF bounds = nodeSteuerung.GetLineNodeBounds();
                float zoom = Math.Min(1.0f, Math.Min((float)thumbGrid.ClientSize.Width / bounds.Width, (float)thumbGrid.ClientSize.Height / bounds.Height));

                daGridScrollPosition = new Point(
                    (int)Math.Round((thumbGridClientRect.X / zoom) + bounds.X),
                    (int)Math.Round((thumbGridClientRect.Y / zoom) + bounds.Y));

                UpdateDaGridClippingRect();
                DaGrid.Invalidate(true);
                }
            howToDrag = DragNDrop.NONE;
        }
 private void TimelineControl_MouseUp(object sender, MouseEventArgs e)
 {
     if (howToDrag == DragNDrop.MOVE_TIMELINE_BAR)
         {
         steuerung.AdvanceTo(GetTimeAtControlPosition(e.Location, false));
         }
     howToDrag = DragNDrop.NONE;
 }
示例#27
0
        void DaGrid_MouseDown(object sender, MouseEventArgs e)
        {
            Vector2 clickedPosition = new Vector2(e.X, e.Y);
            clickedPosition *= zoomMultipliers[zoomComboBox.SelectedIndex, 1];
            clickedPosition += daGridScrollPosition;

            // Node Gedöns
            switch (e.Button)
                {
                case MouseButtons.Left:
                    this.Cursor = Cursors.Default;

                    #region Nodes hinzufügen
                    if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                        {
                        // LineNode hinzufügen
                        List<LineNode> nodesToAdd = new List<LineNode>(m_selectedLineNodes.Count);
                        selectedLineNodesMovingOffset.Clear();

                        // testen ob ein Node schon markiert ist
                        if (selectedLineNodes.Count > 0)
                            {
                            // Mittelpunkt des selektierten LineNodes ermitteln
                            Vector2 midpoint = new Vector2(0, 0);
                            foreach (LineNode ln in selectedLineNodes)
                                {
                                midpoint += ln.position;
                                }
                            midpoint *= (double)1 / selectedLineNodes.Count;

                            // Line Node nach SelectedLineNode einfügen
                            if (!((Control.ModifierKeys & Keys.Shift) == Keys.Shift))
                                {
                                // ersten Line Node erstellen
                                nodesToAdd.Add(new LineNode(DaGrid.DockToGrid(clickedPosition, dockToGrid), cbNetworkLayer.SelectedItem as NetworkLayer, cbStopSign.Checked));
                                selectedLineNodesMovingOffset.Add(m_selectedLineNodes[0].outSlope);

                                // in/outSlope berechnen
                                nodesToAdd[0].outSlope = 30 * Vector2.Normalize(nodesToAdd[0].position - midpoint);
                                nodesToAdd[0].inSlope = -1 * nodesToAdd[0].outSlope;

                                // Connecten
                                nodeSteuerung.Connect(
                                    m_selectedLineNodes[0],
                                    nodesToAdd[0],
                                    (int)nodeConnectionPrioritySpinEdit.Value,
                                    (double)spinTargetVelocity.Value,
                                    carsAllowedCheckBox.Checked,
                                    busAllowedCheckBox.Checked,
                                    tramAllowedCheckBox.Checked,
                                    enableIncomingLineChangeCheckBox.Checked,
                                    enableOutgoingLineChangeCheckBox.Checked);

                                // nun die restlichen LineNodes parallel erstellen
                                for (int i = 1; i < m_selectedLineNodes.Count; i++)
                                    {
                                    Vector2 offset = m_selectedLineNodes[0].position - m_selectedLineNodes[i].position;
                                    selectedLineNodesMovingOffset.Add(offset);

                                    // Line Node erstellen
                                    nodesToAdd.Add(new LineNode(DaGrid.DockToGrid(clickedPosition - offset, dockToGrid), cbNetworkLayer.SelectedItem as NetworkLayer, cbStopSign.Checked));

                                    // in/outSlope berechnen
                                    nodesToAdd[i].outSlope = 30 * Vector2.Normalize(nodesToAdd[i].position - midpoint);
                                    nodesToAdd[i].inSlope = -1 * nodesToAdd[i].outSlope;

                                    // Connecten
                                    nodeSteuerung.Connect(
                                        m_selectedLineNodes[i],
                                        nodesToAdd[i],
                                        (int)nodeConnectionPrioritySpinEdit.Value,
                                        (double)spinTargetVelocity.Value,
                                        carsAllowedCheckBox.Checked,
                                        busAllowedCheckBox.Checked,
                                        tramAllowedCheckBox.Checked,
                                        enableIncomingLineChangeCheckBox.Checked,
                                        enableOutgoingLineChangeCheckBox.Checked);

                                    }
                                }
                            // Line Node vor SelectedLineNode einfügen
                            else
                                {
                                // ersten Line Node erstellen
                                nodesToAdd.Add(new LineNode(DaGrid.DockToGrid(clickedPosition, dockToGrid), cbNetworkLayer.SelectedItem as NetworkLayer, cbStopSign.Checked));
                                selectedLineNodesMovingOffset.Add(m_selectedLineNodes[0].outSlope);

                                // in/outSlope berechnen
                                nodesToAdd[0].outSlope = 30 * Vector2.Normalize(nodesToAdd[0].position - midpoint);
                                nodesToAdd[0].inSlope = -1 * nodesToAdd[0].outSlope;

                                // Connecten
                                nodeSteuerung.Connect(
                                    nodesToAdd[0],
                                    m_selectedLineNodes[0],
                                    (int)nodeConnectionPrioritySpinEdit.Value,
                                    (double)spinTargetVelocity.Value,
                                    carsAllowedCheckBox.Checked,
                                    busAllowedCheckBox.Checked,
                                    tramAllowedCheckBox.Checked,
                                    enableIncomingLineChangeCheckBox.Checked,
                                    enableOutgoingLineChangeCheckBox.Checked);

                                // nun die restlichen LineNodes parallel erstellen
                                for (int i = 1; i < m_selectedLineNodes.Count; i++)
                                    {
                                    Vector2 offset = m_selectedLineNodes[0].position - m_selectedLineNodes[i].position;
                                    selectedLineNodesMovingOffset.Add(offset);

                                    // Line Node erstellen
                                    nodesToAdd.Add(new LineNode(DaGrid.DockToGrid(clickedPosition - offset, dockToGrid), cbNetworkLayer.SelectedItem as NetworkLayer, cbStopSign.Checked));

                                    // in/outSlope berechnen
                                    nodesToAdd[i].outSlope = 30 * Vector2.Normalize(nodesToAdd[i].position - midpoint);
                                    nodesToAdd[i].inSlope = -1 * nodesToAdd[i].outSlope;

                                    // Connecten
                                    nodeSteuerung.Connect(
                                        nodesToAdd[i],
                                        m_selectedLineNodes[i],
                                        (int)nodeConnectionPrioritySpinEdit.Value,
                                        (double)spinTargetVelocity.Value,
                                        carsAllowedCheckBox.Checked,
                                        busAllowedCheckBox.Checked,
                                        tramAllowedCheckBox.Checked,
                                        enableIncomingLineChangeCheckBox.Checked,
                                        enableOutgoingLineChangeCheckBox.Checked);

                                    }
                                }
                            }
                        else
                            {
                            // ersten Line Node erstellen
                            nodesToAdd.Add(new LineNode(DaGrid.DockToGrid(clickedPosition, dockToGrid), cbNetworkLayer.SelectedItem as NetworkLayer, cbStopSign.Checked));
                            selectedLineNodesMovingOffset.Add(new Vector2(0, 0));
                            }

                        previousSelectedNodePositions.Clear();
                        foreach (LineNode ln in m_selectedLineNodes)
                            {
                            previousSelectedNodePositions.Add(ln.position);
                            }

                        selectedLineNodes.Clear();
                        foreach (LineNode ln in nodesToAdd)
                            {
                            nodeSteuerung.AddLineNode(ln);
                            selectedLineNodes.Add(ln);
                            }
                        howToDrag = DragNDrop.CREATE_NODE;
                        }
                    #endregion

                    #region Nodes Verbinden
                    else if (((Control.ModifierKeys & Keys.Alt) == Keys.Alt) && (selectedLineNodes != null))
                        {
                        LineNode nodeToConnectTo = nodeSteuerung.GetLineNodeAt(clickedPosition);

                        if (nodeToConnectTo != null)
                            {
                            foreach (LineNode ln in selectedLineNodes)
                                {
                                nodeSteuerung.Connect(
                                    ln,
                                    nodeToConnectTo,
                                    (int)nodeConnectionPrioritySpinEdit.Value,
                                    (double)spinTargetVelocity.Value,
                                    carsAllowedCheckBox.Checked,
                                    busAllowedCheckBox.Checked,
                                    tramAllowedCheckBox.Checked,
                                    enableIncomingLineChangeCheckBox.Checked,
                                    enableOutgoingLineChangeCheckBox.Checked);
                                }
                            }
                        }
                    #endregion

                    #region Nodes selektieren bzw. verschieben
                    else
                        {
                        bool found = false;

                        if (!lockNodesCheckBox.Checked)
                            {
                            // erst gucken, ob evtl. In/OutSlopes angeklickt wurden
                            if (selectedLineNodes != null && selectedLineNodes.Count >= 1)
                                {
                                    if (m_selectedLineNodes[0].inSlopeRect.Contains(clickedPosition))
                                        {
                                        originalSlopes.Clear();
                                        foreach (LineNode ln in m_selectedLineNodes)
                                            {
                                            originalSlopes.Add(ln.inSlope);
                                            }

                                        howToDrag = DragNDrop.MOVE_IN_SLOPE;
                                        found = true;
                                        }
                                    if (m_selectedLineNodes[0].outSlopeRect.Contains(clickedPosition))
                                        {
                                        originalSlopes.Clear();
                                        foreach (LineNode ln in m_selectedLineNodes)
                                            {
                                            originalSlopes.Add(ln.outSlope);
                                            }

                                        howToDrag = DragNDrop.MOVE_OUT_SLOPE;
                                        found = true;
                                        }
                                }
                            }

                        if (! found)
                            {
                            LineNode ln = nodeSteuerung.GetLineNodeAt(clickedPosition);
                            if (ln != null && !lockNodesCheckBox.Checked)
                                {
                                if (selectedLineNodes.Contains(ln))
                                    {
                                    // MovingOffsets berechnen:
                                    selectedLineNodesMovingOffset.Clear();
                                    foreach (LineNode lln in m_selectedLineNodes)
                                        {
                                        selectedLineNodesMovingOffset.Add(lln.position - clickedPosition);
                                        }

                                    howToDrag = DragNDrop.MOVE_NODES;
                                    }
                                else
                                    {
                                    // bei nur einem Punkt brauchen wir keine MovingOffsets
                                    selectedLineNodesMovingOffset.Clear();
                                    selectedLineNodesMovingOffset.Add(new Vector2(0, 0));

                                    // Häßlicher Workaround, um Settermethode für selectedLineNodes aufzurufen
                                    List<LineNode> foo = new List<LineNode>();
             									foo.Add(ln);
                                    selectedLineNodes = foo;

                                    howToDrag = DragNDrop.MOVE_NODES;
                                    }
                                }
                            else
                                {
                                howToDrag = DragNDrop.DRAG_RUBBERBAND;

                                daGridRubberband.Location = clickedPosition;
                                daGridRubberband.Width = 1;
                                daGridRubberband.Height = 1;
                                }
                            }
                        }
                    #endregion
                    break;
                case MouseButtons.Right:
                    if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                        {
                        #region Nodes löschen
                        this.Cursor = Cursors.Default;
                        // LineNode entfernen
                        LineNode nodeToDelete = nodeSteuerung.GetLineNodeAt(clickedPosition);
                        // checken ob gefunden
                        if (nodeToDelete != null)
                            {
                            if (selectedLineNodes.Contains(nodeToDelete))
                                {
                                selectedLineNodes.Remove(nodeToDelete);
                                }
                            nodeSteuerung.DeleteLineNode(nodeToDelete);
                            }
                        #endregion
                        }
                    else
                        {
                        #region move main grid
                        howToDrag = DragNDrop.MOVE_MAIN_GRID;
                        daGridRubberband.Location = clickedPosition;
                        this.Cursor = Cursors.SizeAll;
                        #endregion
                        }

                    break;
                case MouseButtons.XButton1:
                    daGridScrollPosition.Y += 10 * e.Delta;
                    UpdateDaGridClippingRect();
                    DaGrid.Invalidate();
                    thumbGrid.Invalidate();
                    break;
                }

            Invalidate(InvalidationLevel.ONLY_MAIN_CANVAS);
        }
示例#28
0
    public void OnDrop(PointerEventData eventData)
    {
        DragNDrop DnD = eventData.pointerDrag.GetComponent <DragNDrop>();

        DnD.destinationSlot = this;
    }
示例#29
0
 void Start()
 {
     if (EquipedItems.GetHat() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetHat(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.Hat)
             {
                 EquipGameObject(bodyPart, HatEquipmentPosition.ObjectPosition);
             }
         }
     }
     if (EquipedItems.GetLeftEye() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetLeftEye(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.EyeNose)
             {
                 EquipGameObject(bodyPart, LeftEyePosition);
             }
         }
     }
     if (EquipedItems.GetRightEye() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetRightEye(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.EyeNose)
             {
                 EquipGameObject(bodyPart, RightEyePosition);
             }
         }
     }
     if (EquipedItems.GetNose() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetNose(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.EyeNose)
             {
                 EquipGameObject(bodyPart, NosePosition);
             }
         }
     }
     if (EquipedItems.GetMouth() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetMouth(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.Mouth)
             {
                 EquipGameObject(bodyPart, MouthPosition);
             }
         }
     }
     if (EquipedItems.GetNeck() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetNeck(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.Scarf)
             {
                 EquipGameObject(bodyPart, ScarfPosition);
             }
         }
     }
     if (EquipedItems.GetLeftHand() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetLeftHand(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         obj.transform.localRotation = new Quaternion(0f, 0.9f, 0f, 1f);
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.Mitten)
             {
                 EquipGameObject(bodyPart, LeftMittenPosition);
             }
         }
     }
     if (EquipedItems.GetRightHand() != null)
     {
         GameObject obj = (GameObject)Resources.Load(EquipedItems.GetRightHand(), typeof(GameObject));
         GameObject ins = Instantiate(obj);
         ins.layer = 2;
         ins.transform.localRotation = new Quaternion(0f, -0.9f, 0f, 1f);
         DragNDrop dnd = ins.AddComponent <DragNDrop>();
         dnd.isEquipped = true;
         BodyPart[] bodyParts = ins.GetComponents <BodyPart>();
         foreach (BodyPart bodyPart in bodyParts)
         {
             if (bodyPart != null && bodyPart.bodyPartType == BodyPartType.Mitten)
             {
                 EquipGameObject(bodyPart, RightMittenPosition);
             }
         }
     }
 }