// estos mensajes estan para simplificar las cosas. public void SwapState(PlayerMovementState pms) { movementScript.SwapState(pms); }
public void DoorOpening() { moveState = new PlayerMovingThroughDoorState(gameObject); gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(0, gameObject.GetComponent <Rigidbody2D>().velocity.y); }
/// <summary> /// Initializes a new instance of the <see cref="ChangingMoveStateEventArgs"/> class. /// </summary> /// <param name="player"><inheritdoc cref="Player"/></param> /// <param name="oldState"><inheritdoc cref="OldState"/></param> /// <param name="newState"><inheritdoc cref="NewState"/></param> /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param> public ChangingMoveStateEventArgs(Player player, PlayerMovementState oldState, PlayerMovementState newState, bool isAllowed = true) { Player = player; OldState = oldState; NewState = newState; IsAllowed = isAllowed; }
public MovementProcessor(Transform playerTransform, CharacterController characterController) { this.playerTransform = playerTransform; this.characterController = characterController; this.currentState = PlayerMovementState.Grounded; }
public virtual void InitializeMoveStates() { freeMoveState = new FreeMoveState(this); currentMovementState = freeMoveState; attackState = new AttackState(this); }
private void StartMove(Vector2 targetPosition, float movementTime, PlayerMovementState movementState) { StartTwoPointMove(targetPosition, movementTime); this.MovementState = movementState; }
public Player(Texture2D playerTexture, Texture2D mouseTexture, Vector2 playerPos, ContentManager content) { _mouse = new Mouse(mouseTexture); _playerTexture = playerTexture; _playerPos = playerPos; _lives = 3; this.score = 0; _health = 100; _playerRot = 0; bulletList = new List<Bullet>(); _playerRec = new Rectangle(); //Load Textures shot = content.Load<SoundEffect>("Sounds\\shot"); _bulletTexture = content.Load<Texture2D>("bullet2"); _healthIn = content.Load<Texture2D>("healthbarInside"); _healthOut = content.Load<Texture2D>("healthbarOutside"); Texture2D idle = content.Load<Texture2D>("manIdle"); die = content.Load<Texture2D>("manDie"); _playerRec = new Rectangle((int)_playerPos.X, (int)_playerPos.Y, playerTexture.Width / 2, playerTexture.Height / 2); rRec = new RotatedRectangle(_playerRec, 0.0f); velocity = Vector2.Zero; dieSprite = new AnimatedSprite(die, AnimatedSprite.AnimType.FLASH, 1, 2, 0.5f, new Vector2(200, 200), 2.5f); moveSprite = new AnimatedSprite(_playerTexture, AnimatedSprite.AnimType.LOOP, 1, 2, 0.5f, new Vector2(200, 200), 2.5f); idleSprite = new AnimatedSprite(idle, AnimatedSprite.AnimType.LOOP, 1, 1, 0.5f, new Vector2(200, 200), 2.5f); pSprite = idleSprite; pmState = PlayerMovementState.IDLE; isAlive = true; level = 1; }
public void setPlayerClimbing() { playerMovementState = PlayerMovementState.CLIMBING; }
public Player(Texture2D playerTexture, Mouse mouse, Vector2 playerPos, AnimatedSprite animatedSprite, ContentManager content) { _mouse = mouse; _playerTexture = playerTexture; _playerPos = playerPos; _playerRot = 0; bulletList = new List<Bullet>(); pSprite = animatedSprite; _playerRec = new Rectangle(); //Load Textures shot = content.Load<SoundEffect>("Sounds\\shot"); _bulletTexture = content.Load<Texture2D>("bullet2"); _playerRec = new Rectangle((int)_playerPos.X, (int)_playerPos.Y, playerTexture.Width / 2, playerTexture.Height / 2); rRec = new RotatedRectangle(_playerRec, 0.0f); velocity = Vector2.Zero; pState = PlayerState.ALIVE; pmState = PlayerMovementState.IDLE; }
public void Update(GameTime gameTime, List<TileObject> t, Camera cam) { //Calculate Sprite Rotation _playerPrevPos = _playerPos; Vector2 direction = _playerPos - _mouse.position; direction.Normalize(); _playerRot = (float)Math.Atan2(direction.Y, direction.X) + (float)(Math.PI * 0.5f); previous = current; current = Keyboard.GetState(); if (isAlive) { if (current.IsKeyDown(Keys.W) && !collision(new Vector2(0, -3), t) && !cam.isMovingUp) { if (_playerPos.Y >= 0 + _playerRec.Height / 2) _playerPos.Y -= 3; } if (current.IsKeyDown(Keys.S) && !collision(new Vector2(0, 3), t) && !cam.isMovingDown) { if (_playerPos.Y <= 600 - _playerRec.Height / 2) _playerPos.Y += 3; } if (current.IsKeyDown(Keys.A) && !collision(new Vector2(-3, 0), t) && !cam.isMovingLeft) { if (_playerPos.X >= 0 + _playerRec.Width / 2) _playerPos.X -= 3; } if (current.IsKeyDown(Keys.D) && !collision(new Vector2(3, 0), t) && !cam.isMovingRight) { if (_playerPos.X <= 800 - _playerRec.Width / 2) _playerPos.X += 3; } } if (_mouse.newLeftClick) { if (bulletList.Count < MAX_SHOTS) { bulletList.Add(new Bullet(_bulletTexture, _mouse.position, this._playerPos)); shot.Play(); } } if (bulletList != null ) { foreach (Bullet b in bulletList) { b.Update(); } removeBullets(bulletList); } if (_health <= 0) { isAlive = false; pSprite = dieSprite; } if (_playerPos == _playerPrevPos && !cam.isMovingUp && !cam.isMovingDown && !cam.isMovingLeft && !cam.isMovingRight && isAlive) pmState = PlayerMovementState.IDLE; else if (_playerPos != _playerPrevPos && isAlive) pmState = PlayerMovementState.WALKING; if (pmState == PlayerMovementState.IDLE && isAlive) { pSprite = idleSprite; } if (pmState == PlayerMovementState.WALKING && isAlive) { pSprite = moveSprite; } if (!isAlive & pSprite.isFinished) { dieSprite = new AnimatedSprite(die, AnimatedSprite.AnimType.FLASH, 1, 2, 0.5f, new Vector2(200, 200), 2.5f); _playerPos = new Vector2(150, 150); _lives--; isAlive = true; _health = 100; pState = PlayerState.ALIVE; pmState = PlayerMovementState.IDLE; } _playerRec.X = (int)_playerPos.X; _playerRec.Y = (int)_playerPos.Y; pSprite.Update(gameTime); _mouse.Update(); }
private void Start() { playerState = PlayerMovementState.Running; playerPositionJumping = transform.position; }
public void setPlayerDashing() { playerMovementState = PlayerMovementState.DASHING; }
public void setPlayerPhasing() { playerMovementState = PlayerMovementState.PHASING; }
void MoveStop() { switch(curMovementState) { case PlayerMovementState.Idel: break; case PlayerMovementState.Run: curMovementState = PlayerMovementState.RunOver; break; case PlayerMovementState.Walk: curMovementState = PlayerMovementState.WalkOver; break; case PlayerMovementState.Attack1: curMovementState = PlayerMovementState.Attack1Over; break; case PlayerMovementState.Attack2: curMovementState = PlayerMovementState.Attack2Over; break; case PlayerMovementState.Attack3: curMovementState = PlayerMovementState.Attack3Over; break; case PlayerMovementState.BeHit: curMovementState = PlayerMovementState.BeHitOver; break; case PlayerMovementState.Jump: curMovementState = PlayerMovementState.JumpOver; break; case PlayerMovementState.Rush: curMovementState = PlayerMovementState.RushOver; break; case PlayerMovementState.Catch: curMovementState = PlayerMovementState.CatchOver; break; default: break; } }
public void Update(GameTime gameTime, List <TileObject> t, Camera cam) { //Calculate Sprite Rotation _playerPrevPos = _playerPos; Vector2 direction = _playerPos - _mouse.position; direction.Normalize(); _playerRot = (float)Math.Atan2(direction.Y, direction.X) + (float)(Math.PI * 0.5f); previous = current; current = Keyboard.GetState(); if (isAlive) { if (current.IsKeyDown(Keys.W) && !collision(new Vector2(0, -3), t) && !cam.isMovingUp) { if (_playerPos.Y >= 0 + _playerRec.Height / 2) { _playerPos.Y -= 3; } } if (current.IsKeyDown(Keys.S) && !collision(new Vector2(0, 3), t) && !cam.isMovingDown) { if (_playerPos.Y <= 600 - _playerRec.Height / 2) { _playerPos.Y += 3; } } if (current.IsKeyDown(Keys.A) && !collision(new Vector2(-3, 0), t) && !cam.isMovingLeft) { if (_playerPos.X >= 0 + _playerRec.Width / 2) { _playerPos.X -= 3; } } if (current.IsKeyDown(Keys.D) && !collision(new Vector2(3, 0), t) && !cam.isMovingRight) { if (_playerPos.X <= 800 - _playerRec.Width / 2) { _playerPos.X += 3; } } } if (_mouse.newLeftClick) { if (bulletList.Count < MAX_SHOTS) { bulletList.Add(new Bullet(_bulletTexture, _mouse.position, this._playerPos)); shot.Play(); } } if (bulletList != null) { foreach (Bullet b in bulletList) { b.Update(); } removeBullets(bulletList); } if (_health <= 0) { isAlive = false; pSprite = dieSprite; } if (_playerPos == _playerPrevPos && !cam.isMovingUp && !cam.isMovingDown && !cam.isMovingLeft && !cam.isMovingRight && isAlive) { pmState = PlayerMovementState.IDLE; } else if (_playerPos != _playerPrevPos && isAlive) { pmState = PlayerMovementState.WALKING; } if (pmState == PlayerMovementState.IDLE && isAlive) { pSprite = idleSprite; } if (pmState == PlayerMovementState.WALKING && isAlive) { pSprite = moveSprite; } if (!isAlive & pSprite.isFinished) { dieSprite = new AnimatedSprite(die, AnimatedSprite.AnimType.FLASH, 1, 2, 0.5f, new Vector2(200, 200), 2.5f); _playerPos = new Vector2(150, 150); _lives--; isAlive = true; _health = 100; pState = PlayerState.ALIVE; pmState = PlayerMovementState.IDLE; } _playerRec.X = (int)_playerPos.X; _playerRec.Y = (int)_playerPos.Y; pSprite.Update(gameTime); _mouse.Update(); }
public void SetMovementState(PlayerMovementState mState) { curMovementState = mState; UpdateMovementState(); }
} //I intended to name in that public void setPlayerWalking() { playerMovementState = PlayerMovementState.WALKING; }