/// <summary>
        /// 创建门店的构造函数
        /// </summary>
        public WePoiBaseInfo(string bName, string prov, string city, string addr, string tel,
            List<string> cate, OffsetType offset, double lgt, double lat, List<WePhotoUrl> phList,
            string special, TimeSpan beg, TimeSpan end)
        {
            TkDebug.AssertArgumentNullOrEmpty(bName, "bName", null);
            TkDebug.AssertArgumentNullOrEmpty(prov, "prov", null);
            TkDebug.AssertArgumentNullOrEmpty(city, "city", null);
            TkDebug.AssertArgumentNullOrEmpty(addr, "addr", null);
            TkDebug.AssertArgumentNullOrEmpty(tel, "tel", null);
            TkDebug.AssertArgumentNull(cate, "cate", null);
            TkDebug.AssertArgumentNull(phList, "phList", null);
            TkDebug.AssertArgumentNullOrEmpty(special, "special", null);

            BusinessName = bName;
            Province = prov;
            City = city;
            Address = addr;
            Telephone = tel;
            Categories = cate;
            OffsetType = offset;
            Longitude = lgt;
            Latitude = lat;
            PhotoList = phList;
            Special = special;
            OpenTime = beg.ToString("hh\\:mm") + "-" + end.ToString("hh\\:mm");
        }
        protected void OnOffset(OffsetType type, double offsetX, double offsetY)
        {
            if (null != OffsetAction)
            {
                OffsetAction(this, type, offsetX, offsetY);
            }

            OnElementMovingAction(type, new Rect(_element.Left, _element.Top, _element.Width, _element.Height));
        }
Exemple #3
0
 public Tritemius(string input, string key, OffsetType type)
     : base(input, key)
 {
     _encryptionType = type;
     if (type == OffsetType.Expression)
     {
         CompiledExpression = СompileExpression();
     }
 }
 public MoveAIAction(string target, float sp, FocusType focusT, OffsetType offsetT, int ang = 0, float dist = 0f, bool ine = true, float maxT = 0, int next = AIAction.NEXT_ACTION) : base(Type.MOVE, next)
 {
     targetId = target;
     speed = sp;
     focusType = focusT;
     offsetType = offsetT;
     angle = ang;
     distance = dist;
     inertia = ine;
     maxTime = maxT;
 }
Exemple #5
0
        public PatternOffset(OffsetType type, Whence whence, int offset)
        {
            if (OffsetType.MatchStart == type && Whence.Start == whence && offset < 0) {
                string msg = StringExtensions.Fi("Iris currently does not support negative a negative match start offset starting from the actual match start");
                throw new AssertionViolationException(msg);
            }

            this.OffSetType = type;
            this.Whence = whence;
            this.Offset = offset;
        }
Exemple #6
0
        public void CanParseInitialOffsetFromConfig(string offsetType, OffsetType typeEnum)
        {
            string extensionPath = "AzureWebJobs:Extensions:EventHubs";
            var    options       = TestHelpers.GetConfiguredOptions <EventHubOptions>(
                b =>
            {
                b.AddEventHubs();
            },
                new Dictionary <string, string> {
                { $"{extensionPath}:InitialOffsetOptions:Type", offsetType }
            });

            Assert.AreEqual(typeEnum, options.InitialOffsetOptions.Type);
        }
Exemple #7
0
        public static bool Validate(Rectangle area, List <Rectangle> offsetList, OffsetType offsetType = OffsetType.Column)
        {
            bool isValidate = true;

            if (offsetType == OffsetType.Column)
            {
                isValidate = ValidateColumn(area, offsetList);
            }
            else
            {
                isValidate = ValidateRow(area, offsetList);
            }

            return(isValidate);
        }
        /// <summary>
        /// Read the vertical offset type
        /// </summary>
        private static void ReadOffset(XmlReader r, IDictionary <string, OffsetType> offsets)
        {
            string offsetID = r.GetAttribute("offsetTypeID");

            if (String.IsNullOrEmpty(offsetID))
            {
                return;
            }
            if (!offsets.ContainsKey(offsetID))
            {
                return;
            }

            OffsetType offset = offsets[offsetID];

            offset.Unit = Unit.Unknown;

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element)
                {
                    if (r.Name == "offsetDescription")
                    {
                        r.Read();
                        offset.Description = r.Value;
                    }
                    else if (r.Name == "unitName")
                    {
                        r.Read();
                        offset.Unit.Name = r.Value;
                    }
                    else if (r.Name == "unitType")
                    {
                        r.Read();
                        offset.Unit.UnitsType = r.Value;
                    }
                    else if (r.Name == "unitAbbreviation")
                    {
                        r.Read();
                        offset.Unit.Abbreviation = r.Value;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement && r.Name == "offset")
                {
                    return;
                }
            }
        }
Exemple #9
0
        private long?GetOffsetTypeID(DbConnection conn, OffsetType offsetType)
        {
            const string sqlOffsetType = "SELECT OffsetTypeID FROM OffsetTypes WHERE OffsetDescription = ?";

            using (var cmd = conn.CreateCommand()) {
                cmd.CommandText = sqlOffsetType;
                cmd.Parameters.Add(_db.CreateParameter(DbType.String, offsetType.Description));

                var result = cmd.ExecuteScalar();
                if (result != null)
                {
                    return(Convert.ToInt64(result));
                }
                return(null);
            }
        }
Exemple #10
0
        public int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, OrderType pType = OrderType.Limit, int pCustom = 0, HedgeType pHedge = HedgeType.Speculation)
        {
            InstrumentField    dif;
            ExchangeStatusType es;

            //小节收盘:等待重新开盘
            if (DicInstrumentField.TryGetValue(pInstrument, out dif))
            {
                if (_initFlow)
                {
                    pPrice += _floConfig.FirstAddTicks * (pDirection == DirectionType.Buy ? 1 : -1) * dif.PriceTick;
                }
                //限定在涨跌板范围内
                MarketData f;
                if (_q == null)
                {
                    ShowInfo("行情接口异常");
                    return(-1);
                }
                if (!_q.DicTick.TryGetValue(pInstrument, out f))
                {
                    _q.ReqSubscribeMarketData(pInstrument);
                    Thread.Sleep(200);
                }
                if (_q.DicTick.TryGetValue(pInstrument, out f))
                {
                    ShowInfo($"合约{pInstrument}无行情");
                }
                else
                {
                    pPrice = Math.Max(f.LowerLimitPrice, Math.Min(f.UpperLimitPrice, pPrice));
                }
                //下单前修正价格为最小变动的倍数
                pPrice = (int)(pPrice / dif.PriceTick) * dif.PriceTick;

                if (DicExcStatus.TryGetValue(dif.ProductID, out es) || DicExcStatus.TryGetValue(dif.InstrumentID, out es) || DicExcStatus.TryGetValue(dif.ExchangeID.ToString(), out es))
                {
                    if (es == ExchangeStatusType.NoTrading)                    //小节收盘中:待处理
                    {
                        ShowInfo($"小节收盘,待重新开盘后再发委托:{pInstrument},{pDirection},{ pOffset},{ pPrice},{ pVolume},{pCustom}");
                        _listWaitTrading.Add(new object[] { pInstrument, pDirection, pOffset, pPrice, pVolume, pType, pCustom, pHedge });
                        return(0);
                    }
                }
            }
            return(base.ReqOrderInsert(pInstrument, pDirection, pOffset, pPrice, pVolume, pCustom, pType, pHedge));
        }
 public override void Read(PackFileDeserializer des, BinaryReaderEx br)
 {
     base.Read(des, br);
     m_child      = des.ReadClassPointer <hkbGenerator>(br);
     m_offsetType = (OffsetType)br.ReadInt32();
     m_taeId      = br.ReadInt32();
     m_valIndex   = br.ReadInt32();
     m_valRate    = br.ReadSingle();
     m_enableTae  = br.ReadBoolean();
     br.ReadUInt64();
     br.ReadUInt64();
     br.ReadUInt64();
     br.ReadUInt64();
     br.ReadUInt32();
     br.ReadUInt16();
     br.ReadByte();
 }
Exemple #12
0
        public MemoryOffset(string inputString)
        {
            var split = inputString.Split('|');

            Description         = split[0];
            MemoryOffsetAddress = Convert.ToInt64(split[1], 16);
            OffsetType t;

            if (Enum.TryParse(split[2], out t))
            {
                OffsetType = t;
            }
            else
            {
                OffsetType = OffsetType.IntPointer;
            }
        }
Exemple #13
0
        private static int GetOffsetTypeId(OffsetType type)
        {
            switch (type)
            {
            case OffsetType.Subscript:
                return(0);

            case OffsetType.Regular:
                return(1);

            case OffsetType.Superscript:
                return(2);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #14
0
    public static Vector2 AxialToWorld(Axial axial, float pointRadius, OffsetType type)
    {
        float x;
        float y;

        if (type == OffsetType.EvenR || type == OffsetType.OddR)
        {
            x = pointRadius * Mathf.Sqrt( 3 ) * (axial.q + axial.r / 2);
            y = pointRadius * 3 / 2 * axial.r;
        }
        else
        {
            x = pointRadius * 3 / 2 * axial.q;
            y = pointRadius * Mathf.Sqrt( 3 ) * (axial.r + axial.q / 2);
        }

        return new Vector2( x, y );
    }
Exemple #15
0
    private Vector3 GetOffsetMask(float offset, OffsetType type)
    {
        Vector3 offsetMask = Vector3.zero;

        if (type == OffsetType.Width)
        {
            offsetMask = new Vector3(offset, _etalonPosition.y, _etalonPosition.z);
        }
        else if (type == OffsetType.Height)
        {
            offsetMask = new Vector3(_etalonPosition.x, offset, _etalonPosition.z);
        }
        else if (type == OffsetType.Depth)
        {
            offsetMask = new Vector3(_etalonPosition.x, _etalonPosition.y, offset);
        }

        return(offsetMask);
    }
Exemple #16
0
        private void PopulateOffsetSetting()
        {
            // Populate combos on first pass
            if (cboWCS.Items.Count == 0)
            {
                var offsets = OffsetType.GetAllGCodeIdentifiers(true);

                var wcsList = from o in offsets
                              where o.Category == OffsetType.Categories.WorkingCoordinateSystem
                              select o;

                cboWCS.Items.AddRange(wcsList.ToArray());

                var toolOffsetList = from o in offsets
                                     where o.Category == OffsetType.Categories.ToolHead
                                     select o;

                cboToolOffsets.Items.AddRange(toolOffsetList.ToArray());
            }

            // Select active Working Coordinate System
            foreach (var i in cboWCS.Items)
            {
                if (((OffsetType)i).GCodeIdentifier == _settings.ActiveWorkingCoordinateSystem)
                {
                    cboWCS.SelectedItem = i;
                }
            }

            // Select active Tool offset
            foreach (var i in cboToolOffsets.Items)
            {
                if (((OffsetType)i).GCodeIdentifier == _settings.ActiveToolOffset)
                {
                    cboToolOffsets.SelectedItem = i;
                }
            }

            chkToolLengthOffset.Checked = _settings.ToolLengthOffsetActive;

            SetMachineWorkingOffset();
        }
Exemple #17
0
 public void Offset(OffsetType type, double offsetX, double offsetY)
 {
     switch (type)
     {
         case OffsetType.TopLeft:
             OffsetTopLeft(offsetX, offsetY);
             break;
         case OffsetType.TopRight:
             OffsetTopRight(offsetX, offsetY);
             break;
         case OffsetType.BottomRight:
             OffsetBottomRight(offsetX, offsetY);
             break;
         case OffsetType.BottomLeft:
             OffsetBottomLeft(offsetX, offsetY);
             break;
         case OffsetType.Move:
             OffsetMove(offsetX, offsetY);
             break;
     }
 }
Exemple #18
0
        /// <summary>
        /// Edit vector3 value to a specific range, base on offset type.
        /// </summary>
        /// <param name="vector3"></param>
        /// <param name="offsetType"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        static Vector3 Polish(Vector3 vector3, OffsetType offsetType)
        {
//		if (vector3.IsZero) return Vector3.Zero;

            float GetPosDimOffset(float p) =>
            p >= 0 ? Math.Min(p, MaxPositionOffset) : Math.Max(p, -MaxPositionOffset);
            float GetRotDimOffset(float r) =>
            r >= 0 ? Math.Min(r, MaxRotationOffset) : Math.Max(r, -MaxRotationOffset);

            switch (offsetType)
            {
            case OffsetType.Position:
                return(new Vector3(GetPosDimOffset(vector3.X), GetPosDimOffset(vector3.Y), GetPosDimOffset(vector3.Z)));

            case OffsetType.Rotation:
                return(new Vector3(GetRotDimOffset(vector3.X), GetRotDimOffset(vector3.Y), GetRotDimOffset(vector3.Z)));

            default:
                throw new ArgumentException();
            }
        }
Exemple #19
0
        public Offset GetOffset(string value, OffsetType defaultType)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return(Offset.Empty);
            }

            value = value.Trim();

            if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var d))
            {
                return(new Offset(d, defaultType));
            }

            if (TryExtractOffset(value, out var res))
            {
                return(res);
            }

            throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Offset)}");
        }
        public virtual void AttachSprite(GameElementSprite sprite, OffsetType _offsetType)
        {
            elementSprite = sprite;


            if (elementSprite.spriteRenderer == null)
            {
                elementSprite.spriteRenderer = elementSprite.gameObject.GetComponentInChildren <SpriteRenderer>();
            }

            elementSprite.gameObject.transform.parent        = this.transform;
            elementSprite.gameObject.transform.localPosition = Vector3.zero;
            elementSprite.gameObject.transform.localRotation = Quaternion.identity;

            if (_offsetType == OffsetType.BOTTOM_CENTER)
            {
                elementSprite.spriteRenderer.transform.localPosition = new Vector3(0f, elementSprite.spriteRenderer.size.y * 0.5f, 0f);
            }

            Debugger.Log("sprite attached: " + elementSprite.gameObject.name + " " + elementSprite.spriteRenderer.size);
        }
Exemple #21
0
        /// <summary>
        /// Read the vertical offset type
        /// </summary>
        private void ReadOffset(XmlReader r, Dictionary <string, OffsetType> offsets)
        {
            string offsetID = r.GetAttribute("offsetTypeID");

            if (String.IsNullOrEmpty(offsetID))
            {
                return;
            }
            if (!offsets.ContainsKey(offsetID))
            {
                return;
            }

            OffsetType offset = offsets[offsetID];

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element)
                {
                    if (r.Name == "offsetDescription")
                    {
                        r.Read();
                        offset.Description = r.Value;
                    }
                    else if (r.Name == "units")
                    {
                        Unit units = new Unit();
                        units.Abbreviation = r.GetAttribute("unitsAbbreviation");
                        r.Read();
                        units.Name  = r.Value;
                        offset.Unit = units;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement && r.Name == "offset")
                {
                    return;
                }
            }
        }
Exemple #22
0
        private void PopulateWorkspaceOffsets()
        {
            // First, populate the list of GCode Identifiers if it isn't already loaded
            if (listBoxGCodeIdentifiers.Items.Count == 0)
            {
                listBoxGCodeIdentifiers.Items.AddRange(OffsetType.GetAllGCodeIdentifiers().ToArray());
                listBoxGCodeIdentifiers.SelectedIndex = 0;
            }

            // Next, populate the offsets based on the selected GCode Identifier
            listBoxOffsets.Items.Clear();
            var selectedOffsetType = listBoxGCodeIdentifiers.SelectedItem as OffsetType;

            if (selectedOffsetType != null)
            {
                var filteredOffsetList = from o in _machine.Settings.WorkspaceOffsets
                                         where o.Type.GCodeIdentifier == selectedOffsetType.GCodeIdentifier
                                         select o;

                listBoxOffsets.Items.AddRange(filteredOffsetList.ToArray());

                _suppressEvent = true;          // Prevent chain reactions
                for (int i = 0; i < listBoxOffsets.Items.Count; i++)
                {
                    if (((WorkspaceOffset)listBoxOffsets.Items[i]).Active)
                    {
                        listBoxOffsets.SetItemCheckState(i, CheckState.Checked);
                    }
                }
                _suppressEvent = false;

                if (listBoxOffsets.Items.Count > 0)
                {
                    listBoxOffsets.SelectedIndex = 0;
                }
            }

            PopulateCurrentWorkplaceOffset();
        }
Exemple #23
0
    public static int OffsetDistance(Offset a, Offset b, OffsetType type)
    {
        Cube ac = OffsetToCube(a, type);
        Cube bc = OffsetToCube(b, type);

        return CubeDistance(ac, bc);
    }
Exemple #24
0
 public MemoryOffset(string description, long memoryOffset, OffsetType offsetType)
 {
     Description         = description;
     MemoryOffsetAddress = memoryOffset;
     OffsetType          = offsetType;
 }
Exemple #25
0
 /// <summary>
 /// 委托
 /// </summary>
 /// <param name="pInstrument">合约</param>
 /// <param name="pDirection">买卖</param>
 /// <param name="pOffset">开平</param>
 /// <param name="pPrice">价格</param>
 /// <param name="pVolume">数量</param>
 /// <param name="pType">委托类型</param>
 /// <param name="pCustom">自定义字段(6位数字)</param>
 /// <param name="pHedge">投保</param>
 /// <returns></returns>
 public abstract int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, int pCustom, OrderType pType = OrderType.Limit, HedgeType pHedge = HedgeType.Speculation);
Exemple #26
0
 public static Vector2 getClosestCollisionPoint(Vector2 pivot, Vector2 lineAStart, Vector2 lineAEnd, List<Vector2> v, float offset = float.NaN, OffsetType offsetType = OffsetType.round)
 {
     var list = new List<Vector2>() { lineAStart, lineAEnd, new Vector2(lineAEnd.X + 1, lineAEnd.Y + 1) };
     return getClosestCollisionPoint(pivot, list, v, offset, offsetType);
 }
Exemple #27
0
 //COLLISIONTYPE COLLISION
 public static Vector2 getClosestCollisionPoint(Vector2 pivot, CollisionType collisionType1, CollisionType collisionType2, float offset = float.NaN, OffsetType offsetType = OffsetType.round)
 {
     PolygonSet p1;
     if (collisionType1 == CollisionType.unitCollision)
     {
         p1 = PremadePolygonSets.unitCollision;
     }
     else if (collisionType1 == CollisionType.visionCollision)
     {
         p1 = PremadePolygonSets.visionCollision;
     }
     else if (collisionType1 == CollisionType.bushCollision)
     {
         p1 = PremadePolygonSets.bushCollision;
     }
     else
     {
         return new Vector2(float.NaN, float.NaN);
     }
     PolygonSet p2;
     if (collisionType2 == CollisionType.unitCollision)
     {
         p2 = PremadePolygonSets.unitCollision;
     }
     else if (collisionType2 == CollisionType.visionCollision)
     {
         p2 = PremadePolygonSets.visionCollision;
     }
     else if (collisionType2 == CollisionType.bushCollision)
     {
         p2 = PremadePolygonSets.bushCollision;
     }
     else
     {
         return new Vector2(float.NaN, float.NaN);
     }
     return getCollisionPointClosest(p1, p2, pivot);
 }
 /// <summary>
 /// Returns the position in the nodes stream of the next node.
 /// </summary>
 /// <param name="reader">Reader with exclusive access to the underlying file</param>
 /// <param name="childIndex"></param>
 /// <param name="numberOfChildren"></param>
 /// <param name="offsetType"></param>
 /// <returns></returns>
 private void SetNextNodePosition(BinaryReader reader, byte childIndex, byte numberOfChildren, OffsetType offsetType)
 {
     if (childIndex == 0)
     {
         // Move past the children offset to the first child.
         reader.BaseStream.Position += (numberOfChildren - 1) * SizeOfOffsets(offsetType);
     }
     else
     {
         // Move to the bytes that represent the node position of the next node based on the child index.
         reader.BaseStream.Position += (childIndex - 1) * SizeOfOffsets(offsetType);
         switch (offsetType)
         {
             case OffsetType.Bits16:
                 reader.BaseStream.Position += reader.ReadUInt16();
                 break;
             case OffsetType.Bits32:
                 reader.BaseStream.Position += reader.ReadUInt32();
                 break;
             default:
                 reader.BaseStream.Position += reader.ReadInt64();
                 break;
         }
     }
 }
Exemple #29
0
        /// <summary>
        /// Method to generate a list of offset (from OD OffsetTypes table) in a ValuesDataSet
        /// This is done as a separate method since Values can could contain other VariableValue Types
        ///
        /// </summary>
        /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param>
        /// <returns></returns>
        public static List <OffsetType> datasetOffsetTypes(ValuesDataSet ds)
        {
            /* generate a list
             * create a distinct DataSet
             * - new data view
             * - set filter (no nulls)
             * - use toTable with unique to get unique list
             * foreach to generate qualifiers
             * */
            string            COLUMN    = "OffsetTypeID";
            string            TABLENAME = "offsetTypes";
            List <OffsetType> list      = new List <OffsetType>();

            try
            {
                DataView view = new DataView(ds.DataValues);
                view.RowFilter = COLUMN + " is not Null";
                DataTable ids = view.ToTable(TABLENAME, true, new string[] { COLUMN });

                foreach (DataRow r in ids.Rows)
                {
                    try
                    {
                        Object aId = r[COLUMN];
                        // edit here
                        ValuesDataSet.OffsetTypesRow offset = ds.OffsetTypes.FindByOffsetTypeID((int)aId);
                        if (offset != null)
                        {
                            OffsetType t = new OffsetType();
                            t.offsetTypeID          = offset.OffsetTypeID;
                            t.offsetTypeIDSpecified = true;

                            if (!String.IsNullOrEmpty(offset.OffsetDescription))
                            {
                                t.offsetDescription = offset.OffsetDescription;
                            }

                            ValuesDataSet.UnitsRow offUnit = ds.Units.FindByUnitsID(offset.OffsetUnitsID);
                            string offUnitsCode;
                            string offUnitsName         = null;
                            string offUnitsAbbreviation = null;
                            if (!String.IsNullOrEmpty(offUnit.UnitsAbbreviation))
                            {
                                offUnitsAbbreviation = offUnit.UnitsAbbreviation;
                            }
                            if (!String.IsNullOrEmpty(offUnit.UnitsName))
                            {
                                offUnitsName = offUnit.UnitsName;
                            }
                            if (offUnit != null)
                            {
                                t.units = CuahsiBuilder.CreateUnitsElement(
                                    null, offUnit.UnitsID.ToString(), offUnitsAbbreviation, offUnitsName);
                            }

                            list.Add(t);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Error("Error generating a qualifier " + r.ToString() + e.Message);
                    }
                }
                return(list);
            }

            catch (Exception e)
            {
                log.Error("Error generating a qualifiers " + e.Message);
                // non fatal exceptions
                return(null);
            }
        }
Exemple #30
0
 public static Cube RoundWorldToCube(Vector2 point, float pointRadius, OffsetType type)
 {
     return CubeRound( AxialToCube( WorldToAxial( point, pointRadius, type ) ) );
 }
Exemple #31
0
 protected void OnElementMovedAction(OffsetType type, Rect rect)
 {
     if (null != ElementMovedAction)
     {
         ElementMovedAction(_element, rect);
     }
 }
Exemple #32
0
 static extern bool gimp_drawable_offset(Int32 drawable_ID,
     bool wrap_around,
     OffsetType fill_type,
     int offset_x,
     int offset_y);
Exemple #33
0
 public void Offset(bool wrapAround, OffsetType fillType, Offset offset)
 {
     Offset(wrapAround, fillType, offset.X, offset.Y);
 }
Exemple #34
0
 public void Offset(bool wrapAround, OffsetType fillType,
     int offsetX, int offsetY)
 {
     if (!gimp_drawable_offset(ID, wrapAround, fillType, offsetX,
         offsetY))
     {
       throw new GimpSharpException();
     }
 }
Exemple #35
0
    public static AxialFraction WorldToAxial(Vector2 point, float pointRadius, OffsetType type)
    {
        float q;
        float r;

        // Pointy top
        if ( type == OffsetType.EvenR || type == OffsetType.OddR )
        {
            q = ((point.x * (Mathf.Sqrt(3.0f) / 3.0f)) - (point.y / 3.0f)) / pointRadius;
            r = point.y * 2.0f/3.0f / pointRadius;
        }
        // Flat top
        else
        {
            q = point.x * 2.0f/3.0f / pointRadius;
            r = (-point.x / 3.0f + Mathf.Sqrt(3.0f) / 3.0f * point.y) / pointRadius;
        }

        return new AxialFraction(q, r);
    }
        /// <summary>
        /// Returns the position in the nodes stream of the next node.
        /// </summary>
        /// <param name="reader">Reader with exclusive access to the underlying file</param>
        /// <param name="childIndex"></param>
        /// <param name="numberOfChildren"></param>
        /// <param name="offsetType"></param>
        /// <returns></returns>
        private void SetNextNodePosition(BinaryReader reader, byte childIndex, byte numberOfChildren, OffsetType offsetType)
        {
            if (childIndex == 0)
            {
                // Move past the children offset to the first child.
                reader.BaseStream.Position += (numberOfChildren - 1) * SizeOfOffsets(offsetType);
            }
            else
            {
                // Move to the bytes that represent the node position of the next node based on the child index.
                reader.BaseStream.Position += (childIndex - 1) * SizeOfOffsets(offsetType);
                switch (offsetType)
                {
                case OffsetType.Bits16:
                    reader.BaseStream.Position += reader.ReadUInt16();
                    break;

                case OffsetType.Bits32:
                    reader.BaseStream.Position += reader.ReadUInt32();
                    break;

                default:
                    reader.BaseStream.Position += reader.ReadInt64();
                    break;
                }
            }
        }
Exemple #37
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pInstrument"></param>
 /// <param name="pDirection"></param>
 /// <param name="pOffset"></param>
 /// <param name="pPrice">价格</param>
 /// <param name="pVolume"></param>
 /// <param name="pHedge"></param>
 /// <param name="pType">报单类型</param>
 /// <returns></returns>
 public int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, HedgeType pHedge, OrderType pType, string pCustom)
 {
     return(((DefReqOrderInsert)Invoke(this._handle, "ReqOrderInsert", typeof(DefReqOrderInsert)))(pInstrument, pDirection, pOffset, pPrice, pVolume, pHedge, pType, pCustom));
 }
Exemple #38
0
    public static Vector2 OffsetToWorld(Offset offset, float pointRadius, OffsetType type)
    {
        float x;
        float y;

        if (type == OffsetType.EvenQ)
        {
            x = pointRadius * 3.0f / 2.0f * offset.x;
            y = pointRadius * Mathf.Sqrt(3) * (offset.y - .5f * (offset.x % 2));
        }
        else if (type == OffsetType.EvenR)
        {
            x = pointRadius * Mathf.Sqrt(3) * (offset.x - .5f * (offset.y % 2));
            y = pointRadius * 3.0f / 2.0f * offset.y;
        }
        else if (type == OffsetType.OddQ)
        {
            x = pointRadius * 3.0f / 2.0f * offset.x;
            y = pointRadius * Mathf.Sqrt(3) * (offset.y + .5f * (offset.x % 2));
        }
        //OddR
        else
        {
            x = pointRadius * Mathf.Sqrt(3) * (offset.x + .5f * (offset.y % 2));
            y = pointRadius * 3.0f / 2.0f * offset.y;
        }

        return new Vector2(x, y);
    }
Exemple #39
0
        public override int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, int pCustom, OrderType pType = OrderType.Limit, HedgeType pHedge = HedgeType.Speculation)
        {
            //限价
            var OrderPriceType  = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice;
            var TimeCondition   = TThostFtdcTimeConditionType.THOST_FTDC_TC_GFD;
            var VolumeCondition = TThostFtdcVolumeConditionType.THOST_FTDC_VC_AV;

            if (pType == OrderType.Market) //市价
            {
                OrderPriceType = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_AnyPrice;
                TimeCondition  = TThostFtdcTimeConditionType.THOST_FTDC_TC_IOC;
                //max = instField.MaxMarketOrderVolume;
                pPrice = 0;
            }
            else if (pType == OrderType.FAK) //FAK
            {
                OrderPriceType = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice;
                TimeCondition  = TThostFtdcTimeConditionType.THOST_FTDC_TC_IOC;
            }
            else if (pType == OrderType.FOK) //FOK
            {
                OrderPriceType  = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice;
                TimeCondition   = TThostFtdcTimeConditionType.THOST_FTDC_TC_IOC;
                VolumeCondition = TThostFtdcVolumeConditionType.THOST_FTDC_VC_CV; //全部数量
            }

            return((int)_t.ReqOrderInsert(_broker, _investor, InstrumentID: pInstrument,
                                          OrderRef: string.Format("{0:000000}{1:000000}", _ref++, pCustom % 1000000),
                                          CombHedgeFlag: new string((char)(pHedge == HedgeType.Speculation ? TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation : pHedge == HedgeType.Arbitrage ? TThostFtdcHedgeFlagType.THOST_FTDC_HF_Arbitrage : TThostFtdcHedgeFlagType.THOST_FTDC_HF_Hedge), 1),
                                          CombOffsetFlag: new String((char)(pOffset == OffsetType.Open ? TThostFtdcOffsetFlagType.THOST_FTDC_OF_Open : pOffset == OffsetType.Close ? TThostFtdcOffsetFlagType.THOST_FTDC_OF_Close : TThostFtdcOffsetFlagType.THOST_FTDC_OF_CloseToday), 1),
                                          Direction: pDirection == DirectionType.Buy ? TThostFtdcDirectionType.THOST_FTDC_D_Buy : TThostFtdcDirectionType.THOST_FTDC_D_Sell,
                                          VolumeTotalOriginal: pVolume,
                                          ForceCloseReason: TThostFtdcForceCloseReasonType.THOST_FTDC_FCC_NotForceClose,
                                          ContingentCondition: TThostFtdcContingentConditionType.THOST_FTDC_CC_Immediately,
                                          VolumeCondition: VolumeCondition,
                                          LimitPrice: pPrice,
                                          IsSwapOrder: 0,
                                          MinVolume: 1,
                                          UserForceClose: 0,
                                          TimeCondition: TimeCondition,
                                          OrderPriceType: OrderPriceType));
        }
Exemple #40
0
    public static Cube OffsetToCube( Offset offset, OffsetType type )
    {
        Cube c;

        if (type == OffsetType.EvenQ)
        {
            c = EvenQToCube(offset);
        }
        else if (type == OffsetType.EvenR)
        {
            c = EvenRToCube(offset);
        }
        else if (type == OffsetType.OddQ)
        {
            c = OddQToCube(offset);
        }
        else
        {
            c = OddRToCube(offset);
        }

        return c;
    }
Exemple #41
0
 public static Vector2 getClosestCollisionPoint(Vector2 pivot, List<List<Vector2>> polygonSet1, List<List<Vector2>> polygonSet2, float offset = float.NaN, OffsetType offsetType = OffsetType.round)
 {
     PolygonSet p;
     if (offsetType == OffsetType.round)
     {
         p = Generate.offsetLineRound(PolygonHelperClass.VectorsToPolys(polygonSet1), offset);
     }
     else if (offsetType == OffsetType.square)
     {
         p = Generate.offsetLineSquare(PolygonHelperClass.VectorsToPolys(polygonSet1), offset);
     }
     else
     {
         return new Vector2(float.NaN, float.NaN);
     }
     return getCollisionPointClosest(p, PolygonHelperClass.VectorsToPolys(polygonSet2), pivot);
 }
            /// <summary>
            /// Method to generate a list of offset (from OD OffsetTypes table) in a ValuesDataSet
            /// This is done as a separate method since Values can could contain other VariableValue Types
            ///
            /// </summary>
            /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param>
            /// <returns></returns>
            public static List<OffsetType> datasetOffsetTypes(ValuesDataSet ds, string valuesWhereClause)
            {
                /* generate a list
                 * create a distinct DataSet
                 * - new data view
                 * - set filter (no nulls)
                 * - use toTable with unique to get unique list
                 * foreach to generate qualifiers
                 * */
                string COLUMN = "OffsetTypeID";
                string TABLENAME = "offsetTypes";
                List<OffsetType> list = new List<OffsetType>();
                try
                {
                    DataView view = new DataView(ds.DataValues);
                    view.RowFilter = valuesWhereClause;

                    DataTable ids = view.ToTable(TABLENAME, true, new string[] {COLUMN});

                    foreach (DataRow r in ids.Rows)
                    {
                        try
                        {
                            //Object aId = r[COLUMN];

                            if (r[COLUMN] == DBNull.Value)
                            {
                                continue;
                            }
                int? aId = Convert.ToInt32(r[COLUMN]);
                            // edit here
                            ValuesDataSet.OffsetTypesRow offset = ds.OffsetTypes.FindByOffsetTypeID((int) aId.Value);
                            if (offset != null)
                            {
                                OffsetType t = new OffsetType();
                                t.offsetTypeID = offset.OffsetTypeID;
                                t.offsetTypeIDSpecified = true;

                                t.offsetTypeCode = t.offsetTypeID.ToString();

                                if (!String.IsNullOrEmpty(offset.OffsetDescription))
                                    t.offsetDescription = offset.OffsetDescription;

                                ValuesDataSet.UnitsRow offUnit = ds.Units.FindByUnitsID(offset.OffsetUnitsID);
                                string offUnitsCode;

                                string offUnitsName = null;
                                string offUnitsAbbreviation = null;
                                if (!String.IsNullOrEmpty(offUnit.UnitsAbbreviation))
                                    offUnitsAbbreviation = offUnit.UnitsAbbreviation;
                                if (!String.IsNullOrEmpty(offUnit.UnitsName)) offUnitsName = offUnit.UnitsName;
                                if (offUnit != null)
                                    t.unit = CuahsiBuilder.CreateUnitsElement(
                                        offUnit.UnitsType, offUnit.UnitsID.ToString(), offUnitsAbbreviation,
                                        offUnitsName);

                                list.Add(t);
                            }
                        }
                        catch (Exception e)
                        {
                            log.Error("Error generating a offsetTypes " + r.ToString() + e.Message);
                        }
                    }
                    return list;
                }

                catch (Exception e)
                {
                    log.Error("Error generating a offsetTypes " + e.Message);
                    // non fatal exceptions
                    return null;
                }
            }
Exemple #43
0
 public static Vector2 getClosestCollisionPoint(Vector2 pivot, Vector2 point1, Vector2 point2, float offset = float.NaN, OffsetType offsetType = OffsetType.round)
 {
     var list = new List<Vector2>() { point1, new Vector2(point1.X + 1, point1.Y + 1), new Vector2(point1.X - 1, point1.Y + 1) };
     return getClosestCollisionPoint(pivot, point2, list, offset, offsetType);
 }
Exemple #44
0
 public static Offset OffsetRound(Vector2 point, float pointRadius, OffsetType type)
 {
     if (type == OffsetType.EvenQ)
         return HexMath.CubeToEvenQ(HexMath.CubeRound(HexMath.AxialToCube(HexMath.WorldToAxial(new Vector2(point.x, point.y), .5f, type))));
     else if (type == OffsetType.EvenR)
         return HexMath.CubeToEvenR(HexMath.CubeRound(HexMath.AxialToCube(HexMath.WorldToAxial(new Vector2(point.x, point.y), .5f, type))));
     else if (type == OffsetType.OddQ)
         return HexMath.CubeToOddQ(HexMath.CubeRound(HexMath.AxialToCube(HexMath.WorldToAxial(new Vector2(point.x, point.y), .5f, type))));
     else
         return HexMath.CubeToOddR(HexMath.CubeRound(HexMath.AxialToCube(HexMath.WorldToAxial(new Vector2(point.x, point.y), .5f, type))));
 }
Exemple #45
0
 public static Vector2 getClosestCollisionPoint(Vector2 pivot, Vector2 lineAStart, Vector2 lineAEnd, Vector2 lineBStart, Vector2 lineBEnd, float offset = float.NaN, OffsetType offsetType = OffsetType.round)
 {
     PolygonSet p = new PolygonSet();
     var list = new List<IntPoint>() { new IntPoint(lineBStart.X, lineBStart.Y), new IntPoint(lineBEnd.X, lineBEnd.Y), new IntPoint(lineBEnd.X + 1, lineBEnd.Y + 1) };
     if (offsetType == OffsetType.round)
     {
         p = Generate.offsetLineRound(list, offset);
     }
     else if (offsetType == OffsetType.square)
     {
         p = Generate.offsetLineSquare(list, offset);
     }
     else
     {
         return new Vector2(float.NaN, float.NaN);
     }
     return getClosestCollisionPoint(pivot, lineAStart, lineAEnd, offset, offsetType);
 }
Exemple #46
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pInstrument"></param>
 /// <param name="pDirection"></param>
 /// <param name="pOffset"></param>
 /// <param name="pPrice"></param>
 /// <param name="pVolume"></param>
 /// <param name="pHedge"></param>
 /// <returns>正确返回0</returns>
 public int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, HedgeType pHedge = HedgeType.Speculation, OrderType pType = OrderType.Limit)
 {
     return _proxy.ReqOrderInsert(pInstrument, pDirection, pOffset, pPrice, pVolume, pHedge, pType);
 }
Exemple #47
0
 public MemoryOffset(string description, string memoryOffset, OffsetType offsetType)
 {
     Description         = description;
     MemoryOffsetAddress = Convert.ToInt64(memoryOffset, 16);
     OffsetType          = offsetType;
 }
Exemple #48
0
 internal ExternalOffset(int offset, OffsetType offsetType) : this(None, offset, offsetType)
 {
 }
Exemple #49
0
    public static Offset OffsetNeighbor(Offset start, int direction, OffsetType type)
    {
        Cube startc = OffsetToCube(start, type);

        Cube neighbor = CubeNeighber(startc, direction);

        return CubeToOffset(neighbor, type);
    }
Exemple #50
0
 /// <summary>
 /// Main
 /// </summary>
 internal ExternalOffset(ExternalOffset dependency, int offset, OffsetType offsetType)
 {
     Dependency = dependency;
     Offset     = offset;
     OffsetType = offsetType;
 }
Exemple #51
0
        public static UserType ParseType(XElement xmlType, Dictionary <string, IType> scopedTypes)
        {
            var typeName = xmlType.Attribute("name");
            var type     = new UserType(typeName.Value);

            var subTypes   = xmlType.Elements("type");
            var attributes = xmlType.Elements("attr");

            scopedTypes.Add(type.Name, type);
            foreach (var subType in subTypes)
            {
                var parsed = ParseType(subType, new Dictionary <string, IType>(scopedTypes));
                scopedTypes.Add(parsed.Name, parsed);
            }

            foreach (var attr in attributes)
            {
                var attrName = attr.Attribute("name");

                var typeAttr = attr.Attribute("type");
                var typeExpr = attr.Element("type");

                var offsetExpr = attr.Element("offset");
                var sizeExpr   = attr.Element("size");

                var conditionExpr = attr.Element("if");

                var repeatType = attr.Element("repeat");

                IPotential <IType> typePotential;

                if (typeAttr != null || typeExpr != null)
                {
                    IPotential <string> namePotential = typeAttr != null ?
                                                        (IPotential <string>) new TrivialPotential <string>(typeAttr.Value) :
                                                        (IPotential <string>) new Expression <string>(typeExpr.Value);

                    typePotential = new NamedTypePotential(scopedTypes, namePotential);
                }
                else
                {
                    typePotential = new TrivialPotential <IType>(new VoidType(new Expression <long>(sizeExpr.Value)));
                }

                if (offsetExpr != null)
                {
                    var baseType   = typePotential;
                    var offsetType = new OffsetType(baseType, new Expression <long>(offsetExpr.Value));

                    typePotential = new TrivialPotential <IType>(offsetType);
                }

                if (conditionExpr != null)
                {
                    var baseType        = typePotential;
                    var conditionalType = new ConditionalType(baseType, new Expression <bool>(conditionExpr.Value));

                    typePotential = new TrivialPotential <IType>(conditionalType);
                }

                if (repeatType != null)
                {
                    var lengthExpr = attr.Element("repeat-expr");
                    var untilExpr  = attr.Element("repeat-until");

                    var baseType = typePotential;

                    if (repeatType.Value == "expr")
                    {
                        var arrayType = new DefiniteArrayType(baseType, new Expression <int>(lengthExpr.Value));
                        typePotential = new TrivialPotential <IType>(arrayType);
                    }
                    else if (repeatType.Value == "until")
                    {
                        var arrayType = new IndefiniteArrayType(baseType, new Expression <bool>(untilExpr.Value));
                        typePotential = new TrivialPotential <IType>(arrayType);
                    }
                }

                type.Attributes.Add(attrName.Value, typePotential);
            }

            return(type);
        }
        //-------------------------------------------------
        private void CreateAndAddButtonInfo(EVRButtonId buttonID)
        {
            Transform           buttonTransform = null;
            List <MeshRenderer> buttonRenderers = new List <MeshRenderer>();

            string buttonDebug = "Looking for button: " + buttonID;

            EVRButtonId searchButtonID = buttonID;

            if (buttonID == EVRButtonId.k_EButton_Grip && SteamVR.instance.hmd_TrackingSystemName.ToLowerInvariant().Contains("oculus"))
            {
                searchButtonID = EVRButtonId.k_EButton_Axis2;
            }
            ulong buttonMaskForID = (1ul << (int)searchButtonID);

            foreach (KeyValuePair <string, ulong> componentButtonMask in componentButtonMasks)
            {
                if ((componentButtonMask.Value & buttonMaskForID) == buttonMaskForID)
                {
                    buttonDebug += "\nFound component: " + componentButtonMask.Key + " " + componentButtonMask.Value;
                    Transform componentTransform = renderModel.FindComponent(componentButtonMask.Key);

                    buttonTransform = componentTransform;

                    buttonDebug += "\nFound componentTransform: " + componentTransform + " buttonTransform: " + buttonTransform;

                    buttonRenderers.AddRange(componentTransform.GetComponentsInChildren <MeshRenderer>());
                }
            }

            buttonDebug += "\nFound " + buttonRenderers.Count + " renderers for " + buttonID;
            foreach (MeshRenderer renderer in buttonRenderers)
            {
                buttonDebug += "\n\t" + renderer.name;
            }

            HintDebugLog(buttonDebug);

            if (buttonTransform == null)
            {
                HintDebugLog("Couldn't find buttonTransform for " + buttonID);
                return;
            }

            ButtonHintInfo hintInfo = new ButtonHintInfo();

            buttonHintInfos.Add(buttonID, hintInfo);

            hintInfo.componentName = buttonTransform.name;
            hintInfo.renderers     = buttonRenderers;

            //Get the local transform for the button
            hintInfo.localTransform = buttonTransform.Find(SteamVR_RenderModel.k_localTransformName);

            OffsetType offsetType = OffsetType.Right;

            switch (buttonID)
            {
            case EVRButtonId.k_EButton_SteamVR_Trigger:
            {
                offsetType = OffsetType.Right;
            }
            break;

            case EVRButtonId.k_EButton_ApplicationMenu:
            {
                offsetType = OffsetType.Right;
            }
            break;

            case EVRButtonId.k_EButton_System:
            {
                offsetType = OffsetType.Right;
            }
            break;

            case Valve.VR.EVRButtonId.k_EButton_Grip:
            {
                offsetType = OffsetType.Forward;
            }
            break;

            case Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad:
            {
                offsetType = OffsetType.Up;
            }
            break;
            }

            //Offset for the text end transform
            switch (offsetType)
            {
            case OffsetType.Forward:
                hintInfo.textEndOffsetDir = hintInfo.localTransform.forward;
                break;

            case OffsetType.Back:
                hintInfo.textEndOffsetDir = -hintInfo.localTransform.forward;
                break;

            case OffsetType.Right:
                hintInfo.textEndOffsetDir = hintInfo.localTransform.right;
                break;

            case OffsetType.Up:
                hintInfo.textEndOffsetDir = hintInfo.localTransform.up;
                break;
            }

            //Create the text hint object
            Vector3 hintStartPos = hintInfo.localTransform.position + (hintInfo.localTransform.forward * 0.01f);

            hintInfo.textHintObject      = GameObject.Instantiate(textHintPrefab, hintStartPos, Quaternion.identity) as GameObject;
            hintInfo.textHintObject.name = "Hint_" + hintInfo.componentName + "_Start";
            hintInfo.textHintObject.transform.SetParent(textHintParent);
            hintInfo.textHintObject.layer = gameObject.layer;
            hintInfo.textHintObject.tag   = gameObject.tag;

            //Get all the relevant child objects
            hintInfo.textStartAnchor = hintInfo.textHintObject.transform.Find("Start");
            hintInfo.textEndAnchor   = hintInfo.textHintObject.transform.Find("End");
            hintInfo.canvasOffset    = hintInfo.textHintObject.transform.Find("CanvasOffset");
            hintInfo.line            = hintInfo.textHintObject.transform.Find("Line").GetComponent <LineRenderer>();
            hintInfo.textCanvas      = hintInfo.textHintObject.GetComponentInChildren <Canvas>();
            hintInfo.text            = hintInfo.textCanvas.GetComponentInChildren <Text>();
            hintInfo.textMesh        = hintInfo.textCanvas.GetComponentInChildren <TextMesh>();

            hintInfo.textHintObject.SetActive(false);

            hintInfo.textStartAnchor.position = hintStartPos;

            if (hintInfo.text != null)
            {
                hintInfo.text.text = hintInfo.componentName;
            }

            if (hintInfo.textMesh != null)
            {
                hintInfo.textMesh.text = hintInfo.componentName;
            }

            centerPosition += hintInfo.textStartAnchor.position;

            // Scale hint components to match player size
            hintInfo.textCanvas.transform.localScale      = Vector3.Scale(hintInfo.textCanvas.transform.localScale, player.transform.localScale);
            hintInfo.textStartAnchor.transform.localScale = Vector3.Scale(hintInfo.textStartAnchor.transform.localScale, player.transform.localScale);
            hintInfo.textEndAnchor.transform.localScale   = Vector3.Scale(hintInfo.textEndAnchor.transform.localScale, player.transform.localScale);
            hintInfo.line.transform.localScale            = Vector3.Scale(hintInfo.line.transform.localScale, player.transform.localScale);
        }
Exemple #53
0
 public void UpdateOffset(OffsetType type, double value)
 {
 }
 public static RadialGradient At(this RadialGradient gradient, double x, double y, OffsetType type = OffsetType.Proportional)
 {
     return(gradient.At(new Position(x, y, type)));
 }
Exemple #55
0
    public static List<Offset> GetOffsetsInRange(Offset center, int range, OffsetType type)
    {
        List<Offset> offsets = new List<Offset>();

        List<Cube> cubes = GetCubesInRange(OffsetToCube(center, type), range);

        for (int i = 0; i < cubes.Count; i++)
            offsets.Add(CubeToOffset(cubes[i], type));

        return offsets;
    }
 public static RadialGradient Size(this RadialGradient gradient, double width, double height, OffsetType type = OffsetType.Absolute)
 {
     return(gradient.Size(new Dimensions(width, height, type)));
 }
Exemple #57
0
    public static List<Offset> GetOffsetsInLine(Offset a, Offset b, OffsetType type)
    {
        Cube ac = OffsetToCube(a, type);
        Cube bc = OffsetToCube(b, type);

        List<Cube> cubeList = GetCubesInLine(ac, bc);

        List<Offset> offsetList = new List<Offset>();

        foreach ( Cube cube in cubeList )
            offsetList.Add(CubeToOffset(cube, type));

        return offsetList;
    }
Exemple #58
0
 //POLYGOTSET COLLISION
 public static Vector2 getClosestCollisionPoint(Vector2 pivot, List<List<Vector2>> polygonSet1, CollisionType collisionType, float offset = float.NaN, OffsetType offsetType = OffsetType.round)
 {
     PolygonSet p;
     if (offsetType == OffsetType.round)
     {
         p = Generate.offsetLineRound(PolygonHelperClass.VectorsToPolys(polygonSet1), offset);
     }
     else if (offsetType == OffsetType.square)
     {
         p = Generate.offsetLineSquare(PolygonHelperClass.VectorsToPolys(polygonSet1), offset);
     }
     else
     {
         return new Vector2(float.NaN, float.NaN);
     }
     PolygonSet p2;
     if (collisionType == CollisionType.unitCollision)
     {
         p2 = PremadePolygonSets.unitCollision;
     }
     else if (collisionType == CollisionType.visionCollision)
     {
         p2 = PremadePolygonSets.visionCollision;
     }
     else if (collisionType == CollisionType.bushCollision)
     {
         p2 = PremadePolygonSets.bushCollision;
     }
     else
     {
         return new Vector2(float.NaN, float.NaN);
     }
     return getCollisionPointClosest(p, p2, pivot);
 }
        //-------------------------------------------------
        private void CreateAndAddButtonInfo(ISteamVR_Action_In action, SteamVR_Input_Sources inputSource)
        {
            Transform           buttonTransform = null;
            List <MeshRenderer> buttonRenderers = new List <MeshRenderer>();

            StringBuilder buttonDebug = new StringBuilder();

            buttonDebug.Append("Looking for action: ");

            buttonDebug.AppendLine(action.GetShortName());

            buttonDebug.Append("Action localized origin: ");
            buttonDebug.AppendLine(action.GetLocalizedOrigin(inputSource));

            string actionComponentName = action.GetRenderModelComponentName(inputSource);

            if (componentTransformMap.ContainsKey(actionComponentName))
            {
                buttonDebug.AppendLine(string.Format("Found component: {0} for {1}", actionComponentName, action.GetShortName()));
                Transform componentTransform = componentTransformMap[actionComponentName];

                buttonTransform = componentTransform;

                buttonDebug.AppendLine(string.Format("Found componentTransform: {0}. buttonTransform: {1}", componentTransform, buttonTransform));

                buttonRenderers.AddRange(componentTransform.GetComponentsInChildren <MeshRenderer>());
            }
            else
            {
                buttonDebug.AppendLine(string.Format("Can't find component transform for action: {0}. Component name: \"{1}\"", action.GetShortName(), actionComponentName));
            }

            buttonDebug.AppendLine(string.Format("Found {0} renderers for {1}", buttonRenderers.Count, action.GetShortName()));

            foreach (MeshRenderer renderer in buttonRenderers)
            {
                buttonDebug.Append("\t");
                buttonDebug.AppendLine(renderer.name);
            }

            HintDebugLog(buttonDebug.ToString());

            if (buttonTransform == null)
            {
                HintDebugLog("Couldn't find buttonTransform for " + action.GetShortName());
                return;
            }

            ActionHintInfo hintInfo = new ActionHintInfo();

            actionHintInfos.Add(action, hintInfo);

            hintInfo.componentName = buttonTransform.name;
            hintInfo.renderers     = buttonRenderers;

            //Get the local transform for the button
            for (int childIndex = 0; childIndex < buttonTransform.childCount; childIndex++)
            {
                Transform child = buttonTransform.GetChild(childIndex);
                if (child.name == SteamVR_RenderModel.k_localTransformName)
                {
                    hintInfo.localTransform = child;
                }
            }

            OffsetType offsetType = OffsetType.Right;

            /*
             * switch ( buttonID )
             *          {
             *                  case EVRButtonId.k_EButton_SteamVR_Trigger:
             *                          {
             *                                  offsetType = OffsetType.Right;
             *                          }
             *                          break;
             *                  case EVRButtonId.k_EButton_ApplicationMenu:
             *                          {
             *                                  offsetType = OffsetType.Right;
             *                          }
             *                          break;
             *                  case EVRButtonId.k_EButton_System:
             *                          {
             *                                  offsetType = OffsetType.Right;
             *                          }
             *                          break;
             *                  case Valve.VR.EVRButtonId.k_EButton_Grip:
             *                          {
             *                                  offsetType = OffsetType.Forward;
             *                          }
             *                          break;
             *                  case Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad:
             *                          {
             *                                  offsetType = OffsetType.Up;
             *                          }
             *                          break;
             *          }
             */

            //Offset for the text end transform
            switch (offsetType)
            {
            case OffsetType.Forward:
                hintInfo.textEndOffsetDir = hintInfo.localTransform.forward;
                break;

            case OffsetType.Back:
                hintInfo.textEndOffsetDir = -hintInfo.localTransform.forward;
                break;

            case OffsetType.Right:
                hintInfo.textEndOffsetDir = hintInfo.localTransform.right;
                break;

            case OffsetType.Up:
                hintInfo.textEndOffsetDir = hintInfo.localTransform.up;
                break;
            }

            //Create the text hint object
            Vector3 hintStartPos = hintInfo.localTransform.position + (hintInfo.localTransform.forward * 0.01f);

            hintInfo.textHintObject      = GameObject.Instantiate(textHintPrefab, hintStartPos, Quaternion.identity) as GameObject;
            hintInfo.textHintObject.name = "Hint_" + hintInfo.componentName + "_Start";
            hintInfo.textHintObject.transform.SetParent(textHintParent);
            hintInfo.textHintObject.layer = gameObject.layer;
            hintInfo.textHintObject.tag   = gameObject.tag;

            //Get all the relevant child objects
            hintInfo.textStartAnchor = hintInfo.textHintObject.transform.Find("Start");
            hintInfo.textEndAnchor   = hintInfo.textHintObject.transform.Find("End");
            hintInfo.canvasOffset    = hintInfo.textHintObject.transform.Find("CanvasOffset");
            hintInfo.line            = hintInfo.textHintObject.transform.Find("Line").GetComponent <LineRenderer>();
            hintInfo.textCanvas      = hintInfo.textHintObject.GetComponentInChildren <Canvas>();
            hintInfo.text            = hintInfo.textCanvas.GetComponentInChildren <Text>();
            hintInfo.textMesh        = hintInfo.textCanvas.GetComponentInChildren <TextMesh>();

            hintInfo.textHintObject.SetActive(false);

            hintInfo.textStartAnchor.position = hintStartPos;

            if (hintInfo.text != null)
            {
                hintInfo.text.text = hintInfo.componentName;
            }

            if (hintInfo.textMesh != null)
            {
                hintInfo.textMesh.text = hintInfo.componentName;
            }

            centerPosition += hintInfo.textStartAnchor.position;

            // Scale hint components to match player size
            hintInfo.textCanvas.transform.localScale      = Vector3.Scale(hintInfo.textCanvas.transform.localScale, player.transform.localScale);
            hintInfo.textStartAnchor.transform.localScale = Vector3.Scale(hintInfo.textStartAnchor.transform.localScale, player.transform.localScale);
            hintInfo.textEndAnchor.transform.localScale   = Vector3.Scale(hintInfo.textEndAnchor.transform.localScale, player.transform.localScale);
            hintInfo.line.transform.localScale            = Vector3.Scale(hintInfo.line.transform.localScale, player.transform.localScale);
        }
 /// <summary>
 /// The number of bytes each offset takes.
 /// </summary>
 /// <param name="offsetType"></param>
 /// <returns></returns>
 public static int SizeOfOffsets(OffsetType offsetType)
 {
     switch (offsetType)
     {
         case OffsetType.Bits16:
             return sizeof(ushort);
         case OffsetType.Bits32:
             return sizeof(uint);
         default:
             return sizeof(long);
     }
 }