private void OnAttackPressed() { if (_data.AllowAttack) { _stateMachine.ChangeState(_stateMachine.WallAttackState); } }
public override void Update() { base.Update(); // if we've changed directions if (_input.XInputRaw == (_movement.FacingDirection * -1) && _weaponSystem.MeleeAttackState == MeleeAttackState.BeforeAttack) { // and we're still ramping up, switch directions _movement.Flip(); } // if we've completed the attack and have attack input buffer, attack again else if (_attackInputBuffer && _weaponSystem.MeleeAttackState == MeleeAttackState.AfterAttack && _weaponSystem.AttackCount < _weaponData.MaxComboCount) { if (_input.YInputRaw < 0) { _stateMachine.ChangeState(_stateMachine.BounceAttackState); return; } else if (_weaponSystem.AttackCount == _weaponData.MaxComboCount - 1) { FinisherAttack(); } else { Attack(); } } }
private void OnAttackPressed() { _ceilingDetector.Detect(); if (_ceilingDetector.IsDetected) { return; } _stateMachine.ChangeState(_stateMachine.GroundAttackState); }
private void _MoveLeft() { if (FSM.CurrentState != State.IDLE || inputController.IsPlayerMovingRight) { return; } Stop(); FSM.ChangeState(State.MOVE); }
private void OnAttackCompleted() { if (_input.XInput != 0) { _stateMachine.ChangeState(_stateMachine.MoveState); return; } else { _stateMachine.ChangeState(_stateMachine.IdleState); return; } }
public override void Update() { isPlayerMoving = inputController.IsPlayerMovingLeft != inputController.IsPlayerMovingRight; if (FSM.IsPlayerGrounded && !isPlayerMoving) { if (Mathf.Abs(currentSpeed) < 0.5f) { currentSpeed = 0f; Stop(); FSM.ChangeState(State.IDLE); } } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); // if we're not grounded, but began falling, go to fall state if (_movement.Velocity.y <= 0 && _isJumpLocked == false) { _stateMachine.ChangeState(_stateMachine.FallingState); return; } _movement.MoveX(_input.XInputRaw * _data.MoveSpeed, true); }
public override void Update() { base.Update(); if (_input.YInputRaw < 0 && _data.AllowCrouch) { _stateMachine.ChangeState(_stateMachine.CrouchState); return; } else if (_input.XInputRaw == 0) { _stateMachine.ChangeState(_stateMachine.IdleState); return; } }
public override void Update() { base.Update(); // if player is allowed to climb the wall, test the input and climb if (_data.AllowWallClimb && _input.YInputRaw > 0) { _stateMachine.ChangeState(_stateMachine.WallClimbState); return; } // if the player is allowed to grab the wall, test input and grab else if (_data.AllowWallGrab && _input.YInputRaw == 0) { _stateMachine.ChangeState(_stateMachine.WallGrabState); return; } }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag.Contains("GesturePrefab")) { if (coll.contacts[0].normal.y < -0.9f) { Rigidbody2D rigid = coll.rigidbody; if (rigid.mass > 1.5f) { if (!b_hasTriggered) { b_hasTriggered = true; iTween.ScaleTo(this.gameObject, Vector3.zero, 0.75f); SoundManager.SharedInstance.PlayClip("EnemyDestroy"); Destroy(this.gameObject, 0.8f); } } } else { EventHandler.TriggerEvent(EEventID.EVENT_GESTURE_OBJET_DESTROY, coll.gameObject); } } if (coll.gameObject.tag == "Player") { PlayerFSM player = coll.gameObject.GetComponent <PlayerFSM>(); if (player != null) { player.ChangeState(player.deadState); } } }
public override void Update() { base.Update(); // if we're allowed to climb, test climb input if (_data.AllowWallClimb && _input.YInputRaw > 0) { _stateMachine.ChangeState(_stateMachine.WallClimbState); return; } // if we're inputting down, slide if (_data.AllowWallSlide && _input.YInputRaw < 0) { _stateMachine.ChangeState(_stateMachine.WallSlideState); return; } }
public override void FixedUpdate() { base.FixedUpdate(); _aboveWallDetector.Detect(); _movement.MoveY(_data.WallClimbVelocity); if (_aboveWallDetector.IsDetected == false && _data.AllowLedgeHop) { // space above wall, if wall in front of us it's an upper ledge! if (_wallDetector.Detect() != null) { _stateMachine.ChangeState(_stateMachine.LedgeClimbState); return; } } }
private void OnAttackPressed() { if (!_data.AllowAttack) { return; } if (_groundDetector.IsDetected == false) { _stateMachine.ChangeState(_stateMachine.AirAttackState); return; } else { _stateMachine.ChangeState(_stateMachine.GroundAttackState); return; } }
public override void Update() { base.Update(); // for now land immediately, but consider adding animations and whatnot later if (_input.XInputRaw != 0) { _stateMachine.ChangeState(_stateMachine.MoveState); return; } else if (StateDuration >= _data.LandDuration && _input.XInputRaw == 0) { //TODO: play animations, wait, then transition to idle _stateMachine.ChangeState(_stateMachine.IdleState); return; } }
public override void FixedUpdate() { if (FSM.IsPlayerGrounded) { rb.AddForce(new Vector2(0.0f, JUMPFORCE), ForceMode2D.Impulse); } switch (FSM.PreviousState) { case State.IDLE: case State.MOVE: FSM.ChangeState(FSM.PreviousState); break; default: FSM.ChangeState(State.MOVE); break; } }
public override void Update() { _movement.CheckIfShouldFlip(_input.XInputRaw); if (_input.XInputRaw != 0) { _stateMachine.ChangeState(_stateMachine.MoveState); return; } else if (_input.XInputRaw == 0 && _input.YInputRaw < 0 && _data.AllowCrouch) { _stateMachine.ChangeState(_stateMachine.CrouchState); return; } base.Update(); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { PlayerFSM player = other.GetComponent <PlayerFSM>(); if (player != null) { player.ChangeState(player.deadState); } } }
public override void Update() { base.Update(); if (StateDuration >= _hopDuration) { Debug.Log("Fall state"); _stateMachine.ChangeState(_stateMachine.FallingState); return; } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); _wallDetector.Detect(); _aboveWallDetector.Detect(); // check for wall grab if (_wallDetector.IsDetected && _input.XInputRaw == _movement.FacingDirection) { Debug.Log("Wall detected!"); // determine if we can enter any of our wall states if (_data.AllowWallClimb) { _stateMachine.ChangeState(_stateMachine.WallClimbState); return; } else if (_data.AllowWallGrab) { _stateMachine.ChangeState(_stateMachine.WallGrabState); return; } else if (_data.AllowWallSlide) { _stateMachine.ChangeState(_stateMachine.WallSlideState); return; } } // check for grounded else if (_groundDetector.IsDetected && _movement.Velocity.y < 0.01f) { _stateMachine.ChangeState(_stateMachine.LandState); return; } _movement.MoveX(_input.XInputRaw * _data.MoveSpeed, true); }
public override void FixedUpdate() { base.FixedUpdate(); _ceilingDetector.Detect(); // if we're moving sideways, and not touching ceiling if (_input.YInputRaw >= 0 && _input.XInputRaw != 0 && _ceilingDetector.IsDetected == false) { _stateMachine.ChangeState(_stateMachine.MoveState); return; } // if we're not holding down or side directions, and not touching ceiling else if (_input.YInputRaw != -1 && _input.XInputRaw == 0 && _ceilingDetector.IsDetected == false) { _stateMachine.ChangeState(_stateMachine.IdleState); return; } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); _wallDetector.Detect(); // if we're not grounded, but began falling, go to fall state if (_groundDetector.IsDetected == false && _movement.Velocity.y < 0) { _stateMachine.ChangeState(_stateMachine.FallingState); return; } // otherwise we're against a wall but not holding input against else if (_wallDetector.IsDetected) { _stateMachine.ChangeState(_stateMachine.FallingState); return; } // if movement is now allowed, adjust player if (_isMoveInputAllowed) { _movement.MoveX(_input.XInputRaw * _data.MoveSpeed * _data.WallJumpMovementDampener, true); } else { _movement.MoveX(_data.MoveSpeed * _movement.FacingDirection, false); } }
public override void FixedUpdate() { base.FixedUpdate(); _ceilingDetector.Detect(); _movement.MoveX(_data.CrouchMoveVelocity * _input.XInputRaw, true); // if we're not holding down and holding either direction // AND we're not touching the ceiling if (_input.YInputRaw != -1 && _input.XInputRaw != 0 && _ceilingDetector.IsDetected == false) { _stateMachine.ChangeState(_stateMachine.MoveState); return; } // if we're not holding down or side directions, and not touching the ceiling else if (_input.YInputRaw >= 0 && _input.XInputRaw == 0 && _ceilingDetector.IsDetected == false) { _stateMachine.ChangeState(_stateMachine.IdleState); return; } }
void CheckObjectsInRange() { Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, blastRadius); foreach (var collider in colliders) { if (collider.tag == "Enemy") { EventHandler.TriggerEvent(EEventID.EVENT_DESTROY_ENEMY, collider.gameObject); } else if ((collider.tag == "GesturePrefab") && (collider.gameObject != this.gameObject)) { EventHandler.TriggerEvent(EEventID.EVENT_GESTURE_OBJET_DESTROY, collider.gameObject); } else if (collider.tag == "Player") { PlayerFSM player = collider.GetComponent <PlayerFSM>(); player.ChangeState(player.deadState); } } }
public override bool ExecuteState(FSM fsm) { if (!isInit) { FSM = fsm as PlayerFSM; currentUnit = FSM.GetOwner().CurrentSelectedUnit; enemyCurrentUnit = currentUnit.CurrentEnemy; isInit = OnStartState(); } if (OnExecuteState() || ForceQuit) { FSM.GetOwner().CurrentSelectedUnit.CurrentEnemy = null; FSM.GetOwner().CurrentSelectedUnit = null; FSM.ChangeState(PlayerFSM.PlayerStates.IDLE); return(OnEndState()); } return(false); }
private void OnAttackCompleted() { _stateMachine.ChangeState(_stateMachine.FallingState); }
private void OnAttackPressed() { _movement.MoveY(_movement.Velocity.y * _data.AirAttackVelocityYDampen); _stateMachine.ChangeState(_stateMachine.AirAttackState); }