public override void InitVehicle(Vehicle vehiclePrefab, VehicleGun weaponPrefab, Vector3 position, Quaternion rotation)
    {
        vehicle = ((GameObject)Instantiate(vehiclePrefab.gameObject, position, rotation)).GetComponent <Vehicle>();
        vehicle.transform.parent = transform;
        vehicle.OnDamage        += OnVehicleDamage;
        vehicle.OnDie           += OnVehicleDie;
        vehicle.Initialize();

        if (weaponPrefab != null)
        {
            vehicle.SetPrimaryWeapon(weaponPrefab);
        }

        Targeting.AddTargetable(Team, vehicle);
        var neighrbourSensor = GetComponentInChildren <NeighbourSensor>();

        if (neighrbourSensor != null)
        {
            neighrbourSensor.transform.parent = vehicle.transform;
        }
        var soundSensor = GetComponentInChildren <SoundSensor>();

        if (soundSensor != null)
        {
            soundSensor.transform.parent = vehicle.transform;
        }
        var missileSensor = GetComponentInChildren <MissileSensor>();

        if (missileSensor != null)
        {
            missileSensor.transform.parent = vehicle.transform;
        }
    }
Beispiel #2
0
    public override void InitVehicle(Vehicle vehiclePrefab, VehicleGun weaponPrefab, Vector3 position, Quaternion rotation)
    {
        vehicle = Instantiate(vehiclePrefab.gameObject, position, rotation).GetComponent <Vehicle>();
        vehicle.transform.parent = transform;
        Utility.SetLayerRecursively(vehicle.transform, LayerMask.NameToLayer("Player"));
        vehicle.OnDamage += OnVehicleDamage;
        vehicle.OnDie    += OnVehicleDie;

        vehicle.Initialize();

        if (weaponPrefab != null)
        {
            vehicle.SetPrimaryWeapon(weaponPrefab);
        }
        vehicle.MaxHealth *= 2f;
        vehicle.Health     = vehicle.MaxHealth;
        Targeting.AddTargetable(Team, vehicle);
    }