public override void Load() { //texture = GameManager.Instance.Content.Load<Texture2D>("Mario"); //animation = new Animation("Mario", 2, 50f); animations = new AnimationSet(); animations.AddAnimation("Left", "Player/Player_Still_Left", 2, 250, true); animations.AddAnimation("Right", "Player/Player_Still_Right", 2, 250, true); animations.AddAnimation("Jump_Left", "Player/Mario_Jump_Left", 1, 100, false); animations.AddAnimation("Jump_Right", "Player/Mario_Jump_Right", 1, 100, false); animations.AddAnimation("Death", "Player/Player_Death", 1, 100, false); animations.AddAnimation("Turn_Left", "Player/Player_Turn_Left", 1, 100, false); animations.AddAnimation("Turn_Right", "Player/Player_Turn_Right", 1, 100, false); animations.AddAnimation("Walk_Left", "Player/Player_Walk_Left", 4, 175, true); animations.AddAnimation("Walk_Right", "Player/Player_Walk_Right", 4, 175, true); animations.AddAnimation("Run_Left", "Player/Player_Run_Left", 4, 50, true); animations.AddAnimation("Run_Right", "Player/Player_Run_Right", 4, 50, true); animations.AddAnimation("RunJump_Left", "Player/Mario_RunJump_Left", 1, 100, false); animations.AddAnimation("RunJump_Right", "Player/Mario_RunJump_Right", 1, 100, false); currentAnimation = animations.GetAnimation("Left"); action = ""; debugtexture = GameManager.Instance.CreateColorTexture(20, 255, 20, 1); this.Width = 32; this.Height = 36; }
public void SetWalkAnimation() { bool animChanged = false; if (lastAnimX != last.x) { animChanged = true; } if (lastAnimY != last.y) { animChanged = true; } lastAnimX = last.x; lastAnimY = last.y; lastAnimMoving = isMoving; if (animChanged) { animTime = 0; } else { animTime += Time.deltaTime * ((moveSpeedCurrent > moveSpeed) ? 2f : 1f); } if (animHijack) { if (animTime > animationSet.GetAnimation(animationType).loopTime) { animHijack = false; } } else { if (animMoving) { animationType = "Walk"; } else { animationType = "Idle"; } } animIndex = animationSet.GetAnimationIndex(animationType, lookDirection, animTime); SetSprite(); //animator.SetFloat("Horizontal", last.x); //animator.SetFloat("Vertical", last.y); //animator.SetBool("Moving", animMoving); }
private void setAnimation(GameTime _gameTime) { String mainDirection = current.ToString(); if (isDead) { currentAnimation = animations.GetAnimation(action); } else if (moving == Direction.None && !isJumping) { currentAnimation = animations.GetAnimation(mainDirection); } else { if (moving != Direction.None) { current = moving; } currentAnimation = animations.GetAnimation($"{action}_{mainDirection}"); } currentAnimation.Update(_gameTime); }
protected virtual bool SetAnimation(string name, int direction) { if (activeAnimation != null && activeAnimation.HasName(name) && this.direction == direction) { return(true); } this.direction = direction; if (animationSet != null) { activeAnimation = animationSet.GetAnimation(name); ResetActiveAnimation(); } return(activeAnimation != null); }