コード例 #1
0
    public void BeginCreateZone()
    {
        var zoneDisplay = ZoneDisplayManager.Instance.CreateZoneDisplay();

        Vector3 start = Vector3.zero;

        InputController.Instance.RegisterHandler(new DragHandler("Fire1",
                                                                 (handler, mousePosition) =>
        {
            zoneDisplay.Change(mousePosition, mousePosition, 0);
            start = mousePosition;
        },
                                                                 (handler, mousePosition, delta) =>
        {
            zoneDisplay.Change(start, mousePosition, 0);
        },
                                                                 (handler, point) =>
        {
            InputController.Instance.UnRegisterHandler(handler);
            //check for collisions between rects and merge them
            for (int i = 0; i < ZoneDisplayManager.Instance.Zones.Count; i++)
            {
                ZoneDisplay otherZoneDisplay = ZoneDisplayManager.Instance.Zones[i];
                if (otherZoneDisplay != zoneDisplay && otherZoneDisplay.DisplayedZone.Overlaps(zoneDisplay.DisplayedZone))
                {
                    //will remove otherzonedisplay from zonedisplaymanager
                    zoneDisplay.MergeZone(otherZoneDisplay);
                    i--;
                }
            }

            GeneralDivision.AttachedDivision.AddZone(zoneDisplay.DisplayedZone);
        }));
    }
コード例 #2
0
 public ZoneDisplayContextMenu(ZoneDisplay Display)
 {
     _Items = new List <IContextMenuItem>
     {
         new DeleteZoneContextMenuItem(Display.DisplayedZone, Display),
         new DesignateZoneBehaviorContextMenuItem(Display.DisplayedZone, Display)
     };
 }
コード例 #3
0
 public DesignateZoneBehaviorContextMenu(ZoneDisplay display)
 {
     _Items = new List <IContextMenuItem>();
     foreach (IZoneBehavior behavior in BaseZoneBehavior.GetAllZoneBehaviors())
     {
         _Items.Add(new ZoneBehaviorContextMenuItem(display.DisplayedZone, display, behavior));
     }
 }
コード例 #4
0
    public ZoneDisplay CreateZoneDisplay()
    {
        Zone zone = new Zone(new List <Rect>()
        {
            new Rect(Vector2.zero, Vector2.zero)
        }, Color.white);
        ZoneDisplay zoneDisplay = Instantiate(ZoneDisplayPrefab).GetComponent <ZoneDisplay>();

        zoneDisplay.Init(zone);
        RegisterZoneDisplay(zoneDisplay);
        return(zoneDisplay);
    }
コード例 #5
0
        public void TestFindEdgeLoop()
        {
            List <Vector3>                        verts            = new List <Vector3>();
            List <int>                            tri              = new List <int>();
            List <Vector3>                        normals          = new List <Vector3>();
            List <Vector2>                        uv               = new List <Vector2>();
            HashSet <Edge>                        Edges            = new HashSet <Edge>();
            Dictionary <Vector3, int>             vertPositionMap  = new Dictionary <Vector3, int>();
            Dictionary <Vector3, HashSet <Edge> > edgesIntoPoint   = new Dictionary <Vector3, HashSet <Edge> >();
            List <List <Vector3> >                OrderedEdgeVerts = new List <List <Vector3> >();

            List <Rect> rects = new List <Rect>();

            rects.Add(new Rect(new Vector2(61.5f, 29.5f), new Vector2(6, 1)));
            rects.Add(new Rect(new Vector2(58.5f, 27.5f), new Vector2(5, 5)));
            rects.Add(new Rect(new Vector2(64.5f, 27.5f), new Vector2(1, 5)));

            ZoneDisplay.CreateMeshesHelper(rects, ref verts, ref vertPositionMap, ref Edges, ref edgesIntoPoint, ref OrderedEdgeVerts, ref tri, ref normals, ref uv);
        }
コード例 #6
0
 public void SelectZoneDisplay(ZoneDisplay zoneDisplay)
 {
     ZoneSelectCallback?.Invoke(zoneDisplay);
 }
コード例 #7
0
 public BaseZoneContextMenuItem(IZone Zone, ZoneDisplay Display)
 {
     _Zone    = Zone;
     _Display = Display;
 }
コード例 #8
0
 public void MergeZone(ZoneDisplay Other)
 {
     DisplayedZone.BoundingBoxes.AddRange(Other.DisplayedZone.BoundingBoxes);
     ZoneDisplayManager.Instance.DestroyZoneDisplay(Other);
     CreateMeshes();
 }
コード例 #9
0
 public DesignateZoneBehaviorContextMenuItem(IZone Zone, ZoneDisplay Display) : base(Zone, Display)
 {
 }
コード例 #10
0
 public ZoneBehaviorContextMenuItem(IZone Zone, ZoneDisplay Display, IZoneBehavior behavior) : base(Zone, Display)
 {
     _ZoneBehavior = behavior;
 }
コード例 #11
0
 public DeleteZoneContextMenuItem(IZone Zone, ZoneDisplay Display) : base(Zone, Display)
 {
 }
コード例 #12
0
 public void OnZoneSelected(ZoneDisplay display)
 {
     ZoneDisplaySelectCallback?.Invoke(display);
 }
コード例 #13
0
 public void UnRegisterZoneDisplay(ZoneDisplay zone)
 {
     Zones.Remove(zone);
 }
コード例 #14
0
 public void RegisterZoneDisplay(ZoneDisplay zone)
 {
     Zones.Add(zone);
 }
コード例 #15
0
 public void DestroyZoneDisplay(ZoneDisplay zone)
 {
     UnRegisterZoneDisplay(zone);
     Destroy(zone.gameObject);
     //TODO need to remove the ZD handelers
 }