//public Animator doorAnimator;
    //public float doorPosition;

    void Awake()
    {
        aircraft = GetComponent <AIAircraftSpawn>();
        pilot    = GetComponent <AIPilot>();
        rb       = GetComponent <Rigidbody>();
        //doorAnimator = GetComponentInChildren<Animator>();

        gearAnimator = GetComponentInChildren <GearAnimator>();
        tailHook     = GetComponentInChildren <Tailhook>();
        catHook      = GetComponentInChildren <CatapultHook>();
        refuelPort   = GetComponentInChildren <RefuelPort>();
        wingRotator  = pilot.wingRotator;

        kPlane   = GetComponent <KinematicPlane>();
        fuelTank = GetComponent <FuelTank>();

        waypoint = new Waypoint();
        GameObject waypointObject = new GameObject();

        waypointObject.AddComponent <FloatingOriginTransform>();
        waypoint.SetTransform(waypointObject.transform);

        tilter = GetComponent <TiltController>();

        normalSpeed = pilot.navSpeed;

        health = GetComponent <Health>();
        health.OnDeath.AddListener(OnDeath);
    }
Example #2
0
    private void Awake()
    {
        actor             = gameObject.GetComponent <Actor>();
        lastFiringMessage = new Message_WeaponFiring(-1, false, false, networkUID);
        // lastStoppedFiringMessage = new Message_WeaponStoppedFiring(networkUID);
        lastCountermeasureMessage = new Message_FireCountermeasure(true, true, networkUID);
        lastDeathMessage          = new Message_Death(networkUID, false);
        wheelsController          = GetComponent <WheelsController>();
        aeroController            = GetComponent <AeroController>();
        isPlayer       = actor.isPlayer;
        sequenceNumber = 0;
        lastMessage    = new Message_PlaneUpdate(false, 0, 0, 0, 0, 0, 0, false, false, false, networkUID, sequenceNumber);

        engine = gameObject.GetComponentInChildren <ModuleEngine>();
        if (engine == null)
        {
            Debug.Log("engine was null on vehicle " + gameObject.name);
        }

        weaponManager = GetComponent <WeaponManager>();
        if (weaponManager == null)
        {
            Debug.LogError("Weapon Manager was null on vehicle " + gameObject.name);
        }
        else
        {
            traverse             = Traverse.Create(weaponManager);
            Networker.WeaponSet += WeaponSet;
            //weaponManager.OnWeaponEquipped += Rearm;
            //weaponManager.OnWeaponUnequippedHPIdx +=Rearm;

            //detect player rearm
            PlayerVehicleSetup pv = gameObject.GetComponent <PlayerVehicleSetup>();
            if (pv != null)
            {
                pv.OnEndRearming.AddListener(Rearm);
            }

            if (actor.isPlayer && weaponManager.GetIWBForEquip(3) != null)
            {
                iwb = weaponManager.GetIWBForEquip(3);
            }
        }

        cmManager = GetComponentInChildren <CountermeasureManager>();
        if (cmManager == null)
        {
            Debug.LogError("CountermeasureManager was null on vehicle " + gameObject.name);
        }
        else
        {
            cmManager.OnFiredCM += FireCountermeasure;
        }

        fuelTank = GetComponent <FuelTank>();
        if (fuelTank == null)
        {
            Debug.LogError("FuelTank was null on vehicle " + gameObject.name);
        }


        Debug.Log("Done Plane Sender");
        tailhook   = GetComponentInChildren <Tailhook>();
        launchBar  = GetComponentInChildren <CatapultHook>();
        refuelPort = GetComponentInChildren <RefuelPort>();
    }