Esempio n. 1
0
    void LaunchProjectile()
    {
        //print("LaunchProjectile");

        Projectile.InitSettings projSettings = new Projectile.InitSettings(m_ProjectileSettingsEx);
        projSettings.IgnoreTransform = transform;

        if (m_UseProjectileType)
        {
            /* Use default Projectile manager, This is using before finel commit. We are testing if projectile manager is properly initialized.
             * Chnage first argument for how you want and test it...
             */
            ProjectileManager.Instance.SpawnProjectile(m_ProjectileType, m_SpawnPos.transform.position, m_SpawnPos.transform.forward, projSettings);
        }
        else
        {
            GameObject instance = Instantiate(m_ProjectilePrefab, m_SpawnPos.transform.position, m_SpawnPos.transform.rotation) as GameObject;
            Projectile proj     = instance.GetComponent <Projectile>();
            proj.ProjectileInit(m_SpawnPos.transform.position, m_SpawnPos.transform.forward.normalized, projSettings);
            ActiveProjectiles.Add(proj);
        }

        /*  //This was used for grenade tuning (old code)...
         * GameObject instance = Instantiate(m_ProjectilePrefab, m_SpawnPos.transform.position, m_SpawnPos.transform.rotation) as GameObject;
         * instance.rigidbody.velocity = transform.forward * m_ProjectileSettings.m_Speed;  //Random.insideUnitSphere * 5;
         * instance.rigidbody.SetDensity(1.5F);
         * //instance.rigidbody.centerOfMass = new Vector3(0, 0.0f, 0);
         * //instance.rigidbody.AddTorque(Vector3.up * 10, ForceMode.VelocityChange);
         * instance.rigidbody.AddTorque(Random.insideUnitSphere * 10, ForceMode.VelocityChange);
         * instance.SetActiveRecursively(true);
         */
    }
Esempio n. 2
0
    void InitWorker(AgentHuman Human)
    {
        m_Owner = Human;

        transform.rotation = m_Owner.Transform.rotation;

        m_ProjInitSettings                 = new Projectile.InitSettings();
        m_ProjInitSettings.Agent           = m_Owner;
        m_ProjInitSettings.IgnoreTransform = m_Owner.Transform;
        m_ProjInitSettings.Speed           = m_WpnSettings.m_ProjSpeed;
        m_ProjInitSettings.Damage          = m_WpnSettings.m_Damage;
        m_ProjInitSettings.Impulse         = m_WpnSettings.m_ProjImpuls;

        m_Owner.GadgetsComponent.RegisterLiveGadget(ItemID, GameObject);

        m_ProjInitSettings.ItemID = ItemID;
        Icons.SetTeamIcon(m_Owner.Team);
    }
Esempio n. 3
0
    // -----------------

    // -----
    public void Initialize(AgentHuman owner, E_WeaponID id)
    {
        Settings                  = WeaponSettingsManager.Instance.Get(id);
        InitProjSettings          = new Projectile.InitSettings();
        InitProjSettings.WeaponID = Settings.ID;
        InitProjSettings.Impulse  = Settings.BaseData.Impulse;
        InitProjSettings.Speed    = Settings.BaseData.Speed;      // to have valid valid values here if InitializeModifiersFromUpgrades fails
        InitProjSettings.Damage   = Settings.BaseData.Damage;

        InitializeModifiersFromUpgrades(owner);
        _AmmoInClip   = MaxAmmoInClip;
        _AmmoInWeapon = MaxAmmoInWeapon;
        GameObject    = gameObject;
        Transform     = transform;
        Audio         = GetComponent <AudioSource>();
        RBody         = GetComponent <Rigidbody>();
//		Renderer		= renderer;
        TransformShot = transform.FindChild("Shoot");
    }
Esempio n. 4
0
    public void SpawnProjectile(E_ProjectileType inProjeType, Vector3 inPos, Vector3 inDir, Projectile.InitSettings inSettings)
    {
        //Debug.Log("New SpawnProjectile " + inProjeType);
        // test if we have configured cache for this type of resource...
        if (CacheOfProjectiles.ContainsKey(inProjeType) == false)
        {
            Debug.LogError("ProjectileFactory: unknown type " + inProjeType);
            return;
        }

        // if we known this type but we don't have resource cache than go out,
        // this is corect situation...
        else if (CacheOfProjectiles[inProjeType] == null)
        {
            Debug.LogError("ProjectileFactory: For this type " + inProjeType + " we don't have resource");
            return;
        }

        //check the projectile against the camera frustum - when it doesn't intersect it, do not bother spawning it on client
        if (uLink.Network.isServer == false && inSettings.Agent && inSettings.Agent.IsProxy)
        {
            Frustum.SetupCamera(GameCamera.Instance, 100);
            // variant A: faster but not accurate
            Frustum.E_Location loc = Frustum.LineInFrustumFast(inPos, inPos + inDir * GameCamera.Instance.MainCamera.farClipPlane);
            // variant B: accurate but slower
            //	Frustum.E_Location loc = Frustum.LineInFrustum(GameCamera.Instance.MainCamera,inPos, inPos + inDir * GameCamera.Instance.MainCamera.far);

            if (loc == Frustum.E_Location.Outside)             //do not spawn the projectile if it's not visible at all
            {
//				Debug.Log ("Projectile NOT SPAWNED, pos=" + inPos.ToString("F3") + ", dir=" + inDir.ToString("F3"));
                return;
            }
//			else
//			{
//				Debug.Log ("Projectile SPAWNED, pos=" + inPos.ToString("F3") + ", dir=" + inDir.ToString("F3"));
//			}
        }
        //

        Projectile proj = CacheOfProjectiles[inProjeType].Get();

        if (proj == null)
        {
            Debug.LogError("ProjectileFactory: Can't create projectile for type " + inProjeType);
            return;
        }

        proj.ProjectileInit(inPos, inDir.normalized, inSettings);
        ActiveProjectiles.Add(proj);
    }