public Attacking(State old) { oldState = old; animState = AnimState.Attacking; attacked = null; }
private void Animate(GameTime gameTime) { frameTime += gameTime.ElapsedGameTime.Milliseconds; if (frameTime >= texture.mpf) { if (animCurrent != animEnd) { if (animCurrent.X < texture.cols - 1) { animCurrent.X++; } else { animCurrent.X = 0; if (animCurrent.Y < texture.rows) { animCurrent.Y++; } else throw new NotSupportedException("Animation overflow"); } } else if (animCurrent == animEnd) { state = state.HandleInput(this, States.StateInput.AnimEnd); animStart = animStarts[(int)state.animState]; animEnd = animEnds[(int)state.animState]; animCurrent = animStart; } frameTime = 0; } }
public Player(Level _level, Vector2 _position) { name = "Player"; pressedKeys = Managers.User.kState.GetPressedKeys(); level = _level; heartAsset = Managers.AssetManager.GetTextureAsset("Heart"); position = _position; startHearts = 3; velocity = new Vector2(); texture = Managers.AssetManager.GetTextureAsset(name); animStarts = Managers.AssetManager.GetAnimIndexes(name)[0]; animEnds = Managers.AssetManager.GetAnimIndexes(name)[1]; state = new States.Idle(); equip = new States.Equip(); moveAcceleration = 0.25f; maxFallSpeed = 15f; ignoreTile = Rectangle.Empty; gravityAcceleration = 0.15f; maxSpeed = 2.5f; jumpAcceleration = 3.4f; flip = SpriteEffects.None; NewAnimation(state.animState); effectState = null; immune = false; collCheck = false; midPoint = new Point(Hitbox.X + (Hitbox.Width / 2), Hitbox.Y + (Hitbox.Height / 2)); circCollPoints = new List<Vector2>(); circCollPoints.Add (new Vector2(Hitbox.X, Hitbox.Y)); circCollPoints.Add (new Vector2(Hitbox.X + Hitbox.Width, Hitbox.Y)); circCollPoints.Add (new Vector2(Hitbox.X, Hitbox.Y + Hitbox.Height)); circCollPoints.Add (new Vector2(Hitbox.X + Hitbox.Width, Hitbox.Y + Hitbox.Height)); circCollPoints.Add (new Vector2(Hitbox.X, Hitbox.Y + (Hitbox.Height / 2))); circCollPoints.Add (new Vector2(Hitbox.X + Hitbox.Width, Hitbox.Y + (Hitbox.Height / 2))); equip.EquipItem(this, new Items.TorchItem(position, "Torch", new Light(Color.White, 0.2f, LightType.Point, new Point((int)position.X, (int)position.Y)))); }
public void SendStateInput(States.StateInput input) { States.State newState = state.HandleInput(this, input); if (state.GetType() != newState.GetType()) { state = newState; NewAnimation(state.animState); } }