コード例 #1
0
        public IKMember(ParasiteBodyPart skin, float distance)
        {
            this.distance        = distance;
            this.defaultdistance = distance;        // default distance
            this.skin            = skin;

            // init nnb
            nnb = new List <IKMember>();
        }
コード例 #2
0
        public List <PhysicsObject> GetPNeighbours(ParasiteBodyPart bodyPart)
        {
            if (!setup)
            {
                throw new Exception("SetDimensions must be called first!");
            }

            int x = (int)Math.Floor(bodyPart.Position.X / gridSize);
            int y = (int)Math.Floor(bodyPart.Position.Y / gridSize);

            List <PhysicsObject> returnList = new List <PhysicsObject>();

            int xStart = x - 1;
            int xEnd   = x + 1;
            int yStart = y - 1;
            int yEnd   = y + 1;

            if (xStart <= 0)
            {
                xStart = 0;
            }

            if (xEnd >= width)
            {
                xEnd = width;
            }

            if (yStart <= 0)
            {
                yStart = 0;
            }

            if (yEnd >= height)
            {
                yEnd = height;
            }

            for (int i = xStart; i <= xEnd; i++)
            {
                for (int j = yStart; j <= yEnd; j++)
                {
                    returnList.AddRange(grid[i][j].Values);
                }
            }

            returnList.Remove(bodyPart);

            return(returnList);
        }
コード例 #3
0
        public void CreateParasite(int numParts)
        {
            // Create the Tail
            tail                 = new ParasiteTail(Game, PhysicsOverlord.GetInstance().GetID(), theSprite, 1.0f);
            tail.Position        = new Vector2(50 * numParts, 100);
            tail.relativeGravity = gravity;

            // Create Body Parts
            for (int i = 0; i < numParts; i++)
            {
                ParasiteBodyPart bodyPart = new ParasiteBodyPart(Game, PhysicsOverlord.GetInstance().GetID(), theSprite, 1f);
                bodyPart.Position = new Vector2(50 * i, 100);
                bodyparts.Add(bodyPart);
                bodyPart.relativeGravity = gravity;
            }

            // Create the Head
            head                 = new ParasiteHead(Game, PhysicsOverlord.GetInstance().GetID(), theSprite, 1);
            head.Position        = new Vector2(100, 100);
            head.relativeGravity = gravity;

            // IKPoints

            theParasite.Add(head);

            IKMember headIK = new IKMember(head, 10);
            IKMember lastIK = headIK;

            head.AddIKPoint(headIK);

            for (int i = 0; i < bodyparts.Count; i++)
            {
                ParasiteBodyPart bodyPart = bodyparts[i];

                theParasite.Add(bodyPart);

                IKMember ik = new IKMember(bodyPart, 10);

                if (i != 0)
                {
                    ik.addNeighbour(lastIK);
                }

                lastIK.addNeighbour(ik);

                bodyPart.AddIKPoint(ik);

                lastIK = ik;
            }

            // Uncomment for Rad Wiggle Motion!
            // currentIK = new IKMember(tail, 1);

            //currentIK = new IKMember(tail, 10);
            theParasite.Add(tail);

            IKMember tailIK = new IKMember(tail, 10);

            tailIK.addNeighbour(lastIK);
            lastIK.addNeighbour(tailIK);

            tail.AddIKPoint(tailIK);

            tail.initTail();
        }