コード例 #1
0
    void Update()
    {
        if (canControl)
        {
            // Attack Controls
            // NEED TO UPDATE: Attack timing and type depends on current base attack (shot or laser)
            if (Input.GetButton("Fire1"))
            {
                if (currPow_2_attack_laser == 0)
                {
                    if (Time.time > nextFire)
                    {
                        attackController.FireWeapon(0);
                        nextFire = Time.time + rateOfFire;

                        // Fire attacks from active Options
                        for (int i = 0; i < currPow_4_optionCount; i++)
                        {
                            options[i].attackController.FireWeapon(0);
                        }
                    }
                }
                else
                {
                    // Check if laser is currently in-use
                    if (!attackController.laserController.attack_isFiring)
                    {
                        attackController.FireWeapon(1);

                        // Fire attacks from active Options
                        for (int i = 0; i < currPow_4_optionCount; i++)
                        {
                            options[i].attackController.FireWeapon(1);
                        }
                    }
                }

                // Missile attack refresh rate is independent from main attack
                if (currPow_1_missile != 0)
                {
                    attackController.FireMissiles(currPow_1_missile);

                    // Fire missiles from active Options
                    for (int i = 0; i < currPow_4_optionCount; i++)
                    {
                        options[i].attackController.FireMissiles(currPow_1_missile);
                    }
                }
            }

            // Powerup Controls
            if (Input.GetButton("Fire2"))
            {
                bool powerUp_isUsed = false;

                //Debug.Log("Fire2 pressed. Power Meter = " + powerMeterController.currentLitMeter);
                switch (powerMeterController.currentLitMeter)
                {
                case 0:             // Speed Up
                    powerUp_isUsed = PowerUpFX_0_SpeedUp();
                    break;

                case 1:             // Missile
                    powerUp_isUsed = PowerUpFX_1_Missile();
                    break;

                case 2:             // Laser
                    powerUp_isUsed = PowerUpFX_2_Laser();
                    break;

                case 3:             // Charge
                    break;

                case 4:             // Option
                    powerUp_isUsed = PowerUpFX_4_Option();
                    break;

                case 5:             // Shield
                    break;

                default:            // Do nothing
                case -1:
                    break;
                }

                // Reset power meter if power up used (only when button pressed when not empty and not over maxed power up)
                if (powerMeterController.currentLitMeter != -1 && powerUp_isUsed == true)
                {
                    powerUpFX_RippleFX.gameObject.SetActive(true);
                    powerUpFX_RippleFX.SetTrigger("RestartFX");
                    powerMeterController.ResetMeter();
                }
            }
        }

        if (animator.GetCurrentAnimatorClipInfo(0)[0].clip.name != "Player_SpawnIn")
        {
            animator.applyRootMotion = true;
        }
        else
        {
            animator.applyRootMotion = false;
        }
    }