Attack() private method

private Attack ( ) : void
return void
Beispiel #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (transform.parent.CompareTag("Human"))
     {
         playerAttack.Attack(other.gameObject);
     }
     //if (transform.parent.CompareTag("Mosquito"))
     //{
     //    Debug.Log("other: " + other);
     //    playerAttack.Attack(other.gameObject);
     //}
 }
    private void ActivateSwingEffect()
    {
        RaycastHit hit = raycast.GetHitObject();

        hasActivatedSwingEffect = true;

        if (hit.collider != null)
        {
            // If player hits a tree with an axe
            if (hit.collider.CompareTag("TreeCollider"))
            {
                treeController.MineTree(hit.collider);
            }
            else if (hit.collider.CompareTag("RockCollider"))
            {
                itemCollector.AddItemFromSource(hit.collider.gameObject.GetComponent <RockController>());
            }
            else if (hit.collider.CompareTag("Bush"))
            {
                itemCollector.AddItemFromSource(hit.collider.gameObject.GetComponent <ItemSource>());
            }
            else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Enemy")) // If player swings at an enemy
            {
                attack.Attack(hit.collider.gameObject);
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// ブースト出来るかチェックして、チャージ数をブーストに反映させる
    /// </summary>
    /// <returns>ブースト出来るかできないか</returns>
    private bool BoostCheck()
    {
        // チャージの時間がチャージの開始時間より短かったら
        if (chargeTime < chargeStartTime)
        {
            // 攻撃できる状態なら
            if (!player.IsSlide && !player.IsGlide)
            {
                // 攻撃
                playerAttack.Attack();
            }
        }

        // チャージされていて、かつエネルギー以下なら
        if (chargeCount > 0 && chargeCount <= playerAttack.NowBulletCount)
        {
            // チャージ数をブーストに伝える
            playerBoost.GaugeCount = chargeCount;
            // チャージをリセット
            ChargeReset();
            return(true);
        }
        else
        {
            // チャージをリセット
            ChargeReset();
            return(false);
        }
    }
    private void Update()
    {
        //Collect keyboard inputs at the start of each update loop
        _dirInputX       = Input.GetAxisRaw("Horizontal");                           //Left/Right
        _dirInputY       = Input.GetAxisRaw("Vertical");                             //Up/Down
        _jumpKeyState    = (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.Space)); //Jump
        _dashKeyState    = Input.GetKey(KeyCode.LeftShift);                          //Dash
        _atkKeyState     = Input.GetKey(KeyCode.X);                                  //Attack
        _specialKeyState = Input.GetKey(KeyCode.C);                                  //Special (Bounce Bomb)

        //Jumping
        //Only true when jump key is pressed, which is then sent to PlayerJump script
        _jumping.Jump(_jumpKeyState, false, _dirInputX);
        _slideJump.SlideJump(_jumpKeyState, _dirInputX);

        //Movement
        //Sends single float value -1, 0, or 1 to PlayerMovement script
        _movement.Move(_dirInputX);

        //Dash
        //Only triggers when LeftShift is pressed, which then sends current directional input to PlayerDash script
        _dash.Dash(_dashKeyState, _dirInputX, _atkKeyState);

        if (_dirInputY != -1)
        {
            //Attack
            _attack.Attack(_atkKeyState, _dashKeyState);
        }

        //Ground Pound
        _groundPound.GroundPound(_atkKeyState, _dirInputY);

        //PaintBomb
        _paintBomb.ThrowBomb(_specialKeyState, _dirInputY);
    }
 //近接攻撃
 //注意:もし、攻撃発生までにis_Playableがfalseになっても、攻撃は続行する
 public void Attack()
 {
     //入力を受け取ったら、少しだけ待つ
     if (input.GetKeyDown(Key.Attack))
     {
         start_Attack_Frame_Count = true;
     }
     //待ってる間に下が押されたらキック、1度も押されなかったら横攻撃
     if (start_Attack_Frame_Count)
     {
         attack_Frame_Count++;
         if (Input.GetAxis("Vertical") < -0.1f)
         {
             _attack.Kick();
         }
         else if (attack_Frame_Count > 7)
         {
             _attack.Attack();
         }
         else
         {
             return;
         }
         attack_Frame_Count       = 0;
         start_Attack_Frame_Count = false;
     }
 }
Beispiel #6
0
 private void FixedUpdate()
 {
     //When current dash time goes below zero, indicating that the timeer has en1d.
     //Resets player movement direction and velocity to zero and sets current dash time back to full dash time length.
     if (_currDashing == true && _dashTime > 0)
     {
         //Performs dash when a direction is being pressed
         if (_direction != 0)
         {
             //Begins counting down until current dash time reaches zero
             _dashTime -= Time.deltaTime;
             //Applies high force to player to greatly increase their movement speed for dash duration
             _rigidBody.AddForce(new Vector2(_direction * _dashSpeed, _rigidBody.velocity.y));
             _isDashing = true;
             //_atkKey = Input.GetKey(KeyCode.X);
         }
     }
     else if (_dashTime <= 0)
     {
         _direction          = 0;
         _rigidBody.velocity = Vector2.zero;
         _isDashing          = false;
         //Debug.Log(_currDashing + ", " + _dashTime);
     }
     if (_currDashing == false && _dashTime <= 0)
     {
         _dashTime  = _startDashTime;
         _isDashing = false;
         //Debug.Log("Dash Time Reset");
     }
     _atk.Attack(_atkKey, _isDashing);
 }
Beispiel #7
0
    // 玩家二攻击,玩家一受伤
    public void OnPlayerTwoAttack()
    {
        int damage = Random.Range(minDamage, maxDamage);

        playerTwo.Attack();
        playerOne.Damage(damage);
    }
 //moves toward target & chase
 private void MoveAndAttack()
 {
     if (targetedEnemy == null)
     {
         return;
     }
     navMeshAgent.destination = targetedEnemy.position;
     if (navMeshAgent.remainingDistance >= attackDistance)
     {
         navMeshAgent.Resume();
         //walking = true;
     }
     //rotates player to enemy
     if (navMeshAgent.remainingDistance <= attackDistance)
     {
         transform.LookAt(targetedEnemy);
         Vector3 dirToAttack = targetedEnemy.transform.position - transform.position;
         if (Time.time > nextAttack)
         {
             nextAttack = Time.time + attackSpeed;
             attackScript.Attack(dirToAttack);
         }
         navMeshAgent.Stop();
         //walking = false;
     }
 }
Beispiel #9
0
    private void FixedUpdate()
    {
        horizontal = Input.GetAxis("Horizontal") * stats.speed * Time.deltaTime;
        vertical   = Input.GetAxis("Vertical") * stats.speed * Time.deltaTime;
        transform.Translate(horizontal, vertical, 0);


        if (Input.GetKeyDown(KeyCode.Space))
        {
            Attack.Attack(gameObject.transform);
        }
        if (Input.GetKey(KeyCode.A))
        {
            transform.localScale = new Vector3(1, 1, 1);
            transform.GetChild(1).GetChild(1).localScale = new Vector3(1, 1, 1);
            transform.GetChild(1).GetChild(0).localScale = new Vector3(1, 1, 1);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            transform.localScale = new Vector3(-1, 1, 1);
            transform.GetChild(1).GetChild(1).localScale = new Vector3(-1, 1, 1);
            transform.GetChild(1).GetChild(0).localScale = new Vector3(-1, 1, 1);
        }
        transform.GetChild(1).GetChild(1).GetComponent <Text>().text = stats.health.ToString();
    }
Beispiel #10
0
 void ManageAttacks(InputInfo inputInfo)
 {
     if (inputInfo.GetAttackInput())
     {
         playerAttack.Attack(inputInfo.GetLastMovementKeyPressed());
     }
 }
Beispiel #11
0
    private void Update()
    {
        if (!stunned)
        {
            //float translation = Input.GetAxis(_Joystick) * moveSpeed;
            float translation = Input.GetAxis("Horizontal") * moveSpeed;
            if (translation < 0)
            {
                _playerAttack.ChangeHitbox("left");
            }
            else if (translation > 0)
            {
                _playerAttack.ChangeHitbox("right");
            }

            translation        *= Time.deltaTime;
            transform.position += new Vector3(translation, 0, 0);

            _playerJump.Jump(jump);
            _playerAttack.Attack(punch);
        }
        if (stunned)
        {
            if (t == null)
            {
                t = Timer.StartNew(gameObject, 1f, ChangeStun);
            }
        }
    }
    //近接攻撃
    public void Attack()
    {
        //入力を受け取ったら、少しだけ待つ
        if (input.GetKeyDown(Key.Attack))
        {
            start_Attack_Frame_Count = true;
        }
        //待ってる間に下が押されたらキック、1度も押されなかったら横攻撃
        if (start_Attack_Frame_Count)
        {
            attack_Frame_Count++;
            if (Input.GetAxisRaw("Vertical") < -0.7f)
            {
                _attack.Kick();
                is_Squat = false;
            }
            else if (attack_Frame_Count > 7)
            {
                _attack.Attack();
                start_Charge_Attack_Frame_Count = true; //チャージアタック
            }
            else
            {
                return;
            }
            attack_Frame_Count       = 0;
            start_Attack_Frame_Count = false;
        }

        //チャージアタック溜めるかどうか
        if (start_Charge_Attack_Frame_Count)
        {
            //収集アイテムを集めていないときは不可
            if (!CollectionManager.Instance.Is_Collected("Raiko"))
            {
                start_Charge_Attack_Frame_Count = false;
                return;
            }
            charge_Attack_Frame_Count++;
            //通常攻撃後10フレーム間攻撃ボタン押していたらチャージ開始
            if (charge_Attack_Frame_Count > 10)
            {
                if (input.GetKey(Key.Attack))
                {
                    _charge_Attack.Charge();
                }
                if (!input.GetKey(Key.Attack) || input.GetKeyDown(Key.Fly))
                {
                    _charge_Attack.Charge_Attack();
                    Release_Charge();
                }
            }
            //10フレーム押す前に攻撃ボタンを離したときチャージ開始しない
            else if (!input.GetKey(Key.Attack) || input.GetKeyDown(Key.Fly))
            {
                Release_Charge();
            }
        }
    }
Beispiel #13
0
 private IEnumerator Attack()
 {
     while (bAttack)
     {
         player.Attack();
         yield return(null);
     }
 }
 void FixedUpdate()
 {
     // interprets the controls to the script
     controller.Move(horizontalMove * Time.fixedDeltaTime, jump);
     attacker.Attack(horizontalMove != 0, attack);
     jump   = false;
     attack = false;
 }
Beispiel #15
0
        void Start()
        {
            var hit   = new Hit();
            var slash = new Slash();
            var magic = new Magic();

            // 初期状態は打撃攻撃に設定する
            var playerAttack = new PlayerAttack(hit);

            playerAttack.Attack();

            // 斬撃攻撃に切り替える
            playerAttack.SetAttack(slash);
            playerAttack.Attack();

            // 魔法攻撃に切り替える
            playerAttack.SetAttack(magic);
            playerAttack.Attack();
        }
Beispiel #16
0
 // Update is called once per frame
 void Update()
 {
     NowMagicWord     = Data.Instance.MagicName;
     rigid2d.velocity = new Vector2(0, 0) * 0; //加速度を0に
     Move();                                   //移動処理
     if (Input.GetKeyDown(KeyCode.Z))
     {
         MyAttack.Attack(NowMagicWord);
     }
 }
Beispiel #17
0
 void AttackUpdate()
 {
     if (Inventory.inventory != null)
     {
         if (!doingSpecialAction && Input.GetMouseButtonDown(0) && Inventory.inventory.equipSlots[1].itemID != 0)
         {
             doingSpecialAction = true;
             pa.Attack();
         }
     }
 }
Beispiel #18
0
    private void PlayerControl()
    {
        plyMVT.Move(xInput, yInput);


        if (startAttacking && !inAction)
        {
            StartCoroutine(plyAttack.Attack(damage));
        }

        DashManagement();
    }
    void FixedUpdate()
    {
        // interprets the controls to the script
        controller.Move(horizontalMove * Time.fixedDeltaTime, jumpButton.GetPressedStatus());
        controller.Jump(jump);
        controller.ManageAnim(horizontalMove * Time.fixedDeltaTime, jumpButton.GetPressedStatus());
        controller.DoubleTap(isDoubleTap);
        attacker.Attack(horizontalMove != 0, attack);

        jump        = false;
        attack      = false;
        isDoubleTap = false;
    }
Beispiel #20
0
    private void FixedUpdate()
    {
        mover.Move(horizontalMove, jump, dash);
        attacker.Attack(horizontalMove, attack);
        jump   = false;
        attack = false;
        dash   = false;

        if (health <= 0)
        {
            health = 0;
            isDead = true;
        }
    }
Beispiel #21
0
    /// <summary>
    /// フレーム更新処理
    /// </summary>
    void IState.Update()
    {
        // ジャンプボタンが押されたら
        if (character.IsGlideStart == true)
        {
            // 滑空状態に移行
            character.GlideStart();
            // ブーストのキー入力を確認
            playerCharge.BoostKeyCheck();
            return;
        }
        // 着地したら
        if (character.IsGround == true)
        {
            // ラン状態に移行
            character.RunStart();
            // ブーストのキー入力を確認
            playerCharge.BoostKeyCheck();
            return;
        }

        // アクションボタンが押されたら
        if (character.IsSlideStart == true)
        {
            // 手すりをつかむ猶予時間
            var catchSliderTime = playerSlide.catchSliderTime;
            // 手すりヒット判定
            playerSlide.RayTimerStart(catchSliderTime);
            // 保留 演出の終了
            // playerSlide.EffectOff();
            // チャージ演出を一時停止する
            playerCharge.ChargeStop();
        }

        // ショットボタンが押されたら
        if (character.IsAttack == true)
        {
            playerAttack.Attack();
        }

        // 弾に当たったら
        if (playerAttack.IsHit == true)
        {
            // ダウン状態に移行
            character.Down();
            return;
        }
        // ブーストのキー入力を確認
        playerCharge.BoostKeyCheck();
    }
 //チャージ攻撃,ChargePhase == 3で強攻撃、それ以下で通常攻撃
 public void Charge_Attack()
 {
     if (charge_Phase == 3)
     {
         StartCoroutine("Charge_Attack_Cor");
     }
     else
     {
         _attack.Attack();
     }
     charge_Time = 0;
     player_Effect.Start_Shoot_Charge(0);
     player_SE.Stop_Charge_Sound();
 }
Beispiel #23
0
 private void AttackInput()
 {
     if (currentPlayerState != PlayerState.CannotMove && isGrounded)
     {
         if (Input.GetMouseButtonDown(0))
         {
             attack.Attack();
         }
         if (Input.GetKeyDown(KeyCode.R))
         {
             inventory.InitEquipOrUnequip();
         }
     }
 }
Beispiel #24
0
    // Update is called once per frame
    void Update()
    {
        if (m_Enabled == false)
        {
            return;
        }

        ProcessMovementInput();
        ProcessLookDirection();

        if (Input.GetMouseButtonDown(0))
        {
            m_PLayerAttack.Attack();
        }
    }
        void Start()
        {
            var playerAttack        = new PlayerAttack();
            var attackEffect        = new AttackEffect();
            var attackMotion        = new AttackMotion();
            var playerAttackManager = new PlayerAttackManager(playerAttack, attackEffect, attackMotion);

            // サブシステムの機能をカプセル化した「攻撃する」という一連の処理を行うメソッド
            playerAttackManager.Attack();

            // サブシステムの個々のメソッドもアクセスはできる
            playerAttack.Attack();
            attackEffect.ShowAttackEffect();
            attackMotion.PlayAttackMotion();
        }
    private void AttackInput()
    {
        if (PlayerManager.currentState == PlayerManager.PlayerState.FreeMovement)
        {
            if (Input.GetMouseButtonDown(0) || Input.GetButtonDown("XButton")) //X button or click
            {
                if (grounded && !pManager.IsPaused)
                {
                    pAttack.Attack();
                }
            }
        }

        if (pAttack.IsAttacking && pManager.isLockedOn)
        {
            pMove.LookAtTarget(pTargeting.currentTarget.transform);
        }
    }
Beispiel #27
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position == posToGo)
        {
            anim.SetBool("isRunning", false);
            if (attackingEnemy)
            {
                playerAttack.Attack();
            }
        }
        else
        {
            anim.SetBool("isRunning", true);
        }

        transform.position = Vector3.MoveTowards(transform.position, posToGo, speed * Time.deltaTime);
        transform.rotation = Quaternion.Lerp(transform.rotation, rotation, turnSpeed * Time.deltaTime);
    }
Beispiel #28
0
    /// <summary>
    /// フレーム更新処理
    /// </summary>
    void IState.Update()
    {
        // ジャンプボタンが押されたら
        if (character.IsJumpStart == true)
        {
            // ジャンプ
            playerJump.Jump();
            // 空中状態に移行
            character.AerialStart();
        }

        // アクションボタンが押されたら
        if (character.IsSlideStart == true)
        {
            // 手すりをつかむ猶予時間
            var catchSliderTime = playerSlide.catchSliderTime;
            // 手すりヒット判定
            playerSlide.RayTimerStart(catchSliderTime);
        }

        // 地面から落ちたら
        if (character.IsGround == false)
        {
            // 空中状態に移行
            character.AerialStart();
        }

        // 弾に当たったら
        if (playerAttack.IsHit == true)
        {
            // ダウン状態に移行
            character.Down();
        }

        // アタックボタンが押されたら
        if (character.IsAttack == true)
        {
            playerAttack.Attack();
        }

        // ブーストのキー入力を確認
        playerCharge.BoostKeyCheck();
    }
Beispiel #29
0
    void Update()
    {
        // スライド開始地点.
        if (Input.GetMouseButtonDown(0))
        {
            slideStartPosition = GetCursorPosition();
        }


        // 画面の1割以上移動させたらスライド開始と判断する.
        if (Input.GetMouseButton(0))
        {
            if (Vector2.Distance(slideStartPosition, GetCursorPosition()) >= (Screen.width * 0.1f))
            {
                moved = true;
            }
        }

        // スライド操作が終了したか.
        if (!Input.GetMouseButtonUp(0) && !Input.GetMouseButton(0))
        {
            moved = false;             // スライドは終わった.
        }
        // 移動量を求める.
        if (moved)
        {
            delta = GetCursorPosition() - prevPosition;
        }
        else
        {
            delta = Vector2.zero;
        }

        // カーソル位置を更新.
        prevPosition = GetCursorPosition();

        if (Input.GetMouseButtonDown(1))
        {
            playerAttack.Attack();
            StartCoroutine(inputAttackCheacck.Attack());
        }
    }
Beispiel #30
0
    void FixedUpdate()
    {
        CheckIfOutsideBounds();

        grounded = isGrounded();
        anim.SetBool("Grounded", grounded);
        touchesWall = !grounded?isTouchingWall() : 0;

        //Debug.Log (touchesWall != 0 ? true : false);
        anim.SetBool("TouchesWall", touchesWall != 0 ? true : false);
        if (shouldBlink)
        {
            //playerMovement.DoBlink ();
            playerMovement.DoBlink(playerInputController.lastClickPosition);
        }
        else if (knockBack)
        {
            playerMovement.KnockBack();
        }
        else
        {
            playerMovement.MovePlayer();
        }

        if (shouldAttack)
        {
            playerAttack.Attack();
        }


        float timeSinceBlink = Time.time - lastBlinkTime;

        if (timeSinceBlink < playerMovement.blinkCoolDown)
        {
            blinkBar.value = 1 / playerMovement.blinkCoolDown * timeSinceBlink;
        }

        EnableEnemiesInRange();

        oldPos = body.position;
    }