Пример #1
0
        void StartDrag()
        {
            ForwardOffsetBeforeDragging = UIController.Instance.forwardOffset;
            if (ConstraintController.CanPlace(currentBC))
            {
                string templateName = currentBC.template.name;
                string name         = templateName + "_" + (nbObjectsPlaced++);

                // Place the first Ghost = still green, still not collidin'
                TemplateController.PlaceObject(currentBC, name, BC_State.Ghost);

                draggedBC.Add(currentBC);
                draggingGroup     = currentBC.beyondGroup;
                lastGroupPosition = currentBC.groupPosition;

                currentBC = null;
                CreateNewPlaceableObject(templateName);
                // TODO : another hardcoded position. Not good. Yet, I must move the currentBC to where I started dragging or else I'm going to drag to some unknown place.
                currentBC.transform.position = draggedBC[0].transform.position;
                currentBC.transform.rotation = draggedBC[0].transform.rotation;

                // Instantiate a big bunch of placeable object based on what we are currently dragging
                for (int i = 0; i < MaxDraggedObjectCount; i++)
                {
                    BeyondComponent bc = TemplateController.CreateObject(templateName);
                    //TODO Better names, please
                    name = templateName + "_Ghost" + i;
                    bc.SetBCinGroup(draggingGroup, lastGroupPosition);
                    TemplateController.PlaceObject(bc, name, BC_State.Ghost);
                    bc.gameObject.SetActive(false);
                    draggedBC.Add(bc);
                }
            }
        }
Пример #2
0
 private void CreateNewPlaceableObject(string templateName)
 {
     if (currentBC == null)
     {
         //TemplateController.CreateObject(templateName , ref currentPlaceableObject , ref currentBC) ;
         // refactored into :
         currentBC = TemplateController.CreateObject(templateName);
     }
     else
     {
         Destroy(currentBC.gameObject);  Debug.Log("CreateNewPlaceableobject destroyed placeable object");
     }
 }