예제 #1
0
    public BPartGenericScript makeBodyPart(string nameOfpart, string leftOrRight)
    {
//		Debug.Log ("check: " + nameOfpart + " " + leftOrRight);
        //Debug.Log("name: "+ nameOfpart);
        //Debug.Log("leftor right: "+ leftOrRight);
        //BodyPartDataHolder partData = new BodyPartDataHolder();
        partData = bPartXMLReader.getBodyData(nameOfpart);
        BPartGenericScript instaBodypart = Instantiate(bodyPartObject, Vector3.zero, bodyPartObject.GetComponent <Transform>().rotation);

        //Debug.Log ("body data check: "+bPartXMLReader.getBodyData (nameOfpart).name);
        instaBodypart.CreateNewPart(partData, leftOrRight);
        //Debug.Log ("instantiated after: "+instaBodypart.getName());
        return(instaBodypart);
    }
예제 #2
0
    public void CreateNewPart(BodyPartDataHolder incomingBodyPartData, string leftOrRight)
    {
        //Debug.Log ("incomingbpart name:"+ incomingBodyPartData.name +" leftright " +leftOrRight);
        bPartType = incomingBodyPartData.typeOfpart;                                    //arm,head,legs,shoulder, or torso
        bPartName = incomingBodyPartData.name;

        maxHealth = incomingBodyPartData.maxHealth;

        nodesOfBP = new BodyPartNode[incomingBodyPartData.bodyPartGrid.Length][];
        if (leftOrRight == "left" || leftOrRight == "none")
        {
            leftSide = true;                            //default is left side
        }
        else
        {
            leftSide = false;
        }
        for (int i = 0; i < incomingBodyPartData.bodyPartGrid.Length; i++)              //transfering the int[][] grid
        {
            int g = incomingBodyPartData.bodyPartGrid.Length - i - 1;
            if (leftSide)
            {
                nodesOfBP [i] = new BodyPartNode[incomingBodyPartData.bodyPartGrid[0].Length];
            }
            else                                                                                //mirroring the body part for right hand pieces
            {
                nodesOfBP [g] = new BodyPartNode[incomingBodyPartData.bodyPartGrid[0].Length];
            }
            //nodesOfBP [i] = new BodyPartNode[incomingBodyPartData.bodyPartGrid[0].Length];
            for (int j = 0; j < incomingBodyPartData.bodyPartGrid[0].Length; j++)
            {
                BodyPartNode bodyPartNode = new BodyPartNode();
                if (incomingBodyPartData.bodyPartGrid [i] [j] == 1)
                {
                    bodyPartNode.turnOn();
                }
                if (leftSide)
                {
                    nodesOfBP [i] [j] = bodyPartNode;
                }
                else                                                                                    //mirroring the body part for right hand pieces
                {
                    nodesOfBP [g] [j] = bodyPartNode;
                }
            }
        }
        dimensions = new Vector2(nodesOfBP.Length, nodesOfBP[0].Length);        //dependent on the farthest location from the source (0,0) of the list of binaryDimensions

        if (incomingBodyPartData.simpleAnchorPoints)                            //checking to see if there is one anchor point or more
        {
            if (leftSide)                                                       //if left side (default design), then transfer anchor point normally
            {
                anchorPoint = incomingBodyPartData.anchor;                      //the location in which all parts will be located and placed
            }
            else if (!leftSide)                                                 //if right side, mirror the anchor point across the X axis
            {
                anchorPoint = new Vector2(((dimensions.x) - (incomingBodyPartData.anchor.x + 1)), incomingBodyPartData.anchor.y);
            }
        }
        else
        {
            if (leftSide)                                                                                       //if left side (default design), then transfer anchor point normally
            {
                listOfComplexAnchorPoints = incomingBodyPartData.listOfComplexAnchorPoints;                     //the location in which all parts will be located and placed
            }
            else
            if (!leftSide)                                                                              //if right side, mirror the anchor point across the X axis
            {
                for (int i = 0; i < incomingBodyPartData.listOfComplexAnchorPoints.Count; i++)
                {
                    listOfComplexAnchorPoints.Add(new ComplexAnchorPoints(
                                                      incomingBodyPartData.listOfComplexAnchorPoints[i].nameOfPoint,
                                                      new Vector2((dimensions.x - 1) - (incomingBodyPartData.listOfComplexAnchorPoints[i].anchorPoint.x), incomingBodyPartData.listOfComplexAnchorPoints[i].anchorPoint.y),
                                                      incomingBodyPartData.listOfComplexAnchorPoints[i].male));
                    //the dimension.x+1 is to account for the origin of the points being at 1,1 rather than 0,0.
                }
            }
        }

        currentHealth = incomingBodyPartData.maxHealth;
        resetHealthToFull();
        active           = true;
        fullyDeactivated = false;
        //Debug.Log("complex list for "+bPartName+ " : "+ listOfComplexAnchorPoints.Count);
    }