예제 #1
0
    public void Fire(Vector3 startingPosition, Quaternion rotation, float powerOfProjectile)
    {
        var go = PoolingSystem.Spawn(PoolManager.INSTANCE.GetWeaponPrefab(weaponType), startingPosition);

        go.transform.position = startingPosition;
        go.transform.rotation = rotation;

        WeaponBehaviour weaponBehaviour = go.GetComponent <WeaponBehaviour>();
        PoisonWeapon    poisonWeapon    = go.GetComponent <PoisonWeapon>();
        HommingMissile  missile         = go.GetComponent <HommingMissile>();

        //IF IT IS A SINGLE WEAPON AND IS RIGIDBODY
        if (weaponBehaviour != null)
        {
            weaponBehaviour.FireAndAddForce(powerOfProjectile);
        }
        // ELSE IF ITS PARTICLE SYSTEM SET NEEDED ROTATION IN SCRIPT
        else if (poisonWeapon != null)
        {
            poisonWeapon.SetRotation();
        }
        if (missile != null)
        {
            missile.CasterIsPlayer(caster.CompareTag("TankPlayer"));
        }
    }