コード例 #1
0
        public EntityBetterRopeSegment(Vector2 location, WorldBase world, EntityBetterRopeSegment parent) : base(location, world)
        {
            this.parent = parent;

            if (rand == null)
            {
                rand = new Random();
            }

            width    = 20;
            height   = 20;
            startLoc = location;
            this.frictionMultiplier = 2;
            this.gravityMultiplier  = .5f;
            blocksWeaponsOnHit      = false;
        }
コード例 #2
0
        public override void prePhysicsUpdate(GameTime time)
        {
            base.prePhysicsUpdate(time);

            if (!isAnchor)
            {
                impulse += (parent.location - location) * .025f;
                if (child != null)
                {
                    impulse += (child.location - location) * .025f;
                }
            }
            else
            {
                velocity = new Vector2();
                impulse  = new Vector2();
                location = startLoc;
            }

            if (Vector2.Distance(location, world.player.location) > world.tileGenRadious * Chunk.tilesPerChunk * Chunk.tileDrawWidth * 1.5f)
            {
                world.killEntity(this);
                EntityBetterRopeSegment current = parent;
                while (current != null)
                {
                    world.killEntity(this);
                    current = current.parent;
                }

                current = child;
                while (current != null)
                {
                    world.killEntity(this);
                    current = current.child;
                }
            }
        }