Beispiel #1
0
    public void Initialize(PartOrientation orientation)
    {
        item = true;

        creator = GetComponentInParent <CharacterCreator>();
        creator.character.playerStats += partStats;

        partAction = GetComponent <PartAction>();

        anim = GetComponentInChildren <CharacterPartAnimator>();

        GetMeshes();
        SetColors(partColor1, partColor2);

        SetOrientation(orientation);

        switch (partType)
        {
        case PartType.head:
            creator.character.headPoint.parent        = transform;
            creator.character.headPoint.localPosition = specialPoint.localPosition;
            specialPoint.parent = creator.character.headPoint;
            break;

        case PartType.arm:
            if (orientation == PartOrientation.left)
            {
                creator.character.leftArm = this;
            }
            else if (orientation == PartOrientation.right)
            {
                creator.character.rightArm = this;
            }

            Transform holdPoint = (orientation == PartOrientation.right) ? creator.character.rightHandPoint : creator.character.leftHandPoint;
            if (holdPoint)
            {
                holdPoint.parent        = specialPoint;
                holdPoint.localPosition = Vector3.zero;
            }
            break;

        case PartType.body:
            specialPoint.parent = creator.character.headPoint;
            break;

        case PartType.torso:
            transform.parent        = creator.torsoPoint;
            creator.character.torso = this;
            break;

        case PartType.leg:
            transform.parent = creator.torsoPoint;

            if (orientation == PartOrientation.left)
            {
                creator.character.leftLeg = this;
            }
            else if (orientation == PartOrientation.right)
            {
                creator.character.rightLeg = this;
            }

            // foreach (CharacterPartPoint point in creator.character.torso.constraintPoints)
            // {
            //     if (point.pointOrientation == orientation)
            //     {
            //         findPartPoint = point;
            //         break;
            //     }
            // }

            // if (findPartPoint != null)
            // {
            //     // transform.SetParent(findPartPoint.point);
            //     transform.localScale = Vector3.Scale(transform.localScale, findPartPoint.point.localScale);
            //     transform.localPosition = Vector3.right * (findPartPoint.point.localPosition.x) /* + (Vector3.up * transform.position.y) */ + (Vector3.forward * findPartPoint.point.localPosition.z);
            // }

            break;

        case PartType.backAccessory:
            creator.character.backAccessory = this;
            break;
        }
    }
 public CharacterAttribute(CharacterPartAnimator characterPart, PartVariantColour partVariantColour, PartVariantType partVariantType)
 {
     this.characterPart     = characterPart;
     this.partVariantColour = partVariantColour;
     this.partVariantType   = partVariantType;
 }