private void PlayStandardAnim(AnimationClip clip, bool doLoop, bool reverse) { if (character == null) { return; } Animation animation = null; if (character.spriteChild && character.spriteChild.GetComponent <Animation>()) { animation = character.spriteChild.GetComponent <Animation>(); } if (character.GetComponent <Animation>()) { animation = character.GetComponent <Animation>(); } if (animation != null) { if (clip != null && animation[clip.name] != null) { if (!animation [clip.name].enabled) { if (doLoop) { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Loop, character.animCrossfadeSpeed, null, reverse); } else { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Once, character.animCrossfadeSpeed, null, reverse); } } } else { if (doLoop) { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Loop, character.animCrossfadeSpeed, null, reverse); } else { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Once, character.animCrossfadeSpeed, null, reverse); } } } }
public override void ActionSpeechSkip(ActionSpeech action) { if (action.Speaker && action.Speaker.talkingAnimation == TalkingAnimation.CustomFace && (action.headClip || action.mouthClip)) { AdvGame.CleanUnusedClips(action.Speaker.GetAnimation()); if (action.headClip) { AdvGame.PlayAnimClipFrame(action.Speaker.GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Head), action.headClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, action.Speaker.neckBone, 1f); } if (action.mouthClip) { AdvGame.PlayAnimClipFrame(action.Speaker.GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Mouth), action.mouthClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, action.Speaker.neckBone, 1f); } } }
/** * Initialises the Player's animation. */ public void Initialise() { if (GetAnimation()) { // Hack: Force idle of Legacy characters AdvGame.PlayAnimClip(GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Base), idleAnim, AnimationBlendMode.Blend, WrapMode.Loop, 0f, null, false); } else if (spriteChild) { // Hack: update 2D sprites InitSpriteChild(); } UpdateScale(); GetAnimEngine().TurnHead(Vector2.zero); GetAnimEngine().PlayIdle(); }
/** * Initialises the Player's animation. */ public void Initialise() { if (GetAnimation()) { // Hack: Force idle of Legacy characters AdvGame.PlayAnimClip(GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Base), idleAnim, AnimationBlendMode.Blend, WrapMode.Loop, 0f, null, false); } else if (spriteChild) { // Hack: update 2D sprites if (spriteChild.GetComponent <FollowSortingMap>()) { KickStarter.sceneSettings.UpdateAllSortingMaps(); } UpdateSpriteChild(KickStarter.settingsManager.IsTopDown(), KickStarter.settingsManager.IsUnity2D()); } GetAnimEngine().PlayIdle(); }
private void PlayStandardAnim(AnimationClip clip, bool doLoop, bool reverse) { if (character == null) { return; } Animation animation = character.GetAnimation(); if (animation != null) { AnimationState animationState = animation[NonAllocAnimationClipName(clip)]; if (clip != null && animationState != null) { if (!animationState.enabled) { if (doLoop) { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Loop, character.animCrossfadeSpeed, null, reverse); } else { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Once, character.animCrossfadeSpeed, null, reverse); } } } else { if (doLoop) { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Loop, character.animCrossfadeSpeed, null, reverse); } else { AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Once, character.animCrossfadeSpeed, null, reverse); } } } }
public override void TurnHead(Vector2 angles) { if (character == null) { return; } Animation animation = character.GetAnimation(); if (animation == null) { return; } // Horizontal if (character.headLookLeftAnim && character.headLookRightAnim) { if (angles.x < 0f) { animation.Stop(character.headLookRightAnim.name); AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck), character.headLookLeftAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f); animation [character.headLookLeftAnim.name].weight = -angles.x; animation [character.headLookLeftAnim.name].speed = 0f; } else if (angles.x > 0f) { animation.Stop(character.headLookLeftAnim.name); AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck), character.headLookRightAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f); animation [character.headLookRightAnim.name].weight = angles.x; animation [character.headLookRightAnim.name].speed = 0f; } else { animation.Stop(character.headLookLeftAnim.name); animation.Stop(character.headLookRightAnim.name); } } // Vertical if (character.headLookUpAnim && character.headLookDownAnim) { if (angles.y < 0f) { animation.Stop(character.headLookUpAnim.name); AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck) + 1, character.headLookDownAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f); animation [character.headLookDownAnim.name].weight = -angles.y; animation [character.headLookDownAnim.name].speed = 0f; } else if (angles.y > 0f) { animation.Stop(character.headLookDownAnim.name); AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck) + 1, character.headLookUpAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f); animation [character.headLookUpAnim.name].weight = angles.y; animation [character.headLookUpAnim.name].speed = 0f; } else { animation.Stop(character.headLookDownAnim.name); animation.Stop(character.headLookUpAnim.name); } } }
public override void ActionCharAnimSkip(ActionCharAnim action) { if (character == null) { return; } Animation animation = character.GetAnimation(); if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom && action.clip) { if (action.layer == AnimLayer.Base) { character.charState = CharState.Custom; action.blendMode = AnimationBlendMode.Blend; action.playMode = (AnimPlayMode)action.playModeBase; } if (action.playMode == AnimPlayMode.PlayOnce) { if (action.layer == AnimLayer.Base && action.method == ActionCharAnim.AnimMethodChar.PlayCustom) { character.charState = CharState.Idle; character.ResetBaseClips(); } } else { AdvGame.CleanUnusedClips(animation); WrapMode wrap = WrapMode.Once; Transform mixingTransform = null; if (action.layer == AnimLayer.UpperBody) { mixingTransform = character.upperBodyBone; } else if (action.layer == AnimLayer.LeftArm) { mixingTransform = character.leftArmBone; } else if (action.layer == AnimLayer.RightArm) { mixingTransform = character.rightArmBone; } else if (action.layer == AnimLayer.Neck || action.layer == AnimLayer.Head || action.layer == AnimLayer.Face || action.layer == AnimLayer.Mouth) { mixingTransform = character.neckBone; } if (action.playMode == AnimPlayMode.PlayOnceAndClamp) { wrap = WrapMode.ClampForever; } else if (action.playMode == AnimPlayMode.Loop) { wrap = WrapMode.Loop; } AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(action.layer), action.clip, action.blendMode, wrap, action.fadeTime, mixingTransform, 1f); } AdvGame.CleanUnusedClips(animation); } else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom && action.clip) { if (action.clip != character.idleAnim && action.clip != character.walkAnim) { animation.Blend(action.clip.name, 0f, 0f); } } else if (action.method == ActionCharAnim.AnimMethodChar.ResetToIdle) { character.ResetBaseClips(); character.charState = CharState.Idle; AdvGame.CleanUnusedClips(animation); } else if (action.method == ActionCharAnim.AnimMethodChar.SetStandard) { if (action.clip != null) { if (action.standard == AnimStandard.Idle) { character.idleAnim = action.clip; } else if (action.standard == AnimStandard.Walk) { character.walkAnim = action.clip; } else if (action.standard == AnimStandard.Run) { character.runAnim = action.clip; } else if (action.standard == AnimStandard.Talk) { character.talkAnim = action.clip; } } if (action.changeSpeed) { if (action.standard == AnimStandard.Walk) { character.walkSpeedScale = action.newSpeed; } else if (action.standard == AnimStandard.Run) { character.runSpeedScale = action.newSpeed; } } if (action.changeSound) { if (action.standard == AnimStandard.Walk) { if (action.newSound != null) { character.walkSound = action.newSound; } else { character.walkSound = null; } } else if (action.standard == AnimStandard.Run) { if (action.newSound != null) { character.runSound = action.newSound; } else { character.runSound = null; } } } } }
public override float ActionCharAnimRun(ActionCharAnim action) { if (action.animChar == null) { return(0f); } Animation animation = action.animChar.GetAnimation(); if (!action.isRunning) { action.isRunning = true; if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom && action.clip) { AdvGame.CleanUnusedClips(animation); WrapMode wrap = WrapMode.Once; Transform mixingTransform = null; if (action.layer == AnimLayer.Base) { action.animChar.charState = CharState.Custom; action.blendMode = AnimationBlendMode.Blend; action.playMode = (AnimPlayMode)action.playModeBase; } else if (action.layer == AnimLayer.UpperBody) { mixingTransform = action.animChar.upperBodyBone; } else if (action.layer == AnimLayer.LeftArm) { mixingTransform = action.animChar.leftArmBone; } else if (action.layer == AnimLayer.RightArm) { mixingTransform = action.animChar.rightArmBone; } else if (action.layer == AnimLayer.Neck || action.layer == AnimLayer.Head || action.layer == AnimLayer.Face || action.layer == AnimLayer.Mouth) { mixingTransform = action.animChar.neckBone; } if (action.playMode == AnimPlayMode.PlayOnceAndClamp) { wrap = WrapMode.ClampForever; } else if (action.playMode == AnimPlayMode.Loop) { wrap = WrapMode.Loop; } AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(action.layer), action.clip, action.blendMode, wrap, action.fadeTime, mixingTransform, false); } else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom && action.clip) { if (action.clip != action.animChar.idleAnim && action.clip != action.animChar.walkAnim) { animation.Blend(action.clip.name, 0f, action.fadeTime); } } else if (action.method == ActionCharAnim.AnimMethodChar.ResetToIdle) { action.animChar.ResetBaseClips(); action.animChar.charState = CharState.Idle; AdvGame.CleanUnusedClips(animation); } else if (action.method == ActionCharAnim.AnimMethodChar.SetStandard) { if (action.clip != null) { if (action.standard == AnimStandard.Idle) { action.animChar.idleAnim = action.clip; } else if (action.standard == AnimStandard.Walk) { action.animChar.walkAnim = action.clip; } else if (action.standard == AnimStandard.Run) { action.animChar.runAnim = action.clip; } else if (action.standard == AnimStandard.Talk) { action.animChar.talkAnim = action.clip; } } if (action.changeSpeed) { if (action.standard == AnimStandard.Walk) { action.animChar.walkSpeedScale = action.newSpeed; } else if (action.standard == AnimStandard.Run) { action.animChar.runSpeedScale = action.newSpeed; } } if (action.changeSound) { if (action.standard == AnimStandard.Walk) { if (action.newSound != null) { action.animChar.walkSound = action.newSound; } else { action.animChar.walkSound = null; } } else if (action.standard == AnimStandard.Run) { if (action.newSound != null) { action.animChar.runSound = action.newSound; } else { action.animChar.runSound = null; } } } } if (action.willWait && action.clip) { if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom) { return(action.defaultPauseTime); } else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom) { return(action.fadeTime); } } } else { if (action.animChar.GetAnimation()[action.clip.name] && action.animChar.GetAnimation()[action.clip.name].normalizedTime < 1f && action.animChar.GetAnimation().IsPlaying(action.clip.name)) { return(action.defaultPauseTime); } else { action.isRunning = false; if (action.playMode == AnimPlayMode.PlayOnce) { action.animChar.GetAnimation().Blend(action.clip.name, 0f, action.fadeTime); if (action.layer == AnimLayer.Base && action.method == ActionCharAnim.AnimMethodChar.PlayCustom) { action.animChar.charState = CharState.Idle; action.animChar.ResetBaseClips(); } } AdvGame.CleanUnusedClips(animation); return(0f); } } return(0f); }
public static void ResetPlayer(Player ref_player, int ID, bool resetReferences, Quaternion _rotation) { // Delete current player if (GameObject.FindWithTag(Tags.player)) { DestroyImmediate(GameObject.FindWithTag(Tags.player)); } // Load new player if (ref_player) { SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; Player newPlayer = (Player)Instantiate(ref_player, Vector3.zero, _rotation); newPlayer.ID = ID; newPlayer.name = ref_player.name; playerPrefab = newPlayer; DontDestroyOnLoad(newPlayer); if (KickStarter.runtimeInventory) { KickStarter.runtimeInventory.SetNull(); KickStarter.runtimeInventory.RemoveRecipes(); // Clear inventory if (!settingsManager.shareInventory) { KickStarter.runtimeInventory.localItems.Clear(); } if (KickStarter.saveSystem != null && KickStarter.saveSystem.DoesPlayerDataExist(ID, false)) { saveSystem.AssignPlayerData(ID, !settingsManager.shareInventory); } // Menus foreach (AC.Menu menu in PlayerMenus.GetMenus()) { foreach (MenuElement element in menu.elements) { if (element is MenuInventoryBox) { MenuInventoryBox invBox = (MenuInventoryBox)element; invBox.ResetOffset(); } } } } if (newPlayer.GetComponent <Animation>()) { // Hack: Force idle of Legacy characters AdvGame.PlayAnimClip(newPlayer.GetComponent <Animation>(), AdvGame.GetAnimLayerInt(AnimLayer.Base), newPlayer.idleAnim, AnimationBlendMode.Blend, WrapMode.Loop, 0f, null, false); } else if (newPlayer.spriteChild) { // Hack: update 2D sprites if (newPlayer.spriteChild.GetComponent <FollowSortingMap>()) { newPlayer.spriteChild.GetComponent <FollowSortingMap>().UpdateSortingMap(); } newPlayer.UpdateSpriteChild(settingsManager.IsTopDown(), settingsManager.IsUnity2D()); } newPlayer.animEngine.PlayIdle(); } // Reset player references if (resetReferences) { KickStarter.sceneSettings.ResetPlayerReference(); KickStarter.playerMovement.AssignFPCamera(); KickStarter.stateHandler.IgnoreNavMeshCollisions(); KickStarter.stateHandler.GatherObjects(false); _Camera[] cameras = FindObjectsOfType(typeof(_Camera)) as _Camera[]; foreach (_Camera camera in cameras) { camera.ResetTarget(); } } }