Example #1
0
    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;
    }
Example #2
0
        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));
                }
            }
        }
Example #3
0
 public void Jump()
 {
     if (isGrounded && minJumpTime <= 0f)
     {
         Rigid.AddForce(Vector2.up * JumpForce);
         minJumpTime = 1f;
     }
 }
Example #4
0
    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);
        }
    }
Example #5
0
    public override void OnRelease()
    {
        base.OnRelease();

        Picked = false;

        Rigid.isKinematic = false;
        Rigid.useGravity  = true;
        Rigid.AddForce(Camera.main.transform.forward * throwForce);
    }
Example #6
0
    void Jump()
    {
        if (!isGround)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            Rigid.AddForce(Vector3.up * JumpForce, ForceMode2D.Impulse);
        }
    }
Example #7
0
    //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);
        }
    }
Example #8
0
        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);
            }
        }
Example #9
0
 /// <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);
     }
 }
Example #10
0
    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);
            }
        }
    }
Example #11
0
        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;
                }
            }
        }
Example #12
0
 public void ApplyForce(Vector3 force)
 {
     lastForce = force;
     Rigid.AddForce(force);
 }
Example #13
0
 public void Move(float timeModifer)
 {
     Rigid.AddForce(new Vector2(0, _force * timeModifer * speedModifer * (1 / _sizeModifer)));
 }
Example #14
0
 /// <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);
 }
Example #15
0
 public void Accelerate(int engineForce)
 {
     rb.AddForce(engineForce);
 }