Пример #1
0
    void HandleAttack()
    {
        if (BombManager.sSingleton.dualLinkState == BombManager.DualLinkState.NONE)
        {
            // Primary attack.
            if ((playerID == 1 && (mIsP1KeybInput && Input.GetKey(KeyCode.Z)) || Input.GetKey(mJoystick.fireKey)) ||
                (playerID == 2 && (Input.GetKey(KeyCode.Period) || Input.GetKey(mJoystick.fireKey))))
            {
                if (!mIsCoroutineList[0])
                {
                    BulletSparks();
                    StartCoroutine(DoFirstThenDelay(0, () => mAttackPattern.PrimaryWeaponShoot(), primaryShootDelay));
                }
                if (powerLevel > 0 && !mIsCoroutineList[1])
                {
                    StartCoroutine(DoFirstThenDelay(1, () => mAttackPattern.SecondaryWeaponShoot(), secondaryShootDelay));
                }
            }
            else if ((playerID == 1 && (mIsP1KeybInput && Input.GetKeyUp(KeyCode.Z)) || Input.GetKeyUp(mJoystick.fireKey)) ||
                     (playerID == 2 && (Input.GetKeyUp(KeyCode.Period) || Input.GetKeyUp(mJoystick.fireKey))))
            {
                for (int i = 0; i < shotSparksPSList.Count; i++)
                {
                    shotSparksPSList[i].Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
                }
            }
        }

        // Bomb.
        if (((playerID == 1 && ((mIsP1KeybInput && Input.GetKeyDown(KeyCode.X) || Input.GetKey(mJoystick.bombKey)))) ||
             (playerID == 2 && (Input.GetKeyDown(KeyCode.Slash) || Input.GetKey(mJoystick.bombKey)))) &&
            !mBombController.IsUsingBomb && !mIsWaitOtherInput)
        {
            if (bomb > 0)
            {
                bomb -= 1;
                UIManager.sSingleton.UpdateBomb(playerID, bomb);

                if (GameManager.sSingleton.TotalNumOfPlayer() == 2 && mOtherPlayerController.state != State.SOUL && mOtherPlayerController.state != State.DISABLE_CONTROL)
                {
                    // The other player receiver during dual link ultimate.
                    if (BombManager.sSingleton.dualLinkState == BombManager.DualLinkState.PLAYER_INPUTTED)
                    {
                        mIsWaitOtherInput = true;
                        Debug.Log("Activate pause before shooting.");

                        mBombController.ActivatePotrait();
                        BombManager.sSingleton.BothPlayerInputted();
                    }

                    // If both players gauge are full, stop time for input of second player.
                    if (linkValue >= 1 && mOtherPlayerController.linkValue >= 1 && BombManager.sSingleton.dualLinkState == BombManager.DualLinkState.NONE)
                    {
                        Debug.Log("Player started dual link bomb");
                        Time.timeScale = 0;
                        mBombController.ActivatePotrait();

                        mIsWaitOtherInput = true;
                        BombManager.sSingleton.OnePlayerInputted();
                        StartCoroutine(WaitOtherResponseSequence(BombManager.sSingleton.bombDualLinkInputDur));
                    }
                }

                if (BombManager.sSingleton.dualLinkState == BombManager.DualLinkState.NONE)
                {
                    mBombController.ActivateBomb();
                }
            }
        }
    }