Inheritance: MonoBehaviour
Beispiel #1
0
        public List <GameEntity> GetOccupants(GameEntity pivot, Footprint footprint)
        {
            var entities = new List <GameEntity>();

            for (int i = 0; i < footprint.data.Count; i++)
            {
                var foot_column = footprint.data[i];

                for (int j = 0; j < foot_column.Count; j++)
                {
                    if (foot_column[j] == 1 && pivot.hasCell)
                    {
                        var f_row    = j + pivot.row;
                        var f_column = i + pivot.column;
                        var f_cell   = GetCell(f_row, f_column);

                        if (f_cell != null &&
                            IsOccupied(f_cell) &&
                            !entities.Contains((GameEntity)f_cell.cell.occupant))
                        {
                            entities.Add((GameEntity)f_cell.cell.occupant);
                        }
                    }
                }
            }

            return(entities);
        }
 /// <summary>
 /// Initializes a new <see cref="PickAndPlace.Reel"/>
 /// </summary>
 /// <param name="components">Components on the reel</param>
 /// <param name="speed">Speed of the reel</param>
 public Reel(List <PnpComponent> components, int speed)
 {
     components_ = components;
     speed_      = speed;
     components_.Sort((x, y) => string.Compare(x.Designator, y.Designator));
     footprint_ = new Footprint(components[0].ManufacturerPartNumber);
 }
        /// <summary>
        /// Convert the list of components in to a list of reels
        /// </summary>
        /// <param name="componentList">Components to distribute over the reels</param>
        /// <returns>List of reels with the components</returns>
        private static List <Reel> ComponentsToReels(List <PnpComponent> componentList, int speed)
        {
            List <Reel> tempReelList = new List <Reel>();
            List <Reel> result       = new List <Reel>();

            while (componentList.Count != 0)
            {
                PnpComponent        curComponent       = componentList[0];
                List <PnpComponent> matchingComponents = componentList.FindAll(comp_ => (comp_.Comment == curComponent.Comment) && (comp_.ManufacturerPartNumber == curComponent.ManufacturerPartNumber));
                //Find all components of the same type (footprint and comment/value are the same)
                componentList.RemoveAll(comp => matchingComponents.Contains(comp));
                Reel newReel = new Reel(matchingComponents, speed); //make a reel from the components
                tempReelList.Add(newReel);
            }
            while (tempReelList.Count != 0)
            {
                string manufacturerPartNumber = tempReelList[0].Components[0].ManufacturerPartNumber;
                //Find all matching footprints
                List <Reel> similarReels = tempReelList.FindAll(reel => reel.Components[0].ManufacturerPartNumber == manufacturerPartNumber); //make a list of all reels who share the footprint
                tempReelList.RemoveAll(reel => similarReels.Contains(reel));
                Footprint reelFootprint = DatabaseOperations.GetFootprint(manufacturerPartNumber);
                if (reelFootprint != null)
                {
                    foreach (Reel reel in similarReels)
                    {
                        reel.Footprint = reelFootprint;
                    }
                }
                result.AddRange(similarReels);
            }
            return(result);
        }
Beispiel #4
0
    public void Init()
    {
        gameObject.layer = LayerMask.NameToLayer(layerName);

        // Tunnel dimensions exclude ceiling thickness and any additional ramp
        // structure
        m_vehicleDimensions = Footprint.Measure(vehiclePrefab);
        Vector3 tunnelDimensions = new Vector3(m_vehicleDimensions.x * (1 + tunnelWiggleroom), m_vehicleDimensions.y * (1 + tunnelHeadroom), maxVehiclesInTunnel * m_vehicleDimensions.z * (1 + tunnelVehicleSpacing));

        m_tunnelObject   = CreateNewObject("TunnelInterior", tunnelMaterial, true);
        m_occluderObject = CreateNewObject("TunnelOccluder", occlusionMaterial, false);

        switch (type)
        {
        case Type.StraightRamp:
            m_tunnelBuilder = new TunnelWithStraightRamp(m_tunnelObject, m_occluderObject, tunnelDimensions, m_vehicleDimensions, rampAngle);
            break;

        case Type.SmoothRamp:
            m_tunnelBuilder = new TunnelWithSmoothRamp(m_tunnelObject, m_occluderObject, tunnelDimensions, m_vehicleDimensions, rampAngle, numRampSegments);
            break;

        case Type.RampOnly:
            m_tunnelBuilder = new AngledTunnel(m_tunnelObject, m_occluderObject, tunnelDimensions, m_vehicleDimensions, rampAngle);
            break;
        }

        m_tunnelBuilder.CreateMeshes();

        // Disable sub-objects. They will be re-enabled upon being embedded.
        m_tunnelObject.obj.SetActive(false);
        m_occluderObject.obj.SetActive(false);
    }
Beispiel #5
0
    public void RegisterFootprint(Footprint f)
    {
        existingFootprints.Add(new FootprintRegister(f, f.transform.position.z));
        existingFootprints.Sort();

        ActivateNextUp();
    }
Beispiel #6
0
    public void PlayerSelectedFootprint(Footprint f)
    {
        Player.Instance.ReportFootprintSelected(f.GetMyFootprintStateObject().GetType());

        if (f.GetMyFootprintStateObject().GetType() == typeof(FootprintStatePrime))
        {
            SpawnStepParticleEffect(f.transform.position, partiPrimeStepPrefab);
        }
        else
        {
            SpawnStepParticleEffect(f.transform.position, partiNormalStepPrefab);
        }

        if (existingFootprints[0].footprint.GetInstanceID() == f.GetInstanceID())
        {
            existingFootprints.RemoveAt(0);
            Destroy(f.gameObject);

            ActivateNextUp();
        }
        else
        {
            Debug.LogError("Footprint clicked not at front of stack");
        }
    }
Beispiel #7
0
 public void InstantiatedFootprintDestroyed(Footprint fp)
 {
     if (instantiatedFootprints.Contains(fp))
     {
         instantiatedFootprints.Remove(fp);
     }
 }
Beispiel #8
0
    public void FootprintMissed(Footprint f)
    {
        Player.Instance.ReportFootprintMissed();

        if (f && existingFootprints[0].footprint.GetInstanceID() != f.GetInstanceID())
        {
            Debug.LogError("Footprint clicked not at front of stack");
        }

        for (int i = 0; i < existingFootprints.Count; i++)
        {
            FootprintRegister thisFootprint = existingFootprints[i];
            if (thisFootprint.zPosition - Player.Instance.transform.position.z < distanceToRemoveFootprintsAfterMissStep)
            {
                existingFootprints.RemoveAt(0);
                i--;
                Destroy(thisFootprint.footprint.gameObject);
            }
            else
            {
                break;
            }
        }

        ActivateNextUp();
    }
Beispiel #9
0
        private void CreateCornerFacades(ISubdivisionGeometry geometry, Footprint footprint, int topIndex, IReadOnlyList <IReadOnlyList <Vector2> > corners, string material)
        {
            Contract.Requires(geometry != null);
            Contract.Requires(corners != null);
            Contract.Requires(_floors != null);

            //Calculate altitude of bottom and top of this facade
            var bot = _floors[footprint.BottomIndex].FloorAltitude;
            var top = _floors[topIndex].FloorAltitude + _floors[topIndex].Bounds.Height;
            var mid = (bot + top) * 0.5f;

            //Fill in corner sections (solid)
            foreach (var corner in corners)
            {
                try
                {
                    geometry.Union(geometry
                                   .CreatePrism(material, corner, top - bot)
                                   .Translate(new Vector3(0, mid, 0))
                                   );
                }
                catch (ArgumentException)
                {
                    //Suppress the argument exception, why?
                    //If we try to create a degenerate prism (negative height, only 2 points) we get an arg exception
                    //Corner sections can be very slim, sometimes *so slim* that the four points merge together
                    //In this case we don't care, the section is so small we'll just skip it!
                }
            }
        }
 private void AddAllLoweredFootprints()
 {
     if (this.loweredFootprint == null)
     {
         this.loweredFootprint = new Footprint("Lowered Footprint", 3f);
         BuildingController      buildingController = Service.Get <BuildingController>();
         NodeList <BuildingNode> nodeList           = Service.Get <EntityController>().GetNodeList <BuildingNode>();
         for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
         {
             SmartEntity smartEntity = (SmartEntity)buildingNode.Entity;
             if (!buildingController.IsLifted(smartEntity) && !Service.Get <BaseLayoutToolController>().IsBuildingStashed(smartEntity))
             {
                 this.AddLoweredFootprint(smartEntity);
             }
         }
         if (buildingController.IsPurchasing && !buildingController.IsLifted(buildingController.PurchasingBuilding))
         {
             this.AddLoweredFootprint((SmartEntity)buildingController.PurchasingBuilding);
         }
         bool allowErrorThrown = true;
         if (Service.Get <BaseLayoutToolController>().IsBaseLayoutModeActive)
         {
             allowErrorThrown = false;
         }
         this.loweredFootprint.GenerateMesh(true, false, allowErrorThrown);
     }
 }
 private void RemoveAllLoweredFootprints()
 {
     if (this.loweredFootprint != null)
     {
         this.loweredFootprint.DestroyFootprint();
         this.loweredFootprint = null;
     }
 }
        public DeviceItem(Footprint parent, DeviceDescription device)
        {
            InitializeComponent();
            root.DataContext = this;
            Parent = parent;
            Device = device;

            StatusBrush = Brush_Functions.GetSolidBrushFromResource(this, "Disabled");
        }
        public DeviceItem(Footprint parent, DeviceDescription device)
        {
            InitializeComponent();
            root.DataContext = this;
            Parent           = parent;
            Device           = device;

            StatusBrush = Brush_Functions.GetSolidBrushFromResource(this, "Disabled");
        }
        /// <summary>
        /// Edit the selected footprint
        /// </summary>
        private void EditFootprint()
        {
            string        selectedMPN   = dgvFootprints.CurrentRow.Cells[0].Value.ToString();
            Footprint     footprint     = DatabaseOperations.GetFootprint(selectedMPN);
            FootprintForm footprintForm = new FootprintForm();

            footprintForm.SetFootprint(footprint);
            this.ShowFootprintForm(footprintForm);
        }
Beispiel #15
0
    public void TriggerFootprintButtonPress(bool isLeftFoot)
    {
        Footprint nextFootstepUp = existingFootprints[0].footprint;

        if (nextFootstepUp.isLeftFoot == isLeftFoot &&
            nextFootstepUp.GetCanBeSelected())
        {
            PlayerSelectedFootprint(nextFootstepUp);
        }
    }
Beispiel #16
0
        public MovingFootprint(Footprint fp)
        {
            myFp = fp;

            Random rng = new Random();

            timeToLive = rng.Next(400);
            dx         = rng.NextDouble() * 10 - 5;
            dy         = rng.NextDouble() * 10 - 5;
        }
Beispiel #17
0
    /// <summary>
    /// Gets position and rotation in given target position according to closest edge
    /// </summary>
    /// <param name="target"></param>
    /// <param name="pos"></param>
    /// <param name="rot"></param>
    /// <param name="index"></param>
    /// <param name="placeInside">Is footprint placed inside or outside the edge?</param>
    /// <param name="placeOnEdge">Is footprint placed on the edge or on target?</param>
    public void GetFootprintPosAndRotAtTarget(Vector3 target, out Vector3 pos, out Quaternion rot, out Vector3 closestPoint, int index, bool placeOnEdge = true, bool placeInside = true)
    {
        pos          = Vector3.zero;
        rot          = Quaternion.identity;
        closestPoint = Vector3.zero;

        if (placeOnEdge)
        {
            // Line the footprint with closest edge
            Edge edge = null;
            closestPoint = EdgeGraphUtility.GetClosestPointOnEdge(target, graph.mainPrimitives[0].nodes, graph.mainPrimitives[0].edges, transform, out edge);

            Node    n1     = EdgeGraphUtility.GetNode(edge.Node1, ref graph.mainPrimitives[0].nodes);
            Vector3 eN1Pos = n1.Position;
            Vector3 eN2Pos = EdgeGraphUtility.GetNode(edge.Node2, ref graph.mainPrimitives[0].nodes).Position;

            eN2Pos.y = eN1Pos.y;
            Footprint fp = UtilityTools.Helper.GetComponentInPrefabChildren <Footprint>(footprintPrefabsOnEdge[index]);
            if (fp != null)
            {
                Vector3 fpN1Pos     = fp.nodes[0].Position;
                Vector3 fpN2Pos     = fp.nodes[1].Position;
                Vector3 fpEdgePoint = Edge.GetClosestPointOnEdge(Vector3.zero, fpN1Pos, fpN2Pos);

                //Vector3 nodeDir = (fpN2Pos - fpN1Pos).normalized;
                Vector3 edgeDir = (eN2Pos - eN1Pos).normalized;

                Vector3 edgeNormal = UtilityTools.MathHelper.LeftSideNormal(edgeDir);
                // Check that edge normal points outside (building will be placed inside the edge)
                if (Vector3.Dot(n1.dirToInside, edgeNormal) > 0)
                {
                    edgeNormal = -edgeNormal;
                }

                // Place the building outside
                if (!placeInside)
                {
                    edgeNormal = -edgeNormal;
                }

                pos = closestPoint - edgeNormal * (fpEdgePoint.magnitude + .05f);

                rot = Quaternion.LookRotation((pos - closestPoint), Vector3.up);
            }
            else
            {
                Debug.Log("FootprintPlacer::GetFootprintPosAndRotAtTarget() - No footprint found in prefab.");
            }
        }
        else
        {
            pos = target;
            rot = Quaternion.AngleAxis(Random.Range(0f, 360f), Vector3.up);
        }
    }
Beispiel #18
0
 public ActionResult ClearFoot(int Id)
 {
     using (DataBase db = new DataBase())
     {
         Footprint footPrint = new Footprint();
         footPrint        = db.FootprintDAL.Where(x => x.Id == Id).FirstOrDefault();
         footPrint.Status = 0;
         db.SaveChanges();
     }
     return(RedirectToAction("FootPrintList", "Consumer"));
 }
 private void AddLiftedFootprint(SmartEntity building)
 {
     if (!this.liftedFootprints.ContainsKey(building))
     {
         SizeComponent sizeComp  = building.SizeComp;
         Footprint     footprint = new Footprint(this.LIFTED_FOOTPRINT_NAME, 3f);
         footprint.AddTiles(0f, 0f, sizeComp.Width, sizeComp.Depth, building.WallComp != null);
         footprint.GenerateMesh(true, true);
         this.liftedFootprints.Add(building, footprint);
     }
 }
Beispiel #20
0
    //private List<Collider>
    private void FixedUpdate()
    {
        UpdateDynamics();


        BoxCollider box         = GetComponent <BoxCollider>();
        Vector3     halfExtents = 0.5f * Footprint.Measure(gameObject);

        Collider[] overlapping = Physics.OverlapBox(transform.TransformPoint(box.center), halfExtents, transform.rotation, PlayspaceManager.spatialLayerMask);
        if (overlapping.Length > 0)
        {
            Vector3 resolution = Vector3.zero;
            foreach (Collider c in overlapping)
            {
                Vector3 direction = Vector3.zero;
                float   distance  = 0;
                Physics.ComputePenetration(box, transform.position, transform.rotation, c, c.transform.position, c.transform.rotation, out direction, out distance);
                resolution += distance * direction;
            }

            Vector3 reactionDirection = resolution.normalized;
            Vector3 velocity          = m_rb.velocity;
            m_rb.velocity        = Vector3.zero;
            m_rb.angularVelocity = Vector3.zero;
            m_rb.AddForce(reactionDirection * 1.5f, ForceMode.VelocityChange);
            Debug.Log("Velocity " + velocity + " -> " + m_rb.velocity);
        }

        return;

        // Layers must be set up such that helicopter cannot collide with itself

        /*
         * BoxCollider box = GetComponent<BoxCollider>();
         * Vector3 halfExtents = 0.5f * Footprint.Measure(gameObject);
         * Collider[] overlapping = Physics.OverlapBox(transform.TransformPoint(box.center), halfExtents, transform.rotation, PlayspaceManager.spatialLayerMask);
         * Vector3 reactionDirection = Vector3.zero;
         * foreach (Collider c in overlapping)
         * {
         * //Debug.Log("overlapping " + c.name);
         * //Debug.Log("closest point: " + c.ClosestPoint(transform.position));
         * //reactionDirection += (transform.position - c.ClosestPoint(transform.position)).normalized;
         * }
         * if (overlapping.Length > 0)
         * reactionDirection = -m_rb.velocity;
         * m_rb.AddForce(reactionDirection.normalized * 0.5f, ForceMode.VelocityChange);
         * LineRenderer lr = GetComponent<LineRenderer>();
         * lr.positionCount = 2;
         * lr.SetPosition(0, transform.position);
         * lr.SetPosition(1, reactionDirection.normalized + transform.position);
         * lr.useWorldSpace = true;
         */
    }
Beispiel #21
0
        /// <summary>
        /// Edit the settings of the selected reel in the lvIncluded ListView
        /// </summary>
        private void EditReel(object sender, EventArgs e)
        {
            if (lvIncluded.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a reel", "no reel selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //Find the reel in reelsToPlace
            ListViewItem selectedItem = lvIncluded.SelectedItems[0];
            Reel         selectedReel = reelsToPlace.Find(curReel => curReel.GetDisplayString() == selectedItem.Text);

#if DEBUG
            //this only happens when the listview isn't updated when the reelsToPlace list is changed (the reel is in the excludedReels list)
            if (selectedReel == null)
            {
                MessageBox.Show("This error is the result of a bug," + Environment.NewLine + "You shouldn't see this" + Environment.NewLine + "have a nice day, for safety reasens the program wil automaticly close", "critical error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
#endif
            FootprintForm dialog = new FootprintForm();
            dialog.SetFootprint(selectedReel.Footprint);
            if (dialog.ShowDialog() == DialogResult.Yes)
            {
                StackType oldStackType  = selectedReel.Footprint.StackType;
                Footprint footprint     = dialog.GetFootprint();
                bool      couldBePlaced = pnpMachine.ReelCanBePlaced(selectedReel);
                //Changing MPN = creating/changing footprint, changing reels with the original MPN makes it impossible to break the "connection"
                //between reels with the same MPN
                //however, all reels with the same new MPN need to be updated
                selectedReel.Footprint = footprint; //If the manufacturer part number changes, it needs to be updated
                List <Reel> similarReels = reelsToPlace.FindAll(reel => reel.ManufacturerPartNumber == footprint.ManufacturerPartNumber);
                similarReels.AddRange(excludedReels.FindAll(reel => reel.ManufacturerPartNumber == footprint.ManufacturerPartNumber));
                foreach (Reel reel in similarReels)
                {
                    reel.Footprint = footprint;
                }
                //BUG: a splitted reel is not in the list
                //if ((stacklisters.Count != 0) &&
                //    (couldBePlaced != pnpMachine.ReelCanBeplaced(selectedReel) || (footprint.StackType != oldStackType)))
                //{
                //    //IF the stacks are fild AND
                //    //the ReelCanBePlaced state is changed OR the StackType has changed
                //    //then should the stacks be updated
                //    AssignReels(false);
                //}
                if (stacklisters.Count != 0)
                {
                    AssignReels(false);
                }
                GenerateListViewItems(lvIncluded, reelsToPlace);
            }
        }
Beispiel #22
0
 /// <summary>
 /// Sets the footprint to be eddited
 /// </summary>
 /// <param name="footprint">Footprint to be eddited</param>
 public void setFootprint(Footprint footprint)
 {
     tbxMPN.Text               = footprint.manufacturerPartNumber;
     nudwuHeight.Value         = (decimal)footprint.Height;
     nudwuLength.Value         = (decimal)footprint.Length;
     nudwuWidth.Value          = (decimal)footprint.width;
     nudwuRotation.Value       = footprint.rotation;
     bscOffset.valueX          = (decimal)footprint.offsetStackX;
     bscOffset.valueY          = (decimal)footprint.offsetStackY;
     cbxNozzle.SelectedItem    = footprint.nozzle;
     cbxStackType.SelectedItem = PNPconverterTools.stackTypeToString(footprint.stacktype);
     nudwuFeedRate.Value       = (decimal)footprint.feedRate;
 }
Beispiel #23
0
        public bool HasFreeSpace(List <string> cellTypes, Footprint footprint = default(Footprint))
        {
            foreach (var cell in grid.cells)
            {
                var isFree = GetOccupants(cell, footprint).Count == 0 && !IsThereAnyNullCell(cell, footprint) && AreFootprontCellOfEntityPositionType(cell, footprint, cellTypes);
                if (isFree)
                {
                    return(true);
                }
            }

            return(false);
        }
        private void MoveLiftedFootprint(FootprintMoveData moveData)
        {
            Entity building = moveData.Building;

            if (this.liftedFootprints.ContainsKey(building))
            {
                Footprint footprint = this.liftedFootprints[building];
                if (footprint.MoveTiles(moveData.WorldAnchorX, moveData.WorldAnchorZ, moveData.CanOccupy, true) && Service.Get <BuildingController>().SelectedBuilding == building)
                {
                    Service.Get <EventManager>().SendEvent(EventId.UserGridMovedBuildingAudio, null);
                }
            }
        }
Beispiel #25
0
    private void OnEnable()
    {
        if (target == null)
        {
            m_localScale = Vector3.zero;
            return;
        }

        Vector3 targetSize = Footprint.Measure(target.gameObject);
        float   width      = margin * Mathf.Sqrt(targetSize.x * targetSize.x + targetSize.z * targetSize.z);
        float   height     = margin * targetSize.y;

        width    = maxSize.x == 0 ? width : Mathf.Min(maxSize.x, width);
        height   = maxSize.y == 0 ? height : Mathf.Min(maxSize.y, height);
        m_width  = width;
        m_height = height;
        Vector3 xDir     = Vector3.right;
        Vector3 yDir     = Vector3.up;
        Vector3 xDirBend = Mathf.Cos(bendAngle * Mathf.Deg2Rad) * Vector3.right;
        Vector3 yDirBend = Mathf.Sin(bendAngle * Mathf.Deg2Rad) * Vector3.up;

        LineRenderer line1 = lineRenderers[0];
        LineRenderer line2 = lineRenderers[1];

        line1.positionCount = 4;
        line2.positionCount = 4;

        // Left side
        line1.SetPosition(0, -xDir * 0.5f * width + 0.5f * height * yDir + (xDirBend + yDirBend).normalized * bendLength * width);
        line1.SetPosition(1, -xDir * 0.5f * width + 0.5f * height * yDir);
        line1.SetPosition(2, -xDir * 0.5f * width - 0.5f * height * yDir);
        line1.SetPosition(3, -xDir * 0.5f * width - 0.5f * height * yDir + (xDirBend - yDirBend).normalized * bendLength * width);

        // Right side
        line2.SetPosition(0, xDir * 0.5f * width + 0.5f * height * yDir + (-xDirBend + yDirBend).normalized * bendLength * width);
        line2.SetPosition(1, xDir * 0.5f * width + 0.5f * height * yDir);
        line2.SetPosition(2, xDir * 0.5f * width - 0.5f * height * yDir);
        line2.SetPosition(3, xDir * 0.5f * width - 0.5f * height * yDir + (-xDirBend - yDirBend).normalized * bendLength * width);

        // Text line disabled for now
        LineRenderer line3 = lineRenderers[2];

        line3.gameObject.SetActive(false);
        textMesh.gameObject.SetActive(false);

        m_startPosition = Camera.main.transform.position + zoomPosition;
        m_localScale    = transform.localScale;
        m_startTime     = Time.time;
        ResetCoroutine();
    }
Beispiel #26
0
        /*-------------------------------------------------------------*/
        private void btnSave_Click(object sender, EventArgs e)
        {
            string    manufacturerPartNumber = tbxMPN.Text;
            float     width     = (float)nudwuWidth.Value;
            float     length    = (float)nudwuLength.Value;
            float     height    = (float)nudwuHeight.Value;
            int       rotation  = Convert.ToInt32(nudwuRotation.Value);
            float     offsetX   = (float)bscOffset.valueX;
            float     offsetY   = (float)bscOffset.valueY;
            float     feedRate  = (float)nudwuFeedRate.Value;
            StackType stackType = PNPconverterTools.stringToStackType(cbxStackType.SelectedItem.ToString());

            footPrint_        = new Footprint(manufacturerPartNumber, width, length, height, rotation, offsetX, offsetY, feedRate, (Nozzle)cbxNozzle.SelectedItem, stackType);
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
 /// <summary>
 /// Merges the reels and creates a new reel with a given speed and footprint
 /// </summary>
 /// <param name="reels">Reels to merge</param>
 /// <param name="mainReel">Reel with the settings to keep</param>
 public Reel(List <Reel> reels, Reel mainReel)
 {
     speed_      = mainReel.speed_;
     footprint_  = mainReel.footprint_;
     components_ = new List <PnpComponent>();
     foreach (Reel reel in reels)
     {
         foreach (PnpComponent component_ in reel.components_)
         {
             component_.Comment = mainReel.components_[0].Comment;
             component_.ManufacturerPartNumber = mainReel.components_[0].ManufacturerPartNumber;
         }
         components_.AddRange(reel.Components);
     }
     components_.Sort((x, y) => string.Compare(x.Designator, y.Designator));
 }
Beispiel #28
0
    // Use this for initialization
    void Start()
    {
        Video.GetComponent <Renderer>().material.mainTexture = movTexture;
        movTexture.loop = false;

        flushAudio  = Flush.GetComponent <AudioSource>();
        movAudio    = Video.GetComponent <AudioSource>();
        beepAudio   = Beep.GetComponent <AudioSource>();
        screamAudio = Scream.GetComponent <AudioSource>();

        Video.SetActive(false);
        Footprint.SetActive(false);
        WallCode.SetActive(false);
        LastCode.SetActive(false);
        pic114.SetActive(false);
    }
            public bool Overlaps(Footprint f)
            {
                bool bOverlap = false;

                // if either footprint is zero length, then there is no overlap
                // or if both footprints are identical, then assume they are caused by the same foot and therefore no overlap
                if ((length != 0 && f.length != 0) &&
                    (first != f.first || length != f.length) )
                {
                    if ( (first >= f.first && first <= f.last) || (f.first >= first && f.first <= last) )
                    {
                        bOverlap = true;
                    }
                }

                return bOverlap;
            }
Beispiel #30
0
            public bool Overlaps(Footprint f)
            {
                bool bOverlap = false;

                // if either footprint is zero length, then there is no overlap
                // or if both footprints are identical, then assume they are caused by the same foot and therefore no overlap
                if ((length != 0 && f.length != 0) &&
                    (first != f.first || length != f.length))
                {
                    if ((first >= f.first && first <= f.last) || (f.first >= first && f.first <= last))
                    {
                        bOverlap = true;
                    }
                }

                return(bOverlap);
            }
Beispiel #31
0
    // Update is called once per frame
    void Update()
    {
        // Flush
        if (Input.GetKeyDown(KeyCode.F1))
        {
            flushAudio.Play();
        }

        // Mirrow
        if (Input.GetKeyDown(KeyCode.F2))
        {
            Video.SetActive(true);
            movTexture.Play();
            movAudio.Play();
            playedOnce = true;
        }
        if (movTexture.isPlaying == false && playedOnce)
        {
            Video.SetActive(false);
            Footprint.SetActive(true);
        }

        // Beep (for footprint)
        if (Input.GetKeyDown(KeyCode.F3))
        {
            beepAudio.Play();
        }

        // Scream (for openning box)
        if (Input.GetKeyDown(KeyCode.F4))
        {
            screamAudio.Play();
        }

        // Codes on the wall
        if (Input.GetKeyDown(KeyCode.F5))
        {
            WallCode.SetActive(true);
            LastCode.SetActive(true);
        }
        if (Input.GetKeyDown(KeyCode.F6))
        {
            pic114.SetActive(true);
        }
    }
Beispiel #32
0
 /*-------------------------------------------------------------*/
 private void btnStart_Click(object sender, EventArgs e)
 {
     try
     {
         reelsToPlace.Clear();
         excludedReels.Clear();
         ClearPhases();
         List <Reel> tempReelList = FileOperations.ReadPickAndPlaceFiles(tbxPnPfile.Text, pnpFileParameters, tbxBOMfile.Text, bomFileParameters, pnpMachine.DefaultSpeed);
         while (tempReelList.Count != 0)
         {
             Footprint reelFootprint = tempReelList[0].Footprint;
             //Find all matching footprints
             List <Reel> similarReels = tempReelList.FindAll(reel => reel.ManufacturerPartNumber == reelFootprint.ManufacturerPartNumber); //make a list of all reels who share the footprint
             tempReelList.RemoveAll(reel => similarReels.Contains(reel));                                                                  //remove all the reels from the tempReelList
             reelFootprint = DatabaseOperations.GetFootprint(reelFootprint.ManufacturerPartNumber);
             if (reelFootprint != null)
             {
                 foreach (Reel reel in similarReels)
                 {
                     reel.Footprint = reelFootprint;
                 }
             }
             if (pnpMachine.ReelCanBePlaced(similarReels[0]))
             {
                 reelsToPlace.AddRange(similarReels);                                              //reel can be placed -> included list
             }
             else
             {
                 excludedReels.AddRange(similarReels);  //reel can't be placed -> excludedList
             }
         }
     }
     catch (Exception exc)
     {
         reelsToPlace.Clear();
         excludedReels.Clear();
         MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         UpdateListView();
     }
 }
        public bool CheckForNoOverlap(uint offset, uint length)
        {
            bool bNoOverlap = true;

            // create a new footprint object
            Footprint footprint = new Footprint(offset, length);

            // compare the current footprint against each stored footprint

            for (int i=0; i<m_listFootprints.Count; i++)
            {
                if (footprint.Overlaps(m_listFootprints[i]))
                {
                    bNoOverlap = false;
                    break;
                }
            }

            // add the current footprint to the list of stored footprints
            m_listFootprints.Add(footprint);

            return bNoOverlap;
        }
Beispiel #34
0
 public void InstantiatedFootprintDestroyed(Footprint fp)
 {
     if (instantiatedFootprints.Contains(fp))
         instantiatedFootprints.Remove(fp);
 }
Beispiel #35
0
 void OnEnable()
 {
     footprint = (Footprint)target;
 }
Beispiel #36
0
    bool FootprintOverlapsOthers(Footprint footprint, Matrix4x4 footprintTRSMatrix)
    {
        // Check if any footprint edges cross each other
        for (int i = 0; i < footprint.edges.Count; i++)
        {
            Vector3 n1Pos = footprintTRSMatrix.MultiplyPoint3x4(EdgeGraphUtility.GetNode(footprint.edges[i].Node1, ref footprint.nodes).Position);
            Vector3 n2Pos = footprintTRSMatrix.MultiplyPoint3x4(EdgeGraphUtility.GetNode(footprint.edges[i].Node2, ref footprint.nodes).Position);

            for (int j = 0; j < instantiatedFootprints.Count; j++)
            {
                List<Node> placedFootprintWorldNodes = new List<Node>();
                instantiatedFootprints[j].nodes.ForEach((node) =>
                {
                    Node newNode = new Node(node);
                    newNode.Position = instantiatedFootprints[j].transform.TransformPoint(node.Position);
                    placedFootprintWorldNodes.Add(newNode);
                });

                for (int k = 0; k < instantiatedFootprints[j].edges.Count; k++)
                {
                    Vector3 n3Pos = instantiatedFootprints[j].transform.TransformPoint(EdgeGraphUtility.GetNode(instantiatedFootprints[j].edges[k].Node1, ref instantiatedFootprints[j].nodes).Position);
                    Vector3 n4Pos = instantiatedFootprints[j].transform.TransformPoint(EdgeGraphUtility.GetNode(instantiatedFootprints[j].edges[k].Node2, ref instantiatedFootprints[j].nodes).Position);

                    Vector3 intersect;
                    if (UtilityTools.MathHelper.AreIntersecting(out intersect, n1Pos, n2Pos, n3Pos, n4Pos) == 1)
                    {
                        return true;
                    }
                }
            }
        }

        // Check if footprint is inside placed footprint
        Vector3 nodePosWorld;
        for (int i = 0; i < footprint.nodes.Count; i++)
        {
            nodePosWorld = footprintTRSMatrix.MultiplyPoint3x4(footprint.nodes[i].Position);
            for (int j = 0; j < instantiatedFootprints.Count; j++)
            {
                List<Node> placedFootprintWorldNodes = new List<Node>();
                instantiatedFootprints[j].nodes.ForEach((node) =>
                {
                    Node newNode = new Node(node);
                    newNode.Position = instantiatedFootprints[j].transform.TransformPoint(node.Position);
                    placedFootprintWorldNodes.Add(newNode);
                });

                if (EdgeGraphUtility.PointIsInside(nodePosWorld, placedFootprintWorldNodes, instantiatedFootprints[j].edges))
                {
                    return true;
                }
            }
        }

        // Check if any placed footprint is inside the footprint
        List<Node> footprintWorldNodes = new List<Node>();
        footprint.nodes.ForEach((node) =>
        {
            Node newNode = new Node(node);
            newNode.Position = footprintTRSMatrix.MultiplyPoint3x4(node.Position);
            footprintWorldNodes.Add(newNode);
        });

        for (int i = 0; i < instantiatedFootprints.Count; i++)
        {
            List<Node> placedFootprintWorldNodes = new List<Node>();
            instantiatedFootprints[i].nodes.ForEach((node) =>
            {
                Node newNode = new Node(node);
                newNode.Position = instantiatedFootprints[i].transform.TransformPoint(node.Position);
                placedFootprintWorldNodes.Add(newNode);
            });

            for (int j = 0; j < placedFootprintWorldNodes.Count; j++)
            {
                if (EdgeGraphUtility.PointIsInside(placedFootprintWorldNodes[j].Position, footprintWorldNodes, footprint.edges))
                {
                    return true;
                }
            }
        }

        return false;
    }
Beispiel #37
0
    bool FootprintIsInsideGraph(Footprint footprint, Matrix4x4 footprintTRSMatrix)
    {
        for (int i = 0; i < footprint.edges.Count; i++)
        {
            Vector3 n1PosWorld = footprintTRSMatrix.MultiplyPoint3x4(EdgeGraphUtility.GetNode(footprint.edges[i].Node1, ref footprint.nodes).Position);
            Vector3 n2PosWorld = footprintTRSMatrix.MultiplyPoint3x4(EdgeGraphUtility.GetNode(footprint.edges[i].Node2, ref footprint.nodes).Position);

            Vector3 n1PosGraph = graph.transform.InverseTransformPoint(n1PosWorld);
            Vector3 n2PosGraph = graph.transform.InverseTransformPoint(n2PosWorld);

            if (!EdgeGraphUtility.PointIsInside(n1PosGraph, graph.mainPrimitives[0].nodes, graph.mainPrimitives[0].edges) ||
                !EdgeGraphUtility.PointIsInside(n2PosGraph, graph.mainPrimitives[0].nodes, graph.mainPrimitives[0].edges))
            {
                return false;
            }
        }

        return true;
    }