private void OnCollisionEnter2D(Collision2D collision)
    {
        IProjectile projectile = (IProjectile)collision.gameObject.GetComponent(typeof(IProjectile));

        if (projectile != null && PhotonNetwork.IsMasterClient)
        {
            projectile.DestroyProjectile();
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IProjectile projectile = collision.GetComponent <IProjectile>();

        if (projectile != null)
        {
            projectile.DestroyProjectile();
        }
    }
Esempio n. 3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        IProjectile projectile = (IProjectile)collision.gameObject.GetComponent(typeof(IProjectile));

        if (projectile != null)
        {
            DealDamage(projectile.Damage);
            projectile.DestroyProjectile();
        }
    }
        private void TickProjectiles()
        {
            for (var i = 0; i < m_Projectiles.Count; i++)
            {
                IProjectile projectile = m_Projectiles[i];
                projectile.TickApproaching();
                if (projectile.DidHit())
                {
                    projectile.DestroyProjectile();
                    m_Projectiles[i] = null;
                }
            }

            m_Projectiles.RemoveAll(projectile => projectile == null);
        }
Esempio n. 5
0
        private void TickProjectiles()
        {
            for (int i = 0; i < m_Projectiles.Count; i++)
            {
                IProjectile projectile = m_Projectiles[i];
                projectile.TickApproaching();
                if (projectile.DidHit())
                {
                    projectile.DestroyProjectile();
                    m_Projectiles[i] = null;
                    //Не можем remove в foreach - нельзя модифицировать коллекцию, по которой enumerate
                    //В случае for можно было бы удалить, но тогда нужно думать, что с индексом, проще так
                }
            }

            m_Projectiles.RemoveAll(projectile => projectile == null);
        }