private IEnumerator Assault() { IsAttack = true; IsChase = false; yield return(new WaitForSeconds(0.3f)); Ani.SetBool("isAttack", true); yield return(new WaitForSeconds(0.2f)); AttackObject attack = GameManager.Instance.Pooling.GetAttackObject(PoolManager.AttackObjectList.MonsterMeleeAttack); attack.transform.SetParent(transform); attack.transform.localPosition = Vector3.zero; attack.transform.rotation = transform.rotation; var attackInfo = new AttackInfo(this, Atk * AssaultDamage, 10f, "Player", transform.position, int.MaxValue, (HitInfo info) => { GameManager.Instance.Effect.HitEffect(info.HitUnit.transform.position); }); attack.SetAttackInfo(attackInfo, AttackObject.IgnoreType.IgnoreWallAndFloor); attack.SetTimer(1f, InstantObject.TimerAction.Destory); Rigid.AddForce(transform.forward * AssaultForce, ForceMode.Impulse); yield return(new WaitForSeconds(1f)); Rigid.velocity = Vector3.zero; yield return(new WaitForSeconds(0.8f)); //공격 후딜레이 yield return(new WaitForSeconds(0.25f)); Ani.SetBool("isAttack", false); IsAttack = false; IsChase = true; }
void Update() { // 上下移动。并到达位置后,开始计时。计时结束后往反方向移动。 if (TimeController.Instance.IsOpTime()) { return; } if (Up) { if (KeepTime > 0f) { Rigid.AddForce(new Vector2(0f, 2000f * MoveSpeed)); KeepTime -= Time.deltaTime; } } else { // 移动部分 if (KeepTime > 0f) { KeepTime -= Time.deltaTime; } else { Rigid.AddForce(new Vector2(0f, 2000f * MoveSpeed)); } } }
public void Jump() { if (isGrounded && minJumpTime <= 0f) { Rigid.AddForce(Vector2.up * JumpForce); minJumpTime = 1f; } }
public override void Hurt(ActorInstance actor, int damage = 0, int currentHP = 0, string cause = "attack", bool crit = false) { base.Hurt(actor, damage, currentHP, cause, crit); if (Game.Instance.isBitch) { Rigid.AddForce(2f * actor.Info.ClientPerks.KnockbackModifier * transform.position - actor.transform.position, ForceMode2D.Impulse); } }
public override void OnRelease() { base.OnRelease(); Picked = false; Rigid.isKinematic = false; Rigid.useGravity = true; Rigid.AddForce(Camera.main.transform.forward * throwForce); }
void Jump() { if (!isGround) { return; } if (Input.GetKeyDown(KeyCode.Space)) { Rigid.AddForce(Vector3.up * JumpForce, ForceMode2D.Impulse); } }
//bool CheckGround() //{ // Collider2D collider = Physics2D.OverlapCircle(transform.position + Offset, // Radius, GroundLayer); // return collider != null ? true : false; // //if(collider != null) // //{ // // return true; // //} // //else // //{ // // return false; // //} //} void Jump() { if (!groundChecker.IsGround) // isGround == false; { return; } if (Input.GetKeyDown(KeyCode.Space)) { Rigid.AddForce(Vector3.up * JumpForce, ForceMode2D.Impulse); } }
public override void Movement() { var x = CanMoveX ? Input.GetAxisRaw("Horizontal") : 0; var z = CanMoveZ ? Input.GetAxisRaw("Vertical") : 0; var input = new Vector3(x, 0, z); input = input.normalized * MovementSpeed * Time.deltaTime; Rigid.MovePosition(Trans.position + input); if (CanJump && Input.GetKeyDown(KeyCode.Space) && FloorPlane.GetDistanceToPoint(Trans.position) < 0.51f) { Rigid.AddForce(Vector3.up * 6, ForceMode.Impulse); } }
/// <summary> /// Handling the jump and the airborne movement if the player is airborne /// </summary> private void HandleJump() { if (IsGrounded) { if (CTRLHub.inst.JumpDown && IsFrozen == false) { Rigid.AddForce(-normalizedGravity * maxJumpforce, ForceMode.Impulse); airebornMovementDirection = movementDirection; } } else { Rigid.AddForce(airebornMovementDirection * jumpForwardStrength); airebornMovementDirection = Vector3.Lerp(airebornMovementDirection, Vector3.zero, dropMovementForceWeakening * Time.deltaTime); } }
public override void Hurt(ActorInstance actor, int damage = 0, int currentHP = 0, string cause = "attack", bool crit = false) { base.Hurt(actor, damage, currentHP, cause, crit); if (Game.Instance.isBitch) { if (actor.transform.position.x < transform.position.x) { Rigid.gravityScale = 1f; Rigid.AddForce((damage / Info.MaxHealth) * 3f * actor.Info.ClientPerks.KnockbackModifier * transform.right, ForceMode2D.Impulse); } else { Rigid.gravityScale = 1f; Rigid.AddForce((damage / Info.MaxHealth) * 3f * actor.Info.ClientPerks.KnockbackModifier * -transform.right, ForceMode2D.Impulse); } } }
public override void Movement() { if (_isChargeing) { _chargePercentage += Time.deltaTime * 20; if (_chargePercentage >= 100) { _isChargeing = false; Rigid.AddForce(Trans.forward * 30, ForceMode.Impulse); } Trans.LookAt(ActivePlayer.Trans); } else { _chargePercentage -= Time.deltaTime * 20; if (_chargePercentage <= 0) { _isChargeing = true; } } }
public void ApplyForce(Vector3 force) { lastForce = force; Rigid.AddForce(force); }
public void Move(float timeModifer) { Rigid.AddForce(new Vector2(0, _force * timeModifer * speedModifer * (1 / _sizeModifer))); }
/// <summary> /// Applies AddForce in 'movementDirection' using the given strength and ForceMode, /// according to the inputed movement strength ('GetInputMagnitude()') /// </summary> private void ApplyForceInMovementDirection(float strength, ForceMode forceMode = ForceMode.Force) { Rigid.AddForce(movementDirection * strength * GetInputMagnitude(), forceMode); }
public void Accelerate(int engineForce) { rb.AddForce(engineForce); }