public void playAnimation(AnimationEnum inputEnum, object inputData) { float velocity; bool boolean; if (inputEnum == AnimationEnum.VelocityX || inputEnum == AnimationEnum.VelocityY) { velocity = (float)inputData; anim.SetFloat(inputEnum.ToString(), velocity); //Debug.Log("OMedia-->updateAnimation " + inputEnum.ToString() + velocity); } else if (inputEnum == AnimationEnum.Grounded) { boolean = (bool)inputData; anim.SetBool(inputEnum.ToString(), boolean); //Debug.Log("OMedia-->updateAnimation " + inputEnum.ToString() + boolean); } else if (inputEnum == AnimationEnum.FacingRight) { turnAround(); //Debug.Log("OMedia-->updateMove " + AnimationEnum.FacingRight); } else if (inputEnum == AnimationEnum.Bumped) { boolean = (bool)inputData; anim.SetBool(inputEnum.ToString(), boolean); } }
void SetAnimation(AnimationEnum a) { if (a == animation) { return; } animation = a; var armatureComponent = GetComponent <DragonBones.UnityArmatureComponent> (); if (null == armatureComponent) { return; } string animationName = AnimationEnumToName(animation); if (string.IsNullOrEmpty(animationName)) { armatureComponent.animation.Stop(); } else { armatureComponent.animation.Play(animationName); } }
private MeemkiAnimation TransformStringsToAnimations(AnimationEnum animationKind, IStringAnimation posesRepresentedWithStrings) { List <MeemkiPose> meemkiPoses = new List <MeemkiPose>(); foreach (StringFrame stringFramePose in posesRepresentedWithStrings.StringFramePoses) { meemkiPoses.Add(TransformStringToPose(animationKind, stringFramePose)); } return(new MeemkiAnimation(animationKind, posesRepresentedWithStrings.IsLockingAnimation, meemkiPoses)); }
public MeemkiAnimation(AnimationEnum animationKind, bool isLockingAnimation, List <MeemkiPose> poses) { AnimationKind = animationKind; IsLockingAnimation = isLockingAnimation; if (poses == null) { throw new ArgumentNullException(); } AnimationPoses = poses; }
private void SetAnimation(AnimationEnum ani) { //if (ani == AnimationEnum.None) return; //if(currentAnimationEnum==AnimationEnum.Jump&&m_animator.GetCurrentAnimatorStateInfo(0).IsName("Jump_Down")) //{ //} //else if (currentAnimationEnum==ani) return; //currentAnimationEnum = ani; //m_animator.CrossFade(ani.ToString(), 0.2f); }
public MeemkiPose(AnimationEnum belongsToAnimation, int frame, List <PositionedChar> pose, int xOffsetToPrevious, int yOffsetToPrevious, int showInMilliseconds) { BelongsToAnimation = belongsToAnimation; Frame = frame; if (pose == null) { throw new ArgumentNullException(); } Pose = pose; XOffsetToPrevious = xOffsetToPrevious; YOffsetToPrevious = yOffsetToPrevious; ShowInMilliseconds = showInMilliseconds; }
string AnimationEnumToName(AnimationEnum a) { switch (a) { case AnimationEnum.None: return(string.Empty); case AnimationEnum.Idle: return("idle"); case AnimationEnum.Walk: return("walk"); case AnimationEnum.Drill: return("drill"); } return(string.Empty); }
public void UpdateAnimStates(StateAndParameters animationToUse) { var profile = animationProfile.AllAnimations; for (int i = 0; i < profile.Count; i++) { if (profile[i].parameter == animationToUse) { currentAnimation = profile[i].enumOfAnimation; if (!isLocked) { isLocked = profile[i].LockAnimation; } changeAnimatorComponent.TryChangeState(profile[i].parameter); return; } } }
private MeemkiPose TransformStringToPose(AnimationEnum animationKind, StringFrame stringFramePose) { List <PositionedChar> positionedChars = new List <PositionedChar>(); int x = 0; int y = 0; foreach (char c in stringFramePose.Pose) { if (c == '\x0') { y++; x = 0; continue; } positionedChars.Add(new PositionedChar(new System.Windows.Point(x, y), c)); x++; } return(new MeemkiPose(animationKind, stringFramePose.Frame, positionedChars, stringFramePose.XOffsetToPrevious, stringFramePose.YOffsetToPrevious, stringFramePose.ShowInMilliseconds)); }
public static WCAnimation GetAnimation(AnimationEnum animationID) { if (animations.ContainsKey(animationID)) { return(animations[animationID]); } else { //Load data for animation WCAnimationData data = wcAnimationData[animationID]; Texture2D[] wcAnimation = Resources.LoadAll <Texture2D>(data.path); Texture2D firstFrame = null; if (!string.IsNullOrEmpty(data.optionalFirstFramePath)) { firstFrame = Resources.Load <Texture2D>(data.optionalFirstFramePath); } //Create animation WCAnimation animation = new WCAnimation(wcAnimation, data.additiveComporession, data.basedOnFirstFrame, firstFrame); animations.Add(animationID, animation); return(animation); } }
// Update is called once per frame void Update() { nextAnimationEnum = AnimationEnum.Idle; Vector3 horizontalMove = Vector3.zero; if (Input.GetKey(KeyCode.W)) { Vector3 v = Camera.main.transform.forward; v.y = 0; v.Normalize(); horizontalMove += v; } if (Input.GetKey(KeyCode.S)) { Vector3 v = -Camera.main.transform.forward; v.y = 0; v.Normalize(); horizontalMove += v; } if (Input.GetKey(KeyCode.A)) { Vector3 v = -Camera.main.transform.right; v.y = 0; v.Normalize(); horizontalMove += v; } if (Input.GetKey(KeyCode.D)) { Vector3 v = Camera.main.transform.right; v.y = 0; v.Normalize(); horizontalMove += v; } horizontalMove.Normalize(); if (horizontalMove.magnitude > 0) { RotateToDirection(new Vector2(horizontalMove.x, horizontalMove.z)); nextAnimationEnum = AnimationEnum.Run; } CharacterController cc = GetComponent <CharacterController>(); if (cc.isGrounded) { m_moveVec = new Vector3(0, -0.1f, 0); if (Input.GetKey(KeyCode.Space)) { m_moveVec.y = 10f; nextAnimationEnum = AnimationEnum.Jump; Debug.Log("Space Pressed"); } } else { m_moveVec += Physics.gravity * Time.fixedDeltaTime; nextAnimationEnum = AnimationEnum.None; } m_moveVec = horizontalMove + new Vector3(0, m_moveVec.y, 0); cc.Move(new Vector3(m_moveVec.x * m_moveSpeed, m_moveVec.y, m_moveVec.z * m_moveSpeed) * Time.deltaTime); }
private void ShowNextPose(AnimationEnum animationType) { Console.ForegroundColor = MeemkiColor; MeemkiAnimation animationToPlay = animationList.Where(a => a.AnimationKind == animationType).First(); //handle locking animations //LOCK if (animationToPlay.IsLockingAnimation) { Global.Variables.AnimationLock = true; Global.Variables.LockedAnimation = animationType; } if (animationType == lastAnimationPlayed) { int poseIndex = lastPlayedPoseIndex + 1 < animationToPlay.NumberOfFrames ? lastPlayedPoseIndex + 1 : 0; MeemkiPose newPose = animationToPlay.AnimationPoses[poseIndex]; //loop on the right edge if (meemkiPosition.X + newPose.XOffsetToPrevious + Global.Variables.MeemkiWidth > Console.BufferWidth) //+ Meemki's width, so the check is about whole Meemki and not just the position where the drawing starts... { meemkiPosition.X = 0; } //loop on the left edge else if (meemkiPosition.X + newPose.XOffsetToPrevious < 0) { meemkiPosition.X = Console.BufferWidth - Global.Variables.MeemkiWidth; } else { meemkiPosition.X += newPose.XOffsetToPrevious; } meemkiPosition.Y += newPose.YOffsetToPrevious; foreach (Model.PositionedChar posChar in newPose.Pose) { int xOffset = (int)posChar.Position.X + meemkiPosition.X; int yOffset = (int)posChar.Position.Y + meemkiPosition.Y; Console.SetCursorPosition(xOffset, yOffset); if (posChar.Char != ' ') { Console.Write(posChar.Char); } } System.Threading.Thread.Sleep(newPose.ShowInMilliseconds); lastPlayedPoseIndex = poseIndex; lastAnimationPlayed = animationType; lastMeemkiPosition = meemkiPosition; } else { lastPlayedPoseIndex = -1; lastAnimationPlayed = animationType; ShowNextPose(animationType); } //UNLOCK if (lastPlayedPoseIndex == animationToPlay.NumberOfFrames - 1) { Global.Variables.AnimationLock = false; } }
// Update is called once per frame void Update() { // Stop drilling after x seconds AnimationEnum nextAnimation = animation; if (animation == AnimationEnum.Drill) { const float SecondsToDrill = 3f; if (Time.time - m_DrillStartTime > SecondsToDrill) { m_DrillStartTime = 0; nextAnimation = AnimationEnum.Idle; } } float movementX = 0; float movementY = 0; bool jump = false; bool drill = false; // Use last device which provided input. if (InControl.InputManager.Devices.Count == 0) { return; } if (PlayerIndex < InControl.InputManager.Devices.Count) { InControl.InputDevice device = InControl.InputManager.Devices[PlayerIndex]; movementX = device.LeftStickX; if (device.DPadLeft) { movementX = -1; } else if (device.DPadRight) { movementX = 1; } movementY = device.LeftStickY; if (device.DPadUp) { movementY = 1; } else if (device.DPadDown) { movementY = -1; } jump = device.Action1.WasPressed; drill = device.Action3.WasPressed; } else { InControl.InputDevice device = InControl.InputManager.Devices[0]; movementX = device.RightStickX; movementY = device.RightStickY; jump = device.Action2.WasPressed; drill = device.Action4.WasPressed; } // Move if able if (nextAnimation != AnimationEnum.Drill) { rb.velocity = new Vector2(3.0f * movementX, rb.velocity.y); if (rb.velocity.x == 0) { nextAnimation = AnimationEnum.Idle; } else { nextAnimation = AnimationEnum.Walk; } } // Look the correct way if (rb.velocity.x < 0) { transform.localScale = new Vector3(MirrorHack * -1 * Mathf.Abs(transform.localScale.x), transform.localScale.y, transform.localScale.z); } else if (rb.velocity.x > 0) { transform.localScale = new Vector3(MirrorHack * Mathf.Abs(transform.localScale.x), transform.localScale.y, transform.localScale.z); } // Apply the animation SetAnimation(nextAnimation); // Walking sound if (collider.Raycast(Vector2.down, new RaycastHit2D[] { new RaycastHit2D() }, collider.bounds.extents.y + 0.125f) > 0 && movementX != 0.0f && !audio.isPlaying) { audio.PlayOneShot(walkSound); } //if( inputDevice.GetControl(InControl.InputControlType)) // Rotate target object with left stick. //transform.Rotate(Vector3.down, 500.0f * Time.deltaTime * inputDevice.LeftStickX, Space.World); //transform.Rotate(Vector3.right, 500.0f * Time.deltaTime * inputDevice.LeftStickY, Space.World); // Check direct inputs CheckButton(ActionEnum.Jump, jump); CheckButton(ActionEnum.Drill, drill); // Check for received transmissions if (null == transmissionManager.TransmissionControllers) { return; } foreach (var transmission in transmissionManager.TransmissionControllers) { if (transmission.TransmittedAction.SourcePlayer == gameObject || transmission.TransmittedAction.Seen) { continue; } float distanceToSource = Vector3.Distance(transform.position, transmission.transform.position); float transmissionDistance = transmission.TransmissionDistance(); if (transmissionDistance > distanceToSource) { //Debug.LogFormat ("See transmission: {0} > {1}", transmissionDistance, distanceToSource); audio.PlayOneShot(recvSound, .75f); ActivateButton(transmission.TransmittedAction.Button); transmission.TransmittedAction.Seen = true; } } }
/* * thisObj : the obj that's doing the animation * targetObj: "Target" for the obj * animEnum: Animation for the target to play */ public virtual IEnumerator Play(RSRMonoBehaviour thisObj, RSRMonoBehaviour targetObj, AnimationEnum animEnum) { throw new System.NotImplementedException("Play(GameObject,AnimationEnum) not implemented for this object"); }
protected IEnumerator InvokePlayAnimation(RSRMonoBehaviour targetObj, AnimationEnum animEnum, float time) { yield return(new WaitForSeconds(time)); PlayTarget(targetObj, animEnum); }
public void Animate(AnimationEnum animationType) { CleanLastPose(); ShowNextPose(animationType); }
public static bool animatorStateEquals(Animator animator, AnimationEnum state) { return animator.GetCurrentAnimatorStateInfo (0).nameHash == Animator.StringToHash (state.name); }
public override void Update(GameTime gameTime) { base.Update(gameTime); Gliding = false; Sinking = false; Moving = false; if (Timer > 0) { Timer -= gameTime.ElapsedGameTime.TotalSeconds; Color = Color.Red; } else { Timer = 0; Color = Color.White; } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { animationState = AnimationEnum.Walking; LastFacing = Facing.Right; Direction.X = 1f; Effects = SpriteEffects.None; } else if (Keyboard.GetState().IsKeyDown(Keys.Left)) { animationState = AnimationEnum.Walking; LastFacing = Facing.Left; Direction.X = -1f; Effects = SpriteEffects.FlipHorizontally; } else { animationState = AnimationEnum.Standing; Direction.X = 0f; Velocity.X = 0f; } if (!Airborn && KeyMouseReader.KeyPressed(Keys.Up)) { Velocity.Y = -12; Airborn = true; } while (Airborn) { animationState = AnimationEnum.Jumping; break; } if (KeyMouseReader.KeyPressed(Keys.Space)) { ChangeFrameShooting = true; } if (Health <= 0) { NogardGame.GameOverManager.Lose(); } if (Velocity.Y >= 60) { Health = 0; } Velocity.Y += GravitySpeed; Velocity += Direction * (Speed / Math.Max(1, Math.Abs(Velocity.X))) * (float)gameTime.ElapsedGameTime.TotalSeconds; Velocity = new Vector2(MathHelper.Clamp(Velocity.X, -3, 3), MathHelper.Clamp(Velocity.Y, -20, 60)); frameTimer -= gameTime.ElapsedGameTime.TotalMilliseconds; PlayerFrames(gameTime); }