コード例 #1
0
        public void Align(uint[] instanceIds, ChainType chainType, Vex.Point target, List <Bond> addedBonds, List <Bond> previousBonds)
        {
            BondAttachment bt       = chainType.GetAttachment();
            BondType       bondType = chainType.IsAligned() ? BondType.Anchor : BondType.Spring;

            Bond b;
            Bond prev = null;

            for (int i = 0; i < instanceIds.Length - 1; i++)
            {
                uint id = instanceIds[i];

                if (chainType.IsDistributed())
                {
                    if (i > 0)
                    {
                        RemoveCollidingBond(id, bt, previousBonds, BondType.Anchor);
                    }
                    if (i < instanceIds.Length - 1)
                    {
                        BondAttachment btOpp = chainType.GetOppositeAttachment();
                        RemoveCollidingBond(id, btOpp, previousBonds, BondType.Anchor);
                    }
                }
                else
                {
                    RemoveCollidingBond(id, bt, previousBonds, BondType.Anchor);
                }

                b                = new Bond(id, bt, bondType);
                b.ChainType      = chainType;
                b.TargetLocation = target;
                AddBond(b);
                addedBonds.Add(b);

                b.Previous = prev;
                if (prev != null)
                {
                    prev.Next = b;
                }
                prev = b;
            }

            int  lastIndex = instanceIds.Length - 1;
            uint lastId    = instanceIds[lastIndex];

            RemoveCollidingBond(lastId, bt, previousBonds, BondType.Anchor);

            b                = new Bond(lastId, bt, bondType);
            b.ChainType      = chainType;
            b.TargetLocation = target;
            AddBond(b);
            addedBonds.Add(b);

            b.Previous = prev;
            prev.Next  = b;
        }
コード例 #2
0
ファイル: Bond.cs プロジェクト: yzqlwt/Swf2XNA
        public Bond GetCollidingBond(BondAttachment ba)
        {
            Bond result = null;

            if (ChainType.IsDistributed())
            {
                if (Previous != null && ChainType.GetAttachment() == ba)
                {
                    result = this;
                }
                else if (Next != null && ChainType.GetOppositeAttachment() == ba)
                {
                    result = Next;
                }
            }
            else if (sourceAttachment == ba)
            {
                result = this;
            }
            return(result);
        }