示例#1
0
        public void MovePatch(PatchBody patchBody)
        {
            LineRenderer lineRenderer;

            Outlet[] outlets = patchBody.GetComponentsInChildren <Outlet>();
            foreach (Connection connection in patchBody.Patch.GetOutputConnections())
            {
                foreach (Outlet outlet in outlets)
                {
                    if (connection.SourceOutlet == outlet.Id)
                    {
                        lineRenderer = lines[connection.Id];
                        lineRenderer.SetPositions(GeneratePath(lineRenderer, outlet.transform.position, lineRenderer.GetPosition(lineRenderer.positionCount - 1)));
                    }
                }
            }
            Inlet[] inlets = patchBody.GetComponentsInChildren <Inlet>();
            foreach (Connection connection in patchBody.Patch.GetInputConnections())
            {
                foreach (Inlet inlet in inlets)
                {
                    if (connection.TargetInlet == inlet.Id)
                    {
                        lineRenderer = lines[connection.Id];
                        lineRenderer.SetPositions(GeneratePath(lineRenderer, lineRenderer.GetPosition(0), inlet.transform.position));
                    }
                }
            }
        }
示例#2
0
        private void DoubleTap()
        {
            RaycastHit2D raycastHit2D = RayCast(Layers.PatchBodies);

            if (raycastHit2D.collider)
            {
                PatchBody patchBody = raycastHit2D.collider.gameObject.GetComponent <PatchBody>();
                patchCreator.OpenEditMenu(patchBody);
            }
        }
示例#3
0
 public void Delete()
 {
     if (PatchBody != null)
     {
         PatchBodies.Remove(PatchBody);
         MainManager.GetInstance().Delete(PatchBody.Patch);
         WireDrawer.GetInstance().RemovePatch(PatchBody);
         Destroy(PatchBody.gameObject);
         PatchBody = null;
     }
 }
示例#4
0
 public void OpenEditMenu(PatchBody patchBody)
 {
     if (patchEdit)
     {
         Destroy(patchEdit.gameObject);
     }
     foreach (PatchEdit prefab in patchEditPrefabs)
     {
         if (prefab.name == patchBody.Patch.Code)
         {
             patchEdit = Instantiate(prefab, patchEditHolder.transform, false);
             patchEdit.Init(patchBody.Patch);
         }
     }
 }
示例#5
0
        public void RemovePatch(PatchBody patchBody)
        {
            LineRenderer lineRenderer;

            foreach (Connection connection in patchBody.Patch.GetOutputConnections())
            {
                lineRenderer = lines[connection.Id];
                lines.Remove(connection.Id);
                Destroy(lineRenderer.gameObject);
            }
            foreach (Connection connection in patchBody.Patch.GetInputConnections())
            {
                lineRenderer = lines[connection.Id];
                lines.Remove(connection.Id);
                Destroy(lineRenderer.gameObject);
            }
        }
示例#6
0
 public void Load(Patch[] patches)
 {
     foreach (Patch patch in patches)
     {
         PatchBody patchBodyPrefab = null;
         foreach (PatchBody prefab in patchBodiesPrefabs)
         {
             if (prefab.name == patch.Code)
             {
                 patchBodyPrefab = prefab;
             }
         }
         Vector3 position = new Vector3(patch.PosX, patch.PosY, 0);
         PatchBody                  = Instantiate(patchBodyPrefab, position, Quaternion.identity);
         PatchBody.Patch            = patch;
         PatchBody.PatchCreator     = this;
         PatchBody.transform.parent = patchBodyHolder.transform;
         PatchBodies.Add(PatchBody);
     }
 }
示例#7
0
        public void CreatePatchBody(string patchCode)
        {
            PatchBody patchBodyPrefab = null;

            foreach (PatchBody prefab in patchBodiesPrefabs)
            {
                if (prefab.name == patchCode)
                {
                    patchBodyPrefab = prefab;
                }
            }
            Vector3 position = InputHandler.GetTouchPosition();

            PatchBody                  = Instantiate(patchBodyPrefab, position, Quaternion.identity);
            PatchBody.Patch            = MainManager.GetInstance().CreatePatch(patchCode);
            PatchBody.Patch.PosX       = position.x;
            PatchBody.Patch.PosY       = position.y;
            PatchBody.PatchCreator     = this;
            PatchBody.transform.parent = patchBodyHolder.transform;
            PatchBodies.Add(PatchBody);
        }