Example #1
0
        public void AddAppeal(Type type, AppealType appealType, int value)
        {
            string key = getKey(type, appealType);

            if (dict.ContainsKey(key))
            {
                dict[key] += value;
            }
            else
            {
                dict.Add(key, value);
            }
        }
Example #2
0
        private double GetAppealUpRate(IIdol idol, IIdol center, AppealType targetAppeal)
        {
            var effect = center?.CenterEffect;

            if (effect != null && Unit != null)
            {
                if (effect is CenterEffect.AppealUp)
                {
                    var e = effect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(targetAppeal) == true)
                    {
                        return e.Rate;
                    }
                }
                else if (effect is CenterEffect.ConditionalAppealUp)
                {
                    var e = effect as CenterEffect.ConditionalAppealUp;
                    var conditionFulfilled = false;
                    switch (e.Condition)
                    {
                        case AppealUpCondition.UnitContainsAllTypes:
                            conditionFulfilled = Unit.Slots.Any(x => x.Category == IdolCategory.Cool) &&
                                Unit.Slots.Any(x => x.Category == IdolCategory.Cute) &&
                                Unit.Slots.Any(x => x.Category == IdolCategory.Passion);
                            break;
                        default:
                            break;
                    }

                    if (conditionFulfilled && e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(targetAppeal) == true)
                    {
                        return e.Rate;
                    }
                }
            }

            return 0;
        }
Example #3
0
        private static TimedList <int, Vector4[]> CollectFormationChanges([CanBeNull] ScenarioObject scenario, AppealType appealType)
        {
            var result = new TimedList <int, Vector4[]>();

            if (scenario == null)
            {
                return(result);
            }

            if (scenario.HasFormationChangeEvents())
            {
                var events = scenario.Scenario.WhereToArray(s => s.Type == ScenarioDataType.FormationChange);

                foreach (var ev in events)
                {
                    Debug.Assert(ev != null, nameof(ev) + " != null");

                    // Layer=0: applied to all appeal variants (including no appeal)
                    // Layer>0: applied to that appeal only
                    if (ev.Layer == 0 || ev.Layer == (int)appealType)
                    {
                        var formations = ev.Formation;
                        Debug.Assert(formations != null && formations.Length > 0);

                        var frameIndex = (int)Math.Round(ev.AbsoluteTime * FrameRate.Mltd);

                        var f = new Vector4[formations.Length];

                        for (var i = 0; i < formations.Length; i += 1)
                        {
                            var v = formations[i];
                            f[i] = new Vector4(v.X, v.Y, v.Z, v.W);
                        }

                        result.AddOrUpdate(frameIndex, f);
                    }
                }
            }

            return(result);
        }
Example #4
0
        private VmdBoneFrame[] CreateBoneFrames([NotNull] IBodyAnimationSource mainDance, [NotNull] PrettyAvatar avatar, [NotNull] PmxModel pmx, [NotNull] ScenarioObject baseScenario, [CanBeNull] ScenarioObject formationInfo, [CanBeNull] IBodyAnimationSource danceAppeal, int formationNumber, AppealType appealType)
        {
            var boneLookup = new BoneLookup(_conversionConfig);

            var mltdHierarchy = boneLookup.BuildBoneHierarchy(avatar);

            mltdHierarchy.AssertAllUnique();

            var pmxHierarchy = boneLookup.BuildBoneHierarchy(pmx);

            pmxHierarchy.AssertAllUnique();

            if (_conversionConfig.AppendIKBones || _conversionConfig.AppendEyeBones)
            {
                throw new NotSupportedException("Character motion frames generation (from MLTD) is not supported when appending bones (eyes and/or IK) is enabled.");
            }
            else
            {
                Debug.Assert(mltdHierarchy.Length == pmxHierarchy.Length, "Hierarchy number should be equal between MLTD and MMD.");
            }

            foreach (var mltdBone in mltdHierarchy)
            {
                mltdBone.Initialize();
            }

            foreach (var pmxBone in pmxHierarchy)
            {
                pmxBone.Initialize();
            }

            var mainAnimation     = mainDance.Convert();
            var appealAnimation   = danceAppeal?.Convert();
            var mltdBoneCount     = mltdHierarchy.Length;
            var animatedBoneCount = mainAnimation.BoneCount;
            var keyFrameCount     = mainAnimation.KeyFrames.Length;

            {
                var names1 = mainAnimation.KeyFrames.Take(animatedBoneCount)
                             .Select(kf => kf.Path).ToArray();
                var names = names1.Select(boneLookup.GetVmdBoneNameFromBonePath).ToArray();

                // Mark MLTD key bones.
                foreach (var name in names)
                {
                    MarkNamedBoneAsKeyBone(pmx, name);
                }

                // Special cases
                MarkNamedBoneAsKeyBone(pmx, "KUBI");
                MarkNamedBoneAsKeyBone(pmx, "頭");
            }

            Debug.Assert(keyFrameCount % animatedBoneCount == 0, "keyFrameCount % animatedBoneCount == 0");

            // Use this value to export visible frames only
            var resultFrameCount = (int)(mainAnimation.Duration * FrameRate.Mltd);
            // Use this value to export all frames, including invisible frames in normal MVs (e.g. seek targets)
            // var resultFrameCount = keyFrameCount / animatedBoneCount;

            var boneFrameList = new List <VmdBoneFrame>();

            // Reduce memory pressure of allocating new delegates (see mltdHierarchy.FirstOrDefault(...))
            var boneMatchPredicateCache = new Predicate <PmxBone> [mltdBoneCount];

            for (var j = 0; j < mltdBoneCount; j += 1)
            {
                var refBone = pmx.Bones[j];
                boneMatchPredicateCache[j] = bone => bone.Name == refBone.Name;
            }

            // Cache `mltdBoneName`s so we don't have to compute them all in every iteration
            var boneNameCache = new Dictionary <string, string>();

            var transform60FpsTo30Fps = _conversionConfig.Transform60FpsTo30Fps;
            var scaleToVmdSize        = _conversionConfig.ScaleToVmdSize;
            var unityToVmdScale       = _scalingConfig.ScaleUnityToVmd;

            var baseFormationList   = CollectFormationChanges(formationInfo, AppealType.None);
            var appealFormationList = CollectFormationChanges(formationInfo, appealType);
            var appealTimes         = AppealHelper.CollectAppealTimeInfo(baseScenario);
            var seekFrameControls   = CollectSeekFrames(baseScenario, formationNumber);

            var seekFrameCounter = 0;
            var lastSoughtFrame  = -1;

            // OK, now perform iterations
            for (var mltdFrameIndex = 0; mltdFrameIndex < resultFrameCount; ++mltdFrameIndex)
            {
                if (transform60FpsTo30Fps)
                {
                    if (mltdFrameIndex % 2 == 1)
                    {
                        continue;
                    }
                }

                var shouldUseAppeal = appealType != AppealType.None && (appealTimes.StartFrame <= mltdFrameIndex && mltdFrameIndex < appealTimes.EndFrame) && appealAnimation != null;

                var animation = shouldUseAppeal ? appealAnimation : mainAnimation;

                int projectedFrameIndex;

                if (shouldUseAppeal)
                {
                    var indexInAppeal = mltdFrameIndex - appealTimes.StartFrame;

                    if (indexInAppeal >= appealAnimation.FrameCount)
                    {
                        indexInAppeal = appealAnimation.FrameCount - 1;
                    }

                    // `indexInAppeal`, unlike `mltdFrameIndex`, has not been scaled yet
                    if (transform60FpsTo30Fps)
                    {
                        projectedFrameIndex = indexInAppeal / 2;
                    }
                    else
                    {
                        projectedFrameIndex = indexInAppeal;
                    }
                }
                else
                {
                    projectedFrameIndex = CalculateSeekFrameTarget(mltdFrameIndex, seekFrameControls, ref lastSoughtFrame, ref seekFrameCounter);
                }

                var formationList = shouldUseAppeal ? appealFormationList : baseFormationList;

                formationList.TryGetCurrentValue(mltdFrameIndex, out var formations);

                Vector4 idolOffset;

                if (formations == null || formations.Length < formationNumber)
                {
                    idolOffset = Vector4.Zero;
                }
                else
                {
                    idolOffset = formations[formationNumber - 1];
                }

                var keyFrameIndexStart = projectedFrameIndex * animatedBoneCount;

                for (var j = 0; j < animatedBoneCount; ++j)
                {
                    var keyFrame     = animation.KeyFrames[keyFrameIndexStart + j];
                    var mltdBoneName = GetMltdBoneNameWithoutBodyScale(boneNameCache, keyFrame);

                    // Uniqueness is asserted above
                    var targetBone = mltdHierarchy.Find(bone => bone.Name == mltdBoneName);

                    if (targetBone == null)
                    {
                        //throw new ArgumentException("Bone not found.");
                        continue; // Shika doesn't have the "POSITION" bone.
                    }

                    BoneNode transferredBone = null;

                    foreach (var kv in BoneAttachmentMap)
                    {
                        if (kv.Key != mltdBoneName)
                        {
                            continue;
                        }

                        var attachmentTarget = kv.Value;

                        // Uniqueness is asserted above
                        transferredBone = mltdHierarchy.Find(bone => bone.Name == attachmentTarget);

                        if (transferredBone == null)
                        {
                            throw new ArgumentException("Cannot find transferred bone.");
                        }

                        break;
                    }

                    if (keyFrame.HasPositions)
                    {
                        // ReSharper disable once PossibleInvalidOperationException
                        var x = keyFrame.PositionX.Value;
                        // ReSharper disable once PossibleInvalidOperationException
                        var y = keyFrame.PositionY.Value;
                        // ReSharper disable once PossibleInvalidOperationException
                        var z = keyFrame.PositionZ.Value;

                        if (string.Equals(keyFrame.Path, "MODEL_00", StringComparison.Ordinal))
                        {
                            var worldRotation = Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(idolOffset.W));
                            var newOrigin     = worldRotation * new Vector3(x, y, z);
                            var newPosition   = newOrigin + idolOffset.Xyz;

                            (x, y, z) = (newPosition.X, newPosition.Y, newPosition.Z);
                        }

                        var t = new Vector3(x, y, z);

                        t = t.FixUnityToMmd();

                        if (scaleToVmdSize)
                        {
                            t = t * unityToVmdScale;
                        }

                        targetBone.LocalPosition = t;

                        //if (transferredBone != null) {
                        //    transferredBone.LocalPosition = t;
                        //}
                    }

                    if (keyFrame.HasRotations)
                    {
                        // ReSharper disable once PossibleInvalidOperationException
                        var x = keyFrame.AngleX.Value;
                        // ReSharper disable once PossibleInvalidOperationException
                        var y = keyFrame.AngleY.Value;
                        // ReSharper disable once PossibleInvalidOperationException
                        var z = keyFrame.AngleZ.Value;

                        if (string.Equals(keyFrame.Path, "MODEL_00", StringComparison.Ordinal))
                        {
                            // The W component stores rotation
                            y += idolOffset.W;
                        }

                        var q = UnityRotation.EulerDeg(x, y, z);

                        q = q.FixUnityToOpenTK();

                        targetBone.LocalRotation = q;

                        if (transferredBone != null)
                        {
                            transferredBone.LocalRotation = q;
                        }
                    }
                }

                foreach (var mltdBone in mltdHierarchy)
                {
                    mltdBone.UpdateTransform();
                }

                for (var j = 0; j < mltdBoneCount; ++j)
                {
                    var pmxBone  = pmxHierarchy[j];
                    var mltdBone = mltdHierarchy[j];

                    {
                        var predicate = boneMatchPredicateCache[j];
                        var pb        = pmx.Bones.Find(predicate);

#if DEBUG
                        if (pb == null)
                        {
                            // Lazy evaluation of the assertion message
                            Debug.Assert(pb != null, $"PMX bone with the name \"{pmxBone.Name}\" should exist.");
                        }
#endif

                        if (!pb.IsMltdKeyBone)
                        {
                            continue;
                        }
                    }

                    var skinMatrix      = mltdBone.SkinMatrix;
                    var mPmxBindingPose = pmxBone.BindingPose;
                    var mWorld          = pmxBone.Parent?.WorldMatrix ?? Matrix4.Identity;

                    // skinMatrix == inv(mPmxBindingPose) x mLocal x mWorld
                    var mLocal = mPmxBindingPose * skinMatrix * mWorld.Inverted();

                    // Here, translation is in... world coords? WTF?
                    var t = mLocal.ExtractTranslation();
                    var q = mLocal.ExtractRotation();

                    if (pmxBone.Parent != null)
                    {
                        t = t - (pmxBone.InitialPosition - pmxBone.Parent.InitialPosition);
                    }

                    int vmdFrameIndex;

                    if (_conversionConfig.Transform60FpsTo30Fps)
                    {
                        vmdFrameIndex = mltdFrameIndex / 2;
                    }
                    else
                    {
                        vmdFrameIndex = mltdFrameIndex;
                    }

                    var mltdBoneName = GetMltdBoneNameWithoutBodyScale(boneNameCache, mltdBone.Path);
                    var vmdBoneName  = boneLookup.GetVmdBoneNameFromBoneName(mltdBone.Path);
                    var boneFrame    = new VmdBoneFrame(vmdFrameIndex, vmdBoneName);

                    var isMovable = BoneLookup.IsBoneMovable(mltdBoneName);

                    boneFrame.Position = isMovable ? t : Vector3.Zero;
                    boneFrame.Rotation = q;

                    boneFrameList.Add(boneFrame);

                    pmxBone.LocalPosition = t;
                    pmxBone.LocalRotation = q;
                    pmxBone.UpdateTransform();
                }
            }

            return(boneFrameList.ToArray());
        }
Example #5
0
        public VmdMotion CreateDanceMotion([CanBeNull] IBodyAnimationSource mainDance, [NotNull] ScenarioObject baseScenario, [CanBeNull] ScenarioObject formationInfo, [CanBeNull] PrettyAvatar avatar, [CanBeNull] PmxModel mltdPmxModel, [CanBeNull] IBodyAnimationSource danceAppeal, int formationNumber, AppealType appealType)
        {
            VmdBoneFrame[] frames;

            if (ProcessBoneFrames && (mainDance != null && avatar != null && mltdPmxModel != null))
            {
                frames = CreateBoneFrames(mainDance, avatar, mltdPmxModel, baseScenario, formationInfo, danceAppeal, formationNumber, appealType);
            }
            else
            {
                frames = Array.Empty <VmdBoneFrame>();
            }

            return(new VmdMotion(ModelName, frames, null, null, null, null));
        }
Example #6
0
        private VmdCameraFrame[] CreateCameraFrames([CanBeNull] CharacterImasMotionAsset mainCamera, [NotNull] ScenarioObject baseScenario, [CanBeNull] CharacterImasMotionAsset cameraAppeal, uint fixedFov, AppealType appealType)
        {
            // Here we reuse the logic in MVD camera frame computation
            var mvdCreator = new MvdCreator(_conversionConfig, _scalingConfig)
            {
                ProcessCameraFrames = true,
                ProcessBoneFrames   = false,
                ProcessFacialFrames = false,
                ProcessLightFrames  = false,
            };

            var mvdMotion = mvdCreator.CreateCameraMotion(mainCamera, baseScenario, cameraAppeal, appealType);
            var mvdFrames = mvdMotion.CameraMotions[0].CameraFrames;

            var cameraFrameList = new List <VmdCameraFrame>();

            foreach (var mvdFrame in mvdFrames)
            {
                var vmdFrame = new VmdCameraFrame((int)mvdFrame.FrameNumber);

                vmdFrame.Length      = mvdFrame.Distance * 0.1f;
                vmdFrame.Position    = mvdFrame.Position;
                vmdFrame.Orientation = mvdFrame.Rotation + new Vector3(MathHelper.Pi, 0, MathHelper.Pi);

                // VMD does not have good support for animated FOV. So here just use a constant to avoid "jittering".
                // The drawback is, some effects (like the first zooming cut in Shooting Stars) will not be able to achieve.
                //var fov = FocalLengthToFov(frame.FocalLength);
                //vmdFrame.FieldOfView = (uint)fov;

                vmdFrame.FieldOfView = fixedFov;

                cameraFrameList.Add(vmdFrame);
            }

            return(cameraFrameList.ToArray());
        }
Example #7
0
        private int CalculateAppeal(AppealType targetAppeal, IIdol idol, bool isSupportMember, bool encore = false)
        {
            if (idol == null)
            {
                return 0;
            }
            var rate = 1.0;

            if (!isSupportMember)
            {
                if (EnableRoomEffect)
                {
                    rate += 0.1;
                }

                rate += GetAppealUpRate(idol, Unit?.Center, targetAppeal);
                rate += GetAppealUpRate(idol, Guest, targetAppeal);
            }

            if (GrooveBurst != null)
            {
                if (encore)
                {
                    if (Song != null && Song.Type.HasFlag(idol.Category))
                    {
                        rate += 0.3;
                    }
                }
                else if (GrooveType.HasFlag(idol.Category))
                {
                    rate += 0.3;
                }

                if (GrooveBurst.Value.HasFlag(targetAppeal))
                {
                    rate += 1.5;
                }
            }
            else if (Song != null && Song.Type.HasFlag(idol.Category))
            {
                rate += 0.3;
            }

            return (int)Math.Ceiling(Math.Round((int)idol.GetType().GetProperty(targetAppeal.ToString()).GetValue(idol) * rate * (isSupportMember ? 0.5 : 1), 3));
        }
Example #8
0
 public static string ToLocalizedString(this AppealType cat)
 {
     return(m_appealTypes[cat]);
 }
Example #9
0
        private int CalculateAppeal(AppealType targetAppeal, IIdol idol, bool isSupportMember, bool encore = false)
        {
            if (idol == null)
            {
                return 0;
            }
            var rate = 1.0;

            if (!isSupportMember)
            {
                if (EnableRoomEffect)
                {
                    rate += 0.1;
                }

                if (Unit != null && Unit.Center != null &&
                    Unit.Center.CenterEffect != null && Unit.Center.CenterEffect is CenterEffect.AppealUp)
                {
                    var e = Unit.Center.CenterEffect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) && e.TargetAppeal.HasFlag(targetAppeal))
                    {
                        rate += e.Rate;
                    }
                }

                if (Guest != null && Guest.CenterEffect != null && Guest.CenterEffect is CenterEffect.AppealUp)
                {
                    var e = Guest.CenterEffect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) && e.TargetAppeal.HasFlag(targetAppeal))
                    {
                        rate += e.Rate;
                    }
                }
            }

            if (GrooveBurst != null)
            {
                if (encore)
                {
                    if (Song != null && Song.Type.HasFlag(idol.Category))
                    {
                        rate += 0.3;
                    }
                }
                else if (GrooveType.HasFlag(idol.Category))
                {
                    rate += 0.3;
                }

                if (GrooveBurst.Value.HasFlag(targetAppeal))
                {
                    rate += 1.5;
                }
            }
            else if (Song != null && Song.Type.HasFlag(idol.Category))
            {
                rate += 0.3;
            }

            switch (targetAppeal)
            {
                case AppealType.Vocal:
                    return (int)Math.Ceiling(idol.Vocal * rate * (isSupportMember ? 0.5 : 1));
                case AppealType.Dance:
                    return (int)Math.Ceiling(idol.Dance * rate * (isSupportMember ? 0.5 : 1));
                case AppealType.Visual:
                    return (int)Math.Ceiling(idol.Visual * rate * (isSupportMember ? 0.5 : 1));
                default:
                    throw new Exception();
            }
        }
Example #10
0
        private MvdCameraFrame[] CreateFrames([NotNull] CharacterImasMotionAsset mainCamera, [NotNull] ScenarioObject baseScenario, [CanBeNull] CharacterImasMotionAsset cameraAppeal, AppealType appealType)
        {
            var mainAnimation   = CameraAnimation.CreateFrom(mainCamera);
            var appealAnimation = cameraAppeal != null?CameraAnimation.CreateFrom(cameraAppeal) : null;

            var animationFrameCount = mainAnimation.CameraFrames.Length;

            var cameraFrameList = new List <MvdCameraFrame>();

            var appealTimes = appealType != AppealType.None ? AppealHelper.CollectAppealTimeInfo(baseScenario) : default;

            var transform60FpsTo30Fps = _conversionConfig.Transform60FpsTo30Fps;
            var scaleToVmdSize        = _conversionConfig.ScaleToVmdSize;
            var unityToVmdScale       = _scalingConfig.ScaleUnityToVmd;

            for (var mltdFrameIndex = 0; mltdFrameIndex < animationFrameCount; ++mltdFrameIndex)
            {
                if (transform60FpsTo30Fps)
                {
                    if (mltdFrameIndex % 2 == 1)
                    {
                        continue;
                    }
                }

                // When entering and leaving the appeal, there is also a camera control event (type 58) with `layer` > 0 (see CollectFormationChanges() for the meaning of `layer`).
                var shouldUseAppeal = appealType != AppealType.None && (appealTimes.StartFrame <= mltdFrameIndex && mltdFrameIndex < appealTimes.EndFrame) && appealAnimation != null;
                var animation       = shouldUseAppeal ? appealAnimation : mainAnimation;

                int projectedFrameIndex;

                if (shouldUseAppeal)
                {
                    var indexInAppeal = mltdFrameIndex - appealTimes.StartFrame;

                    if (indexInAppeal >= appealAnimation.FrameCount)
                    {
                        indexInAppeal = appealAnimation.FrameCount - 1;
                    }

                    // `indexInAppeal`, unlike `mltdFrameIndex`, has not been scaled yet
                    if (transform60FpsTo30Fps)
                    {
                        projectedFrameIndex = indexInAppeal / 2;
                    }
                    else
                    {
                        projectedFrameIndex = indexInAppeal;
                    }
                }
                else
                {
                    projectedFrameIndex = mltdFrameIndex;
                }

                var motionFrame = animation.CameraFrames[projectedFrameIndex];

                int mvdFrameIndex;

                if (transform60FpsTo30Fps)
                {
                    mvdFrameIndex = mltdFrameIndex / 2;
                }
                else
                {
                    mvdFrameIndex = mltdFrameIndex;
                }

                var mvdFrame = new MvdCameraFrame(mvdFrameIndex);

                var position = new Vector3(motionFrame.PositionX, motionFrame.PositionY, motionFrame.PositionZ);

                position = position.FixUnityToMmd();

                if (scaleToVmdSize)
                {
                    position = position * unityToVmdScale;
                }

                mvdFrame.Position = position;

                var target = new Vector3(motionFrame.TargetX, motionFrame.TargetY, motionFrame.TargetZ);

                target = target.FixUnityToMmd();

                if (scaleToVmdSize)
                {
                    target = target * unityToVmdScale;
                }

                var delta = target - position;

                mvdFrame.Distance = delta.Length;

                var q = CameraOrientation.QuaternionLookAt(in position, in target, in Vector3.UnitY);

                var rotation = CameraOrientation.ComputeMmdOrientation(in q, motionFrame.AngleZ);

                mvdFrame.Rotation = rotation;

                // MVD has good support of dynamic FOV. So here we can animate its value.
                var fov = FocalLengthToFov(motionFrame.FocalLength);
                mvdFrame.FieldOfView = MathHelper.DegreesToRadians(fov);

                cameraFrameList.Add(mvdFrame);
            }

            return(cameraFrameList.ToArray());
        }
Example #11
0
        private int GetAppeal(OwnedIdol idol,AppealType type)
        {
            if (idol == null)
            {
                return 0;
            }

            var effect = Center?.CenterEffect;
            var rawValue= (int)idol.GetType().GetProperty(type.ToString()).GetValue(idol);
            if (effect != null)
            {
                if (effect is CenterEffect.AppealUp)
                {
                    var e = effect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(type) == true)
                    {
                        return (int)Math.Ceiling(Math.Round(rawValue + rawValue * e.Rate, 3));
                    }
                }
                else if(effect is CenterEffect.ConditionalAppealUp)
                {
                    var e = effect as CenterEffect.ConditionalAppealUp;
                    var conditionFulfilled = false;
                    switch (e.Condition)
                    {
                        case AppealUpCondition.UnitContainsAllTypes:
                            conditionFulfilled = Slots.Any(x => x.Category == IdolCategory.Cool) && 
                                Slots.Any(x => x.Category == IdolCategory.Cute) && 
                                Slots.Any(x => x.Category == IdolCategory.Passion);
                            break;
                        default:
                            break;
                    }

                    if (conditionFulfilled && e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(type) == true)
                    {
                        return (int)Math.Ceiling(Math.Round(rawValue + rawValue * e.Rate, 3));
                    }
                }
            }

            return rawValue;
        }
Example #12
0
 private string getKey(Type type, AppealType appealType)
 {
     return(string.Format("{0}:{1}", type, appealType));
 }
Example #13
0
        private MvdCameraMotion[] CreateCameraMotions([NotNull] CharacterImasMotionAsset mainCamera, [NotNull] ScenarioObject baseScenario, [CanBeNull] CharacterImasMotionAsset cameraAppeal, AppealType appealType)
        {
            var camera               = CreateCamera();
            var cameraFrames         = CreateFrames(mainCamera, baseScenario, cameraAppeal, appealType);
            var cameraPropertyFrames = CreatePropertyFrames();

            var result = new MvdCameraMotion(camera, cameraFrames, cameraPropertyFrames);

            result.DisplayName = CameraName;
            result.EnglishName = CameraName;

            return(new[] { result });
        }
Example #14
0
        public MvdMotion CreateCameraMotion([CanBeNull] CharacterImasMotionAsset mainCamera, [NotNull] ScenarioObject baseScenario, [CanBeNull] CharacterImasMotionAsset cameraAppeal, AppealType appealType)
        {
            MvdCameraMotion[] cameraFrames;

            if (ProcessCameraFrames && mainCamera != null)
            {
                cameraFrames = CreateCameraMotions(mainCamera, baseScenario, cameraAppeal, appealType);
            }
            else
            {
                cameraFrames = Array.Empty <MvdCameraMotion>();
            }

            var mvd = new MvdMotion(cameraFrames);

            if (_conversionConfig.Transform60FpsTo30Fps)
            {
                mvd.Fps = FrameRate.Mmd;
            }
            else
            {
                mvd.Fps = FrameRate.Mltd;
            }

            return(mvd);
        }
Example #15
0
        private static Bonus getBonus(Type musicType, Burst burst, Idol[] effectIdols, bool isSupporter = false)
        {
            Bonus bonus = new Bonus();

            bonus.AddAppeal(Type.All, AppealType.Vocal, 100);
            bonus.AddAppeal(Type.All, AppealType.Dance, 100);
            bonus.AddAppeal(Type.All, AppealType.Visual, 100);

            if (!isSupporter)
            {
                bonus.AddAppeal(Type.All, AppealType.Vocal, 10);
                bonus.AddAppeal(Type.All, AppealType.Dance, 10);
                bonus.AddAppeal(Type.All, AppealType.Visual, 10);
            }

            switch (burst)
            {
            case Burst.Vocal:
                bonus.AddAppeal(Type.All, AppealType.Vocal, 150);
                break;

            case Burst.Dance:
                bonus.AddAppeal(Type.All, AppealType.Dance, 150);
                break;

            case Burst.Visual:
                bonus.AddAppeal(Type.All, AppealType.Visual, 150);
                break;
            }

            bonus.AddAppeal(musicType, AppealType.Vocal, 30);
            bonus.AddAppeal(musicType, AppealType.Dance, 30);
            bonus.AddAppeal(musicType, AppealType.Visual, 30);

            if (effectIdols != null)
            {
                foreach (Idol effectIdol in effectIdols)
                {
                    int value = 0;
                    if (effectIdol.CenterSkill == CenterSkill.All)
                    {
                        if (effectIdol.Rarity == Rarity.SSR && effectIdol.CenterSkillCondition != CenterSkillCondition.None)
                        {
                            value = 50;
                        }
                        else if (effectIdol.Rarity == Rarity.SSR && effectIdol.CenterSkillCondition == CenterSkillCondition.None)
                        {
                            value = 30;
                        }
                        else if (effectIdol.Rarity == Rarity.SR && effectIdol.CenterSkillCondition == CenterSkillCondition.None)
                        {
                            value = 20;
                        }
                        bonus.AddAppeal(effectIdol.Type, AppealType.Vocal, value);
                        bonus.AddAppeal(effectIdol.Type, AppealType.Dance, value);
                        bonus.AddAppeal(effectIdol.Type, AppealType.Visual, value);
                    }
                    else if (effectIdol.CenterSkill == CenterSkill.Vocal ||
                             effectIdol.CenterSkill == CenterSkill.Dance || effectIdol.CenterSkill == CenterSkill.Visual)
                    {
                        AppealType appealType = AppealType.Vocal;
                        if (effectIdol.CenterSkill == CenterSkill.Dance)
                        {
                            appealType = AppealType.Dance;
                        }
                        if (effectIdol.CenterSkill == CenterSkill.Visual)
                        {
                            appealType = AppealType.Visual;
                        }

                        if (effectIdol.CenterSkillType == CenterSkillType.All)
                        {
                            if (effectIdol.Rarity == Rarity.SSR && effectIdol.CenterSkillCondition == CenterSkillCondition.None)
                            {
                                value = 80;
                            }
                            else if (effectIdol.Rarity == Rarity.SSR && effectIdol.CenterSkillCondition != CenterSkillCondition.None)
                            {
                                value = 100;
                            }
                            else if (effectIdol.Rarity == Rarity.SR && effectIdol.CenterSkillCondition == CenterSkillCondition.None)
                            {
                                value = 80;
                            }
                            else if (effectIdol.Rarity == Rarity.SR && effectIdol.CenterSkillCondition != CenterSkillCondition.None)
                            {
                                value = 48;
                            }
                            bonus.AddAppeal(Type.All, appealType, value);
                        }
                        else
                        {
                            if (effectIdol.Rarity == Rarity.SSR)
                            {
                                value = 90;
                            }
                            else if (effectIdol.Rarity == Rarity.SR)
                            {
                                value = 60;
                            }
                            else if (effectIdol.Rarity == Rarity.R)
                            {
                                value = 30;
                            }
                            bonus.AddAppeal(effectIdol.Type, appealType, value);
                        }
                    }
                }
            }

            return(bonus);
        }
Example #16
-1
        private AppealType[] FillAppealArray(List <CaseSessionActComplain> actComplains, List <CaseMigration> migrations, CaseSessionAct sessionAct)
        {
            AppealType[] appeals = new AppealType[actComplains.Count];
            for (int i = 0; i < actComplains.Count; i++)
            {
                appeals[i] = FillAppeal(actComplains[i]);

                //Тъй като имаме изпращане на друг съд на ниво акт, а не на ниво жалене на акт - закачам само на първият входящ документ с който се жали
                if (i == 0)
                {
                    appeals[i].SendTo = FillSendToArray(migrations, sessionAct);
                }
            }
            return(appeals);
        }
Example #17
-1
        private AppealType FillAppeal(CaseSessionActComplain actComplain)
        {
            (var newId, var action) = AppendUpdateIntegrationKeyAction(SourceTypeSelectVM.CaseSessionActComplain, actComplain.Id, false);

            AppealType result = new AppealType();

            result.appeal_id     = newId;
            result.appeal_action = ServiceMethodToAction(action);
            result.appeal_kind   = GetNomValueInt(EpepConstants.Nomenclatures.SessionActAppealDocType, actComplain.ComplainDocument.DocumentTypeId);
            result.appeal_no     = actComplain.ComplainDocument.DocumentNumberValue ?? 0;
            result.appeal_year   = actComplain.ComplainDocument.DocumentDate.Year.ToString();
            result.appeal_date   = actComplain.ComplainDocument.DocumentDate;
            result.Side          = FillDocumentSides(actComplain.ComplainDocument.DocumentPersons.ToList());

            return(result);
        }
Example #18
-1
        public static string GetExitTriggerNameFromAppealType(AppealType appealType)
        {
            switch (appealType)
            {
            case AppealType.Special:
                return(ExitSpecialAppeal);

            case AppealType.Another:
                return(ExitAnotherAppeal);

            case AppealType.Gorgeous:
                return(ExitGorgeousAppeal);

            default:
                throw new ArgumentOutOfRangeException(nameof(appealType), appealType, null);
            }
        }
Example #19
-1
        private int CalculateAppeal(AppealType targetAppeal, IIdol idol, bool isSupportMember, bool encore = false)
        {
            if (idol == null)
            {
                return(0);
            }
            var rate = 1.0;

            if (!isSupportMember)
            {
                if (EnableRoomEffect)
                {
                    rate += 0.1;
                }

                rate += GetAppealUpRate(idol, Unit?.Center, Guest, targetAppeal);
                rate += GetAppealUpRate(idol, Guest, Guest, targetAppeal);
            }

            if (GrooveBurst != null)
            {
                if (encore)
                {
                    if (Song != null && Song.Type.HasFlag(idol.Category))
                    {
                        rate += 0.3;
                    }
                }
                else if (GrooveType.HasFlag(idol.Category))
                {
                    rate += 0.3;
                }

                if (GrooveBurst.Value.HasFlag(targetAppeal))
                {
                    rate += 1.5;
                }
            }
            else if (Song != null && Song.Type.HasFlag(idol.Category))
            {
                rate += 0.3;
            }

            return((int)Math.Ceiling(Math.Round((int)idol.GetType().GetProperty(targetAppeal.ToString()).GetValue(idol) * rate * (isSupportMember ? 0.5 : 1), 3)));
        }
Example #20
-1
        private int GetAppeal(OwnedIdol idol, AppealType type)
        {
            if (idol == null)
            {
                return(0);
            }

            var effect   = Center?.CenterEffect;
            var rawValue = (int)idol.GetType().GetProperty(type.ToString()).GetValue(idol);

            if (effect != null)
            {
                if (effect is CenterEffect.AppealUp)
                {
                    var e = effect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(type) == true)
                    {
                        return((int)Math.Ceiling(Math.Round(rawValue + rawValue * e.Rate, 3)));
                    }
                }
                else if (effect is CenterEffect.ConditionalAppealUp)
                {
                    var e = effect as CenterEffect.ConditionalAppealUp;
                    var conditionFulfilled = false;
                    switch (e.Condition)
                    {
                    case AppealUpCondition.UnitContainsAllTypes:
                        conditionFulfilled = Slots.Any(x => x.Category == IdolCategory.Cool) &&
                                             Slots.Any(x => x.Category == IdolCategory.Cute) &&
                                             Slots.Any(x => x.Category == IdolCategory.Passion);
                        break;

                    default:
                        break;
                    }

                    if (conditionFulfilled && e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(type) == true)
                    {
                        return((int)Math.Ceiling(Math.Round(rawValue + rawValue * e.Rate, 3)));
                    }
                }
            }

            return(rawValue);
        }
Example #21
-1
        public int GetAppeal(Type type, AppealType appealType)
        {
            string keyType = getKey(type, appealType);
            string keyAll  = getKey(Type.All, appealType);

            int value = 0;

            if (dict.ContainsKey(keyType))
            {
                value += dict[keyType];
            }
            if (dict.ContainsKey(keyAll))
            {
                value += dict[keyAll];
            }

            return(value);
        }
Example #22
-1
        private double GetAppealUpRate(IIdol idol, IIdol center, Idol guest, AppealType targetAppeal)
        {
            var effect = center?.CenterEffect;

            if (effect != null && Unit != null)
            {
                if (effect is CenterEffect.AppealUp)
                {
                    var e = effect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(targetAppeal) == true)
                    {
                        return(e.Rate);
                    }
                }
                else if (effect is CenterEffect.ConditionalAppealUp)
                {
                    var e = effect as CenterEffect.ConditionalAppealUp;
                    var conditionFulfilled = false;
                    switch (e.Condition)
                    {
                    case AppealUpCondition.UnitContainsAllTypes:
                        conditionFulfilled = (Unit.Slots.Any(x => x.Category == IdolCategory.Cool) || (Guest?.Category == IdolCategory.Cool)) &&
                                             (Unit.Slots.Any(x => x.Category == IdolCategory.Cute) || (Guest?.Category == IdolCategory.Cute)) &&
                                             (Unit.Slots.Any(x => x.Category == IdolCategory.Passion) || (Guest?.Category == IdolCategory.Passion));
                        break;

                    default:
                        break;
                    }

                    if (conditionFulfilled && e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(targetAppeal) == true)
                    {
                        return(e.Rate);
                    }
                }
            }

            return(0);
        }
Example #23
-1
        public VmdMotion CreateCameraMotion([CanBeNull] CharacterImasMotionAsset mainCamera, [NotNull] ScenarioObject baseScenario, [CanBeNull] CharacterImasMotionAsset cameraAppeal, AppealType appealType)
        {
            VmdCameraFrame[] frames;

            if (ProcessCameraFrames && mainCamera != null)
            {
                frames = CreateCameraFrames(mainCamera, baseScenario, cameraAppeal, FixedFov, appealType);
            }
            else
            {
                frames = null;
            }

            return(new VmdMotion(CameraName, null, null, frames, null, null));
        }