Esempio n. 1
0
 public bool InRange(SimElement inRangeOf, int range, float angle)
 {
     if (Vector2.Distance(position, inRangeOf.position) <= range &&
         Vector2.Angle(position - inRangeOf.position, inRangeOf.orientation) <= angle / 2 &&
         Vector2.Angle(position - inRangeOf.position, inRangeOf.orientation) >= -angle / 2 &&
         !this == inRangeOf)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
    public static List <SimElement> GetInRange(SimElement inRangeOf)
    {
        List <SimElement> inRange = new List <SimElement>();

        foreach (var item in elements)
        {
            if (item.InRange(inRangeOf, Creature.CREATURERANGE, Creature.CREATUREFOA))
            {
                inRange.Add(item);
            }
        }


        return(inRange);
    }
Esempio n. 3
0
    public static SortedList <float, SimElement> GetInRange(SimElement inRangeOf, int range, float angle)
    {
        SortedList <float, SimElement> inRange = new SortedList <float, SimElement>();

        foreach (var item in elements)
        {
            if (item.InRange(inRangeOf, range, angle))
            {
                inRange.Add(Vector2.Distance(inRangeOf.position, item.position), item);
            }
        }


        return(inRange);
    }
Esempio n. 4
0
        /*
         * Marker manage
         */

        SimElemMarker MakeMarker(string id, SimElement simElem, Vector3 pos)
        {
            var marker = GetObject(id, pos);

            marker.elemType = id;
            marker.uid      = simElem.uid;

            List <SimElemMarker> markers;

            if (!_markerDic.TryGetValue(id, out markers))
            {
                markers = new List <SimElemMarker>();
                _markerDic.Add(id, markers);
            }
            markers.Add(marker);

            return(marker);
        }
Esempio n. 5
0
        void DeleteMarker(string id, SimElement simElem)
        {
            List <SimElemMarker> markers;

            if (!_markerDic.TryGetValue(id, out markers))
            {
                return;
            }

            for (var i = 0; i < markers.Count; ++i)
            {
                if (markers[i].uid == simElem.uid)
                {
                    markers[i].gameObject.SetActive(false);
                    markers.RemoveAt(i);
                    return;
                }
            }
        }
        internal override void createProduct(SimObjectBase instance, BEPUikScene scene)
        {
            BEPUikBone connectionA = null;
            BEPUikBone connectionB = null;

            SimObject other = instance.getOtherSimObject(ConnectionASimObjectName);

            if (other == null)
            {
                throw new BEPUikBlacklistException("Cannot find ConnectionA SimObject named '{0}'", ConnectionASimObjectName);
            }

            connectionA = other.getElement(ConnectionABoneName) as BEPUikBone;
            if (connectionA == null)
            {
                throw new BEPUikBlacklistException("Cannot find ConnectionA bone named '{0}' in '{1}'", ConnectionABoneName, ConnectionASimObjectName);
            }

            other = instance.getOtherSimObject(ConnectionBSimObjectName);
            if (other == null)
            {
                throw new BEPUikBlacklistException("Cannot find ConnectionB SimObject named '{0}'", ConnectionBSimObjectName);
            }

            connectionB = other.getElement(ConnectionBBoneName) as BEPUikBone;
            if (connectionB == null)
            {
                throw new BEPUikBlacklistException("Cannot find ConnectionB bone named '{0}' in '{1}'", ConnectionBBoneName, ConnectionBSimObjectName);
            }

            SimElement element = createConstraint(connectionA, connectionB, instance);

            if (element != null)
            {
                instance.addElement(element);
            }
        }
Esempio n. 7
0
    public float GetAngle(SimElement other)
    {
        var l = new Vector2(other.position.x - position.x, other.position.y - position.y);

        return(Vector2.Angle(orientation, l));
    }
Esempio n. 8
0
 public float GetDistance(SimElement other)
 {
     return(Vector2.Distance(position, other.position));
 }
Esempio n. 9
0
 public static void Add(SimElement item)
 {
     elements.Add(item);
 }
Esempio n. 10
0
 public static string GetFQName(this SimElement element) =>
 element.Unit.IsAString() ? $"{element.Name} [{element.Unit}]" : element.Name;
Esempio n. 11
0
 public void AddSimElement(SimElement simElement, int order = 0)
 {
     orderedSimElements.Add(new OrderedSimElement(order, simElement));
 }
Esempio n. 12
0
 public OrderedSimElement(int order, SimElement simElement)
 {
     this.order      = order;
     this.simElement = simElement;
 }