Ejemplo n.º 1
0
    public virtual void Detonate()
    {
        if (m_detonateEffectPrefab != null)
        {
            ScenarioManager.OnSpawnEntity(m_detonateEffectPrefab, transform.position, Quaternion.identity);
        }

        OnDeath(false);
    }
Ejemplo n.º 2
0
    public void OnFireCommand(bool canFire)
    {
        if (canFire && m_projectilePrefab != null)
        {
            Vector3 position = m_muzzleTransform.position;
            position.z = 0f;

            Quaternion rotation = Quaternion.LookRotation(m_targetPosition - position, Vector3.back);

            Entity entity = ScenarioManager.OnSpawnEntity(m_projectilePrefab, position, rotation);
            if (entity != null)
            {
                entity.name = m_projectilePrefab.name + "_" + ScenarioManager.ShotsFired;

                Projectile projectile = entity as Projectile;
                if (projectile != null)
                {
                    float speed = m_projectileSpeed * (ScenarioManager.Scenario != null ? ScenarioManager.Scenario.m_globalSpeedMultiplier : 1f);
                    projectile.Initialize(projectile.ID, m_muzzleTransform.position, m_targetPosition, speed, m_projectileModelPrefab);
                }
                else
                {
                    Debug.LogError(DebugUtilities.AddTimestampPrefix("Couldn't find FuseProjectile component in player missile prefab instance!"), entity);
                }
            }

            if (m_fireSFX != null)
            {
                m_fireSFX.PlayAt(m_muzzleTransform.position, Environment.AudioRoot);
            }

            ScenarioManager.ModifyShotsFired(1);

            //Debug.Log(DebugUtilities.AddTimestampPrefix("Turret fired shot " + ScenarioManager.ShotsFired + "!"), entity);
        }
        else
        {
            m_canNotFireSFX.PlayAt(Camera.main.transform.position, Environment.AudioRoot);
        }
    }