当前位置: 首页>>代码示例>>C#>>正文


C# Link.AddLinkComponent方法代码示例

本文整理汇总了C#中Link.AddLinkComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Link.AddLinkComponent方法的具体用法?C# Link.AddLinkComponent怎么用?C# Link.AddLinkComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Link的用法示例。


在下文中一共展示了Link.AddLinkComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnSpawn

        public override void OnSpawn()
        {
            //Node.cloneNode(parent.Game1.ui.sidebar.ActiveDefaultNode, sword);
            //parent.body.texture = textures.orientedcircle;
            shovelNode.dataStore["shovelnodeparent"] = parent;
            shovelNode.body.pos = parent.body.pos;

            shovelNode.AffectExclusionCheck += (node) => node == parent;

            room.groups.items.IncludeEntity(shovelNode);
            shovelNode.OnSpawn();
            shovelNode.body.AddExclusionCheck(parent.body);
            Spring spring = new Spring();
            spring.restdist = 0;
            spring.springMode = Spring.mode.PullOnly;
            spring.active = true;
            spring.multiplier = 1000;

            Tether tether = new Tether();
            tether.mindist = 0;
            tether.maxdist = 20;
            tether.active = true;

            shovelLink = new Link(shovelNode, new HashSet<Node>(), spring);
            shovelLink.AddLinkComponent(tether);

            //to keep the shovel in reach for physics based control
            Tether rangeTether = new Tether();
            rangeTether.mindist = 0;
            rangeTether.maxdist = (int)shovelReach;
            rangeTether.active = true;
            rangeLink = new Link(parent, shovelNode, rangeTether);
            if (modeShovelPosition == ModeShovelPosition.PhysicsBased)
            {
                rangeLink.active = true;
            }

            //exclusionDel = delegate(Collider c1, Collider c2)
            //{
            //    return shovelLink.active && shovelLink.targets.Contains(c2.parent);
            //};
            //shovelNode.body.ExclusionCheck += exclusionDel;
            //parent.body.ExclusionCheck += exclusionDel;
        }
开发者ID:GameMakersUnion,项目名称:BoulderDash-OrbIt,代码行数:44,代码来源:Shovel.cs

示例2: AddLinkComponent

        private bool AddLinkComponent(object[] o, Link link)
        {
            //bool writeable = false;
            Type t = (Type)o[1];

            object linkComp = Activator.CreateInstance(t);

            link.AddLinkComponent((ILinkable)linkComp);
            //ILinkable l = (ILinkable)linkComp;
            //link.components.Add(l);

            ActiveInspectorParent.DoubleClickItem(this);
            return true;
            /*
            if (!inspectorArea.editNode.comps.ContainsKey((comp)o[1]))
            {
                inspectorArea.editNode.addComponent((comp)o[1], true);
                inspectorArea.ActiveInspectorParent.DoubleClickItem(inspectorArea);
            }
            else PopUp.Prompt(ui,
                        "The node already contains this component. Overwrite to default component?",
                        action: delegate(bool k, object ans) { writeable = k; return true; });

            if (writeable)
            {
                inspectorArea.editNode.addComponent((comp)o[1], true);
                inspectorArea.ActiveInspectorParent.DoubleClickItem(inspectorArea);
                return true;
            }
            else
            {
                return false;
            }
            */
        }
开发者ID:GameMakersUnion,项目名称:BoulderDash-OrbIt,代码行数:35,代码来源:InspectorArea.cs

示例3: OnSpawn

        public override void OnSpawn()
        {
            shootNode.dataStore["linknodeparent"] = parent;
            shootNode.body.pos = parent.body.pos;
            shootNode.addComponent<ColorChanger>(true);
            shootNode.AffectExclusionCheck += (node) => node == parent;
            room.groups.items.IncludeEntity(shootNode);
            shootNode.OnSpawn();
            shootNode.body.AddExclusionCheck(parent.body);
            shootNode.active = false;
            shootNode.movement.maxVelocity.value = 50f;

            spring = new Spring();
            spring.restdist = 0;
            spring.springMode = Spring.mode.PushOnly;
            spring.multiplier = 400;

            //Tether tether = new Tether();
            //tether.mindist = 0;
            //tether.maxdist = 20;
            //tether.active = true;

            //shootNodeLink = new Link(parent, shootNode, spring);
            //shootNodeLink.IsEntangled = true;
            ////shovelLink.components.Add(tether);

            grav = new Gravity();
            grav.mode = Gravity.Mode.ConstantForce;
            //grav.Repulsive = true;
            grav.multiplier = 100;

            shootLink = new Link(parent, shootNode, grav);
            shootLink.AddLinkComponent(spring, true);

            //
            Gravity attachGrav = new Gravity();
            attachGrav.multiplier = 100;
            attachGrav.mode = Gravity.Mode.ConstantForce;

            Tether aTether = new Tether();
            aTether.maxdist = 100;
            aTether.mindist = 0;
            aTether.activated = true;

            Spring aSpring = new Spring();
            aSpring.springMode = Spring.mode.PushAndPull;
            aSpring.multiplier = 100;
            aSpring.restdist = 0;

            attachedNodesQueue = new Queue<Node>();
            //attachLink = new Link(parent, new HashSet<Node>(), attachGrav); //targetsToSelf

            attachLink = new Link(new HashSet<Node>(), new HashSet<Node>(), aTether); //targetsChained
            attachLink.FormationType = formationtype.Chain;
            //attachLink.AddLinkComponent(aTether, true);
            //attachLink.AddLinkComponent(attachGrav, true);

            shootNode.body.OnCollisionEnter += (n, other) =>
                {
                    if (other == parent) return;
                    if (linkMode == LinkMode.TargetsToSelf)
                    {
                        if (!attachLink.targets.Contains(other))
                        {
                            attachLink.targets.Add(other);
                            attachedNodesQueue.Enqueue(other);
                            attachLink.active = true;
                        }
                    }
                    else if (linkMode == LinkMode.TargetsToTargets)
                    {
                        if (!attachLink.sources.Contains(other))
                        {
                            attachLink.sources.Add(other);
                            attachLink.targets.Add(other);
                            attachedNodesQueue.Enqueue(other);
                            attachLink.active = true;
                        }
                    }
                    else if (linkMode == LinkMode.TargetsChained)
                    {
                        if (!attachLink.sources.Contains(other))
                        {
                            attachedNodesQueue.Enqueue(other);
                            attachLink.formation.AddChainNode(other);
                            attachLink.active = true;
                        }
                    }
                };

            parent.body.ExclusionCheck += (c1, c2) =>
                attachLink.targets.Contains(c2.parent);
        }
开发者ID:GameMakersUnion,项目名称:BoulderDash-OrbIt,代码行数:93,代码来源:LinkGun.cs


注:本文中的Link.AddLinkComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。