示例#1
0
    private void PickBoneTypes(GameObject pickupObj, Bone pickedUpBone, out JointType existingJointType, out JointType pickupJointType)
    {
        // Let's think about the rules:
        // - if the bonetype of the picked up bone is not a missing piece, we pick
        //   a random bonetype from the char and get a non-matching joint
        // - if the bone type is missing for the character:
        //   - if it is a lower part and the player has no matching upper part
        //     generate non-matching joint
        //   - if it is a lower part and the player has a matching upper part
        //     generate a random joint type that might match
        //   - if it is an upper part, always match joints

        var pickup  = pickedUpBone.BoneType;
        var hasBone = bonyCharacter.HasBone(pickup);

        var forceMatchingJoints = (pickup == BoneType.LeftUpperArm && !hasBone) || (pickup == BoneType.RightUpperArm && !hasBone);

        var forceMismatchingJoints = hasBone || (pickup == BoneType.LeftLowerArm && !bonyCharacter.HasBone(BoneType.LeftUpperArm)) ||
                                     (pickup == BoneType.RightLowerArm && !bonyCharacter.HasBone(BoneType.RightUpperArm));

        existingJointType = (JointType)UnityEngine.Random.Range(0, 3);
        if (forceMatchingJoints)
        {
            pickupJointType = existingJointType;
        }
        else if (forceMismatchingJoints)
        {
            pickupJointType = GetRandomJointTypeExcept(existingJointType);
        }
        else
        {
            pickupJointType = (JointType)UnityEngine.Random.Range(0, 3);
        }
    }
示例#2
0
    void Update()
    {
        var cc = rightLowerImage.color;

        rightLowerImage.color = new Color(cc.r, cc.g, cc.b, GetAlpha(BoneType.RightLowerArm));
        rightUpperImage.color = new Color(cc.r, cc.g, cc.b, GetAlpha(BoneType.RightUpperArm));
        leftLowerImage.color  = new Color(cc.r, cc.g, cc.b, GetAlpha(BoneType.LeftLowerArm));
        leftLowerImage.color  = new Color(cc.r, cc.g, cc.b, GetAlpha(BoneType.LeftLowerArm));

        if (currentPickupBone != null)
        {
            var hasBone = player.HasBone(currentPickupBone.Value);
            var alpha   = hasBone ? 1 : missingPickupAlpha;
            currentPickupBoneImage.color = new Color(cc.r, cc.g, cc.b, alpha);
        }
    }