//移动控制,包括X轴移动、跳跃、下蹲;通过向移动组件“请求”实现。 private void MoveControl() { if (platform == PlatformJudge.Platfrom.PC || platform == PlatformJudge.Platfrom.WEB_PC) { tempMovement.x = Input.GetAxis("Horizontal"); movementComponent.RequestMoveByFrame(tempMovement, MovementPlayer.MovementMode.PlayerControl, Space.Self); if (Input.GetButtonDown("Jump")) { movementComponent.RequestJump(); } if (Input.GetButton("Crouch")) { movementComponent.RequestChangeControlStatus(0f, MovementPlayer.PlayerControlStatus.Crouch); } } else { tempMovement.x = joystick.Horizontal; movementComponent.RequestMoveByFrame(tempMovement, MovementPlayer.MovementMode.PlayerControl, Space.Self); if (platformJudge.IsJump()) { movementComponent.RequestJump(); platformJudge.ClearJump(); } if (joystick.Vertical < -0.5f) { movementComponent.RequestChangeControlStatus(0f, MovementPlayer.PlayerControlStatus.Crouch); } } }
public void ShortSpell() { Debug.Log("请求火球!"); if (movementComponent.RequestChangeControlStatus(ElementAbilityManager.DEFALT_CASTING_TIME * 2f, MovementPlayer.PlayerControlStatus.AbilityWithMovement)) { fireBallSpell.Cast(); Debug.Log("扔出火球!"); } }
public void ShortSpell() { switch (weapon) { case IceWeapon.Sword: if (movementComponent.RequestChangeControlStatus(IceSwordSpell.ICE_SWORD_TIME, MovementPlayer.PlayerControlStatus.AbilityWithMovement)) { iceSwordSpell.Cast(); } break; case IceWeapon.Arrow: if (movementComponent.RequestChangeControlStatus(IceArrowSpell.ICE_ARROW_TIME, MovementPlayer.PlayerControlStatus.AbilityWithMovement)) { iceArrowSpell.Cast(); } break; case IceWeapon.Shield: if (movementComponent.RequestChangeControlStatus(IceShieldSpell.ICE_SHIELD_TIME, MovementPlayer.PlayerControlStatus.AbilityWithMovement)) { iceShieldSpell.Cast(); } break; case IceWeapon.Hammer: if (movementComponent.RequestChangeControlStatus(IceHammerSpell.ICE_HAMMER_TIME, MovementPlayer.PlayerControlStatus.AbilityWithMovement)) { iceHammerSpell.Cast(); } break; } }
/// <summary> /// 被击退函数 击退方向由攻击者和被击者的位置决定,力的大小由参数parameter决定 /// </summary> /// <param name="attackerPos">攻击者</param> /// <param name="interruptTime">击退时间</param> /// <param name="parameter">力大小参数</param> public void BeatBack(Transform attackerPos, float interruptTime, float parameter) { Vector2 fighterPos = attackerPos.transform.position; Vector2 beFightedPos = transform.position; Vector2 interruptVector = (beFightedPos - fighterPos).normalized * parameter; //获取移动组件 //如果被打的是player if (gameObject.name == "Player") { MovementPlayer movement = gameObject.GetComponent <MovementPlayer>(); if (movement.RequestChangeControlStatus(interruptTime, MovementPlayer.PlayerControlStatus.Interrupt)) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementPlayer.MovementMode.Attacked); } } else { MovementEnemies movement = gameObject.GetComponent <MovementEnemies>(); if (movement.RequestChangeControlStatus(interruptTime, MovementEnemies.EnemyStatus.Stun)) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementEnemies.MovementMode.Attacked); } } }
public void ShortSpell() { if (movementComponent.RequestChangeControlStatus(ElementAbilityManager.DEFALT_CASTING_TIME, MovementPlayer.PlayerControlStatus.AbilityWithMovement)) { windShortSpell.Cast(); } }
public void RocketPackClock() { if (isOn) { velocityVector = rigid.velocity; if (movementComponent.IsFacingLeft()) { velocityVector.x -= (velocityVector.x < 0 ? speedUpRocketForce : slowdownRocketForce) * Time.deltaTime; //forceVector.x = -rocketForce; velocityVector.x = velocityVector.x < -rocketMaxSpeed ? -rocketMaxSpeed : velocityVector.x; } else { velocityVector.x += (velocityVector.x > 0 ? speedUpRocketForce : slowdownRocketForce) * Time.deltaTime; velocityVector.x = velocityVector.x > rocketMaxSpeed ? rocketMaxSpeed : velocityVector.x; } rigid.velocity = velocityVector; if (velocityVector.x > 3 && playerDetector.isRightTouchingGround() || velocityVector.x < -3 && playerDetector.isLeftTouchingGround()) { movementComponent.RequestChangeControlStatus(borkeDownStunTime, MovementPlayer.PlayerControlStatus.Interrupt); isOn = false; curTime = 0f; rigid.velocity = Vector2.zero; rocketPackObject.SetActive(false); } curTime += Time.deltaTime; if (curTime >= rocketTotalTime) { isOn = false; curTime = 0f; rigid.velocity = Vector2.zero; rocketPackObject.SetActive(false); } } }
/// <summary> /// 被击退函数 自定击退方向 /// </summary> /// <param name="attackerPos">攻击者</param> /// <param name="interruptTime">打断时间</param> /// <param name="interruptVector">击退力的方向</param> public void BeatBack(Transform attackerPos, float interruptTime, Vector2 interruptVector) { if (!isImmune) { //获取移动组件 //如果被打的是player if (gameObject.name == "Player") { MovementPlayer movement = gameObject.GetComponent <MovementPlayer>(); if (movement.RequestChangeControlStatus(interruptTime, MovementPlayer.PlayerControlStatus.Stun)) { if (transform.position.x > attackerPos.position.x) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementPlayer.MovementMode.Attacked); } else { movement.RequestMoveByTime(-interruptVector, interruptTime, MovementPlayer.MovementMode.Attacked); } } } else { MovementEnemies movement = gameObject.GetComponent <MovementEnemies>(); if (movement.RequestChangeControlStatus(interruptTime, MovementEnemies.EnemyStatus.Stun)) { if (transform.position.x > attackerPos.position.x) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementEnemies.MovementMode.Attacked); } else { movement.RequestMoveByTime(-interruptVector, interruptTime, MovementEnemies.MovementMode.Attacked); } } } } }