override public void Small() { powerUpState.ToSmall(); if (movementState is DeadState) { movementState = new RightIdleState(this); } }
public MarioObject(Vector2 startingPosition, ContentManager cont, AudioManager audio) { _opacity = 1.0f; warpingUpdates = 0; _objectsToNotCollide = new List <AbsObject>(); _objectsToAdd = new List <AbsObject>(); isVisible = true; deleteThis = false; _position = startingPosition; content = cont; _velocity = new Vector2(0); _acceleration = new Vector2(0, 0.05f); powerUpState = new SmallState(this); movementState = new RightIdleState(this); isGrounded = true; warped = true; Pipe = null; PipeContacted = null; origMoveState = null; origSprite = null; tookDamage = false; this.audio = audio; }
public override void Update(GameTime gameTime) { if (!warped && (movementState is WarpDownState || movementState is WarpUpState)) { if (movementState is WarpDownState) { this.Displace(0, 1); } else { this.Displace(0, -1); } warpingUpdates++; if (warpingUpdates >= (_hitbox.Value.Max.Y - _hitbox.Value.Min.Y)) { if (movementState is WarpDownState) { this.Teleport(Pipe.WarpDestination.Value.X + 9, Pipe.WarpDestination.Value.Y); warpingUpdates = 0; origSprite = _sprite; movementState = new WarpUpState(this); _sprite = origSprite; } else { if (origMoveState is RightIdleState || origMoveState is RightWalkingState) { movementState = new RightIdleState(this); } else { movementState = new LeftIdleState(this); } //_velocity = new Vector2(0); warped = true; } warpingUpdates = 0; } } else { _velocity = _velocity + _acceleration; } if (_velocity.Y > 0.5) { this.isGrounded = false; //if (!(movementState is LeftJumpingIdleState || movementState is LeftJumpingState || movementState is RightJumpingState || movementState is RightJumpingState)) // movementState = new RightJumpingState(this); } if (tookDamage) { damageCounter++; if (damageCounter >= 10) { tookDamage = false; } } if (!(movementState is DeadState)) { if (this.Position.Y > 500) { powerUpState = new SmallState(this); movementState = new DeadState(this); } } Sprite.Update(gameTime); PipeContacted = null; _objectsToNotCollide.Clear(); }