Beispiel #1
0
    public virtual void ManualStart(List<Bullet> p_bullet, GameObject p_panel, GuiManager p_gui, GameObject p_aim, AudioSource p_musicSource, AudioClip p_musicLevel)
    {
        _rigidbody = GetComponent<Rigidbody>();
        _audioSource = GetComponent<AudioSource>();
        _anim = GetComponent<Animator>();
        _flightController = GetComponent<Flight>();
        _collisionManager = GetComponent<AircraftCollisionManager>();

        _flightController.ManualStart();
        TPSCameraController.ManualStart(_rigidbody);
        FPSCameraController.ManualStart(_rigidbody);
        _currentCameraController = TPSCameraController;

        soundController.musicSound = p_musicSource;
        _bullets = p_bullet;
        _instPanel = p_panel;
        _guiManager = p_gui;
        _aimHUD = p_aim;
        _guiManager.energySlider.maxValue = energy;
        _guiManager.energySlider.value = energy;
        _guiManager.heatSlider.maxValue = normalWeaponHeatTime;
        _guiManager.heatSlider.value = _normalWeaponHeatCount;
        _guiManager.armorSlider.maxValue = armorEnergy;
        _guiManager.armorSlider.value = armorEnergy;

        _instPanel.SetActive(false);

        _initialEmissionStartSpeed = fireEmission[0].startSpeed;
        _emissionLightNormalIntensity = lightEmission[0].intensity;

        _animIDBarrelLeft = Animator.StringToHash("BarrelRollLeft");
        _animIDBarrelRight = Animator.StringToHash("BarrelRollRight");
        _animIDShake = Animator.StringToHash("ShakeThird");

        if (currentType != type.AIRCRAFT_3)
        {
            _animIDAcc = Animator.StringToHash("Accelerate");
            _animIDBoost = Animator.StringToHash("Boost");
        }
        if (currentType == type.AIRCRAFT_1)
            _anim.SetBool(_animIDAcc, true);
        _collisionManager.ManualStart();
        _collisionManager.onHitGround += delegate (Vector3 p_point)
        {
            DecreaseEnergy(5f);
            _flightController.ApplyImpactForce(p_point);
                _anim.SetTrigger(_animIDShake);
                Invoke("CancelAnim", 0.5f);
        };
        _collisionManager.onHitStaticObject += delegate (Vector3 p_point)
        {
            DecreaseEnergy(5f);
            _flightController.ApplyImpactForce(p_point);
            _anim.SetTrigger(_animIDShake);
            Invoke("CancelAnim", 0.5f);
        };
        _collisionManager.onHitEnemy += delegate (Vector3 p_point, float p_damage)
        {
                DecreaseEnergy(p_damage);
                //_flightController.ApplyImpactForceMonster(p_point);
                _anim.SetTrigger(_animIDShake);
                Invoke("CancelAnim", 0.8f);
        };
        _collisionManager.onHitEnemyLittle += delegate (Vector3 p_point, float p_damage)
        {
            if (!_inBarrelRoll)
            {
                DecreaseEnergy(p_damage);
                _anim.SetTrigger(_animIDShake);
                Invoke("CancelAnim", 0.5f);
            }
        };

        soundController.PlaySound(SoundController.source.MUSIC, p_musicLevel);
        soundController.PlaySound(SoundController.source.ENGINE, engineSound);

        // Change camera
        soundController.InsideCockpit(false);
        this.enabled = true;
    }